Skip to content
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
31 changes: 17 additions & 14 deletions brainles_preprocessing/defacing/defacer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ def __init__(
# probably be implemented as a property of the the specific modality
self.masking_value = masking_value

@abstractmethod
def deface(
self,
input_image_path: Union[str, Path],
mask_image_path: Union[str, Path],
) -> None:
"""
Generate a defacing mask provided an input image.
@abstractmethod
def deface(
self,
input_image_path: Union[str, Path],
mask_image_path: Union[str, Path],
) -> None:
"""
Generate a defacing mask provided an input image.

Args:
input_image_path (str or Path): Path to the input image (NIfTI format).
mask_image_path (str or Path): Path to the output mask image (NIfTI format).
"""
pass
Args:
input_image_path (str or Path): Path to the input image (NIfTI format).
mask_image_path (str or Path): Path to save the output mask image (NIfTI format).
"""
pass

def apply_mask(
self,
Expand All @@ -52,6 +52,9 @@ def apply_mask(
defaced_image_path (str or Path): Path to save the resulting defaced image (NIfTI format).
"""

input_image_path = Path(input_image_path)
mask_path = Path(mask_path)
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the handling of input_image_path and mask_path, consider also converting defaced_image_path to a Path object at the beginning of the method. While not strictly necessary (since it's only used with str() on line 93), this would ensure uniform type handling for all path parameters.

Suggested change
mask_path = Path(mask_path)
mask_path = Path(mask_path)
defaced_image_path = Path(defaced_image_path)

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consistency with what?


if not input_image_path.is_file():
raise FileNotFoundError(
f"Input image file does not exist: {input_image_path}"
Expand All @@ -72,7 +75,7 @@ def apply_mask(
if input_data.shape != mask_data.shape:
raise ValueError("Input image and mask must have the same dimensions.")

# check whether a global masking value was passed, otherwise choose minimum
# Check whether a global masking value was passed, otherwise choose minimum
if self.masking_value is None:
current_masking_value = np.min(input_data)
else:
Expand Down
2 changes: 0 additions & 2 deletions brainles_preprocessing/registration/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import warnings


try:
from .ANTs.ANTs import ANTsRegistrator
except ImportError:
Expand All @@ -11,7 +10,6 @@

from .niftyreg.niftyreg import NiftyRegRegistrator


try:
from .elastix.elastix import ElastixRegistrator
except ImportError:
Expand Down
Loading