From dc14b67005e7737addfee9e5a0d1dbf06cf1b4b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:10:40 +0000 Subject: [PATCH 1/4] Initial plan From 92e82cdd0b1658f331b905218efe9c1b243662f1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:16:47 +0000 Subject: [PATCH 2/4] Update README with AtlasCentricPreprocessor and NativeSpacePreprocessor examples Co-authored-by: neuronflow <7048826+neuronflow@users.noreply.github.com> --- README.md | 122 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 101 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 0771219..a990fcb 100644 --- a/README.md +++ b/README.md @@ -36,16 +36,21 @@ We recommend using Python `3.10 / 3.11 / 3.12`. ## Usage -A minimal example to register (to the standard atlas using ANTs) and skull strip (using HDBet) a t1c image (center modality) with 1 moving modality (flair) could look like this: + +### Atlas-Centric Preprocessing +Use `AtlasCentricPreprocessor` to register images to an atlas, perform atlas correction, and skull strip. This is useful when you want all images in a common atlas space. + +A minimal example to register (to the standard atlas using ANTs) and skull strip (using HDBet) a t1c image (center modality) with 1 moving modality (flair): ```python from pathlib import Path from brainles_preprocessing.modality import Modality, CenterModality from brainles_preprocessing.normalization.percentile_normalizer import ( PercentileNormalizer, ) -from brainles_preprocessing.preprocessor import Preprocessor +from brainles_preprocessing.preprocessor import AtlasCentricPreprocessor -patient_folder = Path("/home/marcelrosier/preprocessing/patient") +patient_folder = Path("/path/to/patient") +output_folder = Path("/path/to/output") # specify a normalizer percentile_normalizer = PercentileNormalizer( @@ -60,16 +65,17 @@ center = CenterModality( modality_name="t1c", input_path=patient_folder / "t1c.nii.gz", normalizer=percentile_normalizer, - # specify the output paths for the raw and normalized images of each step - here only for atlas registered and brain extraction - raw_skull_output_path="patient/raw_skull_dir/t1c_skull_raw.nii.gz", - raw_bet_output_path="patient/raw_bet_dir/t1c_bet_raw.nii.gz", - raw_defaced_output_path="patient/raw_defaced_dir/t1c_defaced_raw.nii.gz", - 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", - normalized_defaced_output_path="patient/norm_defaced_dir/t1c_defaced_normalized.nii.gz", + # specify the output paths for the raw and normalized images of each step + raw_skull_output_path=output_folder / "raw_skull/t1c_skull_raw.nii.gz", + raw_bet_output_path=output_folder / "raw_bet/t1c_bet_raw.nii.gz", + raw_defaced_output_path=output_folder / "raw_defaced/t1c_defaced_raw.nii.gz", + normalized_skull_output_path=output_folder / "normalized_skull/t1c_skull_normalized.nii.gz", + normalized_bet_output_path=output_folder / "normalized_bet/t1c_bet_normalized.nii.gz", + normalized_defaced_output_path=output_folder / "normalized_defaced/t1c_defaced_normalized.nii.gz", # specify output paths for the brain extraction and defacing masks - bet_mask_output_path="patient/masks/t1c_bet_mask.nii.gz", - defacing_mask_output_path="patient/masks/t1c_defacing_mask.nii.gz", + bet_mask_output_path=output_folder / "masks/t1c_bet_mask.nii.gz", + defacing_mask_output_path=output_folder / "masks/t1c_defacing_mask.nii.gz", + atlas_correction=True, ) moving_modalities = [ @@ -77,23 +83,97 @@ moving_modalities = [ modality_name="flair", input_path=patient_folder / "flair.nii.gz", normalizer=percentile_normalizer, - # specify the output paths for the raw and normalized images of each step - here only for atlas registered and brain extraction - raw_skull_output_path="patient/raw_skull_dir/fla_skull_raw.nii.gz", - raw_bet_output_path="patient/raw_bet_dir/fla_bet_raw.nii.gz", - raw_defaced_output_path="patient/raw_defaced_dir/fla_defaced_raw.nii.gz", - normalized_skull_output_path="patient/norm_skull_dir/fla_skull_normalized.nii.gz", - normalized_bet_output_path="patient/norm_bet_dir/fla_bet_normalized.nii.gz", - normalized_defaced_output_path="patient/norm_defaced_dir/fla_defaced_normalized.nii.gz", + # specify the output paths for the raw and normalized images of each step + raw_skull_output_path=output_folder / "raw_skull/flair_skull_raw.nii.gz", + raw_bet_output_path=output_folder / "raw_bet/flair_bet_raw.nii.gz", + raw_defaced_output_path=output_folder / "raw_defaced/flair_defaced_raw.nii.gz", + normalized_skull_output_path=output_folder / "normalized_skull/flair_skull_normalized.nii.gz", + normalized_bet_output_path=output_folder / "normalized_bet/flair_bet_normalized.nii.gz", + normalized_defaced_output_path=output_folder / "normalized_defaced/flair_defaced_normalized.nii.gz", + atlas_correction=True, ) ] # instantiate and run the preprocessor using defaults for backends (registration, brain extraction, bias correction, defacing) -preprocessor = Preprocessor( +preprocessor = AtlasCentricPreprocessor( + center_modality=center, + moving_modalities=moving_modalities, +) + +preprocessor.run( + save_dir_coregistration=output_folder / "coregistration", + save_dir_atlas_registration=output_folder / "atlas_registration", + save_dir_atlas_correction=output_folder / "atlas_correction", + save_dir_n4_bias_correction=output_folder / "n4_bias_correction", + save_dir_brain_extraction=output_folder / "brain_extraction", + save_dir_defacing=output_folder / "defacing", +) + +``` + +### Native Space Preprocessing +Use `NativeSpacePreprocessor` to perform coregistration, N4 bias correction, brain extraction, and defacing while keeping images in native space (no atlas registration). + +A minimal example: +```python +from pathlib import Path +from brainles_preprocessing.modality import Modality, CenterModality +from brainles_preprocessing.normalization.percentile_normalizer import ( + PercentileNormalizer, +) +from brainles_preprocessing.preprocessor import NativeSpacePreprocessor + +patient_folder = Path("/path/to/patient") +output_folder = Path("/path/to/output") + +# specify a normalizer +percentile_normalizer = PercentileNormalizer( + lower_percentile=0.1, + upper_percentile=99.9, + lower_limit=0, + upper_limit=1, +) + +# define center and moving modalities +center = CenterModality( + modality_name="t1c", + input_path=patient_folder / "t1c.nii.gz", + normalizer=percentile_normalizer, + # specify the output paths for the raw and normalized images + raw_bet_output_path=output_folder / "raw_bet/t1c_bet_raw.nii.gz", + raw_skull_output_path=output_folder / "raw_skull/t1c_skull_raw.nii.gz", + normalized_skull_output_path=output_folder / "normalized_skull/t1c_skull_normalized.nii.gz", + raw_defaced_output_path=output_folder / "raw_defaced/t1c_defaced_raw.nii.gz", + # specify output paths for the brain extraction and defacing masks + bet_mask_output_path=output_folder / "masks/t1c_bet_mask.nii.gz", + defacing_mask_output_path=output_folder / "masks/t1c_defacing_mask.nii.gz", +) + +moving_modalities = [ + Modality( + modality_name="flair", + input_path=patient_folder / "flair.nii.gz", + normalizer=percentile_normalizer, + # specify the output paths for the raw and normalized images + raw_bet_output_path=output_folder / "raw_bet/flair_bet_raw.nii.gz", + raw_skull_output_path=output_folder / "raw_skull/flair_skull_raw.nii.gz", + normalized_skull_output_path=output_folder / "normalized_skull/flair_skull_normalized.nii.gz", + raw_defaced_output_path=output_folder / "raw_defaced/flair_defaced_raw.nii.gz", + ) +] + +# instantiate and run the preprocessor +preprocessor = NativeSpacePreprocessor( center_modality=center, moving_modalities=moving_modalities, ) -preprocessor.run() +preprocessor.run( + save_dir_coregistration=output_folder / "coregistration", + save_dir_n4_bias_correction=output_folder / "n4_bias_correction", + save_dir_brain_extraction=output_folder / "brain_extraction", + save_dir_defacing=output_folder / "defacing", +) ``` From 1e3aac9c9aa7dcbbe3cf04a753f54c6a6633e01d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:57:28 +0000 Subject: [PATCH 3/4] Fix parameter order consistency in README examples Co-authored-by: neuronflow <7048826+neuronflow@users.noreply.github.com> --- README.md | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a990fcb..f6f8b1c 100644 --- a/README.md +++ b/README.md @@ -65,13 +65,11 @@ center = CenterModality( modality_name="t1c", input_path=patient_folder / "t1c.nii.gz", normalizer=percentile_normalizer, - # specify the output paths for the raw and normalized images of each step - raw_skull_output_path=output_folder / "raw_skull/t1c_skull_raw.nii.gz", + # specify the output paths for the raw and normalized images raw_bet_output_path=output_folder / "raw_bet/t1c_bet_raw.nii.gz", - raw_defaced_output_path=output_folder / "raw_defaced/t1c_defaced_raw.nii.gz", + raw_skull_output_path=output_folder / "raw_skull/t1c_skull_raw.nii.gz", normalized_skull_output_path=output_folder / "normalized_skull/t1c_skull_normalized.nii.gz", - normalized_bet_output_path=output_folder / "normalized_bet/t1c_bet_normalized.nii.gz", - normalized_defaced_output_path=output_folder / "normalized_defaced/t1c_defaced_normalized.nii.gz", + raw_defaced_output_path=output_folder / "raw_defaced/t1c_defaced_raw.nii.gz", # specify output paths for the brain extraction and defacing masks bet_mask_output_path=output_folder / "masks/t1c_bet_mask.nii.gz", defacing_mask_output_path=output_folder / "masks/t1c_defacing_mask.nii.gz", @@ -83,13 +81,11 @@ moving_modalities = [ modality_name="flair", input_path=patient_folder / "flair.nii.gz", normalizer=percentile_normalizer, - # specify the output paths for the raw and normalized images of each step - raw_skull_output_path=output_folder / "raw_skull/flair_skull_raw.nii.gz", + # specify the output paths for the raw and normalized images raw_bet_output_path=output_folder / "raw_bet/flair_bet_raw.nii.gz", - raw_defaced_output_path=output_folder / "raw_defaced/flair_defaced_raw.nii.gz", + raw_skull_output_path=output_folder / "raw_skull/flair_skull_raw.nii.gz", normalized_skull_output_path=output_folder / "normalized_skull/flair_skull_normalized.nii.gz", - normalized_bet_output_path=output_folder / "normalized_bet/flair_bet_normalized.nii.gz", - normalized_defaced_output_path=output_folder / "normalized_defaced/flair_defaced_normalized.nii.gz", + raw_defaced_output_path=output_folder / "raw_defaced/flair_defaced_raw.nii.gz", atlas_correction=True, ) ] From 4beb2b512a914840579706f36fee41c60d8fdd10 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Oct 2025 13:08:16 +0000 Subject: [PATCH 4/4] Enhance README with comprehensive examples and improved documentation Co-authored-by: neuronflow <7048826+neuronflow@users.noreply.github.com> --- README.md | 158 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 119 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index f6f8b1c..41c1d4e 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,27 @@ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -`BrainLes preprocessing` is a comprehensive tool for preprocessing tasks in biomedical imaging, with a focus on (but not limited to) multi-modal brain MRI. It can be used to build modular preprocessing pipelines: +`BrainLes preprocessing` is a comprehensive, modular toolkit for preprocessing multi-modal brain MRI and other biomedical imaging data. It provides flexible preprocessing pipelines that can be customized to your specific needs. -This includes **normalization**, **co-registration**, **atlas registration**, **skullstripping / brain extraction**, **N4 Bias correction** and **defacing**. -We provide means to transform images and segmentations in both directions between native and atlas space. +## Features -BrainLes is written modular and `backend-agnostic` meaning it allows to skip or swap registration, brain extraction, N4 bias correction and defacing tools. +### Core Preprocessing Steps +- **Normalization**: Intensity normalization using various methods (e.g., percentile-based) +- **Co-registration**: Align multiple modalities to a reference modality +- **Atlas Registration**: Register images to standard atlas spaces (MNI152, SRI24, etc.) +- **Brain Extraction**: Skull stripping using state-of-the-art methods (HD-BET, SynthStrip) +- **N4 Bias Correction**: Correct intensity inhomogeneities +- **Defacing**: Anonymize images by removing facial features + +### Preprocessing Modes +- **Atlas-Centric**: Process images in atlas space with optional atlas-based intensity correction +- **Native Space**: Process images in patient/native space without atlas registration + +### Key Benefits +- **Modular & Backend-Agnostic**: Easily swap or skip preprocessing steps and choose from multiple backends +- **Flexible Output Options**: Generate any combination of outputs (brain extracted, with skull, defaced, raw, normalized) +- **Bidirectional Transforms**: Transform images and segmentations between native and atlas space +- **Extensible**: Add custom normalizers, registrators, brain extractors, or defacing methods @@ -40,7 +55,23 @@ We recommend using Python `3.10 / 3.11 / 3.12`. ### Atlas-Centric Preprocessing Use `AtlasCentricPreprocessor` to register images to an atlas, perform atlas correction, and skull strip. This is useful when you want all images in a common atlas space. -A minimal example to register (to the standard atlas using ANTs) and skull strip (using HDBet) a t1c image (center modality) with 1 moving modality (flair): +**Key features:** +- Co-registration of moving modalities to center modality +- Registration to atlas space +- Optional atlas correction (intensity adjustment based on atlas) +- N4 bias correction +- Brain extraction +- Defacing for anonymization + +**Example with all output options:** + +This example demonstrates all possible output paths. You can specify any combination of: +- **Raw outputs** (without normalization): `raw_bet_output_path`, `raw_skull_output_path`, `raw_defaced_output_path` +- **Normalized outputs** (requires a normalizer): `normalized_bet_output_path`, `normalized_skull_output_path`, `normalized_defaced_output_path` +- **Masks** (only for CenterModality): `bet_mask_output_path`, `defacing_mask_output_path` + +> **Note:** At least one output path must be specified per modality. All output paths are optional except that at least one must be provided. + ```python from pathlib import Path from brainles_preprocessing.modality import Modality, CenterModality @@ -52,7 +83,7 @@ from brainles_preprocessing.preprocessor import AtlasCentricPreprocessor patient_folder = Path("/path/to/patient") output_folder = Path("/path/to/output") -# specify a normalizer +# specify a normalizer (required if using any normalized_* output paths) percentile_normalizer = PercentileNormalizer( lower_percentile=0.1, upper_percentile=99.9, @@ -60,43 +91,60 @@ percentile_normalizer = PercentileNormalizer( upper_limit=1, ) -# define center and moving modalities +# define center modality with all possible outputs center = CenterModality( - modality_name="t1c", - input_path=patient_folder / "t1c.nii.gz", - normalizer=percentile_normalizer, - # specify the output paths for the raw and normalized images - raw_bet_output_path=output_folder / "raw_bet/t1c_bet_raw.nii.gz", - raw_skull_output_path=output_folder / "raw_skull/t1c_skull_raw.nii.gz", + modality_name="t1c", # required + input_path=patient_folder / "t1c.nii.gz", # required + normalizer=percentile_normalizer, # optional: required for normalized_* outputs + # Raw outputs (optional) + raw_bet_output_path=output_folder / "raw_bet/t1c_bet_raw.nii.gz", # brain extracted + raw_skull_output_path=output_folder / "raw_skull/t1c_skull_raw.nii.gz", # with skull + raw_defaced_output_path=output_folder / "raw_defaced/t1c_defaced_raw.nii.gz", # defaced + # Normalized outputs (optional, requires normalizer) + normalized_bet_output_path=output_folder / "normalized_bet/t1c_bet_normalized.nii.gz", normalized_skull_output_path=output_folder / "normalized_skull/t1c_skull_normalized.nii.gz", - raw_defaced_output_path=output_folder / "raw_defaced/t1c_defaced_raw.nii.gz", - # specify output paths for the brain extraction and defacing masks + normalized_defaced_output_path=output_folder / "normalized_defaced/t1c_defaced_normalized.nii.gz", + # Masks (optional, only for CenterModality) bet_mask_output_path=output_folder / "masks/t1c_bet_mask.nii.gz", defacing_mask_output_path=output_folder / "masks/t1c_defacing_mask.nii.gz", - atlas_correction=True, + # Optional parameters + atlas_correction=True, # default: True + n4_bias_correction=False, # default: False ) +# define moving modalities moving_modalities = [ Modality( - modality_name="flair", - input_path=patient_folder / "flair.nii.gz", - normalizer=percentile_normalizer, - # specify the output paths for the raw and normalized images + modality_name="flair", # required + input_path=patient_folder / "flair.nii.gz", # required + normalizer=percentile_normalizer, # optional: required for normalized_* outputs + # Raw outputs (optional) raw_bet_output_path=output_folder / "raw_bet/flair_bet_raw.nii.gz", raw_skull_output_path=output_folder / "raw_skull/flair_skull_raw.nii.gz", - normalized_skull_output_path=output_folder / "normalized_skull/flair_skull_normalized.nii.gz", raw_defaced_output_path=output_folder / "raw_defaced/flair_defaced_raw.nii.gz", - atlas_correction=True, + # Normalized outputs (optional, requires normalizer) + normalized_bet_output_path=output_folder / "normalized_bet/flair_bet_normalized.nii.gz", + normalized_skull_output_path=output_folder / "normalized_skull/flair_skull_normalized.nii.gz", + normalized_defaced_output_path=output_folder / "normalized_defaced/flair_defaced_normalized.nii.gz", + # Optional parameters + atlas_correction=True, # default: True + n4_bias_correction=False, # default: False ) ] -# instantiate and run the preprocessor using defaults for backends (registration, brain extraction, bias correction, defacing) +# instantiate and run the preprocessor preprocessor = AtlasCentricPreprocessor( center_modality=center, moving_modalities=moving_modalities, + # Optional: customize backends (defaults shown below) + # registrator=ANTsRegistrator(), + # brain_extractor=HDBetExtractor(), + # n4_bias_corrector=SitkN4BiasCorrector(), + # defacer=QuickshearDefacer(), ) preprocessor.run( + # Optional: save intermediate results to these directories save_dir_coregistration=output_folder / "coregistration", save_dir_atlas_registration=output_folder / "atlas_registration", save_dir_atlas_correction=output_folder / "atlas_correction", @@ -110,7 +158,22 @@ preprocessor.run( ### Native Space Preprocessing Use `NativeSpacePreprocessor` to perform coregistration, N4 bias correction, brain extraction, and defacing while keeping images in native space (no atlas registration). -A minimal example: +**Key features:** +- Co-registration of moving modalities to center modality +- N4 bias correction +- Brain extraction +- Defacing for anonymization +- **No atlas registration** - stays in native/patient space + +**Example with all output options:** + +This example demonstrates all possible output paths. You can specify any combination of: +- **Raw outputs** (without normalization): `raw_bet_output_path`, `raw_skull_output_path`, `raw_defaced_output_path` +- **Normalized outputs** (requires a normalizer): `normalized_bet_output_path`, `normalized_skull_output_path`, `normalized_defaced_output_path` +- **Masks** (only for CenterModality): `bet_mask_output_path`, `defacing_mask_output_path` + +> **Note:** At least one output path must be specified per modality. All output paths are optional except that at least one must be provided. + ```python from pathlib import Path from brainles_preprocessing.modality import Modality, CenterModality @@ -122,7 +185,7 @@ from brainles_preprocessing.preprocessor import NativeSpacePreprocessor patient_folder = Path("/path/to/patient") output_folder = Path("/path/to/output") -# specify a normalizer +# specify a normalizer (required if using any normalized_* output paths) percentile_normalizer = PercentileNormalizer( lower_percentile=0.1, upper_percentile=99.9, @@ -130,31 +193,42 @@ percentile_normalizer = PercentileNormalizer( upper_limit=1, ) -# define center and moving modalities +# define center modality with all possible outputs center = CenterModality( - modality_name="t1c", - input_path=patient_folder / "t1c.nii.gz", - normalizer=percentile_normalizer, - # specify the output paths for the raw and normalized images - raw_bet_output_path=output_folder / "raw_bet/t1c_bet_raw.nii.gz", - raw_skull_output_path=output_folder / "raw_skull/t1c_skull_raw.nii.gz", + modality_name="t1c", # required + input_path=patient_folder / "t1c.nii.gz", # required + normalizer=percentile_normalizer, # optional: required for normalized_* outputs + # Raw outputs (optional) + raw_bet_output_path=output_folder / "raw_bet/t1c_bet_raw.nii.gz", # brain extracted + raw_skull_output_path=output_folder / "raw_skull/t1c_skull_raw.nii.gz", # with skull + raw_defaced_output_path=output_folder / "raw_defaced/t1c_defaced_raw.nii.gz", # defaced + # Normalized outputs (optional, requires normalizer) + normalized_bet_output_path=output_folder / "normalized_bet/t1c_bet_normalized.nii.gz", normalized_skull_output_path=output_folder / "normalized_skull/t1c_skull_normalized.nii.gz", - raw_defaced_output_path=output_folder / "raw_defaced/t1c_defaced_raw.nii.gz", - # specify output paths for the brain extraction and defacing masks + normalized_defaced_output_path=output_folder / "normalized_defaced/t1c_defaced_normalized.nii.gz", + # Masks (optional, only for CenterModality) bet_mask_output_path=output_folder / "masks/t1c_bet_mask.nii.gz", defacing_mask_output_path=output_folder / "masks/t1c_defacing_mask.nii.gz", + # Optional parameters (not applicable for native space: no atlas_correction) + n4_bias_correction=False, # default: False ) +# define moving modalities moving_modalities = [ Modality( - modality_name="flair", - input_path=patient_folder / "flair.nii.gz", - normalizer=percentile_normalizer, - # specify the output paths for the raw and normalized images + modality_name="flair", # required + input_path=patient_folder / "flair.nii.gz", # required + normalizer=percentile_normalizer, # optional: required for normalized_* outputs + # Raw outputs (optional) raw_bet_output_path=output_folder / "raw_bet/flair_bet_raw.nii.gz", raw_skull_output_path=output_folder / "raw_skull/flair_skull_raw.nii.gz", - normalized_skull_output_path=output_folder / "normalized_skull/flair_skull_normalized.nii.gz", raw_defaced_output_path=output_folder / "raw_defaced/flair_defaced_raw.nii.gz", + # Normalized outputs (optional, requires normalizer) + normalized_bet_output_path=output_folder / "normalized_bet/flair_bet_normalized.nii.gz", + normalized_skull_output_path=output_folder / "normalized_skull/flair_skull_normalized.nii.gz", + normalized_defaced_output_path=output_folder / "normalized_defaced/flair_defaced_normalized.nii.gz", + # Optional parameters (not applicable for native space: no atlas_correction) + n4_bias_correction=False, # default: False ) ] @@ -162,9 +236,15 @@ moving_modalities = [ preprocessor = NativeSpacePreprocessor( center_modality=center, moving_modalities=moving_modalities, + # Optional: customize backends (defaults shown below) + # registrator=ANTsRegistrator(), + # brain_extractor=HDBetExtractor(), + # n4_bias_corrector=SitkN4BiasCorrector(), + # defacer=QuickshearDefacer(), ) preprocessor.run( + # Optional: save intermediate results to these directories save_dir_coregistration=output_folder / "coregistration", save_dir_n4_bias_correction=output_folder / "n4_bias_correction", save_dir_brain_extraction=output_folder / "brain_extraction",