Skip to content

Commit

Permalink
Fix inconsistent naming
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelRosier committed Nov 6, 2024
1 parent bf4af58 commit ddf7ad3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ center = CenterModality(
normalized_skull_output_path="patient/norm_skull_dir/t1c_skull_normalized.nii.gz",
normalized_bet_output_path="patient/norm_bet_dir/t1c_bet_normalized.nii.gz",
# specify output paths for the brain extraction and defacing masks
bet_mask_output="patient/masks/t1c_bet_mask.nii.gz",
deface_mask_output="patient/masks/t1c_defacing_mask.nii.gz",
bet_mask_output_path="patient/masks/t1c_bet_mask.nii.gz",
defacing_mask_output_path="patient/masks/t1c_defacing_mask.nii.gz",
)

moving_modalities = [
Expand Down
35 changes: 19 additions & 16 deletions brainles_preprocessing/modality.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ class CenterModality(Modality):
normalized_skull_output_path (str or Path, optional): Path to save the normalized modality data with skull. Requires a normalizer.
normalized_defaced_output_path (str or Path, optional): Path to save the normalized defaced modality data. Requires a normalizer.
atlas_correction (bool, optional): Indicates whether atlas correction should be performed.
bet_mask_output (str or Path, optional): Path to save the brain extraction mask.
deface_mask_output (str or Path, optional): Path to save the defacing mask.
bet_mask_output_path (str or Path, optional): Path to save the brain extraction mask.
defacing_mask_output_path (str or Path, optional): Path to save the defacing mask.
Attributes:
modality_name (str): Name of the modality.
Expand All @@ -489,8 +489,8 @@ class CenterModality(Modality):
normalized_defaced_output_path (str or Path, optional): Path to save the normalized defaced modality data. Requires a normalizer.
bet (bool): Indicates whether brain extraction is enabled.
atlas_correction (bool): Indicates whether atlas correction should be performed.
bet_mask_output (Path, optional): Path to save the brain extraction mask.
deface_mask_output (Path, optional): Path to save the defacing mask.
bet_mask_output_path (Path, optional): Path to save the brain extraction mask.
defacing_mask_output_path (Path, optional): Path to save the defacing mask.
Example:
>>> t1_modality = CenterModality(
Expand All @@ -499,7 +499,7 @@ class CenterModality(Modality):
... normalizer=PercentileNormalizer(),
... raw_bet_output_path="/path/to/raw_bet_t1.nii",
... normalized_bet_output_path="/path/to/norm_bet_t1.nii",
... bet_mask_output="/path/to/bet_mask_t1.nii",
... bet_mask_output_path="/path/to/bet_mask_t1.nii",
... )
"""

Expand All @@ -515,8 +515,8 @@ def __init__(
normalized_skull_output_path: Optional[Union[str, Path]] = None,
normalized_defaced_output_path: Optional[Union[str, Path]] = None,
atlas_correction: bool = True,
bet_mask_output: Optional[Union[str, Path]] = None,
deface_mask_output: Optional[Union[str, Path]] = None,
bet_mask_output_path: Optional[Union[str, Path]] = None,
defacing_mask_output_path: Optional[Union[str, Path]] = None,
) -> None:
super().__init__(
modality_name=modality_name,
Expand All @@ -531,9 +531,11 @@ def __init__(
atlas_correction=atlas_correction,
)
# Only for CenterModality
self.bet_mask_output = Path(bet_mask_output) if bet_mask_output else None
self.deface_mask_output = (
Path(deface_mask_output) if deface_mask_output else None
self.bet_mask_output_path = (
Path(bet_mask_output_path) if bet_mask_output_path else None
)
self.defacing_mask_output_path = (
Path(defacing_mask_output_path) if defacing_mask_output_path else None
)

def extract_brain_region(
Expand Down Expand Up @@ -564,9 +566,9 @@ def extract_brain_region(
log_file_path=bet_log,
)

if self.bet_mask_output:
logger.debug(f"Saving bet mask to {self.bet_mask_output}")
self.save_mask(mask_path=mask_path, output_path=self.bet_mask_output)
if self.bet_mask_output_path:
logger.debug(f"Saving bet mask to {self.bet_mask_output_path}")
self.save_mask(mask_path=mask_path, output_path=self.bet_mask_output_path)

# always temporarily store bet image for center modality, since e.g. quickshear defacing could require it
# down the line even if the user does not wish to save the bet image
Expand Down Expand Up @@ -604,10 +606,11 @@ def deface(
input_image_path=self.steps[PreprocessorSteps.BET],
)

if self.deface_mask_output:
logger.debug(f"Saving deface mask to {self.deface_mask_output}")
if self.defacing_mask_output_path:
logger.debug(f"Saving deface mask to {self.defacing_mask_output_path}")
self.save_mask(
mask_path=atlas_mask_path, output_path=self.deface_mask_output
mask_path=atlas_mask_path,
output_path=self.defacing_mask_output_path,
)

return atlas_mask_path
Expand Down

0 comments on commit ddf7ad3

Please sign in to comment.