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

Jacobian through single-subject template #1714

Open
dbrennan44 opened this issue Apr 6, 2024 · 15 comments
Open

Jacobian through single-subject template #1714

dbrennan44 opened this issue Apr 6, 2024 · 15 comments

Comments

@dbrennan44
Copy link

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
Copy link
Member

stnava commented Apr 6, 2024

  • warp both images to the SST
  • calculate log Jacobian - use the Warps with the tails in the SST space
  • subtract in whatever order you want
  • check that what you did makes sense in easy to understand 2D data

@dbrennan44
Copy link
Author

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
Copy link
Member

stnava commented Apr 6, 2024

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

@dbrennan44
Copy link
Author

Thank you for the guidance.

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

@gdevenyi
Copy link
Contributor

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
Copy link
Author

@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
Copy link
Member

cookpa commented Apr 14, 2024

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

@dbrennan44
Copy link
Author

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

@gdevenyi
Copy link
Contributor

@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
Copy link
Author

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
Copy link
Member

cookpa commented Apr 17, 2024

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
Copy link
Member

cookpa commented Apr 17, 2024

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
Copy link
Member

stnava commented Apr 17, 2024

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
Copy link
Contributor

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

@dbrennan44
Copy link
Author

@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

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

4 participants