ANTS coregistration implementation #188
Open
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.
Summary
This PR adds ANTs rigid registration as a third option for PET-to-anatomical coregistration, alongside the existing FreeSurfer
mri_coregandmri_robust_registermethods. It also fixes critical bugs in the ANTs implementation and refactors the registration method interface for clarity.
Motivation
Users reported that the existing registration methods (
mri_coregandmri_robust_register) produced poor results for certain PET datasets. External testing withANTs rigid registration showed excellent alignment for these same datasets. This PR integrates ANTs registration into PETPrep to provide users with a robust
alternative registration method.
Changes
1. Added ANTs Registration Method
New command-line option:
--pet2anat-method {mri_coreg,robust,ants}Implementation details:
Files modified:
2. Fixed Critical ANTs Masking Bug
Problem: Initial implementation passed a pre-masked T1w image to ANTs, causing suboptimal registration.
Solution: ANTs now receives:
Impact: Registration quality now matches external ANTs results.
3. Fixed Report Generation Bug
Problem: The FunctionalSummary report generator had an else clause that labeled ALL non-standard methods (including ANTs) as "FreeSurfer mri_robust_register".
Solution: Added explicit cases for each method:
if registration == 'mri_coreg':
reg = f'FreeSurfer
mri_coreg- {dof} dof'elif registration == 'ants_registration':
reg = 'ANTs rigid registration (6 DoF)'
elif registration == 'mri_robust_register':
reg = 'FreeSurfer
mri_robust_register(NMI cost)'4. Refactored Registration Method Interface
Breaking change: Renamed method choices for accuracy and removed deprecated flag.
Before:
--pet2anat-robust # deprecated boolean flag
After:
--pet2anat-method {mri_coreg,robust,ants}
Rationale:
Files modified:
5. Added Standalone Helper Function
Problem: Nipype cannot serialize inline lambda functions for multiprocessing.
Solution: Added _get_first() helper function to extract first element from ANTs transform list:
def _get_first(in_list):
"""Extract first element from a list (for ANTs transform output)."""
return in_list[0]
Testing
Manual Testing
Unit Tests
Usage Examples
Using ANTs registration (new):
petprep <bids_dir> <output_dir> participant
--participant-label 01
--pet2anat-method ants
--pet2anat-dof 6
Using default FreeSurfer mri_coreg:
petprep <bids_dir> <output_dir> participant
--participant-label 01
--pet2anat-method mri_coreg
--pet2anat-dof 6
Using FreeSurfer robust registration:
petprep <bids_dir> <output_dir> participant
--participant-label 01
--pet2anat-method robust
--pet2anat-dof 6
Breaking Changes
Migration:
Performance Notes
Dependencies
Related Issues
Fixes issues where: