From 219df877b67337529fa4b0741e04d32c2b515cf7 Mon Sep 17 00:00:00 2001 From: Alex Zwanenburg Date: Thu, 4 Apr 2024 15:50:34 +0200 Subject: [PATCH] Removed unused code. Unused code identified in #75. --- mirp/_image_processing/add_noise.py | 32 -------------------- mirp/_image_processing/normalise_image.py | 31 ------------------- mirp/_image_processing/resegmentise_mask.py | 33 --------------------- mirp/_image_processing/saturate_image.py | 18 ----------- 4 files changed, 114 deletions(-) delete mode 100644 mirp/_image_processing/add_noise.py delete mode 100644 mirp/_image_processing/normalise_image.py delete mode 100644 mirp/_image_processing/resegmentise_mask.py delete mode 100644 mirp/_image_processing/saturate_image.py diff --git a/mirp/_image_processing/add_noise.py b/mirp/_image_processing/add_noise.py deleted file mode 100644 index ff13fde5..00000000 --- a/mirp/_image_processing/add_noise.py +++ /dev/null @@ -1,32 +0,0 @@ -from mirp._images.generic_image import GenericImage - - -def add_noise( - image: GenericImage, - noise_level: None | float = None, - noise_estimation_method: str = "chang", - repetitions: None | int = None, - repetition_id: None | int = None -) -> GenericImage | list[GenericImage]: - if (repetitions is None and repetition_id is None) or repetitions == 0: - return image - - if noise_level is None: - noise_level = image.estimate_noise(method=noise_estimation_method) - - if noise_level is None: - return image - - if repetition_id is not None: - image.add_noise(noise_level=noise_level, noise_iteration_id=repetition_id) - return image - - else: - new_images = [] - for ii in range(repetitions): - new_image = image.copy() - new_image.add_noise(noise_level=noise_level, noise_iteration_id=ii) - - new_images += [new_image] - - return new_images diff --git a/mirp/_image_processing/normalise_image.py b/mirp/_image_processing/normalise_image.py deleted file mode 100644 index bd53c109..00000000 --- a/mirp/_image_processing/normalise_image.py +++ /dev/null @@ -1,31 +0,0 @@ -from typing import Any -import numpy as np - -from mirp._images.generic_image import GenericImage - - -def normalise_image( - image: GenericImage, - normalisation_method: None | str = None, - intensity_range: None | tuple[Any, Any] = None, - saturation_range: None | tuple[Any, Any] = None, - mask: None | np.ndarray = None, - in_place: bool = True -): - if intensity_range is None: - intensity_range = [np.nan, np.nan] - - if saturation_range is None: - saturation_range = [np.nan, np.nan] - - if in_place: - image = image.copy() - - image.normalise_intensities( - normalisation_method=normalisation_method, - intensity_range=intensity_range, - saturation_range=saturation_range, - mask=mask - ) - - return image diff --git a/mirp/_image_processing/resegmentise_mask.py b/mirp/_image_processing/resegmentise_mask.py deleted file mode 100644 index 58359e24..00000000 --- a/mirp/_image_processing/resegmentise_mask.py +++ /dev/null @@ -1,33 +0,0 @@ -from typing import Any - -from mirp._image_processing.utilities import standard_image_process_checks -from mirp._images.generic_image import GenericImage -from mirp._masks.base_mask import BaseMask - - -def resegmentise_mask( - image: GenericImage, - masks: None | BaseMask | list[BaseMask], - resegmentation_method: None | str | list[str] = None, - intensity_range: None | tuple[Any, Any] = None, - sigma: None | float = None -): - # Resegmentises mask based on the selected method. - image, masks, return_list = standard_image_process_checks(image, masks) - if return_list is None: - return masks - - masks: list[BaseMask] = masks - - for mask in masks: - mask.resegmentise_mask( - image=image, - resegmentation_method=resegmentation_method, - intensity_range=intensity_range, - sigma=sigma - ) - - if return_list: - return masks - else: - return masks[0] diff --git a/mirp/_image_processing/saturate_image.py b/mirp/_image_processing/saturate_image.py deleted file mode 100644 index bc8ba5c9..00000000 --- a/mirp/_image_processing/saturate_image.py +++ /dev/null @@ -1,18 +0,0 @@ -from typing import Any - -from mirp._images.generic_image import GenericImage - - -def saturate_image( - image: GenericImage, - intensity_range: None | tuple[Any, Any], - fill_value: None | tuple[float, float], - in_place: bool = True -): - if in_place: - image = image.copy() - - # Saturate image - image.saturate(intensity_range=intensity_range, fill_value=fill_value) - - return image