Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change deprecated scipy.ndimage namespaces in optional imports #7847

Merged
merged 3 commits into from
Jun 25, 2024
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
2 changes: 1 addition & 1 deletion monai/apps/deepedit/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

logger = logging.getLogger(__name__)

distance_transform_cdt, _ = optional_import("scipy.ndimage.morphology", name="distance_transform_cdt")
distance_transform_cdt, _ = optional_import("scipy.ndimage", name="distance_transform_cdt")


class DiscardAddGuidanced(MapTransform):
Expand Down
2 changes: 1 addition & 1 deletion monai/apps/deepgrow/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from monai.utils.enums import PostFix

measure, _ = optional_import("skimage.measure", "0.14.2", min_version)
distance_transform_cdt, _ = optional_import("scipy.ndimage.morphology", name="distance_transform_cdt")
distance_transform_cdt, _ = optional_import("scipy.ndimage", name="distance_transform_cdt")

DEFAULT_POST_FIX = PostFix.meta()

Expand Down
2 changes: 1 addition & 1 deletion monai/apps/nuclick/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

measure, _ = optional_import("skimage.measure")
morphology, _ = optional_import("skimage.morphology")
distance_transform_cdt, _ = optional_import("scipy.ndimage.morphology", name="distance_transform_cdt")
distance_transform_cdt, _ = optional_import("scipy.ndimage", name="distance_transform_cdt")


class NuclickKeys(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion monai/apps/pathology/transforms/post/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from monai.utils.misc import ensure_tuple_rep
from monai.utils.type_conversion import convert_to_dst_type, convert_to_tensor

label, _ = optional_import("scipy.ndimage.measurements", name="label")
label, _ = optional_import("scipy.ndimage", name="label")
disk, _ = optional_import("skimage.morphology", name="disk")
opening, _ = optional_import("skimage.morphology", name="opening")
watershed, _ = optional_import("skimage.segmentation", name="watershed")
Expand Down
4 changes: 2 additions & 2 deletions monai/apps/pathology/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def compute_multi_instance_mask(mask: np.ndarray, threshold: float) -> Any:
"""

neg = 255 - mask * 255
distance = ndimage.morphology.distance_transform_edt(neg)
distance = ndimage.distance_transform_edt(neg)
binary = distance < threshold

filled_image = ndimage.morphology.binary_fill_holes(binary)
filled_image = ndimage.binary_fill_holes(binary)
multi_instance_mask = measure.label(filled_image, connectivity=2)

return multi_instance_mask
Expand Down
6 changes: 3 additions & 3 deletions monai/metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
optional_import,
)

binary_erosion, _ = optional_import("scipy.ndimage.morphology", name="binary_erosion")
distance_transform_edt, _ = optional_import("scipy.ndimage.morphology", name="distance_transform_edt")
distance_transform_cdt, _ = optional_import("scipy.ndimage.morphology", name="distance_transform_cdt")
binary_erosion, _ = optional_import("scipy.ndimage", name="binary_erosion")
distance_transform_edt, _ = optional_import("scipy.ndimage", name="distance_transform_edt")
distance_transform_cdt, _ = optional_import("scipy.ndimage", name="distance_transform_cdt")

__all__ = [
"ignore_background",
Expand Down
2 changes: 1 addition & 1 deletion monai/transforms/signal/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from monai.utils.enums import TransformBackends
from monai.utils.type_conversion import convert_data_type, convert_to_tensor

shift, has_shift = optional_import("scipy.ndimage.interpolation", name="shift")
shift, has_shift = optional_import("scipy.ndimage", name="shift")
iirnotch, has_iirnotch = optional_import("scipy.signal", name="iirnotch")
with warnings.catch_warnings():
warnings.simplefilter("ignore", UserWarning) # project-monai/monai#5204
Expand Down
Loading