92 unite registration steps into one transformation#131
Merged
neuronflow merged 16 commits intomainfrom Jun 27, 2025
Merged
Conversation
compose transforms, save intermediate matrix
Modify antspyx and brainles_hd_bet to be flexible within <1.0.0 Restrict "scipy<1.14" to make antspyx work for python >=3.11
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR unites coregistration and atlas registration transformations into a single workflow to minimize resampling and introduces a class for performing inverse mappings from atlas to native space (currently for ANTs and NiftyReg). Key changes include:
- New test cases for composing and inverting affine transforms.
- Updates to dependency versions and parameter handling for registration modules.
- Addition of the BackToNativeSpace class and modifications in modality processing to capture transformation matrices.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_registrators.py | Added tests for affine transform inversion and composition functions. |
| tests/test_back_to_native.py | Added tests to verify inverse transformation calls with correct parameters. |
| pyproject.toml | Updated dependency constraints for antspyx, brainles_hd_bet, and scipy. |
| brainles_preprocessing/registration/registrator.py | Introduced an interpolator parameter and abstract inverse_transform method. |
| brainles_preprocessing/registration/niftyreg/* | Modified matrix path handling, affine composition, and inversion functions. |
| brainles_preprocessing/registration/greedy/greedy.py | Added inverse_transform stub to conform with Registrator interface. |
| brainles_preprocessing/registration/elastix/elastix.py | Added an inverse_transform method that raises NotImplementedError. |
| brainles_preprocessing/registration/ANTs/ANTs.py | Updated transform and inverse_transform to support list-based matrix paths and parameter passing. |
| brainles_preprocessing/preprocessor.py | Added a parameter and logic for saving transformation matrices. |
| brainles_preprocessing/modality.py | Updated transformation path management and registration matrix naming conventions. |
| brainles_preprocessing/back_to_native.py | Implemented BackToNativeSpace class to apply inverse transformations. |
Comments suppressed due to low confidence (2)
brainles_preprocessing/registration/ANTs/ANTs.py:257
- The 'whichtoinvert' parameter is passed to the transform method in inverse_transform but is not explicitly documented or handled in transform; consider updating the API documentation or implementation to clarify its purpose.
whichtoinvert=[True] * len(matrix_path), # Invert all matrices
brainles_preprocessing/modality.py:256
- Changing the registration matrix file name to use a 'M_' prefix without a clear extension may lead to inconsistency; consider appending a proper file extension (e.g. .mat or .txt) to match downstream expectations.
registered_matrix = registration_dir / f"M_{moving_image_name}"
| ) -> Optional[Path]: | ||
| possible_Files = list( | ||
| transform_incomplete_path.parent.glob(f"{transform_incomplete_path.stem}.*") | ||
| ) |
There was a problem hiding this comment.
The _find_transformation_matrix method returns the first match when multiple files exist; consider refining the selection logic or documenting the assumptions to ensure that the correct file is chosen.
neuronflow
approved these changes
Jun 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
unites coreg and atlas reg transformations to reduce resampling and provides class to perform inverse mappings from atlas to native space. As of now, only Ants and NiftyReg are supported.
Hence, this resolves #92, resolves #100, resolves #122