datamint 2.1.3__tar.gz → 2.2.0__tar.gz

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.

Files changed (49) hide show
  1. {datamint-2.1.3 → datamint-2.2.0}/PKG-INFO +2 -2
  2. {datamint-2.1.3 → datamint-2.2.0}/datamint/dataset/base_dataset.py +0 -3
  3. {datamint-2.1.3 → datamint-2.2.0}/datamint/dataset/dataset.py +18 -12
  4. {datamint-2.1.3 → datamint-2.2.0}/pyproject.toml +2 -2
  5. {datamint-2.1.3 → datamint-2.2.0}/README.md +0 -0
  6. {datamint-2.1.3 → datamint-2.2.0}/datamint/__init__.py +0 -0
  7. {datamint-2.1.3 → datamint-2.2.0}/datamint/api/__init__.py +0 -0
  8. {datamint-2.1.3 → datamint-2.2.0}/datamint/api/base_api.py +0 -0
  9. {datamint-2.1.3 → datamint-2.2.0}/datamint/api/client.py +0 -0
  10. {datamint-2.1.3 → datamint-2.2.0}/datamint/api/dto/__init__.py +0 -0
  11. {datamint-2.1.3 → datamint-2.2.0}/datamint/api/endpoints/__init__.py +0 -0
  12. {datamint-2.1.3 → datamint-2.2.0}/datamint/api/endpoints/annotations_api.py +0 -0
  13. {datamint-2.1.3 → datamint-2.2.0}/datamint/api/endpoints/channels_api.py +0 -0
  14. {datamint-2.1.3 → datamint-2.2.0}/datamint/api/endpoints/datasetsinfo_api.py +0 -0
  15. {datamint-2.1.3 → datamint-2.2.0}/datamint/api/endpoints/projects_api.py +0 -0
  16. {datamint-2.1.3 → datamint-2.2.0}/datamint/api/endpoints/resources_api.py +0 -0
  17. {datamint-2.1.3 → datamint-2.2.0}/datamint/api/endpoints/users_api.py +0 -0
  18. {datamint-2.1.3 → datamint-2.2.0}/datamint/api/entity_base_api.py +0 -0
  19. {datamint-2.1.3 → datamint-2.2.0}/datamint/apihandler/annotation_api_handler.py +0 -0
  20. {datamint-2.1.3 → datamint-2.2.0}/datamint/apihandler/api_handler.py +0 -0
  21. {datamint-2.1.3 → datamint-2.2.0}/datamint/apihandler/base_api_handler.py +0 -0
  22. {datamint-2.1.3 → datamint-2.2.0}/datamint/apihandler/dto/__init__.py +0 -0
  23. {datamint-2.1.3 → datamint-2.2.0}/datamint/apihandler/dto/annotation_dto.py +0 -0
  24. {datamint-2.1.3 → datamint-2.2.0}/datamint/apihandler/exp_api_handler.py +0 -0
  25. {datamint-2.1.3 → datamint-2.2.0}/datamint/apihandler/root_api_handler.py +0 -0
  26. {datamint-2.1.3 → datamint-2.2.0}/datamint/client_cmd_tools/__init__.py +0 -0
  27. {datamint-2.1.3 → datamint-2.2.0}/datamint/client_cmd_tools/datamint_config.py +0 -0
  28. {datamint-2.1.3 → datamint-2.2.0}/datamint/client_cmd_tools/datamint_upload.py +0 -0
  29. {datamint-2.1.3 → datamint-2.2.0}/datamint/configs.py +0 -0
  30. {datamint-2.1.3 → datamint-2.2.0}/datamint/dataset/__init__.py +0 -0
  31. {datamint-2.1.3 → datamint-2.2.0}/datamint/dataset/annotation.py +0 -0
  32. {datamint-2.1.3 → datamint-2.2.0}/datamint/entities/__init__.py +0 -0
  33. {datamint-2.1.3 → datamint-2.2.0}/datamint/entities/annotation.py +0 -0
  34. {datamint-2.1.3 → datamint-2.2.0}/datamint/entities/base_entity.py +0 -0
  35. {datamint-2.1.3 → datamint-2.2.0}/datamint/entities/channel.py +0 -0
  36. {datamint-2.1.3 → datamint-2.2.0}/datamint/entities/datasetinfo.py +0 -0
  37. {datamint-2.1.3 → datamint-2.2.0}/datamint/entities/project.py +0 -0
  38. {datamint-2.1.3 → datamint-2.2.0}/datamint/entities/resource.py +0 -0
  39. {datamint-2.1.3 → datamint-2.2.0}/datamint/entities/user.py +0 -0
  40. {datamint-2.1.3 → datamint-2.2.0}/datamint/examples/__init__.py +0 -0
  41. {datamint-2.1.3 → datamint-2.2.0}/datamint/examples/example_projects.py +0 -0
  42. {datamint-2.1.3 → datamint-2.2.0}/datamint/exceptions.py +0 -0
  43. {datamint-2.1.3 → datamint-2.2.0}/datamint/experiment/__init__.py +0 -0
  44. {datamint-2.1.3 → datamint-2.2.0}/datamint/experiment/_patcher.py +0 -0
  45. {datamint-2.1.3 → datamint-2.2.0}/datamint/experiment/experiment.py +0 -0
  46. {datamint-2.1.3 → datamint-2.2.0}/datamint/logging.yaml +0 -0
  47. {datamint-2.1.3 → datamint-2.2.0}/datamint/utils/logging_utils.py +0 -0
  48. {datamint-2.1.3 → datamint-2.2.0}/datamint/utils/torchmetrics.py +0 -0
  49. {datamint-2.1.3 → datamint-2.2.0}/datamint/utils/visualization.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datamint
3
- Version: 2.1.3
3
+ Version: 2.2.0
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
@@ -21,7 +21,7 @@ Requires-Dist: humanize (>=4.0.0,<5.0.0)
21
21
  Requires-Dist: lazy-loader (>=0.3.0)
22
22
  Requires-Dist: lightning
23
23
  Requires-Dist: matplotlib
24
- Requires-Dist: medimgkit (>=0.6.6)
24
+ Requires-Dist: medimgkit (>=0.7.0)
25
25
  Requires-Dist: nest-asyncio (>=1.0.0,<2.0.0)
26
26
  Requires-Dist: nibabel (>=4.0.0)
27
27
  Requires-Dist: numpy
@@ -1,15 +1,12 @@
1
1
  import os
2
2
  import requests
3
- from tqdm.auto import tqdm
4
3
  from typing import Optional, Callable, Any, Literal, Sequence
5
4
  import logging
6
5
  import shutil
7
6
  import json
8
- import yaml
9
7
  import pydicom
10
8
  from pydicom.dataset import FileDataset
11
9
  import numpy as np
12
- from datamint import configs
13
10
  from torch.utils.data import DataLoader
14
11
  import torch
15
12
  from torch import Tensor
@@ -1,5 +1,5 @@
1
1
  from .base_dataset import DatamintBaseDataset
2
- from typing import List, Optional, Callable, Any, Dict, Literal, Sequence
2
+ from typing import Optional, Callable, Any, Literal, Sequence
3
3
  import torch
4
4
  from torch import Tensor
5
5
  import os
@@ -119,8 +119,8 @@ class DatamintDataset(DatamintBaseDataset):
119
119
  raise ValueError("semantic_seg_merge_strategy can only be used if return_as_semantic_segmentation is True")
120
120
 
121
121
  def _load_segmentations(self,
122
- annotations: list[Annotation],
123
- img_shape) -> tuple[dict[str, list], dict[str, list]]:
122
+ annotations: Sequence[Annotation],
123
+ img_shape) -> tuple[dict[str, list], dict[str, list], dict[str, Any]]:
124
124
  """
125
125
  Load segmentations from annotations.
126
126
 
@@ -129,12 +129,13 @@ class DatamintDataset(DatamintBaseDataset):
129
129
  img_shape: shape of the image (#frames, C, H, W)
130
130
 
131
131
  Returns:
132
- tuple[dict[str, list], dict[str, list]]: a tuple of two dictionaries.
132
+ tuple[dict[str, list], dict[str, list], dict[str, Any]]: a tuple of two dictionaries and additional metadata.
133
133
  The first dictionary is author -> list of #frames tensors, each tensor has shape (#instances_i, H, W).
134
134
  The second dictionary is author -> list of #frames segmentation labels (tensors).
135
135
  """
136
136
  segmentations = {}
137
137
  seg_labels = {}
138
+ seg_metainfos = {}
138
139
 
139
140
  if self.return_frame_by_frame:
140
141
  assert len(img_shape) == 3, f"img_shape must have 3 dimensions, got {img_shape}"
@@ -155,11 +156,15 @@ class DatamintDataset(DatamintBaseDataset):
155
156
 
156
157
  segfilepath = ann.file # png file
157
158
  segfilepath = os.path.join(self.dataset_dir, segfilepath)
158
- seg = read_array_normalized(segfilepath) # (frames, C, H, W)
159
+ seg, seg_metainfo = read_array_normalized(segfilepath, return_metainfo=True) # (frames, C, H, W)
159
160
  if seg.shape[1] != 1:
160
161
  raise ValueError(f"Segmentation file must have 1 channel, got {seg.shape} in {segfilepath}")
161
162
  seg = seg[:, 0, :, :] # (frames, H, W)
162
-
163
+
164
+ if seg_metainfo is None:
165
+ raise Exception
166
+ seg_metainfos[author] = seg_metainfo
167
+
163
168
  # # FIXME: avoid enforcing resizing the mask
164
169
  # seg = (Image.open(segfilepath)
165
170
  # .convert('L')
@@ -168,7 +173,7 @@ class DatamintDataset(DatamintBaseDataset):
168
173
  # seg = np.array(seg)
169
174
 
170
175
  seg = torch.from_numpy(seg)
171
- seg = seg == 255 # binary mask
176
+ seg = seg != 0 # binary mask
172
177
  # map the segmentation label to the code
173
178
  if self.return_frame_by_frame:
174
179
  frame_index = 0
@@ -217,7 +222,7 @@ class DatamintDataset(DatamintBaseDataset):
217
222
  author_segs[i] = torch.zeros((0, h, w), dtype=torch.bool)
218
223
  author_labels[i] = torch.zeros(0, dtype=torch.int32)
219
224
 
220
- return segmentations, seg_labels
225
+ return segmentations, seg_labels, seg_metainfos
221
226
 
222
227
  def _instanceseg2semanticseg(self,
223
228
  segmentations: Sequence[Tensor],
@@ -273,19 +278,19 @@ class DatamintDataset(DatamintBaseDataset):
273
278
  raise ValueError(f"Unknown semantic_seg_merge_strategy: {self.semantic_seg_merge_strategy}")
274
279
  return merged_segs.to(torch.get_default_dtype())
275
280
 
276
- def _apply_semantic_seg_merge_strategy_union(self, segmentations: Dict[str, torch.Tensor]) -> torch.Tensor:
281
+ def _apply_semantic_seg_merge_strategy_union(self, segmentations: dict[str, torch.Tensor]) -> torch.Tensor:
277
282
  new_segmentations = torch.zeros_like(list(segmentations.values())[0])
278
283
  for seg in segmentations.values():
279
284
  new_segmentations += seg
280
285
  return new_segmentations.bool()
281
286
 
282
- def _apply_semantic_seg_merge_strategy_intersection(self, segmentations: Dict[str, torch.Tensor]) -> torch.Tensor:
287
+ def _apply_semantic_seg_merge_strategy_intersection(self, segmentations: dict[str, torch.Tensor]) -> torch.Tensor:
283
288
  new_segmentations = torch.ones_like(list(segmentations.values())[0])
284
289
  for seg in segmentations.values():
285
290
  new_segmentations += seg
286
291
  return new_segmentations.bool()
287
292
 
288
- def _apply_semantic_seg_merge_strategy_mode(self, segmentations: Dict[str, torch.Tensor]) -> torch.Tensor:
293
+ def _apply_semantic_seg_merge_strategy_mode(self, segmentations: dict[str, torch.Tensor]) -> torch.Tensor:
289
294
  new_segmentations = torch.zeros_like(list(segmentations.values())[0])
290
295
  for seg in segmentations.values():
291
296
  new_segmentations += seg
@@ -428,7 +433,7 @@ class DatamintDataset(DatamintBaseDataset):
428
433
 
429
434
  try:
430
435
  if self.return_segmentations:
431
- segmentations, seg_labels = self._load_segmentations(annotations, img.shape)
436
+ segmentations, seg_labels, seg_metainfos = self._load_segmentations(annotations, img.shape)
432
437
  # seg_labels can be dict[str, list[Tensor]]
433
438
  # apply mask transform
434
439
  if self.mask_transform is not None:
@@ -475,6 +480,7 @@ class DatamintDataset(DatamintBaseDataset):
475
480
  new_item['seg_labels'] = seg_labels
476
481
  # process seg_labels to convert from code to label names
477
482
  new_item['seg_labels_names'] = self._seg_labels_to_names(seg_labels)
483
+ new_item['seg_metainfo'] = {'file_metainfo': seg_metainfos}
478
484
 
479
485
  except Exception:
480
486
  _LOGGER.error(f'Error in loading/processing segmentations of {metainfo}')
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "datamint"
3
3
  description = "A library for interacting with the Datamint API, designed for efficient data management, processing and Deep Learning workflows."
4
- version = "2.1.3"
4
+ version = "2.2.0"
5
5
  dynamic = ["dependencies"]
6
6
  requires-python = ">=3.10"
7
7
  readme = "README.md"
@@ -40,7 +40,7 @@ matplotlib = "*"
40
40
  lightning = "*"
41
41
  albumentations = ">=2.0.0"
42
42
  lazy-loader = ">=0.3.0"
43
- medimgkit = ">=0.6.6"
43
+ medimgkit = ">=0.7.0"
44
44
  typing_extensions = ">=4.0.0"
45
45
  pydantic = ">=2.6.4"
46
46
  httpx = "*"
File without changes
File without changes
File without changes
File without changes