Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 13, 2023
1 parent 48a2873 commit 880189e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions monai/transforms/post/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ class DistanceTransformEDT(Transform):
Either GPU based with CuPy / cuCIM or CPU based with scipy.ndimage.
Choice only depends on cuCIM being available.
Note that the calculations can deviate, for details look into the cuCIM about distance_transform_edt().
Note that the calculations can deviate, for details look into the cuCIM about distance_transform_edt().
"""

backend = [TransformBackends.NUMPY, TransformBackends.CUPY]
Expand All @@ -969,4 +969,3 @@ def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor:
An array with the same shape and data type as img
"""
return distance_transform_edt(img=img, sampling=self.sampling, force_scipy=self.force_scipy)

6 changes: 3 additions & 3 deletions monai/transforms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2054,9 +2054,9 @@ def has_status_keys(data: torch.Tensor, status_key: Any, default_message: str =

def distance_transform_edt(img: NdarrayOrTensor, sampling: float | list[float]=None, force_scipy: bool=False) -> NdarrayOrTensor:
"""
Euclidean distance transform, either GPU based with CuPy / cuCIM
Euclidean distance transform, either GPU based with CuPy / cuCIM
or CPU based with scipy.ndimage.
Choice only depends on cuCIM being available.
Choice only depends on cuCIM being available.
Args:
img: Input image on which the distance transform shall be run
Expand All @@ -2065,7 +2065,7 @@ def distance_transform_edt(img: NdarrayOrTensor, sampling: float | list[float]=N
"""
distance_transform_edt, has_cucim = optional_import("cucim.core.operations.morphology", name="distance_transform_edt")

if has_cp and has_cucim and not force_scipy:
img_ = convert_to_cupy(img)
# Only accepts 2D and 3D input as of 09-2023
Expand Down
4 changes: 2 additions & 2 deletions tests/test_distance_transform_edt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from parameterized import parameterized

from monai.transforms import DistanceTransformEDT
from tests.utils import SkipIfNoModule, assert_allclose, optional_import
from tests.utils import assert_allclose, optional_import
from tests.utils import HAS_CUPY, skip_if_no_cuda

momorphology, has_cucim = optional_import("cucim.core.operations.morphology")
Expand Down Expand Up @@ -73,7 +73,7 @@ def test_scipy_transform(self, input, expected_output):
transform = DistanceTransformEDT(force_scipy=True)
output = transform(input)
assert_allclose(output, expected_output, atol=1e-4, rtol=1e-4, type_test=False)

@skip_if_no_cuda
@unittest.skipUnless(HAS_CUPY, "CuPy is required.")
@unittest.skipUnless(momorphology, "cuCIM transforms are required.")
Expand Down

0 comments on commit 880189e

Please sign in to comment.