Skip to content

Commit

Permalink
KeepLargestConnectedComponent(d) example transforms (#3108)
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
  • Loading branch information
rijobro authored Oct 11, 2021
1 parent 31f9c1e commit 7b1b772
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/source/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ Post-processing

`KeepLargestConnectedComponent`
"""""""""""""""""""""""""""""""
.. image:: https://github.com/Project-MONAI/DocImages/raw/main/transforms/KeepLargestConnectedComponent.png
:alt: example of KeepLargestConnectedComponent
.. autoclass:: KeepLargestConnectedComponent
:members:
:special-members: __call__
Expand Down Expand Up @@ -1249,6 +1251,8 @@ Post-processing (Dict)

`KeepLargestConnectedComponentd`
""""""""""""""""""""""""""""""""
.. image:: https://github.com/Project-MONAI/DocImages/raw/main/transforms/KeepLargestConnectedComponentd.png
:alt: example of KeepLargestConnectedComponentd
.. autoclass:: KeepLargestConnectedComponentd
:members:
:special-members: __call__
Expand Down
10 changes: 8 additions & 2 deletions monai/transforms/utils_create_transform_ims.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@
StdShiftIntensityd,
ThresholdIntensityd,
)
from monai.transforms.post.array import LabelFilter, LabelToContour
from monai.transforms.post.dictionary import AsDiscreted, LabelFilterd, LabelToContourd
from monai.transforms.post.array import KeepLargestConnectedComponent, LabelFilter, LabelToContour
from monai.transforms.post.dictionary import AsDiscreted, KeepLargestConnectedComponentd, LabelFilterd, LabelToContourd
from monai.transforms.spatial.array import Rand2DElastic, RandAffine, RandAxisFlip, RandRotate90, Resize, Spacing
from monai.transforms.spatial.dictionary import (
Rand2DElasticd,
Expand Down Expand Up @@ -666,3 +666,9 @@ def create_transform_im(
create_transform_im(RandAxisFlipd, dict(keys=keys, prob=1), data)
create_transform_im(Resize, dict(spatial_size=(100, 100, 100)), data)
create_transform_im(Resized, dict(keys=keys, spatial_size=(100, 100, 100), mode=["area", "nearest"]), data)
data_binary = deepcopy(data)
data_binary[CommonKeys.LABEL] = (data_binary[CommonKeys.LABEL] > 0).astype(np.float32)
create_transform_im(KeepLargestConnectedComponent, dict(applied_labels=1), data_binary, is_post=True, ndim=2)
create_transform_im(
KeepLargestConnectedComponentd, dict(keys=CommonKeys.LABEL, applied_labels=1), data_binary, is_post=True, ndim=2
)

0 comments on commit 7b1b772

Please sign in to comment.