Skip to content

Commit

Permalink
handle Nones
Browse files Browse the repository at this point in the history
Signed-off-by: neuronflow <[email protected]>
  • Loading branch information
neuronflow committed Feb 15, 2024
1 parent 9d80f22 commit c2cc450
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions brainles_preprocessing/modality.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,23 @@ def __init__(
self,
modality_name: str,
input_path: str,
raw_bet_output_path: str = None,
raw_skull_output_path: str = None,
normalized_bet_output_path: str = None,
normalized_skull_output_path: str = None,
raw_bet_output_path: str | None = None,
raw_skull_output_path: str | None = None,
normalized_bet_output_path: str | None = None,
normalized_skull_output_path: str | None = None,
normalizer: Optional[Normalizer] = None,
atlas_correction: bool = True,
) -> None:
# basics
self.modality_name = modality_name

self.input_path = turbopath(input_path)
self.current = self.input_path

self.normalizer = normalizer
self.atlas_correction = atlas_correction

# check that atleast one output is generated
if (
raw_bet_output_path is None
and normalized_bet_output_path is None
Expand All @@ -60,26 +68,27 @@ def __init__(
raise ValueError(
"All output paths are None. At least one output path must be provided."
)
self.raw_bet_output_path = turbopath(raw_bet_output_path)
self.raw_skull_output_path = turbopath(raw_skull_output_path)

# handle input paths
if raw_bet_output_path is not None:
self.raw_bet_output_path = turbopath(raw_bet_output_path)

if raw_skull_output_path is not None:
self.raw_skull_output_path = turbopath(raw_skull_output_path)

if normalized_bet_output_path is not None:
if normalizer is None:
raise ValueError(
"A normalizer must be provided if normalized_bet_output_path is not None."
)
self.normalized_bet_output_path = turbopath(normalized_bet_output_path)
self.normalized_bet_output_path = turbopath(normalized_bet_output_path)

if normalized_skull_output_path is not None:
if normalizer is None:
raise ValueError(
"A normalizer must be provided if normalized_skull_output_path is not None."
)
self.normalized_skull_output_path = turbopath(normalized_skull_output_path)

self.normalizer = normalizer
self.atlas_correction = atlas_correction

self.current = self.input_path
self.normalized_skull_output_path = turbopath(normalized_skull_output_path)

@property
def bet(self) -> bool:
Expand Down

0 comments on commit c2cc450

Please sign in to comment.