brainles-preprocessing 0.4.0__tar.gz → 0.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/PKG-INFO +27 -8
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/README.md +24 -4
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/brain_extraction/brain_extractor.py +6 -6
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/constants.py +6 -2
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/defacing/defacer.py +6 -6
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/defacing/quickshear/quickshear.py +18 -5
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/modality.py +106 -79
- brainles_preprocessing-0.6.0/brainles_preprocessing/n4_bias_correction/__init__.py +2 -0
- brainles_preprocessing-0.6.0/brainles_preprocessing/n4_bias_correction/n4_bias_corrector.py +13 -0
- brainles_preprocessing-0.6.0/brainles_preprocessing/n4_bias_correction/sitk/sitk_n4_bias_corrector.py +82 -0
- brainles_preprocessing-0.6.0/brainles_preprocessing/preprocessor/__init__.py +15 -0
- brainles_preprocessing-0.4.0/brainles_preprocessing/preprocessor.py → brainles_preprocessing-0.6.0/brainles_preprocessing/preprocessor/atlas_centric_preprocessor.py +34 -245
- brainles_preprocessing-0.6.0/brainles_preprocessing/preprocessor/native_space_preprocessor.py +200 -0
- brainles_preprocessing-0.6.0/brainles_preprocessing/preprocessor/preprocessor.py +355 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/ANTs/ANTs.py +5 -5
- brainles_preprocessing-0.6.0/brainles_preprocessing/registration/niftyreg/__init__.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg.py +6 -4
- brainles_preprocessing-0.4.0/brainles_preprocessing/back_to_native.py → brainles_preprocessing-0.6.0/brainles_preprocessing/transform.py +32 -17
- brainles_preprocessing-0.6.0/brainles_preprocessing/utils/citation_reminder.py +41 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/pyproject.toml +4 -4
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/LICENSE +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/__init__.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/brain_extraction/__init__.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/brats/__init__.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/brats/t1_centric.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/brats/t1c_centric.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/cli.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/defacing/__init__.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/defacing/quickshear/__init__.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/defacing/quickshear/nipy_quickshear.py +0 -0
- {brainles_preprocessing-0.4.0/brainles_preprocessing/registration/ANTs → brainles_preprocessing-0.6.0/brainles_preprocessing/n4_bias_correction/sitk}/__init__.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/normalization/__init__.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/normalization/normalizer_base.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/normalization/percentile_normalizer.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/normalization/windowing_normalizer.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/ANTs/TODO_ANTs_parameters.py +0 -0
- {brainles_preprocessing-0.4.0/brainles_preprocessing/registration/elastix → brainles_preprocessing-0.6.0/brainles_preprocessing/registration/ANTs}/__init__.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/__init__.py +0 -0
- {brainles_preprocessing-0.4.0/brainles_preprocessing/registration/greedy → brainles_preprocessing-0.6.0/brainles_preprocessing/registration/elastix}/__init__.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/elastix/elastix.py +0 -0
- {brainles_preprocessing-0.4.0/brainles_preprocessing/registration/niftyreg → brainles_preprocessing-0.6.0/brainles_preprocessing/registration/greedy}/__init__.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/greedy/greedy.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/groupwise_niftyreg_params.sh +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/groupwise_niftyreg_run.sh +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_aladin +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_average +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_f3d +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_jacobian +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_measure +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_resample +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_tools +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_transform +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/AffineDeformationFieldKernel.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/AladinContent.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/BlockMatchingKernel.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUAffineDeformationFieldKernel.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUBlockMatchingKernel.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUConvolutionKernel.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUKernelFactory.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUOptimiseKernel.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUResampleImageKernel.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/ConvolutionKernel.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/Kernel.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/KernelFactory.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/OptimiseKernel.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/Platform.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/ResampleImageKernel.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_ReadWriteImage.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_ReadWriteMatrix.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_aladin.cpp +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_aladin.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_aladin_sym.cpp +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_aladin_sym.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_base.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_blockMatching.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_dti.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_f3d.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_f3d2.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_f3d_sym.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_femTrans.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_globalTrans.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_kld.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_lncc.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_localTrans.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_localTrans_jac.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_localTrans_regul.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_macros.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_maths.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_maths_eigen.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_measure.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_mind.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_nmi.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_optimiser.cpp +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_optimiser.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_resampling.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_splineBasis.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_ssd.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_stringFormat.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_tools.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/nifti1.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/nifti1_io.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/png.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pngconf.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pngdebug.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pnginfo.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pnglibconf.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pngpriv.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pngstruct.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/readpng.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/reg_png.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/zlib.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/znzlib.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/zutil.h +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/reg_aladin +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/reg_resample +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/rigid_reg.sh +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/transform.sh +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/registration/registrator.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/utils/__init__.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/utils/generic.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/utils/logging_utils.py +0 -0
- {brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/utils/zenodo.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: brainles_preprocessing
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Tool for preprocessing tasks in biomedical imaging, with a focus on (but not limited to) multi-modal brain MRI
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Keywords: brain tumor,glioma,BraTS,skullstripping,brain extraction
|
|
@@ -20,17 +20,16 @@ Provides-Extra: all
|
|
|
20
20
|
Provides-Extra: itk-elastix
|
|
21
21
|
Provides-Extra: picsl-greedy
|
|
22
22
|
Requires-Dist: antspyx (>=0.5.4,<1.0.0)
|
|
23
|
-
Requires-Dist: auxiliary (>=0.
|
|
24
|
-
Requires-Dist: black (>=22.1.0,<23.0.0)
|
|
23
|
+
Requires-Dist: auxiliary (>=0.3.1)
|
|
25
24
|
Requires-Dist: brainles_hd_bet (>=0.0.10,<1.0.0)
|
|
26
25
|
Requires-Dist: itk-elastix (>=0.20.0,<0.21.0) ; extra == "all" or extra == "itk-elastix"
|
|
27
26
|
Requires-Dist: nibabel (>=3.2.1)
|
|
28
27
|
Requires-Dist: numpy (>=1.23.0,<2.0.0)
|
|
29
|
-
Requires-Dist: path (>=16.10.0,<17.0.0)
|
|
30
28
|
Requires-Dist: pathlib (>=1.0.1,<2.0.0)
|
|
31
29
|
Requires-Dist: picsl_greedy (>=0.0.6,<0.0.7) ; extra == "all" or extra == "picsl-greedy"
|
|
32
30
|
Requires-Dist: rich (>=13.6.0,<14.0.0)
|
|
33
31
|
Requires-Dist: scipy (<1.14)
|
|
32
|
+
Requires-Dist: simpleitk (>=2.2.1)
|
|
34
33
|
Requires-Dist: tqdm (>=4.64.1,<5.0.0)
|
|
35
34
|
Requires-Dist: ttictoc (>=0.5.6,<0.6.0)
|
|
36
35
|
Requires-Dist: typer (>=0.15.0,<0.16.0)
|
|
@@ -49,9 +48,10 @@ Description-Content-Type: text/markdown
|
|
|
49
48
|
|
|
50
49
|
`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:
|
|
51
50
|
|
|
52
|
-
This includes **normalization**, **co-registration**, **atlas registration
|
|
51
|
+
This includes **normalization**, **co-registration**, **atlas registration**, **skullstripping / brain extraction**, **N4 Bias correction** and **defacing**.
|
|
52
|
+
We provide means to transform images and segmentations in both directions between native and atlas space.
|
|
53
53
|
|
|
54
|
-
BrainLes is written `backend-agnostic` meaning it allows to swap
|
|
54
|
+
BrainLes is written modular and `backend-agnostic` meaning it allows to skip or swap registration, brain extraction, N4 bias correction and defacing tools.
|
|
55
55
|
|
|
56
56
|
<!-- TODO include image here -->
|
|
57
57
|
|
|
@@ -125,7 +125,7 @@ moving_modalities = [
|
|
|
125
125
|
)
|
|
126
126
|
]
|
|
127
127
|
|
|
128
|
-
# instantiate and run the preprocessor using defaults for registration
|
|
128
|
+
# instantiate and run the preprocessor using defaults for backends (registration, brain extraction, bias correction, defacing)
|
|
129
129
|
preprocessor = Preprocessor(
|
|
130
130
|
center_modality=center,
|
|
131
131
|
moving_modalities=moving_modalities,
|
|
@@ -149,9 +149,25 @@ For further information please have a look at our [Jupyter Notebook tutorials](h
|
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
|
|
152
|
+
## Citation
|
|
152
153
|
|
|
154
|
+
> [!IMPORTANT]
|
|
155
|
+
> If you use `brainles-preprocessing` in your research, please cite it to support the development!
|
|
153
156
|
|
|
154
|
-
|
|
157
|
+
Kofler, F., Rosier, M., Astaraki, M., Möller, H., Mekki, I. I., Buchner, J. A., Schmick, A., Pfiffer, A., Oswald, E., Zimmer, L., Rosa, E. de la, Pati, S., Canisius, J., Piffer, A., Baid, U., Valizadeh, M., Linardos, A., Peeken, J. C., Shit, S., … Menze, B. (2025). *BrainLesion Suite: A Flexible and User-Friendly Framework for Modular Brain Lesion Image Analysis* [arXiv preprint arXiv:2507.09036](https://doi.org/10.48550/arXiv.2507.09036)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
@misc{kofler2025brainlesionsuiteflexibleuserfriendly,
|
|
162
|
+
title={BrainLesion Suite: A Flexible and User-Friendly Framework for Modular Brain Lesion Image Analysis},
|
|
163
|
+
author={Florian Kofler and Marcel Rosier and Mehdi Astaraki and Hendrik Möller and Ilhem Isra Mekki and Josef A. Buchner and Anton Schmick and Arianna Pfiffer and Eva Oswald and Lucas Zimmer and Ezequiel de la Rosa and Sarthak Pati and Julian Canisius and Arianna Piffer and Ujjwal Baid and Mahyar Valizadeh and Akis Linardos and Jan C. Peeken and Surprosanna Shit and Felix Steinbauer and Daniel Rueckert and Rolf Heckemann and Spyridon Bakas and Jan Kirschke and Constantin von See and Ivan Ezhov and Marie Piraud and Benedikt Wiestler and Bjoern Menze},
|
|
164
|
+
year={2025},
|
|
165
|
+
eprint={2507.09036},
|
|
166
|
+
archivePrefix={arXiv},
|
|
167
|
+
primaryClass={cs.CV},
|
|
168
|
+
url={https://arxiv.org/abs/2507.09036},
|
|
169
|
+
}
|
|
170
|
+
```
|
|
155
171
|
|
|
156
172
|
## Documentation
|
|
157
173
|
We provide a (WIP) documentation. Have a look [here](https://brainles-preprocessing.readthedocs.io/en/latest/?badge=latest)
|
|
@@ -166,6 +182,9 @@ We currently provide support for [ANTs](https://github.com/ANTsX/ANTs) (default)
|
|
|
166
182
|
We provide the SRI-24 atlas from this [publication](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2915788/).
|
|
167
183
|
However, custom atlases in NIfTI format are supported.
|
|
168
184
|
|
|
185
|
+
### N4 Bias correction
|
|
186
|
+
We currently provide support for N4 Bias correction based on [SimpleITK](https://simpleitk.org/)
|
|
187
|
+
|
|
169
188
|
### Brain extraction
|
|
170
189
|
We currently provide support for [HD-BET](https://github.com/MIC-DKFZ/HD-BET).
|
|
171
190
|
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
`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:
|
|
12
12
|
|
|
13
|
-
This includes **normalization**, **co-registration**, **atlas registration
|
|
13
|
+
This includes **normalization**, **co-registration**, **atlas registration**, **skullstripping / brain extraction**, **N4 Bias correction** and **defacing**.
|
|
14
|
+
We provide means to transform images and segmentations in both directions between native and atlas space.
|
|
14
15
|
|
|
15
|
-
BrainLes is written `backend-agnostic` meaning it allows to swap
|
|
16
|
+
BrainLes is written modular and `backend-agnostic` meaning it allows to skip or swap registration, brain extraction, N4 bias correction and defacing tools.
|
|
16
17
|
|
|
17
18
|
<!-- TODO include image here -->
|
|
18
19
|
|
|
@@ -86,7 +87,7 @@ moving_modalities = [
|
|
|
86
87
|
)
|
|
87
88
|
]
|
|
88
89
|
|
|
89
|
-
# instantiate and run the preprocessor using defaults for registration
|
|
90
|
+
# instantiate and run the preprocessor using defaults for backends (registration, brain extraction, bias correction, defacing)
|
|
90
91
|
preprocessor = Preprocessor(
|
|
91
92
|
center_modality=center,
|
|
92
93
|
moving_modalities=moving_modalities,
|
|
@@ -110,9 +111,25 @@ For further information please have a look at our [Jupyter Notebook tutorials](h
|
|
|
110
111
|
|
|
111
112
|
|
|
112
113
|
|
|
114
|
+
## Citation
|
|
113
115
|
|
|
116
|
+
> [!IMPORTANT]
|
|
117
|
+
> If you use `brainles-preprocessing` in your research, please cite it to support the development!
|
|
114
118
|
|
|
115
|
-
|
|
119
|
+
Kofler, F., Rosier, M., Astaraki, M., Möller, H., Mekki, I. I., Buchner, J. A., Schmick, A., Pfiffer, A., Oswald, E., Zimmer, L., Rosa, E. de la, Pati, S., Canisius, J., Piffer, A., Baid, U., Valizadeh, M., Linardos, A., Peeken, J. C., Shit, S., … Menze, B. (2025). *BrainLesion Suite: A Flexible and User-Friendly Framework for Modular Brain Lesion Image Analysis* [arXiv preprint arXiv:2507.09036](https://doi.org/10.48550/arXiv.2507.09036)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
@misc{kofler2025brainlesionsuiteflexibleuserfriendly,
|
|
124
|
+
title={BrainLesion Suite: A Flexible and User-Friendly Framework for Modular Brain Lesion Image Analysis},
|
|
125
|
+
author={Florian Kofler and Marcel Rosier and Mehdi Astaraki and Hendrik Möller and Ilhem Isra Mekki and Josef A. Buchner and Anton Schmick and Arianna Pfiffer and Eva Oswald and Lucas Zimmer and Ezequiel de la Rosa and Sarthak Pati and Julian Canisius and Arianna Piffer and Ujjwal Baid and Mahyar Valizadeh and Akis Linardos and Jan C. Peeken and Surprosanna Shit and Felix Steinbauer and Daniel Rueckert and Rolf Heckemann and Spyridon Bakas and Jan Kirschke and Constantin von See and Ivan Ezhov and Marie Piraud and Benedikt Wiestler and Bjoern Menze},
|
|
126
|
+
year={2025},
|
|
127
|
+
eprint={2507.09036},
|
|
128
|
+
archivePrefix={arXiv},
|
|
129
|
+
primaryClass={cs.CV},
|
|
130
|
+
url={https://arxiv.org/abs/2507.09036},
|
|
131
|
+
}
|
|
132
|
+
```
|
|
116
133
|
|
|
117
134
|
## Documentation
|
|
118
135
|
We provide a (WIP) documentation. Have a look [here](https://brainles-preprocessing.readthedocs.io/en/latest/?badge=latest)
|
|
@@ -127,6 +144,9 @@ We currently provide support for [ANTs](https://github.com/ANTsX/ANTs) (default)
|
|
|
127
144
|
We provide the SRI-24 atlas from this [publication](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2915788/).
|
|
128
145
|
However, custom atlases in NIfTI format are supported.
|
|
129
146
|
|
|
147
|
+
### N4 Bias correction
|
|
148
|
+
We currently provide support for N4 Bias correction based on [SimpleITK](https://simpleitk.org/)
|
|
149
|
+
|
|
130
150
|
### Brain extraction
|
|
131
151
|
We currently provide support for [HD-BET](https://github.com/MIC-DKFZ/HD-BET).
|
|
132
152
|
|
|
@@ -5,7 +5,7 @@ from pathlib import Path
|
|
|
5
5
|
from typing import Optional, Union
|
|
6
6
|
from enum import Enum
|
|
7
7
|
|
|
8
|
-
from auxiliary.
|
|
8
|
+
from auxiliary.io import read_image, write_image
|
|
9
9
|
from brainles_hd_bet import run_hd_bet
|
|
10
10
|
|
|
11
11
|
|
|
@@ -55,8 +55,8 @@ class BrainExtractor:
|
|
|
55
55
|
|
|
56
56
|
try:
|
|
57
57
|
# Read data
|
|
58
|
-
input_data =
|
|
59
|
-
mask_data =
|
|
58
|
+
input_data = read_image(str(input_image_path))
|
|
59
|
+
mask_data = read_image(str(mask_path))
|
|
60
60
|
except FileNotFoundError as e:
|
|
61
61
|
raise FileNotFoundError(f"File not found: {e.filename}") from e
|
|
62
62
|
except Exception as e:
|
|
@@ -70,10 +70,10 @@ class BrainExtractor:
|
|
|
70
70
|
masked_data = input_data * mask_data
|
|
71
71
|
|
|
72
72
|
try:
|
|
73
|
-
|
|
73
|
+
write_image(
|
|
74
74
|
input_array=masked_data,
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
output_path=str(bet_image_path),
|
|
76
|
+
reference_path=str(input_image_path),
|
|
77
77
|
create_parent_directory=True,
|
|
78
78
|
)
|
|
79
79
|
except Exception as e:
|
{brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/constants.py
RENAMED
|
@@ -6,8 +6,9 @@ class PreprocessorSteps(IntEnum):
|
|
|
6
6
|
COREGISTERED = 1
|
|
7
7
|
ATLAS_REGISTERED = 2
|
|
8
8
|
ATLAS_CORRECTED = 3
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
N4_BIAS_CORRECTED = 4
|
|
10
|
+
BET = 5
|
|
11
|
+
DEFACED = 6
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
class Atlas(str, Enum):
|
|
@@ -23,3 +24,6 @@ class Atlas(str, Enum):
|
|
|
23
24
|
|
|
24
25
|
BRATS_MNI152 = "brats_MNI152lin_T1_1mm.nii.gz"
|
|
25
26
|
"""Slightly modified MNI152 atlas as found in the BraTS challenges"""
|
|
27
|
+
|
|
28
|
+
MNI152 = "mni_icbm152_t1_tal_nlin_sym_09c.nii"
|
|
29
|
+
"""MNI_ICBM_2009c_Nonlinear_Symmetric atlas from https://nist.mni.mcgill.ca/icbm-152-nonlinear-atlases-2009/"""
|
|
@@ -2,7 +2,7 @@ from abc import ABC, abstractmethod
|
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
from typing import Union
|
|
4
4
|
|
|
5
|
-
from auxiliary.
|
|
5
|
+
from auxiliary.io import read_image, write_image
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class Defacer(ABC):
|
|
@@ -52,8 +52,8 @@ class Defacer(ABC):
|
|
|
52
52
|
|
|
53
53
|
try:
|
|
54
54
|
# Read data
|
|
55
|
-
input_data =
|
|
56
|
-
mask_data =
|
|
55
|
+
input_data = read_image(str(input_image_path))
|
|
56
|
+
mask_data = read_image(str(mask_path))
|
|
57
57
|
except Exception as e:
|
|
58
58
|
raise RuntimeError(
|
|
59
59
|
f"An error occurred while reading input files: {e}"
|
|
@@ -67,9 +67,9 @@ class Defacer(ABC):
|
|
|
67
67
|
masked_data = input_data * mask_data
|
|
68
68
|
|
|
69
69
|
# Save the defaced image
|
|
70
|
-
|
|
70
|
+
write_image(
|
|
71
71
|
input_array=masked_data,
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
output_path=str(defaced_image_path),
|
|
73
|
+
reference_path=str(input_image_path),
|
|
74
74
|
create_parent_directory=True,
|
|
75
75
|
)
|
|
@@ -2,10 +2,11 @@ from pathlib import Path
|
|
|
2
2
|
from typing import Union
|
|
3
3
|
|
|
4
4
|
import nibabel as nib
|
|
5
|
+
from auxiliary.io import read_image, write_image
|
|
5
6
|
|
|
6
7
|
from brainles_preprocessing.defacing.defacer import Defacer
|
|
7
8
|
from brainles_preprocessing.defacing.quickshear.nipy_quickshear import run_quickshear
|
|
8
|
-
from
|
|
9
|
+
from brainles_preprocessing.constants import Atlas
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class QuickshearDefacer(Defacer):
|
|
@@ -29,14 +30,23 @@ class QuickshearDefacer(Defacer):
|
|
|
29
30
|
```
|
|
30
31
|
"""
|
|
31
32
|
|
|
32
|
-
def __init__(
|
|
33
|
+
def __init__(
|
|
34
|
+
self,
|
|
35
|
+
buffer: float = 10.0,
|
|
36
|
+
force_atlas_registration: bool = True,
|
|
37
|
+
atlas_image_path: Union[str, Path, Atlas] = Atlas.SRI24,
|
|
38
|
+
):
|
|
33
39
|
"""Initialize Quickshear defacer
|
|
34
40
|
|
|
35
41
|
Args:
|
|
36
42
|
buffer (float, optional): buffer parameter from quickshear algorithm. Defaults to 10.0.
|
|
43
|
+
force_atlas_registration (bool, optional): If True, forces atlas registration of the BET mask before defacing to potentially boost quickshear performance. Defaults to True.
|
|
44
|
+
atlas_image_path (Union[str, Path, Atlas], optional): Path to the atlas image or an Atlas enum value that will be used for the optional atlas registrations. Defaults to Atlas.SRI24.
|
|
37
45
|
"""
|
|
38
46
|
super().__init__()
|
|
39
47
|
self.buffer = buffer
|
|
48
|
+
self.force_atlas_registration = force_atlas_registration
|
|
49
|
+
self.atlas_image_path = atlas_image_path
|
|
40
50
|
|
|
41
51
|
def deface(
|
|
42
52
|
self,
|
|
@@ -56,8 +66,11 @@ class QuickshearDefacer(Defacer):
|
|
|
56
66
|
|
|
57
67
|
bet_img = nib.load(str(input_image_path))
|
|
58
68
|
mask = run_quickshear(bet_img=bet_img, buffer=self.buffer)
|
|
59
|
-
|
|
69
|
+
|
|
70
|
+
# transpose to match simpletik order
|
|
71
|
+
mask = mask.transpose(2, 1, 0)
|
|
72
|
+
write_image(
|
|
60
73
|
input_array=mask,
|
|
61
|
-
|
|
62
|
-
|
|
74
|
+
output_path=str(mask_image_path),
|
|
75
|
+
reference_path=str(input_image_path),
|
|
63
76
|
)
|
{brainles_preprocessing-0.4.0 → brainles_preprocessing-0.6.0}/brainles_preprocessing/modality.py
RENAMED
|
@@ -4,10 +4,10 @@ import warnings
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from typing import Dict, Optional, Union
|
|
6
6
|
|
|
7
|
-
from auxiliary.
|
|
7
|
+
from auxiliary.io import read_image, write_image
|
|
8
8
|
|
|
9
9
|
from brainles_preprocessing.brain_extraction.brain_extractor import BrainExtractor
|
|
10
|
-
from brainles_preprocessing.constants import PreprocessorSteps
|
|
10
|
+
from brainles_preprocessing.constants import Atlas, PreprocessorSteps
|
|
11
11
|
from brainles_preprocessing.defacing import Defacer, QuickshearDefacer
|
|
12
12
|
from brainles_preprocessing.normalization.normalizer_base import Normalizer
|
|
13
13
|
from brainles_preprocessing.registration import ( # TODO: this will throw warnings if ANTs or NiftyReg are not installed, not ideal
|
|
@@ -15,6 +15,7 @@ from brainles_preprocessing.registration import ( # TODO: this will throw warni
|
|
|
15
15
|
NiftyRegRegistrator,
|
|
16
16
|
)
|
|
17
17
|
from brainles_preprocessing.registration.registrator import Registrator
|
|
18
|
+
from brainles_preprocessing.utils.zenodo import verify_or_download_atlases
|
|
18
19
|
|
|
19
20
|
logger = logging.getLogger(__name__)
|
|
20
21
|
|
|
@@ -34,6 +35,7 @@ class Modality:
|
|
|
34
35
|
normalized_skull_output_path (str or Path, optional): Path to save the normalized modality data with skull. Requires a normalizer.
|
|
35
36
|
normalized_defaced_output_path (str or Path, optional): Path to save the normalized defaced modality data. Requires a normalizer.
|
|
36
37
|
atlas_correction (bool, optional): Indicates whether atlas correction should be performed.
|
|
38
|
+
n4_bias_correction (bool, optional): Indicates whether N4 bias correction should be performed.
|
|
37
39
|
|
|
38
40
|
Attributes:
|
|
39
41
|
modality_name (str): Name of the modality.
|
|
@@ -47,6 +49,7 @@ class Modality:
|
|
|
47
49
|
normalized_defaced_output_path (str or Path, optional): Path to save the normalized defaced modality data. Requires a normalizer.
|
|
48
50
|
bet (bool): Indicates whether brain extraction is enabled.
|
|
49
51
|
atlas_correction (bool): Indicates whether atlas correction should be performed.
|
|
52
|
+
n4_bias_correction (bool): Indicates whether N4 bias correction should be performed.
|
|
50
53
|
coregistration_transform_path (str or None): Path to the coregistration transformation matrix, will be set after coregistration.
|
|
51
54
|
|
|
52
55
|
Example:
|
|
@@ -72,6 +75,7 @@ class Modality:
|
|
|
72
75
|
normalized_skull_output_path: Optional[Union[str, Path]] = None,
|
|
73
76
|
normalized_defaced_output_path: Optional[Union[str, Path]] = None,
|
|
74
77
|
atlas_correction: bool = True,
|
|
78
|
+
n4_bias_correction: bool = False,
|
|
75
79
|
) -> None:
|
|
76
80
|
# Basics
|
|
77
81
|
self.modality_name = modality_name
|
|
@@ -79,6 +83,7 @@ class Modality:
|
|
|
79
83
|
self.current = self.input_path
|
|
80
84
|
self.normalizer = normalizer
|
|
81
85
|
self.atlas_correction = atlas_correction
|
|
86
|
+
self.n4_bias_correction = n4_bias_correction
|
|
82
87
|
self.transformation_paths: Dict[PreprocessorSteps, Path | None] = {}
|
|
83
88
|
|
|
84
89
|
# Check that atleast one output is generated
|
|
@@ -195,12 +200,12 @@ class Modality:
|
|
|
195
200
|
|
|
196
201
|
# Normalize the image
|
|
197
202
|
if self.normalizer:
|
|
198
|
-
image =
|
|
203
|
+
image = read_image(str(self.current))
|
|
199
204
|
normalized_image = self.normalizer.normalize(image=image)
|
|
200
|
-
|
|
205
|
+
write_image(
|
|
201
206
|
input_array=normalized_image,
|
|
202
|
-
|
|
203
|
-
|
|
207
|
+
output_path=str(self.current),
|
|
208
|
+
reference_path=str(self.current),
|
|
204
209
|
)
|
|
205
210
|
else:
|
|
206
211
|
logger.info("No normalizer specified; skipping normalization.")
|
|
@@ -291,7 +296,7 @@ class Modality:
|
|
|
291
296
|
if self.bet:
|
|
292
297
|
mask_path = Path(mask_path)
|
|
293
298
|
bet_dir = Path(bet_dir)
|
|
294
|
-
bet_img = bet_dir / f"
|
|
299
|
+
bet_img = bet_dir / f"{self.modality_name}_bet.nii.gz"
|
|
295
300
|
|
|
296
301
|
brain_extractor.apply_mask(
|
|
297
302
|
input_image_path=self.current,
|
|
@@ -320,14 +325,27 @@ class Modality:
|
|
|
320
325
|
if self.requires_deface:
|
|
321
326
|
mask_path = Path(mask_path)
|
|
322
327
|
deface_dir = Path(deface_dir)
|
|
323
|
-
defaced_img = deface_dir / f"
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
328
|
+
defaced_img = deface_dir / f"{self.modality_name}_defaced.nii.gz"
|
|
329
|
+
|
|
330
|
+
# For Atlas centric preprocessing, we use the atlas corrected or registered image as input
|
|
331
|
+
# For Native space preprocessing, we use the coregistered image as input
|
|
332
|
+
input_img = (
|
|
333
|
+
self.steps[
|
|
334
|
+
(
|
|
335
|
+
PreprocessorSteps.ATLAS_CORRECTED
|
|
336
|
+
if self.atlas_correction
|
|
337
|
+
else PreprocessorSteps.ATLAS_REGISTERED
|
|
338
|
+
)
|
|
339
|
+
]
|
|
340
|
+
or self.steps[PreprocessorSteps.COREGISTERED]
|
|
341
|
+
)
|
|
342
|
+
|
|
343
|
+
if input_img is None:
|
|
344
|
+
raise ValueError(
|
|
345
|
+
"Input image for defacing is missing. Ensure that the required preprocessing steps "
|
|
346
|
+
"have been performed before defacing."
|
|
329
347
|
)
|
|
330
|
-
|
|
348
|
+
|
|
331
349
|
defacer.apply_mask(
|
|
332
350
|
input_image_path=input_img,
|
|
333
351
|
mask_path=mask_path,
|
|
@@ -424,65 +442,40 @@ class Modality:
|
|
|
424
442
|
"Legacy method. Please Migrate to use the CenterModality Class. Will be removed in future versions.",
|
|
425
443
|
category=DeprecationWarning,
|
|
426
444
|
)
|
|
427
|
-
|
|
428
445
|
bet_dir_path = Path(bet_dir_path)
|
|
429
446
|
bet_log = bet_dir_path / "brain-extraction.log"
|
|
430
447
|
|
|
431
|
-
|
|
432
|
-
mask_path = bet_dir_path / f"
|
|
448
|
+
bet = bet_dir_path / f"{self.modality_name}_bet.nii.gz"
|
|
449
|
+
mask_path = bet_dir_path / f"{self.modality_name}_brain_mask.nii.gz"
|
|
433
450
|
|
|
434
451
|
brain_extractor.extract(
|
|
435
452
|
input_image_path=self.current,
|
|
436
|
-
masked_image_path=
|
|
453
|
+
masked_image_path=bet,
|
|
437
454
|
brain_mask_path=mask_path,
|
|
438
455
|
log_file_path=bet_log,
|
|
439
456
|
)
|
|
440
457
|
|
|
441
458
|
# always temporarily store bet image for center modality, since e.g. quickshear defacing could require it
|
|
442
459
|
# down the line even if the user does not wish to save the bet image
|
|
443
|
-
self.steps[PreprocessorSteps.BET] =
|
|
460
|
+
self.steps[PreprocessorSteps.BET] = bet
|
|
444
461
|
|
|
445
462
|
if self.bet:
|
|
446
|
-
self.current =
|
|
463
|
+
self.current = bet
|
|
447
464
|
return mask_path
|
|
448
465
|
|
|
449
466
|
def deface(
|
|
450
467
|
self,
|
|
451
468
|
defacer,
|
|
452
469
|
defaced_dir_path: Union[str, Path],
|
|
453
|
-
|
|
470
|
+
registrator: Optional[Registrator] = None,
|
|
471
|
+
) -> Path | None:
|
|
454
472
|
"""
|
|
455
473
|
WARNING: Legacy method. Please Migrate to use the CenterModality Class. Will be removed in future versions.
|
|
456
|
-
|
|
457
|
-
Deface the current modality using the specified defacer.
|
|
458
|
-
|
|
459
|
-
Args:
|
|
460
|
-
defacer (Defacer): The defacer object.
|
|
461
|
-
defaced_dir_path (str or Path): Directory to store defacing results.
|
|
462
|
-
|
|
463
|
-
Returns:
|
|
464
|
-
Path: Path to the extracted brain mask.
|
|
465
474
|
"""
|
|
466
|
-
|
|
467
|
-
"
|
|
468
|
-
|
|
475
|
+
raise RuntimeError(
|
|
476
|
+
"The 'deface' method has been deprecated and moved to the CenterModality class as its only supposed to be called once from the CenterModality. "
|
|
477
|
+
"Please update your code to use the 'CenterModality.deface()' method instead."
|
|
469
478
|
)
|
|
470
|
-
if isinstance(defacer, QuickshearDefacer):
|
|
471
|
-
defaced_dir_path = Path(defaced_dir_path)
|
|
472
|
-
atlas_mask_path = (
|
|
473
|
-
defaced_dir_path / f"atlas__{self.modality_name}_deface_mask.nii.gz"
|
|
474
|
-
)
|
|
475
|
-
|
|
476
|
-
defacer.deface(
|
|
477
|
-
mask_image_path=atlas_mask_path,
|
|
478
|
-
input_image_path=self.steps[PreprocessorSteps.BET],
|
|
479
|
-
)
|
|
480
|
-
return atlas_mask_path
|
|
481
|
-
else:
|
|
482
|
-
logger.warning(
|
|
483
|
-
"Defacing method not implemented yet. Skipping defacing for this modality."
|
|
484
|
-
)
|
|
485
|
-
return None
|
|
486
479
|
|
|
487
480
|
def save_current_image(
|
|
488
481
|
self,
|
|
@@ -505,12 +498,12 @@ class Modality:
|
|
|
505
498
|
if normalization:
|
|
506
499
|
if self.normalizer is None:
|
|
507
500
|
raise ValueError("Normalizer is required for normalization.")
|
|
508
|
-
image =
|
|
501
|
+
image = read_image(str(self.current))
|
|
509
502
|
normalized_image = self.normalizer.normalize(image=image)
|
|
510
|
-
|
|
503
|
+
write_image(
|
|
511
504
|
input_array=normalized_image,
|
|
512
|
-
|
|
513
|
-
|
|
505
|
+
output_path=str(output_path),
|
|
506
|
+
reference_path=str(self.current),
|
|
514
507
|
)
|
|
515
508
|
else:
|
|
516
509
|
shutil.copyfile(
|
|
@@ -534,6 +527,7 @@ class CenterModality(Modality):
|
|
|
534
527
|
normalized_skull_output_path (str or Path, optional): Path to save the normalized modality data with skull. Requires a normalizer.
|
|
535
528
|
normalized_defaced_output_path (str or Path, optional): Path to save the normalized defaced modality data. Requires a normalizer.
|
|
536
529
|
atlas_correction (bool, optional): Indicates whether atlas correction should be performed.
|
|
530
|
+
n4_bias_correction (bool, optional): Indicates whether N4 bias correction should be performed.
|
|
537
531
|
bet_mask_output_path (str or Path, optional): Path to save the brain extraction mask.
|
|
538
532
|
defacing_mask_output_path (str or Path, optional): Path to save the defacing mask.
|
|
539
533
|
|
|
@@ -549,6 +543,7 @@ class CenterModality(Modality):
|
|
|
549
543
|
normalized_defaced_output_path (str or Path, optional): Path to save the normalized defaced modality data. Requires a normalizer.
|
|
550
544
|
bet (bool): Indicates whether brain extraction is enabled.
|
|
551
545
|
atlas_correction (bool): Indicates whether atlas correction should be performed.
|
|
546
|
+
n4_bias_correction (bool): Indicates whether N4 bias correction should be performed.
|
|
552
547
|
bet_mask_output_path (Path, optional): Path to save the brain extraction mask.
|
|
553
548
|
defacing_mask_output_path (Path, optional): Path to save the defacing mask.
|
|
554
549
|
|
|
@@ -575,6 +570,7 @@ class CenterModality(Modality):
|
|
|
575
570
|
normalized_skull_output_path: Optional[Union[str, Path]] = None,
|
|
576
571
|
normalized_defaced_output_path: Optional[Union[str, Path]] = None,
|
|
577
572
|
atlas_correction: bool = True,
|
|
573
|
+
n4_bias_correction: bool = False,
|
|
578
574
|
bet_mask_output_path: Optional[Union[str, Path]] = None,
|
|
579
575
|
defacing_mask_output_path: Optional[Union[str, Path]] = None,
|
|
580
576
|
) -> None:
|
|
@@ -589,6 +585,7 @@ class CenterModality(Modality):
|
|
|
589
585
|
normalized_skull_output_path=normalized_skull_output_path,
|
|
590
586
|
normalized_defaced_output_path=normalized_defaced_output_path,
|
|
591
587
|
atlas_correction=atlas_correction,
|
|
588
|
+
n4_bias_correction=n4_bias_correction,
|
|
592
589
|
)
|
|
593
590
|
# Only for CenterModality
|
|
594
591
|
self.bet_mask_output_path = (
|
|
@@ -604,6 +601,7 @@ class CenterModality(Modality):
|
|
|
604
601
|
bet_dir_path: Union[str, Path],
|
|
605
602
|
) -> Path:
|
|
606
603
|
"""
|
|
604
|
+
|
|
607
605
|
Extract the brain region using the specified brain extractor.
|
|
608
606
|
|
|
609
607
|
Args:
|
|
@@ -613,66 +611,95 @@ class CenterModality(Modality):
|
|
|
613
611
|
Returns:
|
|
614
612
|
Path: Path to the extracted brain mask.
|
|
615
613
|
"""
|
|
614
|
+
|
|
616
615
|
bet_dir_path = Path(bet_dir_path)
|
|
617
616
|
bet_log = bet_dir_path / "brain-extraction.log"
|
|
618
617
|
|
|
619
|
-
|
|
620
|
-
mask_path = bet_dir_path / f"
|
|
618
|
+
bet = bet_dir_path / f"{self.modality_name}_bet.nii.gz"
|
|
619
|
+
mask_path = bet_dir_path / f"{self.modality_name}_brain_mask.nii.gz"
|
|
621
620
|
|
|
622
621
|
brain_extractor.extract(
|
|
623
622
|
input_image_path=self.current,
|
|
624
|
-
masked_image_path=
|
|
623
|
+
masked_image_path=bet,
|
|
625
624
|
brain_mask_path=mask_path,
|
|
626
625
|
log_file_path=bet_log,
|
|
627
626
|
)
|
|
628
627
|
|
|
629
|
-
if self.bet_mask_output_path:
|
|
630
|
-
logger.debug(f"Saving bet mask to {self.bet_mask_output_path}")
|
|
631
|
-
self.save_mask(mask_path=mask_path, output_path=self.bet_mask_output_path)
|
|
632
|
-
|
|
633
628
|
# always temporarily store bet image for center modality, since e.g. quickshear defacing could require it
|
|
634
629
|
# down the line even if the user does not wish to save the bet image
|
|
635
|
-
self.steps[PreprocessorSteps.BET] =
|
|
630
|
+
self.steps[PreprocessorSteps.BET] = bet
|
|
636
631
|
|
|
637
632
|
if self.bet:
|
|
638
|
-
self.current =
|
|
633
|
+
self.current = bet
|
|
639
634
|
return mask_path
|
|
640
635
|
|
|
641
636
|
def deface(
|
|
642
637
|
self,
|
|
643
|
-
defacer,
|
|
638
|
+
defacer: Defacer,
|
|
644
639
|
defaced_dir_path: Union[str, Path],
|
|
645
|
-
|
|
640
|
+
registrator: Optional[Registrator] = None,
|
|
641
|
+
) -> Path | None:
|
|
646
642
|
"""
|
|
647
643
|
Deface the current modality using the specified defacer.
|
|
648
644
|
|
|
649
645
|
Args:
|
|
650
646
|
defacer (Defacer): The defacer object.
|
|
651
647
|
defaced_dir_path (str or Path): Directory to store defacing results.
|
|
648
|
+
registrator (Registrator, optional): The registrator object for atlas registration.
|
|
652
649
|
|
|
653
650
|
Returns:
|
|
654
|
-
Path: Path to the
|
|
651
|
+
Path | None: Path to the defacing mask if successful, None otherwise.
|
|
655
652
|
"""
|
|
656
|
-
|
|
657
653
|
if isinstance(defacer, QuickshearDefacer):
|
|
658
654
|
defaced_dir_path = Path(defaced_dir_path)
|
|
659
|
-
|
|
660
|
-
defaced_dir_path / f"atlas__{self.modality_name}_deface_mask.nii.gz"
|
|
661
|
-
)
|
|
655
|
+
mask_path = defaced_dir_path / f"{self.modality_name}_deface_mask.nii.gz"
|
|
662
656
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
657
|
+
if self.steps.get(PreprocessorSteps.BET, None) is None:
|
|
658
|
+
raise ValueError(
|
|
659
|
+
"Brain extraction must be performed before defacing. "
|
|
660
|
+
"Please run brain extraction first."
|
|
661
|
+
)
|
|
667
662
|
|
|
668
|
-
if
|
|
669
|
-
logger.
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
663
|
+
if defacer.force_atlas_registration and registrator is not None:
|
|
664
|
+
logger.info("Forcing atlas registration before defacing as requested.")
|
|
665
|
+
atlas_bet = defaced_dir_path / "atlas_bet.nii.gz"
|
|
666
|
+
atlas_bet_M = defaced_dir_path / "M_atlas_bet"
|
|
667
|
+
|
|
668
|
+
# resolve atlas image path
|
|
669
|
+
if isinstance(defacer.atlas_image_path, Atlas):
|
|
670
|
+
atlas_folder = verify_or_download_atlases()
|
|
671
|
+
atlas_image_path = atlas_folder / defacer.atlas_image_path.value
|
|
672
|
+
else:
|
|
673
|
+
atlas_image_path = Path(defacer.atlas_image_path)
|
|
674
|
+
|
|
675
|
+
registrator.register(
|
|
676
|
+
fixed_image_path=atlas_image_path,
|
|
677
|
+
moving_image_path=self.steps[PreprocessorSteps.BET],
|
|
678
|
+
transformed_image_path=atlas_bet,
|
|
679
|
+
matrix_path=atlas_bet_M,
|
|
680
|
+
log_file_path=defaced_dir_path / "atlas_bet.log",
|
|
681
|
+
)
|
|
682
|
+
|
|
683
|
+
deface_mask_atlas = defaced_dir_path / "deface_mask_atlas.nii.gz"
|
|
684
|
+
defacer.deface(
|
|
685
|
+
input_image_path=atlas_bet,
|
|
686
|
+
mask_image_path=deface_mask_atlas,
|
|
687
|
+
)
|
|
688
|
+
|
|
689
|
+
registrator.inverse_transform(
|
|
690
|
+
fixed_image_path=self.steps[PreprocessorSteps.BET],
|
|
691
|
+
moving_image_path=deface_mask_atlas,
|
|
692
|
+
transformed_image_path=mask_path,
|
|
693
|
+
matrix_path=atlas_bet_M,
|
|
694
|
+
log_file_path=defaced_dir_path / "inverse_transform.log",
|
|
695
|
+
)
|
|
696
|
+
else:
|
|
697
|
+
defacer.deface(
|
|
698
|
+
input_image_path=self.steps[PreprocessorSteps.BET],
|
|
699
|
+
mask_image_path=mask_path,
|
|
673
700
|
)
|
|
674
701
|
|
|
675
|
-
return
|
|
702
|
+
return mask_path
|
|
676
703
|
else:
|
|
677
704
|
logger.warning(
|
|
678
705
|
"Defacing method not implemented yet. Skipping defacing for this modality."
|