datamint 1.7.1__py3-none-any.whl → 1.7.3__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/apihandler/root_api_handler.py +25 -25
- {datamint-1.7.1.dist-info → datamint-1.7.3.dist-info}/METADATA +1 -1
- {datamint-1.7.1.dist-info → datamint-1.7.3.dist-info}/RECORD +5 -5
- {datamint-1.7.1.dist-info → datamint-1.7.3.dist-info}/WHEEL +0 -0
- {datamint-1.7.1.dist-info → datamint-1.7.3.dist-info}/entry_points.txt +0 -0
|
@@ -239,14 +239,14 @@ class RootAPIHandler(BaseAPIHandler):
|
|
|
239
239
|
names = _infinite_gen(names)
|
|
240
240
|
frame_indices = segfiles.get('frame_index', _infinite_gen(None))
|
|
241
241
|
for f, name, frame_index in tqdm(zip(fpaths, names, frame_indices),
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
desc=f"Uploading segmentations for {file_path}",
|
|
243
|
+
total=len(fpaths)):
|
|
244
244
|
if f is not None:
|
|
245
245
|
await self._upload_segmentations_async(rid,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
246
|
+
file_path=f,
|
|
247
|
+
name=name,
|
|
248
|
+
frame_index=frame_index,
|
|
249
|
+
transpose_segmentation=transpose_segmentation)
|
|
250
250
|
return rid
|
|
251
251
|
|
|
252
252
|
tasks = [__upload_single_resource(f, segfiles, metadata_file)
|
|
@@ -368,26 +368,29 @@ class RootAPIHandler(BaseAPIHandler):
|
|
|
368
368
|
def _is_dicom_report(file_path: str | IO) -> bool:
|
|
369
369
|
"""
|
|
370
370
|
Check if a DICOM file is a report (e.g., Structured Report).
|
|
371
|
-
|
|
371
|
+
|
|
372
372
|
Args:
|
|
373
373
|
file_path: Path to the DICOM file or file-like object.
|
|
374
|
-
|
|
374
|
+
|
|
375
375
|
Returns:
|
|
376
376
|
bool: True if the DICOM file is a report, False otherwise.
|
|
377
377
|
"""
|
|
378
378
|
try:
|
|
379
379
|
if not is_dicom(file_path):
|
|
380
380
|
return False
|
|
381
|
-
|
|
381
|
+
|
|
382
382
|
ds = pydicom.dcmread(file_path, stop_before_pixels=True)
|
|
383
|
+
if hasattr(file_path, 'seek'):
|
|
384
|
+
file_path.seek(0)
|
|
383
385
|
modality = getattr(ds, 'Modality', None)
|
|
384
|
-
|
|
386
|
+
|
|
385
387
|
# Common report modalities
|
|
386
|
-
|
|
387
|
-
|
|
388
|
+
# SR=Structured Report, DOC=Document, KO=Key Object, PR=Presentation State
|
|
389
|
+
report_modalities = {'SR', 'DOC', 'KO', 'PR', 'ESR'}
|
|
390
|
+
|
|
388
391
|
return modality in report_modalities
|
|
389
392
|
except Exception as e:
|
|
390
|
-
_LOGGER.
|
|
393
|
+
_LOGGER.warning(f"Error checking if DICOM is a report: {e}")
|
|
391
394
|
return False
|
|
392
395
|
|
|
393
396
|
def upload_resources(self,
|
|
@@ -443,21 +446,18 @@ class RootAPIHandler(BaseAPIHandler):
|
|
|
443
446
|
list[str | Exception]: A list of resource IDs or errors.
|
|
444
447
|
"""
|
|
445
448
|
|
|
446
|
-
if discard_dicom_reports:
|
|
447
|
-
if isinstance(files_path, (str, Path)):
|
|
448
|
-
files_path = [files_path]
|
|
449
|
-
elif isinstance(files_path, pydicom.dataset.Dataset):
|
|
450
|
-
files_path = [files_path]
|
|
451
|
-
|
|
452
|
-
old_size = len(files_path)
|
|
453
|
-
files_path = [f for f in files_path if not RootAPIHandler._is_dicom_report(f)]
|
|
454
|
-
if old_size != len(files_path):
|
|
455
|
-
_LOGGER.info(f"Discarded {old_size - len(files_path)} DICOM report files from upload.")
|
|
456
|
-
|
|
457
449
|
if on_error not in ['raise', 'skip']:
|
|
458
450
|
raise ValueError("on_error must be either 'raise' or 'skip'")
|
|
459
451
|
|
|
460
452
|
files_path, is_multiple_resources = RootAPIHandler.__process_files_parameter(files_path)
|
|
453
|
+
|
|
454
|
+
### Discard DICOM reports
|
|
455
|
+
if discard_dicom_reports:
|
|
456
|
+
files_path = [f for f in files_path if not RootAPIHandler._is_dicom_report(f)]
|
|
457
|
+
old_size = len(files_path)
|
|
458
|
+
if old_size is not None and old_size != len(files_path):
|
|
459
|
+
_LOGGER.info(f"Discarded {old_size - len(files_path)} DICOM report files from upload.")
|
|
460
|
+
|
|
461
461
|
if isinstance(metadata, (str, dict)):
|
|
462
462
|
_LOGGER.debug("Converting metadatas to a list")
|
|
463
463
|
metadata = [metadata]
|
|
@@ -903,7 +903,7 @@ class RootAPIHandler(BaseAPIHandler):
|
|
|
903
903
|
) -> None:
|
|
904
904
|
"""
|
|
905
905
|
Download multiple resources and save them to the specified paths.
|
|
906
|
-
|
|
906
|
+
|
|
907
907
|
Args:
|
|
908
908
|
resource_ids (list[str]): A list of resource unique ids.
|
|
909
909
|
save_path (list[str] | str): A list of paths to save the files or a directory path.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: datamint
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.3
|
|
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
|
|
@@ -4,7 +4,7 @@ datamint/apihandler/api_handler.py,sha256=cdVSddrFCKlF_BJ81LO1aJ0OP49rssjpNEFzJ6
|
|
|
4
4
|
datamint/apihandler/base_api_handler.py,sha256=dWLiowyuP1XiGfNc-_D5oQSmJdfR0Quy0ToeJlkRA8s,11911
|
|
5
5
|
datamint/apihandler/dto/annotation_dto.py,sha256=qId1RK1VO7dXrvGJ7dqJ31jBQB7Z8yy5x0tLSiMxTB4,7105
|
|
6
6
|
datamint/apihandler/exp_api_handler.py,sha256=hFUgUgBc5rL7odK7gTW3MnrvMY1pVfJUpUdzRNobMQE,6226
|
|
7
|
-
datamint/apihandler/root_api_handler.py,sha256=
|
|
7
|
+
datamint/apihandler/root_api_handler.py,sha256=aPJSPYEedm3oBKyEMJAz5J2l3eh1iw_nDVloWgQoeR4,56857
|
|
8
8
|
datamint/client_cmd_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
datamint/client_cmd_tools/datamint_config.py,sha256=md7dnWrbl10lPtXKbmD9yo6onLJsajeG8Vz0ZWH1v4M,8181
|
|
10
10
|
datamint/client_cmd_tools/datamint_upload.py,sha256=890USkrtaH23mNjTRYVHWce2q9jSmkUNHIP_e8fnJRM,29502
|
|
@@ -22,7 +22,7 @@ datamint/logging.yaml,sha256=a5dsATpul7QHeUHB2TjABFjWaPXBMbO--dgn8GlRqwk,483
|
|
|
22
22
|
datamint/utils/logging_utils.py,sha256=DvoA35ATYG3JTwfXEXYawDyKRfHeCrH0a9czfkmz8kM,1851
|
|
23
23
|
datamint/utils/torchmetrics.py,sha256=lwU0nOtsSWfebyp7dvjlAggaqXtj5ohSEUXOg3L0hJE,2837
|
|
24
24
|
datamint/utils/visualization.py,sha256=yaUVAOHar59VrGUjpAWv5eVvQSfztFG0eP9p5Vt3l-M,4470
|
|
25
|
-
datamint-1.7.
|
|
26
|
-
datamint-1.7.
|
|
27
|
-
datamint-1.7.
|
|
28
|
-
datamint-1.7.
|
|
25
|
+
datamint-1.7.3.dist-info/METADATA,sha256=YTALWrY1wwiyjk2a-4FOx_LBxTKxd__QrchCCukTcDA,4090
|
|
26
|
+
datamint-1.7.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
27
|
+
datamint-1.7.3.dist-info/entry_points.txt,sha256=mn5H6jPjO-rY0W0CAZ6Z_KKWhMLvyVaSpoqk77jlTI4,145
|
|
28
|
+
datamint-1.7.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|