monai-weekly 1.4.dev2440__py3-none-any.whl → 1.5.dev2442__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 +1 -1
- monai/_version.py +3 -3
- monai/apps/deepgrow/transforms.py +46 -23
- monai/networks/schedulers/ddim.py +1 -1
- monai/networks/schedulers/ddpm.py +6 -2
- monai/transforms/regularization/array.py +5 -0
- {monai_weekly-1.4.dev2440.dist-info → monai_weekly-1.5.dev2442.dist-info}/METADATA +6 -6
- {monai_weekly-1.4.dev2440.dist-info → monai_weekly-1.5.dev2442.dist-info}/RECORD +11 -11
- {monai_weekly-1.4.dev2440.dist-info → monai_weekly-1.5.dev2442.dist-info}/WHEEL +1 -1
- {monai_weekly-1.4.dev2440.dist-info → monai_weekly-1.5.dev2442.dist-info}/LICENSE +0 -0
- {monai_weekly-1.4.dev2440.dist-info → monai_weekly-1.5.dev2442.dist-info}/top_level.txt +0 -0
monai/__init__.py
CHANGED
monai/_version.py
CHANGED
@@ -8,11 +8,11 @@ import json
|
|
8
8
|
|
9
9
|
version_json = '''
|
10
10
|
{
|
11
|
-
"date": "2024-10-
|
11
|
+
"date": "2024-10-20T02:29:48+0000",
|
12
12
|
"dirty": false,
|
13
13
|
"error": null,
|
14
|
-
"full-revisionid": "
|
15
|
-
"version": "1.
|
14
|
+
"full-revisionid": "d850fe3e5160f867a27d3f9e45f7ca1e4c7e53e5",
|
15
|
+
"version": "1.5.dev2442"
|
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
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
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
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
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
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
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
|
-
|
870
|
-
|
871
|
-
|
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
|
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]
|
@@ -220,7 +220,7 @@ class DDIMScheduler(Scheduler):
|
|
220
220
|
if eta > 0:
|
221
221
|
# randn_like does not support generator https://github.com/pytorch/pytorch/issues/27072
|
222
222
|
device: torch.device = torch.device(model_output.device if torch.is_tensor(model_output) else "cpu")
|
223
|
-
noise = torch.randn(model_output.shape, dtype=model_output.dtype, generator=generator
|
223
|
+
noise = torch.randn(model_output.shape, dtype=model_output.dtype, generator=generator, device=device)
|
224
224
|
variance = self._get_variance(timestep, prev_timestep) ** 0.5 * eta * noise
|
225
225
|
|
226
226
|
pred_prev_sample = pred_prev_sample + variance
|
@@ -241,8 +241,12 @@ class DDPMScheduler(Scheduler):
|
|
241
241
|
variance = 0
|
242
242
|
if timestep > 0:
|
243
243
|
noise = torch.randn(
|
244
|
-
model_output.size(),
|
245
|
-
|
244
|
+
model_output.size(),
|
245
|
+
dtype=model_output.dtype,
|
246
|
+
layout=model_output.layout,
|
247
|
+
generator=generator,
|
248
|
+
device=model_output.device,
|
249
|
+
)
|
246
250
|
variance = (self._get_variance(timestep, predicted_variance=predicted_variance) ** 0.5) * noise
|
247
251
|
|
248
252
|
pred_prev_sample = pred_prev_sample + variance
|
@@ -112,6 +112,11 @@ class CutMix(Mixer):
|
|
112
112
|
the mixing weight but also the size of the random rectangles used during for mixing.
|
113
113
|
Please refer to the paper for details.
|
114
114
|
|
115
|
+
Please note that there is a change in behavior starting from version 1.4.0. In the previous
|
116
|
+
implementation, the transform would generate a different label each time it was called.
|
117
|
+
To ensure determinism, the new implementation will now generate the same label for
|
118
|
+
the same input image when using the same operation.
|
119
|
+
|
115
120
|
The most common use case is something close to:
|
116
121
|
|
117
122
|
.. code-block:: python
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: monai-weekly
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.5.dev2442
|
4
4
|
Summary: AI Toolkit for Healthcare Imaging
|
5
5
|
Home-page: https://monai.io/
|
6
6
|
Author: MONAI Consortium
|
@@ -171,11 +171,11 @@ Requires-Dist: zarr; extra == "zarr"
|
|
171
171
|
[](https://codecov.io/gh/Project-MONAI/MONAI)
|
172
172
|
[](https://piptrends.com/package/monai)
|
173
173
|
|
174
|
-
MONAI is a [PyTorch](https://pytorch.org/)-based, [open-source](https://github.com/Project-MONAI/MONAI/blob/dev/LICENSE) framework for deep learning in healthcare imaging, part of [PyTorch Ecosystem](https://pytorch.org/ecosystem/).
|
175
|
-
Its ambitions are:
|
176
|
-
-
|
177
|
-
-
|
178
|
-
-
|
174
|
+
MONAI is a [PyTorch](https://pytorch.org/)-based, [open-source](https://github.com/Project-MONAI/MONAI/blob/dev/LICENSE) framework for deep learning in healthcare imaging, part of the [PyTorch Ecosystem](https://pytorch.org/ecosystem/).
|
175
|
+
Its ambitions are as follows:
|
176
|
+
- Developing a community of academic, industrial and clinical researchers collaborating on a common foundation;
|
177
|
+
- Creating state-of-the-art, end-to-end training workflows for healthcare imaging;
|
178
|
+
- Providing researchers with the optimized and standardized way to create and evaluate deep learning models.
|
179
179
|
|
180
180
|
|
181
181
|
## Features
|
@@ -1,5 +1,5 @@
|
|
1
|
-
monai/__init__.py,sha256=
|
2
|
-
monai/_version.py,sha256
|
1
|
+
monai/__init__.py,sha256=Pq8CvtjSIIpM46e3BgLQoDLKxCuHcP-V20mBqi5EA78,4095
|
2
|
+
monai/_version.py,sha256=2XTx0tN1SVpKgJ5hNz8ZFMQ6-HRSmdB6OUfhWAZQmUY,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=
|
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
|
@@ -336,8 +336,8 @@ monai/networks/nets/vnet.py,sha256=zaJi5kSiTLAuFHThSZfhJvHP6zKh3oBWsTWG-328O_g,1
|
|
336
336
|
monai/networks/nets/voxelmorph.py,sha256=Q5VQFLLKSFqhsG0Z8_72ZGfK1nA4kdCfFnGbqI6Eofg,20665
|
337
337
|
monai/networks/nets/vqvae.py,sha256=Zf9fTL_rluhuJhH6gTNB6iiKRfwBxfuuyhCdU9TLmAk,18417
|
338
338
|
monai/networks/schedulers/__init__.py,sha256=rPmrNvnt8Bh9D2omPMgDiGVuT1XVJlgtlWIlqA_sjb4,755
|
339
|
-
monai/networks/schedulers/ddim.py,sha256=
|
340
|
-
monai/networks/schedulers/ddpm.py,sha256=
|
339
|
+
monai/networks/schedulers/ddim.py,sha256=MygHvgLB_NL9488DhHsE_g-EvV6DlDPtiBROpnCvDHc,14380
|
340
|
+
monai/networks/schedulers/ddpm.py,sha256=LPqmlNJex32QrqcVb5s7XCNKVlFPsd_05-IJHpUJZPI,11387
|
341
341
|
monai/networks/schedulers/pndm.py,sha256=9Qe8NOw_tvlpCBK7yvkmyriyGfIO5RRDV8ZKPh85cQY,14472
|
342
342
|
monai/networks/schedulers/scheduler.py,sha256=X5eu5AmtNiads9cgaFy5r7BdlKYASSICyGSyF-fk6x8,9206
|
343
343
|
monai/optimizers/__init__.py,sha256=XUL7o9vSL7bZImpxVZqcc1c8MwUMrOZL4nJ-mjAA7yM,796
|
@@ -379,7 +379,7 @@ monai/transforms/post/__init__.py,sha256=s9djSd6kvViPnFvMR11Dgd30Lv4oY6FaPJr4ZZJ
|
|
379
379
|
monai/transforms/post/array.py,sha256=06Dfd_6cf-VJneet7WwbxFFlJEhYh365xu3fkcvGTws,45042
|
380
380
|
monai/transforms/post/dictionary.py,sha256=pq4Oh3GoDcS6sjUkLvHzYmySxuxzVW7grjogFuRsUsA,43042
|
381
381
|
monai/transforms/regularization/__init__.py,sha256=s9djSd6kvViPnFvMR11Dgd30Lv4oY6FaPJr4ZZJZLq0,573
|
382
|
-
monai/transforms/regularization/array.py,sha256=
|
382
|
+
monai/transforms/regularization/array.py,sha256=oSG08b7opKGbHVZkpefdG1o0sX_F7-VoltzpNm5MB6k,8384
|
383
383
|
monai/transforms/regularization/dictionary.py,sha256=b2hw8nElkQeyu3LZSnWvz7pQMcK9tCuNHpLueAGTQr8,4800
|
384
384
|
monai/transforms/signal/__init__.py,sha256=s9djSd6kvViPnFvMR11Dgd30Lv4oY6FaPJr4ZZJZLq0,573
|
385
385
|
monai/transforms/signal/array.py,sha256=eTlvqOIUQixh-voTNJcl532RvG4ZlQBNeHhg3TT3Cto,16325
|
@@ -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.
|
420
|
-
monai_weekly-1.
|
421
|
-
monai_weekly-1.
|
422
|
-
monai_weekly-1.
|
423
|
-
monai_weekly-1.
|
419
|
+
monai_weekly-1.5.dev2442.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
420
|
+
monai_weekly-1.5.dev2442.dist-info/METADATA,sha256=ViLiKZdT67FCg3CtHo78A50SXdzyR7bPnOEcM_YSKeU,11187
|
421
|
+
monai_weekly-1.5.dev2442.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
422
|
+
monai_weekly-1.5.dev2442.dist-info/top_level.txt,sha256=UaNwRzLGORdus41Ip446s3bBfViLkdkDsXDo34J2P44,6
|
423
|
+
monai_weekly-1.5.dev2442.dist-info/RECORD,,
|
File without changes
|
File without changes
|