Skip to content

Commit

Permalink
Fix review comments (Project-MONAI#2678)
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Penhouet <sebastian.penhouet@airamed.de>
  • Loading branch information
Sebastian Penhouet committed Aug 6, 2021
1 parent 13f759a commit a4a6bde
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
8 changes: 4 additions & 4 deletions docs/source/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,13 @@ Post-processing
:special-members: __call__

`LabelFilter`
"""""""""""""""""""""""""""""""
"""""""""""""
.. autoclass:: LabelFilter
:members:
:special-members: __call__

`FillHoles`
"""""""""""""""""""""""""""""""
"""""""""""
.. autoclass:: FillHoles
:members:
:special-members: __call__
Expand Down Expand Up @@ -968,13 +968,13 @@ Post-processing (Dict)
:special-members: __call__

`LabelFilterd`
""""""""""""""""""""""""""""""""
""""""""""""""
.. autoclass:: LabelFilterd
:members:
:special-members: __call__

`FillHolesd`
""""""""""""""""""""""""""""""""
""""""""""""
.. autoclass:: FillHolesd
:members:
:special-members: __call__
Expand Down
20 changes: 8 additions & 12 deletions monai/transforms/post/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def __init__(self, applied_labels: Union[Sequence[int], int]) -> None:
Initialize the LabelFilter class with the labels to filter on.
Args:
applied_labels (Union[Sequence[int], int]): Label(s) to filter on.
applied_labels: Label(s) to filter on.
"""
self.applied_labels = ensure_tuple(applied_labels)

Expand All @@ -324,13 +324,13 @@ def __call__(self, img: NdarrayTensor) -> NdarrayTensor:
Filter the image on the `applied_labels`.
Args:
img (NdarrayTensor): Pytorch tensor or numpy array of any shape.
img: Pytorch tensor or numpy array of any shape.
Raises:
NotImplementedError: The provided image was not a Pytorch Tensor or numpy array.
Returns:
Union[np.ndarray, torch.Tensor]: Pytorch tensor or numpy array of the same shape as the input.
Pytorch tensor or numpy array of the same shape as the input.
"""
if isinstance(img, np.ndarray):
return np.asarray(np.where(np.isin(img, self.applied_labels), img, 0))
Expand Down Expand Up @@ -388,11 +388,9 @@ def __init__(
Initialize the connectivity and limit the labels for which holes are filled.
Args:
applied_labels (Optional[Union[Iterable[int], int]], optional): Labels for which to fill holes. Defaults to None,
that is filling holes for all labels.
connectivity (int, optional): Maximum number of orthogonal hops to consider a pixel/voxel as a neighbor.
Accepted values are ranging from 1 to input.ndim. Defaults to a full
connectivity of ``input.ndim``.
applied_labels: Labels for which to fill holes. Defaults to None, that is filling holes for all labels.
connectivity: Maximum number of orthogonal hops to consider a pixel/voxel as a neighbor.
Accepted values are ranging from 1 to input.ndim. Defaults to a full connectivity of ``input.ndim``.
"""
super().__init__()
self.applied_labels = ensure_tuple(applied_labels) if applied_labels else None
Expand All @@ -406,15 +404,13 @@ def __call__(self, img: NdarrayTensor) -> NdarrayTensor:
The value 0 is assumed as background label.
Args:
img (NdarrayTensor): Pytorch Tensor or numpy array
of shape [batch_size, num_channel, spatial_dim1[, spatial_dim2, ...]].
img: Pytorch Tensor or numpy array of shape [batch_size, num_channel, spatial_dim1[, spatial_dim2, ...]].
Raises:
NotImplementedError: The provided image was not a Pytorch Tensor or numpy array.
Returns:
Union[np.ndarray, torch.Tensor]: Pytorch Tensor or numpy array
of shape [batch_size, num_channel, spatial_dim1[, spatial_dim2, ...]].
Pytorch Tensor or numpy array of shape [batch_size, num_channel, spatial_dim1[, spatial_dim2, ...]].
"""
if isinstance(img, np.ndarray):
channel_axis = 1
Expand Down
2 changes: 1 addition & 1 deletion monai/transforms/post/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def __init__(
Args:
keys: keys of the corresponding items to be transformed.
See also: :py:class:`monai.transforms.compose.MapTransform`
applied_labels (Union[Sequence[int], int]): Label(s) to filter on.
applied_labels: Label(s) to filter on.
allow_missing_keys: don't raise exception if key is missing.
"""
Expand Down
8 changes: 4 additions & 4 deletions monai/transforms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,15 +750,15 @@ def fill_holes(
Limiting the number of `applied_labels` results in a big decrease in processing time.
Args:
img_arr (np.ndarray): numpy array of shape [batch_size, spatial_dim1[, spatial_dim2, ...]].
applied_labels (Optional[Iterable[int]], optional): Labels for which to fill holes. Defaults to None,
img_arr: numpy array of shape [batch_size, spatial_dim1[, spatial_dim2, ...]].
applied_labels: Labels for which to fill holes. Defaults to None,
that is filling holes for all labels.
connectivity (Optional[int], optional): connectivity (int, optional): Maximum number of orthogonal hops to
connectivity: connectivity (int, optional): Maximum number of orthogonal hops to
consider a pixel/voxel as a neighbor. Accepted values are ranging from 1 to input.ndim.
Defaults to a full connectivity of ``input.ndim``.
Returns:
np.ndarray: numpy array of shape [batch_size, spatial_dim1[, spatial_dim2, ...]].
numpy array of shape [batch_size, spatial_dim1[, spatial_dim2, ...]].
"""
# Ignore batch dimension in structure (window for dilation steps)
spatial_dims = img_arr.ndim - 1
Expand Down

0 comments on commit a4a6bde

Please sign in to comment.