Images not aligned when applying inverse transform
See original GitHub issueDescribe the bug I am attempting to align two images using a rigid body transformation, then applying the inverse of the registration. The initial registration works as expected but the application of the inverse does not give expected results. See screenshots for details. The first screenshot is the initial alignment and the second is the application of the inverse to the original fixed image.
To Reproduce The call for the registration is:
flair_txfm = ants.registration(fixed=flair_bet, moving=flair_ref, type_of_transform="Rigid")
Then I apply the inverse with:
flair_bet_reg = ants.apply_transforms(moving=flair_bet, fixed=flair_ref, transformlist=flair_txfm['invtransforms'])
The images are: flair_bet: ANTsImage (RPI) Pixel Type : float (float32) Components : 1 Dimensions : (512, 512, 26) Spacing : (0.4297, 0.4297, 5.9996) Origin : (-138.1599, 33.0662, -70.0059) Direction : [ 0.9421 0.3352 -0.0132 0.3343 -0.9347 0.1211 -0.0282 0.1185 0.9926]
flair_ref: ANTsImage (RPI) Pixel Type : float (float32) Components : 1 Dimensions : (156, 156, 36) Spacing : (1.1667, 1.3974, 5.0556) Origin : (-90.0, 126.0, -72.0) Direction : [ 1. 0. 0. 0. -1. 0. 0. 0. 1.]
Expected behavior I would expect the second step (applying inverse) to generate similar results to the initial transformation. In other words, I would expect the images to be aligned.
Screenshots
Environment
- OS: MacOS 11.5
- antspy 0.3.2
- python 3.9
Please let me know if you need any other info.
Thanks!
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
The set of “inverse transforms” is simply the list of transform files stored in the correct order. However, in the case of a linear transform, we only write the forward transform to disk and depend on the user to specify the linear transform which needs to be inverted on the fly. It’s a bit suboptimal but this choice is also based on a legacy relationship with both the ANTsR implementation and the original C++ command line version.
Turn on the verbose output and make sure your output looks something like: