Closed rueberger closed 4 years ago
I have consulted with ANTSdoc and see that ANT's transformation representation isn't necessarily invertible. That's unfortunate. But perhaps it would be possible to achieve approximate invertibility by somehow increasing the resolution of the forward transformation?
deformation fields are generally not invertible. velocity fields can be used to generate forward and (at least incremental) inverse maps which is what we usually do. syn
provides fwd and inverse maps but these don't help you in the case of template building. see one of our older papers to understand this further.
I assure you that it works. one of the most used parts of ants. here is an example.
image = ants.image_read( ants.get_ants_data('r16') )
image2 = ants.image_read( ants.get_ants_data('r27') )
image3 = ants.image_read( ants.get_ants_data('r85') )
timage = ants.build_template( image_list = ( image, image2, image3 ), iterations=3 )
and if you want something more complex, then see:
https://github.com/ntustison/TemplateBuildingExample
which you should be able to reproduce in python.
in general, one does not want to try to invert deformation fields directly. this is a losing proposition, for a variety of reasons.
My impression was that deformations in ANTs
are diffeomorphisms, which are definitionally invertible, and that invertibility problems arise out of limitations of the representation. Is that not the case?
How would you express the inverse (even approximately) of a deformation field in ANTs
? Or am I just S.O.L.?
Well like I said, I am certainly no registration expert. But to my untrained eyes things don't look good.
Here are a few of the brains that I wish to construct a mean brain from:
And here is the template I get from ants.build_template
Looks 'blurry', no?
I could imagine such a template being useful for the purposes of registering your original brains to it (although I was not impressed with the results I got when I did that) - but my main goal presently is to obtain the mean brain itself. And even to my untrained eyes, it's clear that the present result isn't suitable.
My impression was that deformations in ANTs are diffeomorphisms, which are definitionally invertible, and that invertibility problems arise out of limitations of the representation. Is that not the case?
that is the case. the deformation field representation is insufficient to generate the inverse mapping. for that, you need the velocity field. SyN returns the fwd and inverse maps which are computed in tandem throughout the optimization. so if you want both - and certain numerical guarantees on the accuracy of that inverse map - then use SyN. if you want the velocity fields, use an exponential map or the time-varying framework. then you can generate fwd and inverse maps from the velocity fields - not from the deformations.
. How would you express the inverse (even approximately) of a deformation field in ANTs? Or am I just S.O.L.?
you either use the inverse warp provided by SyN or use a different method (exponential or time varying) and use the velocity fields to generate fwd and inverse deformations the accuracy of which will depend on several details beyond the scope of this discussion.
Looks 'blurry', no?
I think your original data looks low quality (maybe blurry) and inconsistent ( potentially violating the theory of the template construction) and, as such, the template is roughly what you might expect. particularly given that you are using default parameters on a problem for which parameters have not been optimized. you may also be suffering from several other issues including inhomogeneity, poor overlap of anatomy across Subjects due to bounding box issues, boundary conditions and who knows what else ( perhaps bad initialization, bad affine mapping or sub-optimal parameter selection ).
some possible solutions
try n4 to fix inhomogeneity
pad the images before registration - or at least pad the target image (eg iMath PadImage )
use the CC metric
optimize the affine template first
optimize the small deformation template second
proceed to higher resolution registration and CC metric last
one more thing:
And as far as I can tell build_template follows this prescription except for the last step - where it transforms the mean intensity image by the mean transformation (as opposed to the inverse of the mean transformation).
the steps described by Bogovic are implemented in https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2818274/ and https://www.ncbi.nlm.nih.gov/pubmed/15501083 and in the ANTs build template family of commands ie they are implement the same procedure (at least language wise) consistent with the description above.
also - if we were not inverting the mean transformation, nothing would work. we would in fact diverge quite disastrously.
OK now I'm confused, can you help me understand where in build_template
the mean transformation is inverted?
we follow the negative gradient of the shape space which is defined by the average transport from the previous template to the whole population
I don't follow that - will have to get cozy with your manuscript.
Quick q: you suggested earlier using an exponential map - what's the type_of_transform
argument for that? The only mention of elastic I see is as a regularizer for SyN.
I tried to take the inverse of a deformation field and was met with a
ValueError
. Is there not a well defined notion of the inverse of a deformation field?I'm doing this in the context of template building, something very much like
ants.build_template
. I'm still a novice at registration, but it's unclear to me thatbuild_template
works - I get a 'blurred' result.I've been following Bogovic et. al 2018's prescription for creating a template from a set of brains:
And as far as I can tell
build_template
follows this prescription except for the last step - where it transforms the mean intensity image by the mean transformation (as opposed to the inverse of the mean transformation).