datamint 1.4.0__py3-none-any.whl → 1.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of datamint might be problematic. Click here for more details.
- datamint/client_cmd_tools/datamint_upload.py +10 -5
- datamint/experiment/experiment.py +1 -1
- datamint/utils/io_utils.py +37 -10
- {datamint-1.4.0.dist-info → datamint-1.4.1.dist-info}/METADATA +1 -1
- {datamint-1.4.0.dist-info → datamint-1.4.1.dist-info}/RECORD +7 -7
- {datamint-1.4.0.dist-info → datamint-1.4.1.dist-info}/WHEEL +0 -0
- {datamint-1.4.0.dist-info → datamint-1.4.1.dist-info}/entry_points.txt +0 -0
|
@@ -267,7 +267,13 @@ def _find_json_metadata(file_path: str | Path) -> Optional[str]:
|
|
|
267
267
|
Optional[str]: Path to the JSON metadata file if found, None otherwise
|
|
268
268
|
"""
|
|
269
269
|
file_path = Path(file_path)
|
|
270
|
-
|
|
270
|
+
|
|
271
|
+
# Handle .nii.gz files specially - need to remove both extensions
|
|
272
|
+
if file_path.name.endswith('.nii.gz'):
|
|
273
|
+
base_name = file_path.name[:-7] # Remove .nii.gz
|
|
274
|
+
json_path = file_path.parent / f"{base_name}.json"
|
|
275
|
+
else:
|
|
276
|
+
json_path = file_path.with_suffix('.json')
|
|
271
277
|
|
|
272
278
|
if json_path.exists() and json_path.is_file():
|
|
273
279
|
_LOGGER.debug(f"Found JSON metadata file: {json_path}")
|
|
@@ -313,12 +319,11 @@ def _collect_metadata_files(files_path: list[str], auto_detect_json: bool) -> tu
|
|
|
313
319
|
if used_json_files:
|
|
314
320
|
_LOGGER.debug(f"Filtering out {len(used_json_files)} JSON metadata files from main upload list")
|
|
315
321
|
filtered_metadata_files = []
|
|
316
|
-
|
|
317
|
-
|
|
322
|
+
|
|
318
323
|
for original_file in files_path:
|
|
319
324
|
if original_file not in used_json_files:
|
|
320
|
-
|
|
321
|
-
|
|
325
|
+
original_index = files_path.index(original_file)
|
|
326
|
+
filtered_metadata_files.append(metadata_files[original_index])
|
|
322
327
|
|
|
323
328
|
metadata_files = filtered_metadata_files
|
|
324
329
|
|
|
@@ -803,7 +803,7 @@ class Experiment:
|
|
|
803
803
|
Args:
|
|
804
804
|
resource_id: The resource ID of the sample.
|
|
805
805
|
predictions: The predictions of the model. One binary mask for each class. Can be a numpy array of shape (H, W) or (N,H,W);
|
|
806
|
-
Or a path to a png file; Or a path to a .nii.gz file.
|
|
806
|
+
Or a path to a png file; Or a path to a .nii/.nii.gz file.
|
|
807
807
|
label_name: The name of the class or a dictionary mapping pixel values to names.
|
|
808
808
|
Example: ``{1: 'Femur', 2: 'Tibia'}`` means that pixel value 1 is 'Femur' and pixel value 2 is 'Tibia'.
|
|
809
809
|
frame_index: The frame index of the prediction or a list of frame indexes.
|
datamint/utils/io_utils.py
CHANGED
|
@@ -54,17 +54,32 @@ def read_video(file_path: str, index: int = None) -> np.ndarray:
|
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
def read_nifti(file_path: str) -> np.ndarray:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
"""
|
|
58
|
+
Read a NIfTI file and return the image data in standardized format.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
file_path: Path to the NIfTI file (.nii or .nii.gz)
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
np.ndarray: Image data with shape (#frames, C, H, W)
|
|
65
|
+
"""
|
|
66
|
+
try:
|
|
67
|
+
nii_img = nib.load(file_path)
|
|
68
|
+
imgs = nii_img.get_fdata() # shape: (W, H, #frame) or (W, H)
|
|
69
|
+
|
|
70
|
+
if imgs.ndim == 2:
|
|
71
|
+
imgs = imgs.transpose(1, 0) # (W, H) -> (H, W)
|
|
72
|
+
imgs = imgs[np.newaxis, np.newaxis] # -> (1, 1, H, W)
|
|
73
|
+
elif imgs.ndim == 3:
|
|
74
|
+
imgs = imgs.transpose(2, 1, 0) # (W, H, #frame) -> (#frame, H, W)
|
|
75
|
+
imgs = imgs[:, np.newaxis] # -> (#frame, 1, H, W)
|
|
76
|
+
else:
|
|
77
|
+
raise ValueError(f"Unsupported number of dimensions in '{file_path}': {imgs.ndim}")
|
|
66
78
|
|
|
67
|
-
|
|
79
|
+
return imgs
|
|
80
|
+
except Exception as e:
|
|
81
|
+
_LOGGER.error(f"Failed to read NIfTI file '{file_path}': {e}")
|
|
82
|
+
raise e
|
|
68
83
|
|
|
69
84
|
|
|
70
85
|
def read_image(file_path: str) -> np.ndarray:
|
|
@@ -123,6 +138,18 @@ def read_array_normalized(file_path: str,
|
|
|
123
138
|
else:
|
|
124
139
|
if mime_type == 'image/x.nifti' or file_path.endswith(NII_EXTS):
|
|
125
140
|
imgs = read_nifti(file_path)
|
|
141
|
+
# For NIfTI files, try to load associated JSON metadata
|
|
142
|
+
if return_metainfo:
|
|
143
|
+
json_path = file_path.replace('.nii.gz', '.json').replace('.nii', '.json')
|
|
144
|
+
if os.path.exists(json_path):
|
|
145
|
+
try:
|
|
146
|
+
import json
|
|
147
|
+
with open(json_path, 'r') as f:
|
|
148
|
+
metainfo = json.load(f)
|
|
149
|
+
_LOGGER.debug(f"Loaded JSON metadata from {json_path}")
|
|
150
|
+
except Exception as e:
|
|
151
|
+
_LOGGER.warning(f"Failed to load JSON metadata from {json_path}: {e}")
|
|
152
|
+
metainfo = None
|
|
126
153
|
elif mime_type.startswith('image/') or file_path.endswith(IMAGE_EXTS):
|
|
127
154
|
imgs = read_image(file_path)
|
|
128
155
|
elif file_path.endswith('.npy') or mime_type == 'application/x-numpy-data':
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: datamint
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: A library for interacting with the Datamint API, designed for efficient data management, processing and Deep Learning workflows.
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -7,7 +7,7 @@ datamint/apihandler/exp_api_handler.py,sha256=hFUgUgBc5rL7odK7gTW3MnrvMY1pVfJUpU
|
|
|
7
7
|
datamint/apihandler/root_api_handler.py,sha256=-dy5IxDP3wJAr2ahhxKKswWfyKSzn6hHrPSYwKKW1pQ,44507
|
|
8
8
|
datamint/client_cmd_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
datamint/client_cmd_tools/datamint_config.py,sha256=NNWLBaHXYhY1fqherwg0u3bcu0r95ZJIMTH45X-bJ2Q,6279
|
|
10
|
-
datamint/client_cmd_tools/datamint_upload.py,sha256=
|
|
10
|
+
datamint/client_cmd_tools/datamint_upload.py,sha256=oDNt-91Naz8fQER2sk3I9x9G7C7xzQ0SjBjr0XNht1k,25900
|
|
11
11
|
datamint/configs.py,sha256=Bdp6NydYwyCJ2dk19_gf_o3M2ZyQOmMHpLi8wEWNHUk,1426
|
|
12
12
|
datamint/dataset/__init__.py,sha256=4PlUKSvVhdfQvvuq8jQXrkdqnot-iTTizM3aM1vgSwg,47
|
|
13
13
|
datamint/dataset/base_dataset.py,sha256=EnnIeF3ZaBL2M8qEV39U0ogKptyvezBNoVOvrS12bZ8,38756
|
|
@@ -16,14 +16,14 @@ datamint/examples/__init__.py,sha256=zcYnd5nLVme9GCTPYH-1JpGo8xXK2WEYvhzcy_2alZc
|
|
|
16
16
|
datamint/examples/example_projects.py,sha256=7Nb_EaIdzJTQa9zopqc-WhTBQWQJSoQZ_KjRS4PB4FI,2931
|
|
17
17
|
datamint/experiment/__init__.py,sha256=5qQOMzoG17DEd1YnTF-vS0qiM-DGdbNh42EUo91CRhQ,34
|
|
18
18
|
datamint/experiment/_patcher.py,sha256=ZgbezoevAYhJsbiJTvWPALGTcUiMT371xddcTllt3H4,23296
|
|
19
|
-
datamint/experiment/experiment.py,sha256=
|
|
19
|
+
datamint/experiment/experiment.py,sha256=aHK9dRFdQTi569xgUg1KqlCZLHZpDmSH3g3ndPIZvXw,44546
|
|
20
20
|
datamint/logging.yaml,sha256=a5dsATpul7QHeUHB2TjABFjWaPXBMbO--dgn8GlRqwk,483
|
|
21
21
|
datamint/utils/dicom_utils.py,sha256=HTuEjwXyTSMaTVGb9pFOO76q2KLTr2CxTDoCRElVHRA,26023
|
|
22
|
-
datamint/utils/io_utils.py,sha256=
|
|
22
|
+
datamint/utils/io_utils.py,sha256=ebP1atKkhKEf1mUU1LsVwDq0h_so7kVKkD_7hQYn_kM,6754
|
|
23
23
|
datamint/utils/logging_utils.py,sha256=DvoA35ATYG3JTwfXEXYawDyKRfHeCrH0a9czfkmz8kM,1851
|
|
24
24
|
datamint/utils/torchmetrics.py,sha256=lwU0nOtsSWfebyp7dvjlAggaqXtj5ohSEUXOg3L0hJE,2837
|
|
25
25
|
datamint/utils/visualization.py,sha256=yaUVAOHar59VrGUjpAWv5eVvQSfztFG0eP9p5Vt3l-M,4470
|
|
26
|
-
datamint-1.4.
|
|
27
|
-
datamint-1.4.
|
|
28
|
-
datamint-1.4.
|
|
29
|
-
datamint-1.4.
|
|
26
|
+
datamint-1.4.1.dist-info/METADATA,sha256=Av01QDy0f3zl0oud-ebW6vyjk0J0P33MGWMq8wg3nMs,4065
|
|
27
|
+
datamint-1.4.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
28
|
+
datamint-1.4.1.dist-info/entry_points.txt,sha256=mn5H6jPjO-rY0W0CAZ6Z_KKWhMLvyVaSpoqk77jlTI4,145
|
|
29
|
+
datamint-1.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|