brainles-preprocessing 0.3.6__tar.gz → 0.4.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.3.6 → brainles_preprocessing-0.4.0}/PKG-INFO +4 -3
- brainles_preprocessing-0.4.0/brainles_preprocessing/back_to_native.py +100 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/modality.py +71 -10
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/preprocessor.py +24 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/ANTs/ANTs.py +102 -28
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/elastix/elastix.py +15 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/greedy/greedy.py +16 -2
- brainles_preprocessing-0.4.0/brainles_preprocessing/registration/niftyreg/niftyreg.py +266 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/transform.sh +4 -3
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/registrator.py +26 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/pyproject.toml +5 -3
- brainles_preprocessing-0.3.6/brainles_preprocessing/registration/niftyreg/niftyreg.py +0 -135
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/LICENSE +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/README.md +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/__init__.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/brain_extraction/__init__.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/brain_extraction/brain_extractor.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/brats/__init__.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/brats/t1_centric.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/brats/t1c_centric.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/cli.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/constants.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/defacing/__init__.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/defacing/defacer.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/defacing/quickshear/__init__.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/defacing/quickshear/nipy_quickshear.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/defacing/quickshear/quickshear.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/normalization/__init__.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/normalization/normalizer_base.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/normalization/percentile_normalizer.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/normalization/windowing_normalizer.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/ANTs/TODO_ANTs_parameters.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/ANTs/__init__.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/__init__.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/elastix/__init__.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/greedy/__init__.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/__init__.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/groupwise_niftyreg_params.sh +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/groupwise_niftyreg_run.sh +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_aladin +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_average +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_f3d +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_jacobian +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_measure +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_resample +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_tools +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_transform +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/AffineDeformationFieldKernel.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/AladinContent.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/BlockMatchingKernel.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUAffineDeformationFieldKernel.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUBlockMatchingKernel.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUConvolutionKernel.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUKernelFactory.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUOptimiseKernel.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUResampleImageKernel.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/ConvolutionKernel.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/Kernel.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/KernelFactory.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/OptimiseKernel.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/Platform.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/ResampleImageKernel.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_ReadWriteImage.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_ReadWriteMatrix.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_aladin.cpp +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_aladin.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_aladin_sym.cpp +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_aladin_sym.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_base.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_blockMatching.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_dti.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_f3d.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_f3d2.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_f3d_sym.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_femTrans.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_globalTrans.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_kld.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_lncc.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_localTrans.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_localTrans_jac.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_localTrans_regul.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_macros.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_maths.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_maths_eigen.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_measure.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_mind.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_nmi.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_optimiser.cpp +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_optimiser.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_resampling.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_splineBasis.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_ssd.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_stringFormat.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_tools.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/nifti1.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/nifti1_io.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/png.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pngconf.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pngdebug.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pnginfo.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pnglibconf.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pngpriv.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pngstruct.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/readpng.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/reg_png.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/zlib.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/znzlib.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/zutil.h +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/reg_aladin +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/reg_resample +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/rigid_reg.sh +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/utils/__init__.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/utils/generic.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/utils/logging_utils.py +0 -0
- {brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.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.4.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
|
|
@@ -19,10 +19,10 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
19
19
|
Provides-Extra: all
|
|
20
20
|
Provides-Extra: itk-elastix
|
|
21
21
|
Provides-Extra: picsl-greedy
|
|
22
|
-
Requires-Dist: antspyx (>=0.4.
|
|
22
|
+
Requires-Dist: antspyx (>=0.5.4,<1.0.0)
|
|
23
23
|
Requires-Dist: auxiliary (>=0.0.42)
|
|
24
24
|
Requires-Dist: black (>=22.1.0,<23.0.0)
|
|
25
|
-
Requires-Dist: brainles_hd_bet (>=0.0.10)
|
|
25
|
+
Requires-Dist: brainles_hd_bet (>=0.0.10,<1.0.0)
|
|
26
26
|
Requires-Dist: itk-elastix (>=0.20.0,<0.21.0) ; extra == "all" or extra == "itk-elastix"
|
|
27
27
|
Requires-Dist: nibabel (>=3.2.1)
|
|
28
28
|
Requires-Dist: numpy (>=1.23.0,<2.0.0)
|
|
@@ -30,6 +30,7 @@ Requires-Dist: path (>=16.10.0,<17.0.0)
|
|
|
30
30
|
Requires-Dist: pathlib (>=1.0.1,<2.0.0)
|
|
31
31
|
Requires-Dist: picsl_greedy (>=0.0.6,<0.0.7) ; extra == "all" or extra == "picsl-greedy"
|
|
32
32
|
Requires-Dist: rich (>=13.6.0,<14.0.0)
|
|
33
|
+
Requires-Dist: scipy (<1.14)
|
|
33
34
|
Requires-Dist: tqdm (>=4.64.1,<5.0.0)
|
|
34
35
|
Requires-Dist: ttictoc (>=0.5.6,<0.6.0)
|
|
35
36
|
Requires-Dist: typer (>=0.15.0,<0.16.0)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import List, Optional, Union
|
|
3
|
+
|
|
4
|
+
from brainles_preprocessing.constants import Atlas, PreprocessorSteps
|
|
5
|
+
from brainles_preprocessing.defacing import Defacer, QuickshearDefacer
|
|
6
|
+
from brainles_preprocessing.modality import CenterModality, Modality
|
|
7
|
+
from brainles_preprocessing.registration import ANTsRegistrator
|
|
8
|
+
from brainles_preprocessing.registration.registrator import Registrator
|
|
9
|
+
from brainles_preprocessing.utils.logging_utils import LoggingManager
|
|
10
|
+
from brainles_preprocessing.utils.zenodo import verify_or_download_atlases
|
|
11
|
+
|
|
12
|
+
logging_man = LoggingManager(name=__name__)
|
|
13
|
+
logger = logging_man.get_logger()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class BackToNativeSpace:
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
transformations_dir: Union[str, Path],
|
|
21
|
+
registrator: Optional[Registrator] = None,
|
|
22
|
+
):
|
|
23
|
+
|
|
24
|
+
self.transformations_dir = Path(transformations_dir)
|
|
25
|
+
|
|
26
|
+
if registrator is None:
|
|
27
|
+
logger.warning(
|
|
28
|
+
"No registrator provided, using default ANTsRegistrator for registration."
|
|
29
|
+
)
|
|
30
|
+
self.registrator: Registrator = registrator or ANTsRegistrator()
|
|
31
|
+
|
|
32
|
+
def transform(
|
|
33
|
+
self,
|
|
34
|
+
target_modality_name: str,
|
|
35
|
+
target_modality_img: Union[str, Path],
|
|
36
|
+
moving_image: Union[str, Path],
|
|
37
|
+
output_img_path: Union[str, Path],
|
|
38
|
+
log_file_path: Union[str, Path],
|
|
39
|
+
interpolator: Optional[str] = None,
|
|
40
|
+
):
|
|
41
|
+
"""
|
|
42
|
+
Apply inverse transformation to a moving image to align it with a target modality.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
target_modality_name (str): Name of the target modality. Must match the name used to create the transformations.
|
|
46
|
+
target_modality_img (Union[str, Path]): Path to the target modality image.
|
|
47
|
+
moving_image (Union[str, Path]): Path to the moving image. E.g., this could be a segmentation in atlas space.
|
|
48
|
+
output_img_path (Union[str, Path]): Path where the transformed image will be saved.
|
|
49
|
+
log_file_path (Union[str, Path]): Path to the log file where transformation details will be written.
|
|
50
|
+
interpolator (Optional[str]): Interpolation method used during transformation.
|
|
51
|
+
Available options depend on the chosen registrator:
|
|
52
|
+
|
|
53
|
+
- **ANTsRegistrator**:
|
|
54
|
+
- "linear" (default)
|
|
55
|
+
- "nearestNeighbor"
|
|
56
|
+
- "multiLabel" (deprecated, prefer "genericLabel")
|
|
57
|
+
- "gaussian"
|
|
58
|
+
- "bSpline"
|
|
59
|
+
- "cosineWindowedSinc"
|
|
60
|
+
- "welchWindowedSinc"
|
|
61
|
+
- "hammingWindowedSinc"
|
|
62
|
+
- "lanczosWindowedSinc"
|
|
63
|
+
- "genericLabel" (recommended for label images)
|
|
64
|
+
|
|
65
|
+
- **NiftyReg**:
|
|
66
|
+
- "0": nearest neighbor
|
|
67
|
+
- "1": linear (default)
|
|
68
|
+
- "3": cubic spline
|
|
69
|
+
- "4": sinc
|
|
70
|
+
|
|
71
|
+
Raises:
|
|
72
|
+
AssertionError: If the transformations directory for the given modality does not exist.
|
|
73
|
+
"""
|
|
74
|
+
logger.info(
|
|
75
|
+
f"Applying inverse transformation for {target_modality_name} using {self.registrator.__class__.__name__}."
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
# assert modality name eixsts in transformations_dir
|
|
79
|
+
modality_transformations_dir = (
|
|
80
|
+
self.transformations_dir / f"{target_modality_name}"
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
assert (
|
|
84
|
+
modality_transformations_dir.exists()
|
|
85
|
+
), f"Transformations directory for {target_modality_name} does not exist: {modality_transformations_dir}"
|
|
86
|
+
|
|
87
|
+
transforms = list(modality_transformations_dir.iterdir())
|
|
88
|
+
transforms.sort() # sort by name to get order for forward transform
|
|
89
|
+
transforms = transforms[::-1] # inverse order for inverse transform
|
|
90
|
+
|
|
91
|
+
kwargs = {
|
|
92
|
+
"fixed_image_path": target_modality_img,
|
|
93
|
+
"moving_image_path": moving_image,
|
|
94
|
+
"transformed_image_path": output_img_path,
|
|
95
|
+
"matrix_path": transforms,
|
|
96
|
+
"log_file_path": str(log_file_path),
|
|
97
|
+
}
|
|
98
|
+
if interpolator is not None:
|
|
99
|
+
kwargs["interpolator"] = interpolator
|
|
100
|
+
self.registrator.inverse_transform(**kwargs)
|
{brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/modality.py
RENAMED
|
@@ -2,13 +2,18 @@ import logging
|
|
|
2
2
|
import shutil
|
|
3
3
|
import warnings
|
|
4
4
|
from pathlib import Path
|
|
5
|
-
from typing import Optional, Union
|
|
5
|
+
from typing import Dict, Optional, Union
|
|
6
6
|
|
|
7
7
|
from auxiliary.nifti.io import read_nifti, write_nifti
|
|
8
|
+
|
|
8
9
|
from brainles_preprocessing.brain_extraction.brain_extractor import BrainExtractor
|
|
9
10
|
from brainles_preprocessing.constants import PreprocessorSteps
|
|
10
11
|
from brainles_preprocessing.defacing import Defacer, QuickshearDefacer
|
|
11
12
|
from brainles_preprocessing.normalization.normalizer_base import Normalizer
|
|
13
|
+
from brainles_preprocessing.registration import ( # TODO: this will throw warnings if ANTs or NiftyReg are not installed, not ideal
|
|
14
|
+
ANTsRegistrator,
|
|
15
|
+
NiftyRegRegistrator,
|
|
16
|
+
)
|
|
12
17
|
from brainles_preprocessing.registration.registrator import Registrator
|
|
13
18
|
|
|
14
19
|
logger = logging.getLogger(__name__)
|
|
@@ -42,6 +47,7 @@ class Modality:
|
|
|
42
47
|
normalized_defaced_output_path (str or Path, optional): Path to save the normalized defaced modality data. Requires a normalizer.
|
|
43
48
|
bet (bool): Indicates whether brain extraction is enabled.
|
|
44
49
|
atlas_correction (bool): Indicates whether atlas correction should be performed.
|
|
50
|
+
coregistration_transform_path (str or None): Path to the coregistration transformation matrix, will be set after coregistration.
|
|
45
51
|
|
|
46
52
|
Example:
|
|
47
53
|
>>> t1_modality = Modality(
|
|
@@ -73,6 +79,7 @@ class Modality:
|
|
|
73
79
|
self.current = self.input_path
|
|
74
80
|
self.normalizer = normalizer
|
|
75
81
|
self.atlas_correction = atlas_correction
|
|
82
|
+
self.transformation_paths: Dict[PreprocessorSteps, Path | None] = {}
|
|
76
83
|
|
|
77
84
|
# Check that atleast one output is generated
|
|
78
85
|
if not any(
|
|
@@ -128,6 +135,7 @@ class Modality:
|
|
|
128
135
|
self.normalized_defaced_output_path = None
|
|
129
136
|
|
|
130
137
|
self.steps = {k: None for k in PreprocessorSteps}
|
|
138
|
+
self.steps[PreprocessorSteps.INPUT] = self.input_path
|
|
131
139
|
|
|
132
140
|
@property
|
|
133
141
|
def bet(self) -> bool:
|
|
@@ -197,6 +205,26 @@ class Modality:
|
|
|
197
205
|
else:
|
|
198
206
|
logger.info("No normalizer specified; skipping normalization.")
|
|
199
207
|
|
|
208
|
+
def _find_transformation_matrix(
|
|
209
|
+
self, transform_incomplete_path: Path
|
|
210
|
+
) -> Optional[Path]:
|
|
211
|
+
possible_Files = list(
|
|
212
|
+
transform_incomplete_path.parent.glob(f"{transform_incomplete_path.stem}.*")
|
|
213
|
+
)
|
|
214
|
+
if len(possible_Files) == 0:
|
|
215
|
+
logger.warning(
|
|
216
|
+
f"No transformation matrix found for {transform_incomplete_path}. "
|
|
217
|
+
"Returning None."
|
|
218
|
+
)
|
|
219
|
+
return None
|
|
220
|
+
elif len(possible_Files) > 1:
|
|
221
|
+
# TODO: Handle this case more gracefully, e.g., try to find proper extension based on the registrator
|
|
222
|
+
logger.warning(
|
|
223
|
+
f"Multiple transformation matrices found for {transform_incomplete_path}. "
|
|
224
|
+
"Returning the first one."
|
|
225
|
+
)
|
|
226
|
+
return possible_Files[0]
|
|
227
|
+
|
|
200
228
|
def register(
|
|
201
229
|
self,
|
|
202
230
|
registrator: Registrator,
|
|
@@ -213,6 +241,7 @@ class Modality:
|
|
|
213
241
|
fixed_image_path (str or Path): Path to the fixed image.
|
|
214
242
|
registration_dir (str or Path): Directory to store registration results.
|
|
215
243
|
moving_image_name (str): Name of the moving image.
|
|
244
|
+
step (PreprocessorSteps): The current preprocessing step.
|
|
216
245
|
|
|
217
246
|
Returns:
|
|
218
247
|
Path: Path to the registration matrix.
|
|
@@ -224,7 +253,7 @@ class Modality:
|
|
|
224
253
|
registered_log = registration_dir / f"{moving_image_name}.log"
|
|
225
254
|
|
|
226
255
|
# Note, add file ending depending on registration backend!
|
|
227
|
-
registered_matrix = registration_dir / f"{moving_image_name}"
|
|
256
|
+
registered_matrix = registration_dir / f"M_{moving_image_name}"
|
|
228
257
|
|
|
229
258
|
registrator.register(
|
|
230
259
|
fixed_image_path=fixed_image_path,
|
|
@@ -235,6 +264,11 @@ class Modality:
|
|
|
235
264
|
)
|
|
236
265
|
self.current = registered
|
|
237
266
|
self.steps[step] = registered
|
|
267
|
+
|
|
268
|
+
self.transformation_paths[step] = self._find_transformation_matrix(
|
|
269
|
+
transform_incomplete_path=registered_matrix
|
|
270
|
+
)
|
|
271
|
+
|
|
238
272
|
return registered_matrix
|
|
239
273
|
|
|
240
274
|
def apply_bet_mask(
|
|
@@ -320,7 +354,7 @@ class Modality:
|
|
|
320
354
|
registration_dir_path (str or Path): Directory to store transformation results.
|
|
321
355
|
moving_image_name (str): Name of the moving image.
|
|
322
356
|
transformation_matrix_path (str or Path): Path to the transformation matrix.
|
|
323
|
-
|
|
357
|
+
step (PreprocessorSteps): The current preprocessing step.
|
|
324
358
|
Returns:
|
|
325
359
|
None
|
|
326
360
|
"""
|
|
@@ -331,15 +365,42 @@ class Modality:
|
|
|
331
365
|
transformed = registration_dir_path / f"{moving_image_name}.nii.gz"
|
|
332
366
|
transformed_log = registration_dir_path / f"{moving_image_name}.log"
|
|
333
367
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
368
|
+
if (
|
|
369
|
+
isinstance(registrator, (ANTsRegistrator, NiftyRegRegistrator))
|
|
370
|
+
and step == PreprocessorSteps.ATLAS_REGISTERED
|
|
371
|
+
):
|
|
372
|
+
# we test uniting transforms for these registrators
|
|
373
|
+
assert (
|
|
374
|
+
self.transformation_paths.get(PreprocessorSteps.COREGISTERED, None)
|
|
375
|
+
is not None
|
|
376
|
+
), "Coregistration must be performed before applying atlas registration."
|
|
377
|
+
|
|
378
|
+
registrator.transform(
|
|
379
|
+
fixed_image_path=fixed_image_path,
|
|
380
|
+
moving_image_path=self.steps[PreprocessorSteps.INPUT],
|
|
381
|
+
transformed_image_path=transformed,
|
|
382
|
+
matrix_path=[
|
|
383
|
+
self.transformation_paths[
|
|
384
|
+
PreprocessorSteps.COREGISTERED
|
|
385
|
+
], # coregistration matrix
|
|
386
|
+
transformation_matrix_path, # atlas registration matrix
|
|
387
|
+
],
|
|
388
|
+
log_file_path=transformed_log,
|
|
389
|
+
)
|
|
390
|
+
else:
|
|
391
|
+
registrator.transform(
|
|
392
|
+
fixed_image_path=fixed_image_path,
|
|
393
|
+
moving_image_path=self.current,
|
|
394
|
+
transformed_image_path=transformed,
|
|
395
|
+
matrix_path=transformation_matrix_path,
|
|
396
|
+
log_file_path=transformed_log,
|
|
397
|
+
)
|
|
398
|
+
|
|
341
399
|
self.current = transformed
|
|
342
400
|
self.steps[step] = transformed
|
|
401
|
+
self.transformation_paths[step] = self._find_transformation_matrix(
|
|
402
|
+
transform_incomplete_path=transformation_matrix_path
|
|
403
|
+
)
|
|
343
404
|
|
|
344
405
|
def extract_brain_region(
|
|
345
406
|
self,
|
{brainles_preprocessing-0.3.6 → brainles_preprocessing-0.4.0}/brainles_preprocessing/preprocessor.py
RENAMED
|
@@ -164,6 +164,7 @@ class Preprocessor:
|
|
|
164
164
|
save_dir_atlas_correction: Optional[Union[str, Path]] = None,
|
|
165
165
|
save_dir_brain_extraction: Optional[Union[str, Path]] = None,
|
|
166
166
|
save_dir_defacing: Optional[Union[str, Path]] = None,
|
|
167
|
+
save_dir_transformations: Optional[Union[str, Path]] = None,
|
|
167
168
|
log_file: Optional[Union[str, Path]] = None,
|
|
168
169
|
):
|
|
169
170
|
"""
|
|
@@ -176,6 +177,7 @@ class Preprocessor:
|
|
|
176
177
|
save_dir_atlas_correction (str or Path, optional): Directory path to save intermediate atlas correction results.
|
|
177
178
|
save_dir_brain_extraction (str or Path, optional): Directory path to save intermediate brain extraction results.
|
|
178
179
|
save_dir_defacing (str or Path, optional): Directory path to save intermediate defacing results.
|
|
180
|
+
save_dir_transformations (str or Path, optional): Directory path to save transformation matrices. Defaults to None.
|
|
179
181
|
log_file (str or Path, optional): Path to save the log file. Defaults to a timestamped file in the current directory.
|
|
180
182
|
|
|
181
183
|
This method orchestrates the entire preprocessing workflow by sequentially performing:
|
|
@@ -250,6 +252,28 @@ class Preprocessor:
|
|
|
250
252
|
save_dir_defacing=save_dir_defacing,
|
|
251
253
|
)
|
|
252
254
|
|
|
255
|
+
# move to separate method
|
|
256
|
+
if save_dir_transformations:
|
|
257
|
+
save_dir_transformations = Path(save_dir_transformations)
|
|
258
|
+
|
|
259
|
+
# Save transformation matrices
|
|
260
|
+
logger.info(f"Saving transformation matrices to {save_dir_transformations}")
|
|
261
|
+
for modality in self.all_modalities:
|
|
262
|
+
|
|
263
|
+
modality_transformations_dir = (
|
|
264
|
+
save_dir_transformations / modality.modality_name
|
|
265
|
+
)
|
|
266
|
+
modality_transformations_dir.mkdir(exist_ok=True, parents=True)
|
|
267
|
+
for step, path in modality.transformation_paths.items():
|
|
268
|
+
if path is not None:
|
|
269
|
+
shutil.copyfile(
|
|
270
|
+
src=str(path.absolute()),
|
|
271
|
+
dst=str(
|
|
272
|
+
modality_transformations_dir
|
|
273
|
+
/ f"{step.value}_{path.name}"
|
|
274
|
+
),
|
|
275
|
+
)
|
|
276
|
+
|
|
253
277
|
# End
|
|
254
278
|
logger.info(f"{' Preprocessing complete ':=^80}")
|
|
255
279
|
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
# TODO add typing and docs
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
2
4
|
import datetime
|
|
3
5
|
import shutil
|
|
4
6
|
from pathlib import Path
|
|
5
|
-
from typing import Any, Dict, Optional, Union
|
|
7
|
+
from typing import Any, Dict, List, Optional, Union
|
|
6
8
|
|
|
7
9
|
import ants
|
|
8
10
|
|
|
9
11
|
from brainles_preprocessing.registration.registrator import Registrator
|
|
10
12
|
|
|
13
|
+
VALID_INTERPOLATORS = [
|
|
14
|
+
"linear",
|
|
15
|
+
"nearestNeighbor",
|
|
16
|
+
"multiLabel", # for label images (deprecated, prefer genericLabel)
|
|
17
|
+
"gaussian",
|
|
18
|
+
"bSpline",
|
|
19
|
+
"cosineWindowedSinc",
|
|
20
|
+
"welchWindowedSinc",
|
|
21
|
+
"hammingWindowedSinc",
|
|
22
|
+
"lanczosWindowedSinc",
|
|
23
|
+
"genericLabel", # use this for label images
|
|
24
|
+
]
|
|
25
|
+
|
|
11
26
|
|
|
12
27
|
class ANTsRegistrator(Registrator):
|
|
13
28
|
def __init__(
|
|
@@ -58,6 +73,9 @@ class ANTsRegistrator(Registrator):
|
|
|
58
73
|
matrix_path (str or Path): Path to the transformation matrix (output).
|
|
59
74
|
log_file_path (str or Path): Path to the log file.
|
|
60
75
|
**kwargs: Additional registration parameters to update the instantiated defaults.
|
|
76
|
+
|
|
77
|
+
Raises:
|
|
78
|
+
FileNotFoundError: If the fixed or moving image paths do not exist.
|
|
61
79
|
"""
|
|
62
80
|
start_time = datetime.datetime.now()
|
|
63
81
|
|
|
@@ -122,8 +140,9 @@ class ANTsRegistrator(Registrator):
|
|
|
122
140
|
fixed_image_path: Union[str, Path],
|
|
123
141
|
moving_image_path: Union[str, Path],
|
|
124
142
|
transformed_image_path: Union[str, Path],
|
|
125
|
-
matrix_path:
|
|
143
|
+
matrix_path: str | Path | List[str | Path],
|
|
126
144
|
log_file_path: Union[str, Path],
|
|
145
|
+
interpolator: str = "linear",
|
|
127
146
|
**kwargs,
|
|
128
147
|
) -> None:
|
|
129
148
|
"""
|
|
@@ -133,12 +152,21 @@ class ANTsRegistrator(Registrator):
|
|
|
133
152
|
fixed_image_path (str or Path): Path to the fixed image.
|
|
134
153
|
moving_image_path (str or Path): Path to the moving image.
|
|
135
154
|
transformed_image_path (str or Path): Path to the transformed image (output).
|
|
136
|
-
matrix_path (str or Path): Path to the transformation matrix.
|
|
155
|
+
matrix_path (str or Path or List[str | Path]): Path to the transformation matrix or a list of matrices.
|
|
137
156
|
log_file_path (str or Path): Path to the log file.
|
|
157
|
+
interpolator (str): Interpolator to use for the transformation. Default is 'linear'.
|
|
138
158
|
**kwargs: Additional transformation parameters to update the instantiated defaults.
|
|
159
|
+
Raises:
|
|
160
|
+
AssertionError: If the interpolator is not valid.
|
|
161
|
+
FileNotFoundError: If the fixed or moving image paths do not exist.
|
|
139
162
|
"""
|
|
140
163
|
start_time = datetime.datetime.now()
|
|
141
164
|
|
|
165
|
+
assert interpolator in VALID_INTERPOLATORS, (
|
|
166
|
+
f"Invalid interpolator: {interpolator}. "
|
|
167
|
+
f"Valid options are: {', '.join(VALID_INTERPOLATORS)}."
|
|
168
|
+
)
|
|
169
|
+
|
|
142
170
|
# TODO - self.transformation_params
|
|
143
171
|
# we update the transformation parameters with the provided kwargs
|
|
144
172
|
transform_kwargs = {**self.transformation_params, **kwargs}
|
|
@@ -147,7 +175,16 @@ class ANTsRegistrator(Registrator):
|
|
|
147
175
|
fixed_image_path = Path(fixed_image_path)
|
|
148
176
|
moving_image_path = Path(moving_image_path)
|
|
149
177
|
transformed_image_path = Path(transformed_image_path)
|
|
150
|
-
|
|
178
|
+
|
|
179
|
+
if not isinstance(matrix_path, list):
|
|
180
|
+
matrix_path = [matrix_path]
|
|
181
|
+
|
|
182
|
+
matrix_path = [str(Path(p).with_suffix(".mat")) for p in matrix_path]
|
|
183
|
+
|
|
184
|
+
matrix_path = matrix_path[
|
|
185
|
+
::-1
|
|
186
|
+
] # Ants expects the last matrix to be the first one applied
|
|
187
|
+
|
|
151
188
|
log_file_path = Path(log_file_path)
|
|
152
189
|
|
|
153
190
|
if not fixed_image_path.is_file():
|
|
@@ -161,14 +198,11 @@ class ANTsRegistrator(Registrator):
|
|
|
161
198
|
# Ensure output directory exist
|
|
162
199
|
transformed_image_path.parent.mkdir(parents=True, exist_ok=True)
|
|
163
200
|
|
|
164
|
-
# Ensure matrix_path has .mat suffix
|
|
165
|
-
if matrix_path.suffix != ".mat":
|
|
166
|
-
matrix_path = matrix_path.with_suffix(".mat")
|
|
167
|
-
|
|
168
201
|
transformed_image = ants.apply_transforms(
|
|
169
202
|
fixed=fixed_image,
|
|
170
203
|
moving=moving_image,
|
|
171
|
-
transformlist=
|
|
204
|
+
transformlist=matrix_path,
|
|
205
|
+
interpolator=interpolator,
|
|
172
206
|
**transform_kwargs,
|
|
173
207
|
)
|
|
174
208
|
ants.image_write(transformed_image, str(transformed_image_path))
|
|
@@ -183,12 +217,48 @@ class ANTsRegistrator(Registrator):
|
|
|
183
217
|
fixed_image_path=fixed_image_path,
|
|
184
218
|
moving_image_path=moving_image_path,
|
|
185
219
|
transformed_image_path=transformed_image_path,
|
|
220
|
+
interpolator=interpolator,
|
|
186
221
|
matrix_path=matrix_path,
|
|
187
222
|
operation_name="transformation",
|
|
188
223
|
start_time=start_time,
|
|
189
224
|
end_time=end_time,
|
|
190
225
|
)
|
|
191
226
|
|
|
227
|
+
def inverse_transform(
|
|
228
|
+
self,
|
|
229
|
+
fixed_image_path: Union[str, Path],
|
|
230
|
+
moving_image_path: Union[str, Path],
|
|
231
|
+
transformed_image_path: Union[str, Path],
|
|
232
|
+
matrix_path: str | Path | List[str | Path],
|
|
233
|
+
log_file_path: Union[str, Path],
|
|
234
|
+
interpolator: str = "linear",
|
|
235
|
+
**kwargs,
|
|
236
|
+
) -> None:
|
|
237
|
+
"""
|
|
238
|
+
Apply an inverse transformation using ANTs.
|
|
239
|
+
|
|
240
|
+
Args:
|
|
241
|
+
fixed_image_path (str or Path): Path to the fixed image.
|
|
242
|
+
moving_image_path (str or Path): Path to the moving image.
|
|
243
|
+
transformed_image_path (str or Path): Path to the transformed image (output).
|
|
244
|
+
matrix_path (str or Path): Path to the transformation matrix.
|
|
245
|
+
log_file_path (str or Path): Path to the log file.
|
|
246
|
+
interpolator (str): Interpolator to use for the transformation. Default is 'linear'.
|
|
247
|
+
**kwargs: Additional transformation parameters to update the instantiated defaults.
|
|
248
|
+
"""
|
|
249
|
+
if not isinstance(matrix_path, list):
|
|
250
|
+
matrix_path = [matrix_path]
|
|
251
|
+
self.transform(
|
|
252
|
+
fixed_image_path=fixed_image_path,
|
|
253
|
+
moving_image_path=moving_image_path,
|
|
254
|
+
transformed_image_path=transformed_image_path,
|
|
255
|
+
matrix_path=matrix_path,
|
|
256
|
+
log_file_path=log_file_path,
|
|
257
|
+
whichtoinvert=[True] * len(matrix_path), # Invert all matrices
|
|
258
|
+
interpolator=interpolator,
|
|
259
|
+
**kwargs,
|
|
260
|
+
)
|
|
261
|
+
|
|
192
262
|
@staticmethod
|
|
193
263
|
def _log_to_file(
|
|
194
264
|
log_file_path: Union[str, Path],
|
|
@@ -199,6 +269,7 @@ class ANTsRegistrator(Registrator):
|
|
|
199
269
|
operation_name: str,
|
|
200
270
|
start_time: datetime.datetime,
|
|
201
271
|
end_time: datetime.datetime,
|
|
272
|
+
interpolator: Optional[str] = None,
|
|
202
273
|
) -> None:
|
|
203
274
|
"""
|
|
204
275
|
Log the operation details to a file.
|
|
@@ -212,6 +283,7 @@ class ANTsRegistrator(Registrator):
|
|
|
212
283
|
operation_name (str): Name of the operation ('registration' or 'transformation').
|
|
213
284
|
start_time (datetime.datetime): Start time of the operation.
|
|
214
285
|
end_time (datetime.datetime): End time of the operation.
|
|
286
|
+
interpolator (Optional[str]): Interpolator used for the transformation, if applicable.
|
|
215
287
|
"""
|
|
216
288
|
|
|
217
289
|
# Calculate the duration and make it human readable
|
|
@@ -231,27 +303,29 @@ class ANTsRegistrator(Registrator):
|
|
|
231
303
|
f.write(f"fixed image: {fixed_image_path} \n")
|
|
232
304
|
f.write(f"moving image: {moving_image_path} \n")
|
|
233
305
|
f.write(f"transformed image: {transformed_image_path} \n")
|
|
306
|
+
if interpolator is not None:
|
|
307
|
+
f.write(f"interpolator: {interpolator} \n")
|
|
234
308
|
f.write(f"matrix: {matrix_path} \n")
|
|
235
309
|
f.write(f"end time: {end_time} \n")
|
|
236
310
|
f.write(f"duration: {duration_formatted}\n")
|
|
237
311
|
|
|
238
312
|
|
|
239
|
-
if __name__ == "__main__":
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
313
|
+
# if __name__ == "__main__":
|
|
314
|
+
# # TODO move this into unit tests
|
|
315
|
+
# reg = ANTsRegistrator()
|
|
316
|
+
|
|
317
|
+
# reg.register(
|
|
318
|
+
# fixed_image_path="example/example_data/TCGA-DU-7294/AX_T1_POST_GD_FLAIR_TCGA-DU-7294_TCGA-DU-7294_GE_TCGA-DU-7294_AX_T1_POST_GD_FLAIR_RM_13_t1c.nii.gz",
|
|
319
|
+
# moving_image_path="example/example_data/TCGA-DU-7294/AX_T2_FR-FSE_RF2_150_TCGA-DU-7294_TCGA-DU-7294_GE_TCGA-DU-7294_AX_T2_FR-FSE_RF2_150_RM_4_t2.nii.gz",
|
|
320
|
+
# transformed_image_path="example/example_ants/transformed_image.nii.gz",
|
|
321
|
+
# matrix_path="example/example_ants_matrix/matrix",
|
|
322
|
+
# log_file_path="example/example_ants/log.txt",
|
|
323
|
+
# )
|
|
324
|
+
|
|
325
|
+
# reg.transform(
|
|
326
|
+
# fixed_image_path="example/example_data/TCGA-DU-7294/AX_T1_POST_GD_FLAIR_TCGA-DU-7294_TCGA-DU-7294_GE_TCGA-DU-7294_AX_T1_POST_GD_FLAIR_RM_13_t1c.nii.gz",
|
|
327
|
+
# moving_image_path="example/example_data/OtherEXampleFromTCIA/T1_AX_OtherEXampleTCIA_TCGA-FG-6692_Si_TCGA-FG-6692_T1_AX_SE_10_se2d1_t1.nii.gz",
|
|
328
|
+
# transformed_image_path="example/example_ants_transformed/transformed_image.nii.gz",
|
|
329
|
+
# matrix_path="example/example_ants_matrix/matrix.mat",
|
|
330
|
+
# log_file_path="example/example_ants/log.txt",
|
|
331
|
+
# )
|
|
@@ -78,6 +78,8 @@ class ElastixRegistrator(Registrator):
|
|
|
78
78
|
transformed_image_path: str,
|
|
79
79
|
matrix_path: str,
|
|
80
80
|
log_file_path: Optional[str] = None,
|
|
81
|
+
interpolator: str = "linear",
|
|
82
|
+
**kwargs
|
|
81
83
|
) -> None:
|
|
82
84
|
"""
|
|
83
85
|
Apply a transformation using elastix.
|
|
@@ -117,3 +119,16 @@ class ElastixRegistrator(Registrator):
|
|
|
117
119
|
default_rigid_parameter_map = parameter_object.GetDefaultParameterMap("rigid")
|
|
118
120
|
parameter_object.AddParameterMap(default_rigid_parameter_map)
|
|
119
121
|
return parameter_object
|
|
122
|
+
|
|
123
|
+
def inverse_transform(
|
|
124
|
+
self,
|
|
125
|
+
fixed_image_path: str,
|
|
126
|
+
moving_image_path: str,
|
|
127
|
+
transformed_image_path: str,
|
|
128
|
+
matrix_path: str,
|
|
129
|
+
log_file_path: Optional[str] = None,
|
|
130
|
+
interpolator: str = "linear",
|
|
131
|
+
) -> None:
|
|
132
|
+
raise NotImplementedError(
|
|
133
|
+
"Inverse transform is not yet implemented for elastix"
|
|
134
|
+
)
|
|
@@ -57,8 +57,9 @@ class GreedyRegistrator(Registrator):
|
|
|
57
57
|
moving_image_path: str,
|
|
58
58
|
transformed_image_path: str,
|
|
59
59
|
matrix_path: str,
|
|
60
|
-
interpolator: Optional[str] = "LINEAR",
|
|
61
60
|
log_file_path: Optional[str] = None,
|
|
61
|
+
interpolator: str = "LINEAR",
|
|
62
|
+
**kwargs: Optional[dict],
|
|
62
63
|
) -> None:
|
|
63
64
|
"""
|
|
64
65
|
Apply a transformation using greedy.
|
|
@@ -68,8 +69,8 @@ class GreedyRegistrator(Registrator):
|
|
|
68
69
|
moving_image_path (str): Path to the moving image.
|
|
69
70
|
transformed_image_path (str): Path to the transformed image (output).
|
|
70
71
|
matrix_path (str): Path to the transformation matrix (output). This gets overwritten if it already exists.
|
|
71
|
-
interpolator (Optional[str]): The interpolator to use; one of NN, LINEAR or LABEL.
|
|
72
72
|
log_file_path (Optional[str]): Path to the log file, which is not used.
|
|
73
|
+
interpolator (Optional[str]): The interpolator to use; one of NN, LINEAR or LABEL. Defaults to LINEAR.
|
|
73
74
|
"""
|
|
74
75
|
registor = Greedy3D()
|
|
75
76
|
interpolator_upper = interpolator.upper()
|
|
@@ -94,3 +95,16 @@ class GreedyRegistrator(Registrator):
|
|
|
94
95
|
registor.execute(command_to_run)
|
|
95
96
|
else:
|
|
96
97
|
registor.execute(command_to_run)
|
|
98
|
+
|
|
99
|
+
def inverse_transform(
|
|
100
|
+
self,
|
|
101
|
+
fixed_image_path: str,
|
|
102
|
+
moving_image_path: str,
|
|
103
|
+
transformed_image_path: str,
|
|
104
|
+
matrix_path: str,
|
|
105
|
+
log_file_path: Optional[str] = None,
|
|
106
|
+
interpolator: str = "linear",
|
|
107
|
+
) -> None:
|
|
108
|
+
raise NotImplementedError(
|
|
109
|
+
"Inverse transform is not yet implemented for greedy."
|
|
110
|
+
)
|