Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 211cfd8

Browse filesBrowse files
Remove deprecated feature for v1.5 (#1989)
Part of Project-MONAI/MONAI#8421 ### Description Remove deprecated feature for v1.5 ### Checks <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [ ] Avoid including large-size files in the PR. - [ ] Clean up long text outputs from code cells in the notebook. - [ ] For security purposes, please check the contents and remove any sensitive info such as user names and private key. - [ ] Ensure (1) hyperlinks and markdown anchors are working (2) use relative paths for tutorial repo files (3) put figure and graphs in the `./figure` folder - [ ] Notebook runs automatically `./runner.sh -t <path to .ipynb file>` --------- Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent fd86def commit 211cfd8
Copy full SHA for 211cfd8
Expand file treeCollapse file tree

35 files changed

+67
-66
lines changed

‎3d_segmentation/spleen_segmentation_3d.ipynb

Copy file name to clipboardExpand all lines: 3d_segmentation/spleen_segmentation_3d.ipynb
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@
284284
" b_max=1.0,\n",
285285
" clip=True,\n",
286286
" ),\n",
287-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
287+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
288288
" Orientationd(keys=[\"image\", \"label\"], axcodes=\"RAS\"),\n",
289289
" Spacingd(keys=[\"image\", \"label\"], pixdim=(1.5, 1.5, 2.0), mode=(\"bilinear\", \"nearest\")),\n",
290290
" RandCropByPosNegLabeld(\n",
@@ -318,7 +318,7 @@
318318
" b_max=1.0,\n",
319319
" clip=True,\n",
320320
" ),\n",
321-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
321+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
322322
" Orientationd(keys=[\"image\", \"label\"], axcodes=\"RAS\"),\n",
323323
" Spacingd(keys=[\"image\", \"label\"], pixdim=(1.5, 1.5, 2.0), mode=(\"bilinear\", \"nearest\")),\n",
324324
" ]\n",
@@ -690,7 +690,7 @@
690690
" b_max=1.0,\n",
691691
" clip=True,\n",
692692
" ),\n",
693-
" CropForegroundd(keys=[\"image\"], source_key=\"image\"),\n",
693+
" CropForegroundd(keys=[\"image\"], source_key=\"image\", allow_smaller=True),\n",
694694
" ]\n",
695695
")\n",
696696
"\n",
@@ -784,7 +784,7 @@
784784
" b_max=1.0,\n",
785785
" clip=True,\n",
786786
" ),\n",
787-
" CropForegroundd(keys=[\"image\"], source_key=\"image\"),\n",
787+
" CropForegroundd(keys=[\"image\"], source_key=\"image\", allow_smaller=True),\n",
788788
" ]\n",
789789
")\n",
790790
"\n",

‎3d_segmentation/spleen_segmentation_3d_lightning.ipynb

Copy file name to clipboardExpand all lines: 3d_segmentation/spleen_segmentation_3d_lightning.ipynb
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@
278278
" b_max=1.0,\n",
279279
" clip=True,\n",
280280
" ),\n",
281-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
281+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
282282
" # randomly crop out patch samples from\n",
283283
" # big image based on pos / neg ratio\n",
284284
" # the image centers of negative samples\n",
@@ -321,7 +321,7 @@
321321
" b_max=1.0,\n",
322322
" clip=True,\n",
323323
" ),\n",
324-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
324+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
325325
" ]\n",
326326
" )\n",
327327
"\n",

‎3d_segmentation/spleen_segmentation_3d_visualization_basic.ipynb

Copy file name to clipboardExpand all lines: 3d_segmentation/spleen_segmentation_3d_visualization_basic.ipynb
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@
317317
" b_max=1.0,\n",
318318
" clip=True,\n",
319319
" ),\n",
320-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
320+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
321321
" Orientationd(keys=[\"image\", \"label\"], axcodes=\"RAS\"),\n",
322322
" Spacingd(keys=[\"image\", \"label\"], pixdim=(1.5, 1.5, 2.0), mode=(\"bilinear\", \"nearest\")),\n",
323323
" RandCropByPosNegLabeld(\n",
@@ -351,7 +351,7 @@
351351
" b_max=1.0,\n",
352352
" clip=True,\n",
353353
" ),\n",
354-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
354+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
355355
" Orientationd(keys=[\"image\", \"label\"], axcodes=\"RAS\"),\n",
356356
" Spacingd(keys=[\"image\", \"label\"], pixdim=(1.5, 1.5, 2.0), mode=(\"bilinear\", \"nearest\")),\n",
357357
" ]\n",
@@ -782,7 +782,7 @@
782782
" b_max=1.0,\n",
783783
" clip=True,\n",
784784
" ),\n",
785-
" CropForegroundd(keys=[\"image\"], source_key=\"image\"),\n",
785+
" CropForegroundd(keys=[\"image\"], source_key=\"image\", allow_smaller=True),\n",
786786
" ]\n",
787787
")\n",
788788
"\n",

‎3d_segmentation/swin_unetr_brats21_segmentation_3d.ipynb

Copy file name to clipboardExpand all lines: 3d_segmentation/swin_unetr_brats21_segmentation_3d.ipynb
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@
326326
" keys=[\"image\", \"label\"],\n",
327327
" source_key=\"image\",\n",
328328
" k_divisible=[roi[0], roi[1], roi[2]],\n",
329+
" allow_smaller=True,\n",
329330
" ),\n",
330331
" transforms.RandSpatialCropd(\n",
331332
" keys=[\"image\", \"label\"],\n",
@@ -467,7 +468,6 @@
467468
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
468469
"\n",
469470
"model = SwinUNETR(\n",
470-
" img_size=roi,\n",
471471
" in_channels=4,\n",
472472
" out_channels=3,\n",
473473
" feature_size=48,\n",

‎3d_segmentation/swin_unetr_btcv_segmentation_3d.ipynb

Copy file name to clipboardExpand all lines: 3d_segmentation/swin_unetr_btcv_segmentation_3d.ipynb
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
" b_max=1.0,\n",
244244
" clip=True,\n",
245245
" ),\n",
246-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
246+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
247247
" Orientationd(keys=[\"image\", \"label\"], axcodes=\"RAS\"),\n",
248248
" Spacingd(\n",
249249
" keys=[\"image\", \"label\"],\n",
@@ -292,7 +292,7 @@
292292
" [\n",
293293
" LoadImaged(keys=[\"image\", \"label\"], ensure_channel_first=True),\n",
294294
" ScaleIntensityRanged(keys=[\"image\"], a_min=-175, a_max=250, b_min=0.0, b_max=1.0, clip=True),\n",
295-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
295+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
296296
" Orientationd(keys=[\"image\", \"label\"], axcodes=\"RAS\"),\n",
297297
" Spacingd(\n",
298298
" keys=[\"image\", \"label\"],\n",
@@ -439,7 +439,6 @@
439439
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
440440
"\n",
441441
"model = SwinUNETR(\n",
442-
" img_size=(96, 96, 96),\n",
443442
" in_channels=1,\n",
444443
" out_channels=14,\n",
445444
" feature_size=48,\n",

‎3d_segmentation/unetr_btcv_segmentation_3d.ipynb

Copy file name to clipboardExpand all lines: 3d_segmentation/unetr_btcv_segmentation_3d.ipynb
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
" b_max=1.0,\n",
229229
" clip=True,\n",
230230
" ),\n",
231-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
231+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
232232
" RandCropByPosNegLabeld(\n",
233233
" keys=[\"image\", \"label\"],\n",
234234
" label_key=\"label\",\n",
@@ -277,7 +277,7 @@
277277
" mode=(\"bilinear\", \"nearest\"),\n",
278278
" ),\n",
279279
" ScaleIntensityRanged(keys=[\"image\"], a_min=-175, a_max=250, b_min=0.0, b_max=1.0, clip=True),\n",
280-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
280+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
281281
" ]\n",
282282
")"
283283
]

‎3d_segmentation/unetr_btcv_segmentation_3d_lightning.ipynb

Copy file name to clipboardExpand all lines: 3d_segmentation/unetr_btcv_segmentation_3d_lightning.ipynb
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@
466466
" b_max=1.0,\n",
467467
" clip=True,\n",
468468
" ),\n",
469-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
469+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
470470
" Orientationd(keys=[\"image\", \"label\"], axcodes=\"RAS\"),\n",
471471
" Spacingd(\n",
472472
" keys=[\"image\", \"label\"],\n",
@@ -522,7 +522,7 @@
522522
" b_max=1.0,\n",
523523
" clip=True,\n",
524524
" ),\n",
525-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
525+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
526526
" Orientationd(keys=[\"image\", \"label\"], axcodes=\"RAS\"),\n",
527527
" Spacingd(\n",
528528
" keys=[\"image\", \"label\"],\n",

‎acceleration/automatic_mixed_precision.ipynb

Copy file name to clipboardExpand all lines: acceleration/automatic_mixed_precision.ipynb
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
" b_max=1.0,\n",
200200
" clip=True,\n",
201201
" ),\n",
202-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
202+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
203203
" # pre-compute foreground and background indexes\n",
204204
" # and cache them to accelerate training\n",
205205
" FgBgToIndicesd(\n",
@@ -241,7 +241,7 @@
241241
" b_max=1.0,\n",
242242
" clip=True,\n",
243243
" ),\n",
244-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
244+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
245245
" ]\n",
246246
" )\n",
247247
" return train_transforms, val_transforms"

‎acceleration/dataset_type_performance.ipynb

Copy file name to clipboardExpand all lines: acceleration/dataset_type_performance.ipynb
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@
380380
" b_max=1.0,\n",
381381
" clip=True,\n",
382382
" ),\n",
383-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
383+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
384384
" # randomly crop out patch samples from big\n",
385385
" # image based on pos / neg ratio\n",
386386
" # the image centers of negative samples\n",
@@ -420,7 +420,7 @@
420420
" b_max=1.0,\n",
421421
" clip=True,\n",
422422
" ),\n",
423-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
423+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
424424
" ]\n",
425425
" )\n",
426426
" return train_transforms, val_transforms"

‎acceleration/fast_training_tutorial.ipynb

Copy file name to clipboardExpand all lines: acceleration/fast_training_tutorial.ipynb
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@
311311
" clip=True,\n",
312312
" ),\n",
313313
" ),\n",
314-
" range_func(\"CropForeground\", CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\")),\n",
314+
" range_func(\"CropForeground\", CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True)),\n",
315315
" # pre-compute foreground and background indexes\n",
316316
" # and cache them to accelerate training\n",
317317
" range_func(\n",
@@ -368,7 +368,7 @@
368368
" b_max=1.0,\n",
369369
" clip=True,\n",
370370
" ),\n",
371-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
371+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
372372
" ]\n",
373373
" if fast:\n",
374374
" # convert the data to Tensor without meta, move to GPU and cache to avoid CPU -> GPU sync in every epoch\n",

‎auto3dseg/docs/algorithm_generation.md

Copy file name to clipboardExpand all lines: auto3dseg/docs/algorithm_generation.md
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,12 @@ class DintsAlgo(BundleAlgo):
143143
"b_max": 1.0,
144144
"clip": True,
145145
},
146-
{"_target_": "CropForegroundd", "keys": ["@image_key", "@label_key"], "source_key": "@image_key"},
146+
{
147+
"_target_": "CropForegroundd",
148+
"keys": ["@image_key", "@label_key"],
149+
"source_key": "@image_key",
150+
"allow_smaller:" True,
151+
},
147152
],
148153
}
149154

‎auto3dseg/tasks/hecktor22/hecktor_crop_neck_region.py

Copy file name to clipboardExpand all lines: auto3dseg/tasks/hecktor22/hecktor_crop_neck_region.py
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,16 @@ def __init__(
3131
source_key="image",
3232
box_size=[200, 200, 310],
3333
allow_missing_keys=True,
34+
allow_smaller=True,
3435
**kwargs,
3536
) -> None:
36-
super().__init__(keys=keys, source_key=source_key, allow_missing_keys=allow_missing_keys, **kwargs)
37+
super().__init__(
38+
keys=keys,
39+
source_key=source_key,
40+
allow_missing_keys=allow_missing_keys,
41+
allow_smaller=allow_smaller,
42+
**kwargs,
43+
)
3744
self.box_size = box_size
3845

3946
def __call__(self, data, **kwargs):

‎bundle/python_bundle_workflow/scripts/inference.py

Copy file name to clipboardExpand all lines: bundle/python_bundle_workflow/scripts/inference.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class InferenceWorkflow(BundleWorkflow):
4848
"""
4949

5050
def __init__(self, dataset_dir: str = "./infer"):
51-
super().__init__(workflow="inference")
51+
super().__init__(workflow_type="inference")
5252
print_config()
5353
# set root log level to INFO and init a evaluation logger, will be used in `StatsHandler`
5454
logging.basicConfig(stream=sys.stdout, level=logging.INFO)

‎bundle/python_bundle_workflow/scripts/train.py

Copy file name to clipboardExpand all lines: bundle/python_bundle_workflow/scripts/train.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class TrainWorkflow(BundleWorkflow):
6767
"""
6868

6969
def __init__(self, dataset_dir: str = "./train"):
70-
super().__init__(workflow="train")
70+
super().__init__(workflow_type="train")
7171
print_config()
7272
# set root log level to INFO and init a train logger, will be used in `StatsHandler`
7373
logging.basicConfig(stream=sys.stdout, level=logging.INFO)

‎bundle/pythonic_usage_guidance/pythonic_bundle_access.ipynb

Copy file name to clipboardExpand all lines: bundle/pythonic_usage_guidance/pythonic_bundle_access.ipynb
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,7 @@
397397
"metadata": {},
398398
"outputs": [],
399399
"source": [
400-
"# Here we specify `return_state_dict=False` to return an instantiated model only for compatibility, will remove after MONAI v1.5.\n",
401-
"# directly get an instantiated network that loaded the weights.\n",
402-
"model = load(name=\"brats_mri_segmentation\", bundle_dir=root_dir, source=\"monaihosting\", return_state_dict=False)\n",
400+
"model = load(name=\"brats_mri_segmentation\", bundle_dir=root_dir, source=\"monaihosting\")\n",
403401
"\n",
404402
"# directly update the parameters for the model from the bundle.\n",
405403
"model = load(\n",
@@ -408,7 +406,6 @@
408406
" source=\"monaihosting\",\n",
409407
" in_channels=3,\n",
410408
" out_channels=1,\n",
411-
" return_state_dict=False,\n",
412409
")\n",
413410
"\n",
414411
"# using `exclude_vars` to filter loading weights.\n",
@@ -417,7 +414,6 @@
417414
" bundle_dir=root_dir,\n",
418415
" source=\"monaihosting\",\n",
419416
" copy_model_args={\"exclude_vars\": \"convInit|conv_final\"},\n",
420-
" return_state_dict=False,\n",
421417
")\n",
422418
"\n",
423419
"# pass model and return an instantiated network that loaded the weights.\n",

‎deepgrow/ignite/train.py

Copy file name to clipboardExpand all lines: deepgrow/ignite/train.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def get_pre_transforms(roi_size, model_size, dimensions):
9292
t = [
9393
LoadImaged(keys=("image", "label")),
9494
EnsureChannelFirstd(keys=("image", "label"), channel_dim="no_channel"),
95-
SpatialCropForegroundd(keys=("image", "label"), source_key="label", spatial_size=roi_size),
95+
SpatialCropForegroundd(keys=("image", "label"), source_key="label", spatial_size=roi_size, allow_smaller=True),
9696
Resized(keys=("image", "label"), spatial_size=model_size, mode=("area", "nearest")),
9797
NormalizeIntensityd(keys="image", subtrahend=208.0, divisor=388.0),
9898
]

‎deployment/Triton/models/monai_covid/1/model.py

Copy file name to clipboardExpand all lines: deployment/Triton/models/monai_covid/1/model.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def initialize(self, args):
112112
LoadImage(reader="NibabelReader", image_only=True, dtype=np.float32),
113113
EnsureChannelFirst(channel_dim="no_channel"),
114114
ScaleIntensityRange(a_min=-1000, a_max=500, b_min=0.0, b_max=1.0, clip=True),
115-
CropForeground(margin=5),
115+
CropForeground(margin=5, allow_smaller=True),
116116
Resize([192, 192, 64], mode="area"),
117117
EnsureChannelFirst(channel_dim="no_channel"),
118118
ToTensor(),

‎experiment_management/spleen_segmentation_aim.ipynb

Copy file name to clipboardExpand all lines: experiment_management/spleen_segmentation_aim.ipynb
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@
251251
" b_max=1.0,\n",
252252
" clip=True,\n",
253253
" ),\n",
254-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
254+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
255255
" RandCropByPosNegLabeld(\n",
256256
" keys=[\"image\", \"label\"],\n",
257257
" label_key=\"label\",\n",
@@ -285,7 +285,7 @@
285285
" b_max=1.0,\n",
286286
" clip=True,\n",
287287
" ),\n",
288-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
288+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
289289
" ]\n",
290290
")"
291291
]

‎experiment_management/spleen_segmentation_mlflow.ipynb

Copy file name to clipboardExpand all lines: experiment_management/spleen_segmentation_mlflow.ipynb
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249
" b_max=1.0,\n",
250250
" clip=True,\n",
251251
" ),\n",
252-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
252+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
253253
" RandCropByPosNegLabeld(\n",
254254
" keys=[\"image\", \"label\"],\n",
255255
" label_key=\"label\",\n",
@@ -283,7 +283,7 @@
283283
" b_max=1.0,\n",
284284
" clip=True,\n",
285285
" ),\n",
286-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
286+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
287287
" ]\n",
288288
")"
289289
]

‎model_zoo/transfer_learning_with_bundle/evaluate.py

Copy file name to clipboardExpand all lines: model_zoo/transfer_learning_with_bundle/evaluate.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
AsDiscrete,
3838
AsDiscreted,
3939
Compose,
40-
CropForegroundd,
4140
EnsureChannelFirstd,
4241
Invertd,
4342
LoadImaged,

‎model_zoo/transfer_learning_with_bundle/train.py

Copy file name to clipboardExpand all lines: model_zoo/transfer_learning_with_bundle/train.py
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,11 @@
3535
from monai.transforms import (
3636
Activations,
3737
AsDiscrete,
38-
AsDiscreted,
3938
Compose,
40-
CropForegroundd,
4139
EnsureChannelFirstd,
42-
Invertd,
4340
LoadImaged,
4441
Orientationd,
4542
RandCropByPosNegLabeld,
46-
SaveImaged,
4743
ScaleIntensityRanged,
4844
Spacingd,
4945
)

‎modules/dynunet_pipeline/transforms.py

Copy file name to clipboardExpand all lines: modules/dynunet_pipeline/transforms.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def __init__(
277277
self.mean = normalize_values[0]
278278
self.std = normalize_values[1]
279279
self.training = False
280-
self.crop_foreg = CropForegroundd(keys=["image", "label"], source_key="image")
280+
self.crop_foreg = CropForegroundd(keys=["image", "label"], source_key="image", allow_smaller=True)
281281
self.normalize_intensity = NormalizeIntensity(nonzero=True, channel_wise=True)
282282
if model_mode in ["train"]:
283283
self.training = True
@@ -310,7 +310,7 @@ def __call__(self, data):
310310
image, label = cropped_data["image"], cropped_data["label"]
311311
else:
312312
d["original_shape"] = np.array(image.shape[1:])
313-
box_start, box_end = generate_spatial_bounding_box(image)
313+
box_start, box_end = generate_spatial_bounding_box(image, allow_smaller=True)
314314
image = SpatialCrop(roi_start=box_start, roi_end=box_end)(image)
315315
d["bbox"] = np.vstack([box_start, box_end])
316316
d["crop_shape"] = np.array(image.shape[1:])

‎modules/integrate_3rd_party_transforms.ipynb

Copy file name to clipboardExpand all lines: modules/integrate_3rd_party_transforms.ipynb
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
" Orientationd(keys=[\"image\", \"label\"], axcodes=\"RAS\"),\n",
211211
" Spacingd(keys=[\"image\", \"label\"], pixdim=(1.5, 1.5, 2.0), mode=(\"bilinear\", \"nearest\")),\n",
212212
" ScaleIntensityRanged(keys=[\"image\"], a_min=-57, a_max=164, b_min=0.0, b_max=1.0, clip=True),\n",
213-
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
213+
" CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\", allow_smaller=True),\n",
214214
" EnsureTyped(keys=[\"image\", \"label\"], data_type=\"numpy\"),\n",
215215
"]"
216216
]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.