Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix atlas_registration inverse transform from atlas to func #27

Closed
poldrack opened this issue Jun 7, 2022 · 8 comments
Closed

fix atlas_registration inverse transform from atlas to func #27

poldrack opened this issue Jun 7, 2022 · 8 comments

Comments

@poldrack
Copy link
Contributor

poldrack commented Jun 7, 2022

the individual registrations from func->anat and anat->atlas seem to be working properly, but the composite inverse transform from atlas-> func is still failing. need to figure out why...

@poldrack
Copy link
Contributor Author

poldrack commented Jun 7, 2022

@lukebrez interested to hear if you have thoughts on how to fix this...

@bellabrez
Copy link
Collaborator

ok so this could be an issue with the order of the transforms in the "transformlist" input to apply_transforms, or could be an issue with the inverse transform itself (or both).

Regarding the transformlist, the order of that list is pretty confusing and an important detail is hidden in the docs. apply_transforms has an input whichtoinvert, which says "(list of booleans (optional)) – Must be same length as transformlist. whichtoinvert[i] is True if transformlist[i] is a matrix, and the matrix should be inverted. If transformlist[i] is a warp field, whichtoinvert[i] must be False. If the transform list is a matrix followed by a warp field, whichtoinvert defaults to (True,False). Otherwise it defaults to [False]*len(transformlist))." So to be honest I can't even wrap my head around this, but @rueberger says this means if you do a SyN warp, which outputs a matrix and warp field, if you want to apply those transforms you need to provide the transform list as [warp field, matrix], which is the reverse of what I would have assumed. Furthermore, if you do an affine from func->anat, then SyN from anat->template, and then you want to apply those transforms, the list would be [aff['fwdtransforms'][0], syn['fwdtransforms'][0],syn['fwdtransforms'][1]] (sorry I forget if the first element of syn['fwdtransforms'] is a matrix or warp field).

Regarding the inverse transform, I think there may be a serious issue here of the inverse transforms actually being identical to the forward transforms, such that you may just want to re-run the registration in the other direction. @rueberger can set us straight here - is this true?

@poldrack
Copy link
Contributor Author

poldrack commented Jun 8, 2022 via email

@rueberger
Copy link
Contributor

Regarding the inverse transform, I think there may be a serious issue here of the inverse transforms actually being identical to the forward transforms, such that you may just want to re-run the registration in the other direction. @rueberger can set us straight here - is this true?

can't comment on what's happening in this library but for ants the story is that, for reasons beyond my understanding, the forward and inverse affines returned by a registration are identical.

ie:

aff = ants.registration(f, m, type_of_transform='Affine')
# passes
assert aff['fwdtransforms'][0] == aff['invtransforms'][0]

the forward and inverse warp fields for a SyN registration are actually forward and inverted though.

this leads to the insane default behavior of whichtoinvert

I did some experiments a couple weeks back to validate the order of the forward transform list, if it would be useful I can do the same for the inverse and we can put it in a wiki or something

@poldrack
Copy link
Contributor Author

poldrack commented Jun 8, 2022 via email

@rueberger
Copy link
Contributor

do you know about git lfs?

@poldrack
Copy link
Contributor Author

poldrack commented Jun 8, 2022 via email

@poldrack
Copy link
Contributor Author

fixed, see solution in tests/test_register.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants