brainles-preprocessing 0.3.5__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.
Files changed (123) hide show
  1. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/PKG-INFO +5 -6
  2. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/README.md +1 -1
  3. brainles_preprocessing-0.4.0/brainles_preprocessing/back_to_native.py +100 -0
  4. brainles_preprocessing-0.4.0/brainles_preprocessing/constants.py +25 -0
  5. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/modality.py +71 -10
  6. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/preprocessor.py +30 -6
  7. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/ANTs/ANTs.py +102 -28
  8. brainles_preprocessing-0.4.0/brainles_preprocessing/registration/__init__.py +27 -0
  9. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/elastix/elastix.py +15 -0
  10. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/greedy/greedy.py +16 -2
  11. brainles_preprocessing-0.4.0/brainles_preprocessing/registration/niftyreg/niftyreg.py +266 -0
  12. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/transform.sh +4 -3
  13. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/registrator.py +26 -0
  14. brainles_preprocessing-0.4.0/brainles_preprocessing/utils/zenodo.py +189 -0
  15. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/pyproject.toml +6 -6
  16. brainles_preprocessing-0.3.5/brainles_preprocessing/constants.py +0 -10
  17. brainles_preprocessing-0.3.5/brainles_preprocessing/registration/__init__.py +0 -23
  18. brainles_preprocessing-0.3.5/brainles_preprocessing/registration/atlas/copyright.md +0 -11
  19. brainles_preprocessing-0.3.5/brainles_preprocessing/registration/atlas/t1_brats_space.nii +0 -0
  20. brainles_preprocessing-0.3.5/brainles_preprocessing/registration/atlas/t1_skullstripped_brats_space.nii +0 -0
  21. brainles_preprocessing-0.3.5/brainles_preprocessing/registration/eReg/config_files/TODO.md +0 -0
  22. brainles_preprocessing-0.3.5/brainles_preprocessing/registration/eReg/eReg.py +0 -100
  23. brainles_preprocessing-0.3.5/brainles_preprocessing/registration/niftyreg/__init__.py +0 -0
  24. brainles_preprocessing-0.3.5/brainles_preprocessing/registration/niftyreg/niftyreg.py +0 -135
  25. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/LICENSE +0 -0
  26. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/__init__.py +0 -0
  27. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/brain_extraction/__init__.py +0 -0
  28. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/brain_extraction/brain_extractor.py +0 -0
  29. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/brats/__init__.py +0 -0
  30. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/brats/t1_centric.py +0 -0
  31. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/brats/t1c_centric.py +0 -0
  32. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/cli.py +0 -0
  33. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/defacing/__init__.py +0 -0
  34. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/defacing/defacer.py +0 -0
  35. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/defacing/quickshear/__init__.py +0 -0
  36. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/defacing/quickshear/nipy_quickshear.py +0 -0
  37. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/defacing/quickshear/quickshear.py +0 -0
  38. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/normalization/__init__.py +0 -0
  39. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/normalization/normalizer_base.py +0 -0
  40. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/normalization/percentile_normalizer.py +0 -0
  41. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/normalization/windowing_normalizer.py +0 -0
  42. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/ANTs/TODO_ANTs_parameters.py +0 -0
  43. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/ANTs/__init__.py +0 -0
  44. {brainles_preprocessing-0.3.5/brainles_preprocessing/registration/eReg → brainles_preprocessing-0.4.0/brainles_preprocessing/registration/elastix}/__init__.py +0 -0
  45. {brainles_preprocessing-0.3.5/brainles_preprocessing/registration/elastix → brainles_preprocessing-0.4.0/brainles_preprocessing/registration/greedy}/__init__.py +0 -0
  46. {brainles_preprocessing-0.3.5/brainles_preprocessing/registration/greedy → brainles_preprocessing-0.4.0/brainles_preprocessing/registration/niftyreg}/__init__.py +0 -0
  47. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/groupwise_niftyreg_params.sh +0 -0
  48. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/groupwise_niftyreg_run.sh +0 -0
  49. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_aladin +0 -0
  50. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_average +0 -0
  51. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_f3d +0 -0
  52. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_jacobian +0 -0
  53. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_measure +0 -0
  54. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_resample +0 -0
  55. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_tools +0 -0
  56. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/bin/reg_transform +0 -0
  57. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/AffineDeformationFieldKernel.h +0 -0
  58. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/AladinContent.h +0 -0
  59. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/BlockMatchingKernel.h +0 -0
  60. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUAffineDeformationFieldKernel.h +0 -0
  61. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUBlockMatchingKernel.h +0 -0
  62. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUConvolutionKernel.h +0 -0
  63. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUKernelFactory.h +0 -0
  64. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUOptimiseKernel.h +0 -0
  65. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/CPUResampleImageKernel.h +0 -0
  66. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/ConvolutionKernel.h +0 -0
  67. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/Kernel.h +0 -0
  68. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/KernelFactory.h +0 -0
  69. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/OptimiseKernel.h +0 -0
  70. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/Platform.h +0 -0
  71. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/ResampleImageKernel.h +0 -0
  72. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_ReadWriteImage.h +0 -0
  73. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_ReadWriteMatrix.h +0 -0
  74. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_aladin.cpp +0 -0
  75. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_aladin.h +0 -0
  76. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_aladin_sym.cpp +0 -0
  77. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_aladin_sym.h +0 -0
  78. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_base.h +0 -0
  79. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_blockMatching.h +0 -0
  80. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_dti.h +0 -0
  81. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_f3d.h +0 -0
  82. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_f3d2.h +0 -0
  83. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_f3d_sym.h +0 -0
  84. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_femTrans.h +0 -0
  85. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_globalTrans.h +0 -0
  86. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_kld.h +0 -0
  87. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_lncc.h +0 -0
  88. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_localTrans.h +0 -0
  89. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_localTrans_jac.h +0 -0
  90. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_localTrans_regul.h +0 -0
  91. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_macros.h +0 -0
  92. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_maths.h +0 -0
  93. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_maths_eigen.h +0 -0
  94. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_measure.h +0 -0
  95. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_mind.h +0 -0
  96. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_nmi.h +0 -0
  97. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_optimiser.cpp +0 -0
  98. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_optimiser.h +0 -0
  99. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_resampling.h +0 -0
  100. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_splineBasis.h +0 -0
  101. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_ssd.h +0 -0
  102. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_stringFormat.h +0 -0
  103. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/_reg_tools.h +0 -0
  104. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/nifti1.h +0 -0
  105. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/nifti1_io.h +0 -0
  106. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/png.h +0 -0
  107. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pngconf.h +0 -0
  108. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pngdebug.h +0 -0
  109. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pnginfo.h +0 -0
  110. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pnglibconf.h +0 -0
  111. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pngpriv.h +0 -0
  112. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/pngstruct.h +0 -0
  113. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/readpng.h +0 -0
  114. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/reg_png.h +0 -0
  115. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/zlib.h +0 -0
  116. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/znzlib.h +0 -0
  117. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/niftyreg_1.5.68/include/zutil.h +0 -0
  118. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/reg_aladin +0 -0
  119. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/reg_resample +0 -0
  120. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/registration/niftyreg/niftyreg_scripts/rigid_reg.sh +0 -0
  121. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/utils/__init__.py +0 -0
  122. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/utils/generic.py +0 -0
  123. {brainles_preprocessing-0.3.5 → brainles_preprocessing-0.4.0}/brainles_preprocessing/utils/logging_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: brainles_preprocessing
3
- Version: 0.3.5
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
@@ -17,14 +17,12 @@ Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
19
  Provides-Extra: all
20
- Provides-Extra: ereg
21
20
  Provides-Extra: itk-elastix
22
21
  Provides-Extra: picsl-greedy
23
- Requires-Dist: antspyx (>=0.4.2,<0.5.0)
22
+ Requires-Dist: antspyx (>=0.5.4,<1.0.0)
24
23
  Requires-Dist: auxiliary (>=0.0.42)
25
24
  Requires-Dist: black (>=22.1.0,<23.0.0)
26
- Requires-Dist: brainles_hd_bet (>=0.0.10)
27
- Requires-Dist: ereg (>=0.0.10,<0.0.11) ; extra == "all" or extra == "ereg"
25
+ Requires-Dist: brainles_hd_bet (>=0.0.10,<1.0.0)
28
26
  Requires-Dist: itk-elastix (>=0.20.0,<0.21.0) ; extra == "all" or extra == "itk-elastix"
29
27
  Requires-Dist: nibabel (>=3.2.1)
30
28
  Requires-Dist: numpy (>=1.23.0,<2.0.0)
@@ -32,6 +30,7 @@ Requires-Dist: path (>=16.10.0,<17.0.0)
32
30
  Requires-Dist: pathlib (>=1.0.1,<2.0.0)
33
31
  Requires-Dist: picsl_greedy (>=0.0.6,<0.0.7) ; extra == "all" or extra == "picsl-greedy"
34
32
  Requires-Dist: rich (>=13.6.0,<14.0.0)
33
+ Requires-Dist: scipy (<1.14)
35
34
  Requires-Dist: tqdm (>=4.64.1,<5.0.0)
36
35
  Requires-Dist: ttictoc (>=0.5.6,<0.6.0)
37
36
  Requires-Dist: typer (>=0.15.0,<0.16.0)
@@ -161,7 +160,7 @@ We provide a (WIP) documentation. Have a look [here](https://brainles-preprocess
161
160
  Please credit the authors by citing their work.
162
161
 
163
162
  ### Registration
164
- We currently provide support for [ANTs](https://github.com/ANTsX/ANTs) (default), [Niftyreg](https://github.com/KCL-BMEIS/niftyreg) (Linux), eReg (experimental)
163
+ We currently provide support for [ANTs](https://github.com/ANTsX/ANTs) (default), [Niftyreg](https://github.com/KCL-BMEIS/niftyreg) (Linux).
165
164
 
166
165
  ### Atlas Reference
167
166
  We provide the SRI-24 atlas from this [publication](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2915788/).
@@ -121,7 +121,7 @@ We provide a (WIP) documentation. Have a look [here](https://brainles-preprocess
121
121
  Please credit the authors by citing their work.
122
122
 
123
123
  ### Registration
124
- We currently provide support for [ANTs](https://github.com/ANTsX/ANTs) (default), [Niftyreg](https://github.com/KCL-BMEIS/niftyreg) (Linux), eReg (experimental)
124
+ We currently provide support for [ANTs](https://github.com/ANTsX/ANTs) (default), [Niftyreg](https://github.com/KCL-BMEIS/niftyreg) (Linux).
125
125
 
126
126
  ### Atlas Reference
127
127
  We provide the SRI-24 atlas from this [publication](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2915788/).
@@ -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)
@@ -0,0 +1,25 @@
1
+ from enum import Enum, IntEnum
2
+
3
+
4
+ class PreprocessorSteps(IntEnum):
5
+ INPUT = 0
6
+ COREGISTERED = 1
7
+ ATLAS_REGISTERED = 2
8
+ ATLAS_CORRECTED = 3
9
+ BET = 4
10
+ DEFACED = 5
11
+
12
+
13
+ class Atlas(str, Enum):
14
+ BRATS_SRI24 = "brats_sri24.nii"
15
+ """Slightly modified SRI24 atlas as found in the BraTS challenges"""
16
+ BRATS_SRI24_SKULLSTRIPPED = "brats_sri24_skullstripped.nii"
17
+ """Slightly modified SRI24 skull stripped atlas as found in the BraTS challenges"""
18
+
19
+ SRI24 = "sri24.nii"
20
+ """SRI24 atlas from https://www.nitrc.org/frs/download.php/4502/sri24_anatomy_unstripped_nifti.zip"""
21
+ SRI24_SKULLSTRIPPED = "sri24_skullstripped.nii"
22
+ """SRI24 skull stripped atlas from https://www.nitrc.org/frs/download.php/4499/sri24_anatomy_nifti.zip"""
23
+
24
+ BRATS_MNI152 = "brats_MNI152lin_T1_1mm.nii.gz"
25
+ """Slightly modified MNI152 atlas as found in the BraTS challenges"""
@@ -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
- registrator.transform(
335
- fixed_image_path=fixed_image_path,
336
- moving_image_path=self.current,
337
- transformed_image_path=transformed,
338
- matrix_path=transformation_matrix_path,
339
- log_file_path=transformed_log,
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,
@@ -12,8 +12,9 @@ from pathlib import Path
12
12
  from typing import List, Optional, Union
13
13
  import warnings
14
14
 
15
- from brainles_preprocessing.constants import PreprocessorSteps
15
+ from brainles_preprocessing.constants import Atlas, PreprocessorSteps
16
16
  from brainles_preprocessing.defacing import Defacer, QuickshearDefacer
17
+ from brainles_preprocessing.utils.zenodo import verify_or_download_atlases
17
18
 
18
19
  from .brain_extraction.brain_extractor import BrainExtractor, HDBetExtractor
19
20
  from .modality import Modality, CenterModality
@@ -50,7 +51,7 @@ class Preprocessor:
50
51
  registrator: Registrator = None,
51
52
  brain_extractor: Optional[BrainExtractor] = None,
52
53
  defacer: Optional[Defacer] = None,
53
- atlas_image_path: Union[str, Path] = None,
54
+ atlas_image_path: Union[str, Path, Atlas] = Atlas.BRATS_SRI24,
54
55
  temp_folder: Optional[Union[str, Path]] = None,
55
56
  use_gpu: Optional[bool] = None,
56
57
  limit_cuda_visible_devices: Optional[str] = None,
@@ -67,10 +68,9 @@ class Preprocessor:
67
68
  self.center_modality = center_modality
68
69
  self.moving_modalities = moving_modalities
69
70
 
70
- if atlas_image_path is None:
71
- self.atlas_image_path = (
72
- Path(__file__).parent / "registration" / "atlas" / "t1_brats_space.nii"
73
- )
71
+ if isinstance(atlas_image_path, Atlas):
72
+ atlas_folder = verify_or_download_atlases()
73
+ self.atlas_image_path = atlas_folder / atlas_image_path.value
74
74
  else:
75
75
  self.atlas_image_path = Path(atlas_image_path)
76
76
 
@@ -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: Union[str, 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
- matrix_path = Path(matrix_path)
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=[str(matrix_path)],
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
- # TODO move this into unit tests
241
- reg = ANTsRegistrator()
242
-
243
- reg.register(
244
- 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",
245
- 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",
246
- transformed_image_path="example/example_ants/transformed_image.nii.gz",
247
- matrix_path="example/example_ants_matrix/matrix",
248
- log_file_path="example/example_ants/log.txt",
249
- )
250
-
251
- reg.transform(
252
- 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",
253
- 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",
254
- transformed_image_path="example/example_ants_transformed/transformed_image.nii.gz",
255
- matrix_path="example/example_ants_matrix/matrix.mat",
256
- log_file_path="example/example_ants/log.txt",
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
+ # )
@@ -0,0 +1,27 @@
1
+ import warnings
2
+
3
+
4
+ try:
5
+ from .ANTs.ANTs import ANTsRegistrator
6
+ except ImportError:
7
+ warnings.warn(
8
+ "ANTS package not found. If you want to use it, please install it using 'pip install antspyx'"
9
+ )
10
+
11
+
12
+ from .niftyreg.niftyreg import NiftyRegRegistrator
13
+
14
+
15
+ try:
16
+ from .elastix.elastix import ElastixRegistrator
17
+ except ImportError:
18
+ warnings.warn(
19
+ "itk-elastix package not found. If you want to use it, please install it using 'pip install brainles_preprocessing[itk-elastix]'"
20
+ )
21
+
22
+ try:
23
+ from .greedy.greedy import GreedyRegistrator
24
+ except ImportError:
25
+ warnings.warn(
26
+ "picsl_greedy package not found. If you want to use it, please install it using 'pip install brainles_preprocessing[picsl_greedy]'"
27
+ )