ANTsX / ANTs

Advanced Normalization Tools (ANTs)
Apache License 2.0
1.18k stars 381 forks source link

REQUEST: principles of template construction: Wiki page connecting the script to the math/principles in the paper? #1172

Closed gdevenyi closed 3 years ago

gdevenyi commented 3 years ago

Upon reading through the old issues (in particular, https://github.com/ANTsX/ANTs/issues/520 ) and the papers, I have a reasonable sense of the principles of template construction, although I would like to request a full wiki page which describes the steps taken by the script and connects them directly to the math described in the paper.

Related to this, I came across this very subtle step: https://github.com/ANTsX/ANTs/blob/master/Scripts/antsMultivariateTemplateConstruction2.sh#L325

Where during scaling of the average transform, it's actually multiplied by a negative number (something I would call maybe a pseudo inverse?) before being applied four (4) times (the origin of this number has been asked about and not been resolved either).

So I'd like to ask, why is this negative scaling done, rather than scaling the average of the inverse transforms?

Edit: After reading over https://github.com/ANTsX/ANTs/issues/520 again, I guess this is kinda answered at https://github.com/ANTsX/ANTs/issues/806#issuecomment-513474171 however it says "read the paper". I'm interested specifically in how the various steps the scripts take correspond to the math in the paper.

cookpa commented 3 years ago

I don't think I understand enough to write more than what's been said already, which I will attempt to summarize. The averaging of the displacement fields *Warp.nii.gz comes from section 2.2.2 of the Avants et al paper. The whole argument of that section is that we approach the optimal shape by minimizing the average of the forward warps. The negative scaling is applied to update the template shape such that the average forward warp will be reduced.

The forward and inverse warps aren't interchangeable, the inverse warp isn't just the forward warp multiplied by -1.

For the multiple applications of the estimated velocity field, the reference is the DARTEL paper. They test various numbers of integration steps. In their case they are dividing up a solution from pairwise registration, but in the ANTs template scripts we're trying to approach an (unknown) optimal shape incrementally, so a smaller step size is warranted. For as long as I can remember its been 4 steps for as long as I can remember, with a default (large) step size of 0.25. If anything, this should be reduced for better performance.

stnava commented 3 years ago

* we average forward warps because the "tails" of these occupy the same domain. the inverse warps do not.

avants2004.pdf

the original reference for this work is attached and now looks prehistoric .... I recall "writing" most of this paper on a long drive from Philadelphia to Chapel Hill ... my favorite results from that era were movies demonstrating the average shape change due to normal aging vs AD vs FTD .... presented at LONI during a summer visit but not published ...

gdevenyi commented 3 years ago

Thanks for the addition information/detail @stnava !

as such, we wanted to "move quickly" to the average. so grad step 0.25 composed 4 times gets you an aggressive step to the mean. however, it will oscillate when you get close; smaller step sizes should be used at that point.

Interesting, I got that sense as well and proposed a possible adjustment for that: https://github.com/ANTsX/ANTs/issues/729

gdevenyi commented 3 years ago

One more question @stnava did you ever investigate model "convergence"? I've been experimenting with measuring the magnitude of the average warp field as a possible feedback measure.

stnava commented 3 years ago

Yes, that is close to what we used originally but you can also look directly at related measures in appearance space.

On Sun, May 9, 2021 at 3:04 PM Gabriel A. Devenyi @.***> wrote:

One more question @stnava https://github.com/stnava did you ever investigate model "convergence"? I've been experimenting with measuring the magnitude of the average warp field as a possible feedback measure.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ANTsX/ANTs/issues/1172#issuecomment-835865032, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACPE7Q3G7ZXAVI4WQLZF4LTM3MDZANCNFSM42O7ZX6Q .

--

brian

thomshaw92 commented 1 year ago

Hi @stnava Following up on this question and your answer "also mentioned by @ cookpa , when this script was first built in roughly 2003 (as part of my dissertation work), computation time was much more expensive and, as such, we wanted to "move quickly" to the average. so grad step 0.25 composed 4 times gets you an aggressive step to the mean. however, it will oscillate when you get close; smaller step sizes should be used at that point."

So just to understand this better (I'm trying to update some of my own template code for smaller sized images): 1) if we want smaller steps towards the mean template we reduce the -g option (to e.g., 0.1) - by multiplying the average transform by a smaller factor, it doesn't move the average shape closer to the mean than a larger one (i'm still lost as to why it's a negative though https://github.com/ANTsX/ANTs/blob/2d10611e431479bbaab3c0c75cbf0833582c47ad/Scripts/antsMultivariateTemplateConstruction2.sh#L399 gradientstep=-$5.) 2) if computational time isn't an issue, would we need to compose the transform 4 times at all? The DARTEL paper wasn't as helpful for my understanding of this point.
3) If known: would smoothing the displacement field offer similar behaviour to the gradient step update?

Thank you so much! :D