Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/source/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,8 @@ Spatial

`GridDistortion`
""""""""""""""""
.. image:: https://github.com/Project-MONAI/DocImages/raw/main/transforms/GridDistortion.png
:alt: example of GridDistortion
.. autoclass:: GridDistortion
:members:
:special-members: __call__
Expand Down Expand Up @@ -735,12 +737,16 @@ Smooth Field

`RandSmoothFieldAdjustContrast`
"""""""""""""""""""""""""""""""
.. image:: https://github.com/Project-MONAI/DocImages/raw/main/transforms/RandSmoothFieldAdjustContrast.png
:alt: example of RandSmoothFieldAdjustContrast
.. autoclass:: RandSmoothFieldAdjustContrast
:members:
:special-members: __call__

`RandSmoothFieldAdjustIntensity`
""""""""""""""""""""""""""""""""
.. image:: https://github.com/Project-MONAI/DocImages/raw/main/transforms/RandSmoothFieldAdjustIntensity.png
:alt: example of RandSmoothFieldAdjustIntensity
.. autoclass:: RandSmoothFieldAdjustIntensity
:members:
:special-members: __call__
Expand Down Expand Up @@ -1521,6 +1527,8 @@ Spatial (Dict)

`GridDistortiond`
"""""""""""""""""
.. image:: https://github.com/Project-MONAI/DocImages/raw/main/transforms/GridDistortiond.png
:alt: example of GridDistortiond
.. autoclass:: GridDistortiond
:members:
:special-members: __call__
Expand All @@ -1538,12 +1546,16 @@ Smooth Field (Dict)

`RandSmoothFieldAdjustContrastd`
""""""""""""""""""""""""""""""""
.. image:: https://github.com/Project-MONAI/DocImages/raw/main/transforms/RandSmoothFieldAdjustContrastd.png
:alt: example of RandSmoothFieldAdjustContrastd
.. autoclass:: RandSmoothFieldAdjustContrastd
:members:
:special-members: __call__

`RandSmoothFieldAdjustIntensityd`
"""""""""""""""""""""""""""""""""
.. image:: https://github.com/Project-MONAI/DocImages/raw/main/transforms/RandSmoothFieldAdjustIntensityd.png
:alt: example of RandSmoothFieldAdjustIntensityd
.. autoclass:: RandSmoothFieldAdjustIntensityd
:members:
:special-members: __call__
Expand Down
3 changes: 0 additions & 3 deletions monai/transforms/smooth_field/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,6 @@ def __call__(self, img: np.ndarray, randomize: bool = True):
if not self._do_transform:
return img

img_min = img.min()
img_max = img.max()

field = self.sfield()
rfield, *_ = convert_to_dst_type(field, img)

Expand Down
32 changes: 32 additions & 0 deletions monai/transforms/utils_create_transform_ims.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@
)
from monai.transforms.post.array import KeepLargestConnectedComponent, LabelFilter, LabelToContour
from monai.transforms.post.dictionary import AsDiscreted, KeepLargestConnectedComponentd, LabelFilterd, LabelToContourd
from monai.transforms.smooth_field.array import RandSmoothFieldAdjustContrast, RandSmoothFieldAdjustIntensity
from monai.transforms.smooth_field.dictionary import RandSmoothFieldAdjustContrastd, RandSmoothFieldAdjustIntensityd
from monai.transforms.spatial.array import (
GridDistortion,
Rand2DElastic,
RandAffine,
RandAxisFlip,
Expand All @@ -155,6 +158,7 @@
Spacing,
)
from monai.transforms.spatial.dictionary import (
GridDistortiond,
Rand2DElasticd,
RandAffined,
RandAxisFlipd,
Expand Down Expand Up @@ -668,9 +672,37 @@ def create_transform_im(
create_transform_im(
KeepLargestConnectedComponentd, dict(keys=CommonKeys.LABEL, applied_labels=1), data_binary, is_post=True, ndim=2
)
create_transform_im(
GridDistortion, dict(num_cells=3, distort_steps=[(1.5,) * 4] * 3, mode="nearest", padding_mode="zeros"), data
)
create_transform_im(
GridDistortiond,
dict(
keys=keys, num_cells=3, distort_steps=[(1.5,) * 4] * 3, mode=["bilinear", "nearest"], padding_mode="zeros"
),
data,
)
create_transform_im(RandGridDistortion, dict(num_cells=3, prob=1.0, distort_limit=(-0.1, 0.1)), data)
create_transform_im(
RandGridDistortiond,
dict(keys=keys, num_cells=4, prob=1.0, distort_limit=(-0.2, 0.2), mode=["bilinear", "nearest"]),
data,
)
create_transform_im(
RandSmoothFieldAdjustContrast, dict(spatial_size=(217, 217, 217), rand_size=(100, 100, 100), prob=1.0), data
)
create_transform_im(
RandSmoothFieldAdjustContrastd,
dict(keys=keys, spatial_size=(217, 217, 217), rand_size=(100, 100, 100), prob=1.0),
data,
)
create_transform_im(
RandSmoothFieldAdjustIntensity,
dict(spatial_size=(217, 217, 217), rand_size=(100, 100, 100), prob=1.0, gamma=(0.5, 4.5)),
data,
)
create_transform_im(
RandSmoothFieldAdjustIntensityd,
dict(keys=keys, spatial_size=(217, 217, 217), rand_size=(100, 100, 100), prob=1.0, gamma=(0.5, 4.5)),
data,
)