ANTsX / ANTs

Advanced Normalization Tools (ANTs)
Apache License 2.0
1.14k stars 374 forks source link

Jacobian through single-subject template #1714

Open dbrennan44 opened 3 months ago

dbrennan44 commented 3 months ago

Hi ANTs team, What is the suggested way to calculate a between-scan Jacobian through an intermediary template such as a single-subject template? Such that expansion is jacobian > 0 .

Between scan 1 and scan 2:

J1 = warp scan 1 to SST, calculate Jacobian s1->SST using SyN (inverse?) warp. J2 = warp scan 2 to SST, calculate Jacobian s2->SST using SyN (inverse?) warp.

subtract J2 from J1, warp resulting image to standard space.

Or:

Combine the SyN warps using antsApplyTransforms, with " -r ${single-subject-template} " and " -t s1_SST_1InverseWarp.nii.gz -t s2_SST_1Warp.nii.gz -o [ s2_s1_SyNwarp.nii.gz, 1 ] "

Calculating jacobian from s2_s1_SyNwarp, warping resulting image to standard space.

Thank you for clarifying, I feel that I am always second guessing my procedure.

stnava commented 3 months ago
dbrennan44 commented 3 months ago

Thank you, is there a reason subtraction is suggested over combining warps? Just wondering.

And, if subtraction is valid, linear regression over the log Jacobians is also valid (for n > 2 scans for example)?

For clarity, (i think) the Jacobians are inverse of the warps ( s1 -> SST warp produces jacobian > 0 for expansion of SST-> s1 due to warping of points etc.)

so calculating log jacobians from inverse SyN warps:

if s1 < SST < s2 : s1logJacobian(+) - s2logJacobian(-) would produce (++ i.e. expansion) which is correct.

I will also check with 2d data but I'm frequently second guessing the calculations. Thank you!

stnava commented 3 months ago

use the SST as the fixed image and use the fixed warps

dbrennan44 commented 2 months ago

Thank you for the guidance.

is warping through the SST is necessary or optimal for only two timepoints?

gdevenyi commented 2 months ago

optimal for only two timepoints?

I have discovered a truly marvelous proof of this, which this comment is too small to contain. I need to finish the draft so I can point people at an arXiv version.

Chiming in late here, but I have a pipeline to do all this automatically https://github.com/CoBrALab/optimized_antsMultivariateTemplateConstruction

dbrennan44 commented 2 months ago

@gdevenyi excellent, I look forward to it! I have come across your pipeline before but never implemented it myself, perhaps now is the time. Thank you

cookpa commented 2 months ago

@gdevenyi please post your preprint when it's up, should be interesting. Many of the ideas you have encoded make sense.

dbrennan44 commented 2 months ago

@gdevenyi by the way, do you have an interpretation for the "absolute" Jacobians (affine + deformable)?

gdevenyi commented 2 months ago

@gdevenyi by the way, do you have an interpretation for the "absolute" Jacobians (affine + deformable)?

Absolutely (no pun intended ;))

Each voxel represents the total volume change in this case.

This is easiest understood in a developmental context, consider two timepoints over a period of fairly rapid brain volume increase. The absolute jacobians will encode how much the total volume of each voxel changes, whereas the relative jacobians will be "normalized" (not by division or statistcally, but by removing any affine components) to represent local volumes within the brain.

dbrennan44 commented 2 months ago

The absolute jacobians will encode how much the total volume of each voxel changes, whereas the relative jacobians will be "normalized" (not by division or statistcally, but by removing any affine components) to represent local volumes within the brain.

I'm not sure I'm appreciating the difference here. If we see gross atrophy lets say in an entire WM structure such as corpus callosum, is the relative or absolute more appropriate? will the affine component "eat" the entirety of the volume change and thus the relative jacobians will miss the atrophy?

cookpa commented 2 months ago

I'm not sure I'm appreciating the difference here. If we see gross atrophy lets say in an entire WM structure such as corpus callosum, is the relative or absolute more appropriate? will the affine component "eat" the entirety of the volume change and thus the relative jacobians will miss the atrophy?

You'd miss the atrophy in that case but you'd see apparent expansion elsewhere in the relative jacobians, as the nonlinear transform will tend to compensate for the erroneous global scaling.

cookpa commented 2 months ago

To be clear, I'm saying in the (IMO unlikely) hypothetical case where the corpus callosum atrophy was so pronounced it was able to bias the affine transform to fit the atrophied CC exactly, then the relative jacobian would show zero change in the CC. The rest of the brain would also be scaled by the same affine transform, and the relative jacobians would show expansion.

stnava commented 2 months ago

it is my opinion that one should only use the "relative Jacobian" .... ie after whatever low-dimensional transform ( call it A) is used. however, one should also keep track of the determinant of A. then you can flexibly build models testing hypotheses on det(A) alone or its use along with the Jacobian. note : you may want log( det(A) ) if you are using log J. there are good numerical reasons for this in addition to it being a more expressive and efficient representation.

gdevenyi commented 2 months ago

Thanks @cookpa and @stnava for the assist, I agree on all those points.

dbrennan44 commented 2 months ago

@cookpa this is a helpful insight. In TBI we of course see global atrophy which both shows contraction in certain areas but expansion in areas just outside the gray matter. My concern is "missing" the (full magnitude of) contraction if we did something like apply a white matter mask or skeletonize, which would not see or consider the expansion of the CSF space.

A previous thread on this topic mentioned others use only a rigid transform and then nonlinear, which to me appears similar to including the affine scaling components in the Jacobian. Perhaps calculating a warp which masks for the area of interest is ideal?

Thanks everyone