Skip to content

78 feature request n4 bias correction support#133

Merged
neuronflow merged 16 commits intomainfrom
78-feature-request-n4-bias-correction-support
Jul 10, 2025
Merged

78 feature request n4 bias correction support#133
neuronflow merged 16 commits intomainfrom
78-feature-request-n4-bias-correction-support

Conversation

@MarcelRosier
Copy link
Collaborator

Update read/write usage after auxiliary update
Add support for optional customizable N4 bias correction

@MarcelRosier MarcelRosier self-assigned this Jul 7, 2025
@MarcelRosier MarcelRosier linked an issue Jul 7, 2025 that may be closed by this pull request
@MarcelRosier MarcelRosier marked this pull request as ready for review July 7, 2025 12:22
Copilot AI review requested due to automatic review settings July 7, 2025 12:22

This comment was marked as outdated.

Fix return docstrings

This comment was marked as outdated.

Fix Docstring typo
Fix str/ path concat
Copy link
Collaborator

@neuronflow neuronflow left a comment

Choose a reason for hiding this comment

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

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.

@MarcelRosier MarcelRosier requested a review from neuronflow July 9, 2025 12:49
@neuronflow neuronflow requested a review from Copilot July 9, 2025 22:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_correction into Preprocessor and add n4_bias_correction flags to Modality/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

  • N4BiasOptions is 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 Preprocessor constructor expects n4_bias_corrector, not n4_bias_opts. Update the keyword to match the parameter name.
            n4_bias_opts=N4BiasOptions(

example/example_modality_centric_preprocessor.py:16

  • [nitpick] SimpleITK as sitk is 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))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now we are using nibabel and sitk in parallel?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

probbaly needs to be changed?

@MarcelRosier MarcelRosier requested a review from neuronflow July 10, 2025 14:19
@neuronflow neuronflow merged commit 7e0123c into main Jul 10, 2025
4 checks passed
@neuronflow neuronflow deleted the 78-feature-request-n4-bias-correction-support branch July 10, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature request] N4 bias correction support

3 participants