ANTsX / ANTsPy

A fast medical imaging analysis library in Python with algorithms for registration, segmentation, and more.
https://antspyx.readthedocs.io
Apache License 2.0
640 stars 162 forks source link

Extracting the LDDMM geodesic from ANTs registration #206

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hello,

I understand that the 'fwdtransforms' entry of the dictionary returned by ants.registration() contains the matrix representation of the diffeomorphism mapping the moving image to the fixed image. This diffeomorphism [phi] is the endpoint at t = 1 of the full geodesic path of diffeomorphisms going from the identity diffeomorphism (t = 0) to the full registration [phi]. How can I extract this geodesic path using ANTs? This would ultimately boil down to finding the time-varying velocity field between the two images, from which I can compute the flow via integration to obtain a point on the desired geodesic at any time 0 < t < 1. Any help or suggestions would be really appreciated.

Many thanks, Gianfranco Cortes

ntustison commented 4 years ago

If you want to use one of the TimeVaryingVelocityField transforms and write out the velocity field, you're going to need to use the ANTs antsRegistration program directly. ants.registration() in ANTsPy doesn't provide user access to that output.

stnava commented 4 years ago

@ntustison - quick q: do you think it would be easy to add this option to ants.registration and antsRegistration given our recent various discussions on this topic?

ntustison commented 4 years ago

Yeah, I'll see if I can do that.

ntustison commented 4 years ago

https://github.com/ANTsX/ANTsPy/pull/207

This should work. Once we get it checked in, I'll propagate the enhancements to ANTsR.

stnava commented 4 years ago

here is an example from a recent checkin building on commits by @ntustison

python
import ants
fi = ants.image_read(ants.get_ants_data('r16'))
mi = ants.image_read(ants.get_ants_data('r64'))
syn = ants.registration(fixed=fi, moving=mi, type_of_transform = 'SyNCC' )
mytx = ants.registration(fixed=fi, moving=mi, type_of_transform = 'TV[6]', grad_step=10, syn_metric='CC', syn_sampling=4, verbose=True )
ants.image_mutual_information( fi, mi )
ants.image_mutual_information( fi,  mytx['warpedmovout']  )
ants.image_mutual_information( fi,  syn['warpedmovout']  )

however, we have not added post-hoc velocity field integration to antsr or antspy just yet.

stnava commented 4 years ago

ok - we added ants.integrate_velocity which should make this complete.