78 feature request n4 bias correction support#133
Conversation
Removes path, bump aux add sitk
Fix return docstrings
Fix Docstring typo Fix str/ path concat
neuronflow
left a comment
There was a problem hiding this comment.
as discussed we will promote n4 bias field correction to the same level as bet and registration.
we will keep in mind the option to create n4 bias corrected outputs instead of boolen true/false option.
There was a problem hiding this comment.
Pull Request Overview
Adds optional N4 bias field correction to the preprocessing pipeline and updates example and dependencies accordingly.
- Introduce N4BiasCorrector interface and SitkN4BiasCorrector implementation
- Integrate
run_n4_bias_correctionintoPreprocessorand addn4_bias_correctionflags toModality/CenterModality - Update example script to demonstrate customizable N4 settings and bump dependencies in
pyproject.toml
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Added simpleitk and bumped auxiliary dependency version |
| example/example_modality_centric_preprocessor.py | Updated example to show N4 bias options and output directories |
| brainles_preprocessing/preprocessor.py | Integrated N4 bias correction step and parameter inits |
| brainles_preprocessing/n4_bias_correction/n4_bias_corrector.py | New abstract base class for N4 bias correctors |
| brainles_preprocessing/n4_bias_correction/sitk/sitk_n4_bias_corrector.py | New SimpleITK-based N4 implementation |
| brainles_preprocessing/n4_bias_correction/init.py | Expose N4 bias correction classes |
| brainles_preprocessing/modality.py | Added n4_bias_correction flag and serialization support |
| brainles_preprocessing/constants.py | Updated PreprocessorSteps enum to include N4 step |
| brainles_preprocessing/defacing/quickshear/quickshear.py | Refactored read/write calls to use auxiliary.io |
| brainles_preprocessing/defacing/defacer.py | Refactored read/write calls to use auxiliary.io |
| brainles_preprocessing/brain_extraction/brain_extractor.py | Refactored read/write calls to use auxiliary.io |
Comments suppressed due to low confidence (4)
brainles_preprocessing/n4_bias_correction/sitk/sitk_n4_bias_corrector.py:1
- [nitpick] No tests appear to cover
SitkN4BiasCorrector; consider adding unit tests to verify mask generation and parameter handling.
from pathlib import Path
example/example_modality_centric_preprocessor.py:2
N4BiasOptionsis not defined in the codebase; either implement this class or import the correct options type for customizing N4 parameters.
from brainles_preprocessing.n4_bias_correction import N4BiasOptions
example/example_modality_centric_preprocessor.py:133
- The
Preprocessorconstructor expectsn4_bias_corrector, notn4_bias_opts. Update the keyword to match the parameter name.
n4_bias_opts=N4BiasOptions(
example/example_modality_centric_preprocessor.py:16
- [nitpick]
SimpleITK as sitkis imported but not used in this example; consider removing the unused import to reduce clutter.
import SimpleITK as sitk
| @@ -56,8 +56,11 @@ def deface( | |||
|
|
|||
| bet_img = nib.load(str(input_image_path)) | |||
There was a problem hiding this comment.
Now we are using nibabel and sitk in parallel?
There was a problem hiding this comment.
yes - but only for quickshear since the quickshear implementation depends on nibabel functionalities
| @@ -1,17 +1,19 @@ | |||
| # This script is an example of how to use the ModalityCentricPreprocessor class to preprocess a set of MR images. It is only here for quick development and testing purposes. It is not intended to be used in a production environment. | |||
| from brainles_preprocessing.n4_bias_correction import N4BiasOptions | |||
There was a problem hiding this comment.
probbaly needs to be changed?
Update read/write usage after auxiliary update
Add support for optional customizable N4 bias correction