monai-weekly 1.4.dev2439__py3-none-any.whl → 1.4.dev2441__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.
monai/__init__.py CHANGED
@@ -136,4 +136,4 @@ except BaseException:
136
136
 
137
137
  if MONAIEnvVars.debug():
138
138
  raise
139
- __commit_id__ = "8546be098daaf6841c39a2748412bbda83929c92"
139
+ __commit_id__ = "796271ccd4ee48065af3b2afd56bf46960a53112"
monai/_version.py CHANGED
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2024-09-29T02:29:04+0000",
11
+ "date": "2024-10-13T02:28:40+0000",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "1bac3a18df3d8aac051ac832fc0d7d3d3c50e350",
15
- "version": "1.4.dev2439"
14
+ "full-revisionid": "cf815ed4e44a5b8ce67e894ab0bc2765279a1a59",
15
+ "version": "1.4.dev2441"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -803,6 +803,14 @@ class RestoreLabeld(MapTransform):
803
803
  original_shape_key: key that records original shape for foreground.
804
804
  cropped_shape_key: key that records cropped shape for foreground.
805
805
  allow_missing_keys: don't raise exception if key is missing.
806
+ restore_resizing: used to enable or disable resizing restoration, default is True.
807
+ If True, the transform will resize the items back to its original shape.
808
+ restore_cropping: used to enable or disable cropping restoration, default is True.
809
+ If True, the transform will restore the items to its uncropped size.
810
+ restore_spacing: used to enable or disable spacing restoration, default is True.
811
+ If True, the transform will resample the items back to the spacing it had before being altered.
812
+ restore_slicing: used to enable or disable slicing restoration, default is True.
813
+ If True, the transform will reassemble the full volume by restoring the slices to their original positions.
806
814
  """
807
815
 
808
816
  def __init__(
@@ -819,6 +827,10 @@ class RestoreLabeld(MapTransform):
819
827
  original_shape_key: str = "foreground_original_shape",
820
828
  cropped_shape_key: str = "foreground_cropped_shape",
821
829
  allow_missing_keys: bool = False,
830
+ restore_resizing: bool = True,
831
+ restore_cropping: bool = True,
832
+ restore_spacing: bool = True,
833
+ restore_slicing: bool = True,
822
834
  ) -> None:
823
835
  super().__init__(keys, allow_missing_keys)
824
836
  self.ref_image = ref_image
@@ -833,6 +845,10 @@ class RestoreLabeld(MapTransform):
833
845
  self.end_coord_key = end_coord_key
834
846
  self.original_shape_key = original_shape_key
835
847
  self.cropped_shape_key = cropped_shape_key
848
+ self.restore_resizing = restore_resizing
849
+ self.restore_cropping = restore_cropping
850
+ self.restore_spacing = restore_spacing
851
+ self.restore_slicing = restore_slicing
836
852
 
837
853
  def __call__(self, data: Any) -> dict:
838
854
  d = dict(data)
@@ -842,38 +858,45 @@ class RestoreLabeld(MapTransform):
842
858
  image = d[key]
843
859
 
844
860
  # Undo Resize
845
- current_shape = image.shape
846
- cropped_shape = meta_dict[self.cropped_shape_key]
847
- if np.any(np.not_equal(current_shape, cropped_shape)):
848
- resizer = Resize(spatial_size=cropped_shape[1:], mode=mode)
849
- image = resizer(image, mode=mode, align_corners=align_corners)
861
+ if self.restore_resizing:
862
+ current_shape = image.shape
863
+ cropped_shape = meta_dict[self.cropped_shape_key]
864
+ if np.any(np.not_equal(current_shape, cropped_shape)):
865
+ resizer = Resize(spatial_size=cropped_shape[1:], mode=mode)
866
+ image = resizer(image, mode=mode, align_corners=align_corners)
850
867
 
851
868
  # Undo Crop
852
- original_shape = meta_dict[self.original_shape_key]
853
- result = np.zeros(original_shape, dtype=np.float32)
854
- box_start = meta_dict[self.start_coord_key]
855
- box_end = meta_dict[self.end_coord_key]
856
-
857
- spatial_dims = min(len(box_start), len(image.shape[1:]))
858
- slices = tuple(
859
- [slice(None)] + [slice(s, e) for s, e in zip(box_start[:spatial_dims], box_end[:spatial_dims])]
860
- )
861
- result[slices] = image
869
+ if self.restore_cropping:
870
+ original_shape = meta_dict[self.original_shape_key]
871
+ result = np.zeros(original_shape, dtype=np.float32)
872
+ box_start = meta_dict[self.start_coord_key]
873
+ box_end = meta_dict[self.end_coord_key]
874
+
875
+ spatial_dims = min(len(box_start), len(image.shape[1:]))
876
+ slices = tuple(
877
+ [slice(None)] + [slice(s, e) for s, e in zip(box_start[:spatial_dims], box_end[:spatial_dims])]
878
+ )
879
+ result[slices] = image
880
+ else:
881
+ result = image
862
882
 
863
883
  # Undo Spacing
864
- current_size = result.shape[1:]
865
- # change spatial_shape from HWD to DHW
866
- spatial_shape = list(np.roll(meta_dict["spatial_shape"], 1))
867
- spatial_size = spatial_shape[-len(current_size) :]
884
+ if self.restore_spacing:
885
+ current_size = result.shape[1:]
886
+ # change spatial_shape from HWD to DHW
887
+ spatial_shape = list(np.roll(meta_dict["spatial_shape"], 1))
888
+ spatial_size = spatial_shape[-len(current_size) :]
868
889
 
869
- if np.any(np.not_equal(current_size, spatial_size)):
870
- resizer = Resize(spatial_size=spatial_size, mode=mode)
871
- result = resizer(result, mode=mode, align_corners=align_corners) # type: ignore
890
+ if np.any(np.not_equal(current_size, spatial_size)):
891
+ resizer = Resize(spatial_size=spatial_size, mode=mode)
892
+ result = resizer(result, mode=mode, align_corners=align_corners) # type: ignore
872
893
 
873
894
  # Undo Slicing
874
895
  slice_idx = meta_dict.get("slice_idx")
875
896
  final_result: NdarrayOrTensor
876
- if slice_idx is None or self.slice_only:
897
+ if not self.restore_slicing: # do nothing if restore slicing isn't requested
898
+ final_result = result
899
+ elif slice_idx is None or self.slice_only:
877
900
  final_result = result if len(result.shape) <= 3 else result[0]
878
901
  else:
879
902
  slice_idx = meta_dict["slice_idx"][0]
monai/config/__init__.py CHANGED
@@ -14,6 +14,7 @@ from __future__ import annotations
14
14
  from .deviceconfig import (
15
15
  USE_COMPILED,
16
16
  USE_META_DICT,
17
+ IgniteInfo,
17
18
  get_config_values,
18
19
  get_gpu_info,
19
20
  get_optional_config_values,
@@ -23,6 +23,8 @@ import numpy as np
23
23
  import torch
24
24
 
25
25
  import monai
26
+ from monai.utils.deprecate_utils import deprecated
27
+ from monai.utils.enums import IgniteInfo as _IgniteInfo
26
28
  from monai.utils.module import OptionalImportError, get_package_version, optional_import
27
29
 
28
30
  try:
@@ -45,6 +47,7 @@ __all__ = [
45
47
  "print_debug_info",
46
48
  "USE_COMPILED",
47
49
  "USE_META_DICT",
50
+ "IgniteInfo",
48
51
  ]
49
52
 
50
53
 
@@ -260,5 +263,12 @@ def print_debug_info(file: TextIO = sys.stdout) -> None:
260
263
  print_gpu_info(file)
261
264
 
262
265
 
266
+ @deprecated(since="1.4.0", removed="1.6.0", msg_suffix="Please use `monai.utils.enums.IgniteInfo` instead.")
267
+ class IgniteInfo:
268
+ """Deprecated Import of IgniteInfo enum, which was moved to `monai.utils.enums.IgniteInfo`."""
269
+
270
+ OPT_IMPORT_VERSION = _IgniteInfo.OPT_IMPORT_VERSION
271
+
272
+
263
273
  if __name__ == "__main__":
264
274
  print_debug_info()
monai/utils/enums.py CHANGED
@@ -727,7 +727,7 @@ class IgniteInfo(StrEnum):
727
727
 
728
728
  """
729
729
 
730
- OPT_IMPORT_VERSION = "0.4.4"
730
+ OPT_IMPORT_VERSION = "0.4.11"
731
731
 
732
732
 
733
733
  if TYPE_CHECKING:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: monai-weekly
3
- Version: 1.4.dev2439
3
+ Version: 1.4.dev2441
4
4
  Summary: AI Toolkit for Healthcare Imaging
5
5
  Home-page: https://monai.io/
6
6
  Author: MONAI Consortium
@@ -1,5 +1,5 @@
1
- monai/__init__.py,sha256=CmkgY5g-rxGpBMHr6uWjyQrAbg8kqEIBMmfRy0M5nRA,4095
2
- monai/_version.py,sha256=NNobIKI9e8RMOS96iH0hSWqMTzcTLl2Vv0qCGKdkDlk,503
1
+ monai/__init__.py,sha256=0V-ca1Bt9VxdrUBijK2gfQswTYDXWtBA9PBHIs9oSZ0,4095
2
+ monai/_version.py,sha256=pfNb_sO0WbswtIrF1esHnac1VUqYKHVs5ovDRsLId8w,503
3
3
  monai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  monai/_extensions/__init__.py,sha256=NEBPreRhQ8H9gVvgrLr_y52_TmqB96u_u4VQmeNT93I,642
5
5
  monai/_extensions/loader.py,sha256=7SiKw36q-nOzH8CRbBurFrz7GM40GCu7rc93Tm8XpnI,3643
@@ -26,7 +26,7 @@ monai/apps/deepedit/transforms.py,sha256=Udj35m10Irek5Gtqo6Hgv6Lt7S6jSo-z0NuyVbs
26
26
  monai/apps/deepgrow/__init__.py,sha256=s9djSd6kvViPnFvMR11Dgd30Lv4oY6FaPJr4ZZJZLq0,573
27
27
  monai/apps/deepgrow/dataset.py,sha256=W0wv1QujA4sZgrAcBS64dl3OBbDBM2cF4RK0fDCQnRU,10054
28
28
  monai/apps/deepgrow/interaction.py,sha256=-smtOl93i_SDEo_Yo8DE5U3FnDrUcdJWeP14nCq5GS4,3748
29
- monai/apps/deepgrow/transforms.py,sha256=MQ3WPGfqagXoN6ySccpPFWOQAcxKOX4VUeQ0Zybx45I,41873
29
+ monai/apps/deepgrow/transforms.py,sha256=RmKMoN4sqhT84ognTJt55t6UtkL_OpkzRcP5VPseSss,43349
30
30
  monai/apps/detection/__init__.py,sha256=s9djSd6kvViPnFvMR11Dgd30Lv4oY6FaPJr4ZZJZLq0,573
31
31
  monai/apps/detection/metrics/__init__.py,sha256=s9djSd6kvViPnFvMR11Dgd30Lv4oY6FaPJr4ZZJZLq0,573
32
32
  monai/apps/detection/metrics/coco.py,sha256=bpF6hAAMKsBNLfat-Fzh0CR-0swDsAAVcwTaZ-lo1_g,26618
@@ -117,8 +117,8 @@ monai/bundle/reference_resolver.py,sha256=aBw3ML7B_YsiFUNl_mcRYPry1UbrEIK0R39A0z
117
117
  monai/bundle/scripts.py,sha256=ziTH32hd2A00c1wzXzAe2cttCEQtZoDqDx1bCDI1TR0,89136
118
118
  monai/bundle/utils.py,sha256=t-22uFvLn7Yy-dr1v1U33peNOxgAmU4TJiGAbsBrUKs,10108
119
119
  monai/bundle/workflows.py,sha256=KADIppCZY6jCDvyCH2PmJm0Q-6xwCnB7x7KjFfRP8LY,24655
120
- monai/config/__init__.py,sha256=x7Had67mmng8xKkLDKrrJwqFW3ohlhrJ7iJ_rdvewX8,1032
121
- monai/config/deviceconfig.py,sha256=T-slMfnvHmXYZqcQJcqXxTz1DYFGD3mKnnAUZSVa6C0,10172
120
+ monai/config/__init__.py,sha256=CN28CfTdsp301gv8YXfVvkbztCfbAqrLKrJi_C8oP9s,1048
121
+ monai/config/deviceconfig.py,sha256=f3Xa0OL9kNqdsbZ0PfUEvm6NZivAPh454_VCE8BmsWE,10582
122
122
  monai/config/type_definitions.py,sha256=0fAuI-_uX2Ac_33bgDVXKmBSl-fJNFcsOqBqYV16fhk,3485
123
123
  monai/data/__init__.py,sha256=loDwAMF14hb4HS04SwukoIchIfU6iGY-xPrJVGyVwBo,5167
124
124
  monai/data/box_utils.py,sha256=YbG6lOoYwUGmwcNmoKzq2xnNTbYA4LMkHmfsqteopCg,50102
@@ -399,7 +399,7 @@ monai/utils/component_store.py,sha256=VMF7CtPu5Wi_eX_qFtm9iWo5kvoWFuCUIxdRzk90zZ
399
399
  monai/utils/decorators.py,sha256=YRK5iEMdbc2INrWnBNDSMTaHge_0ezRf2b9yJGL-opg,3129
400
400
  monai/utils/deprecate_utils.py,sha256=gKeEV4MsI51qeQ5gci2me_C-0e-tDwa3VZzd3XPQqLk,14759
401
401
  monai/utils/dist.py,sha256=QUVRusnAdiySK_dnTrDWqxNMl4XU4pwzvlMaGsvVE3Y,8644
402
- monai/utils/enums.py,sha256=ihvq2X9Z_cjmDKXhgHFLDcTJzWbi1AtLbbYSZC9iezI,19512
402
+ monai/utils/enums.py,sha256=orCV7SGDajYtl3DhTTjbLDbayr6WxkMSw_bZ6yeGGTY,19513
403
403
  monai/utils/jupyter_utils.py,sha256=kQqfLTLAre3TLzXTt091X_XeWy5K0QKAcTuYlJ8BOag,15650
404
404
  monai/utils/misc.py,sha256=4KCY-Kmlzjup3KE2bgJsjIItKdDMxXwA0_rH1ghHONE,31410
405
405
  monai/utils/module.py,sha256=ICsVqQMV-069FuVwjCHm3d3hyvIOx9El17IXZ-2sfQk,24319
@@ -416,8 +416,8 @@ monai/visualize/img2tensorboard.py,sha256=NnMcyfIFqX-jD7TBO3Rn02zt5uug79d_7pIIaV
416
416
  monai/visualize/occlusion_sensitivity.py,sha256=OQHEJLyIhB8zWqQsfKaX-1kvCjWFVYtLfS4dFC0nKFI,18160
417
417
  monai/visualize/utils.py,sha256=B-MhTVs7sQbIqYS3yPnpBwPw2K82rE2PBtGIfpwZtWM,9894
418
418
  monai/visualize/visualizer.py,sha256=qckyaMZCbezYUwE20k5yc-Pb7UozVavMDbrmyQwfYHY,1377
419
- monai_weekly-1.4.dev2439.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
420
- monai_weekly-1.4.dev2439.dist-info/METADATA,sha256=P2ERflLdl70ZUYCzPV3aJB53ToRiUSYgnLWVeXJAr3k,11172
421
- monai_weekly-1.4.dev2439.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
422
- monai_weekly-1.4.dev2439.dist-info/top_level.txt,sha256=UaNwRzLGORdus41Ip446s3bBfViLkdkDsXDo34J2P44,6
423
- monai_weekly-1.4.dev2439.dist-info/RECORD,,
419
+ monai_weekly-1.4.dev2441.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
420
+ monai_weekly-1.4.dev2441.dist-info/METADATA,sha256=VPKdbi178DBdGodZ-DsfUHOc13tPT-58VDGTFXdV_DE,11172
421
+ monai_weekly-1.4.dev2441.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
422
+ monai_weekly-1.4.dev2441.dist-info/top_level.txt,sha256=UaNwRzLGORdus41Ip446s3bBfViLkdkDsXDo34J2P44,6
423
+ monai_weekly-1.4.dev2441.dist-info/RECORD,,