I have a question that is not specifically related to AFNI but has been confusing me recently.
Consider warping brain A to a brain atlas, and wanting to see the brain volume differences of brain A compared to this atlas. Does Jacobian of this warp show it or should I compute it for the inverse warp?

The warp field is made in the base/master dset grid. A value sits at each grid point, and tells you where to pull data from in the input/source dset. Through an interpolation kernel (NN, wsinc5, cubic splines, etc.), a value is mapped via the warp dset to that new location.

The Jacobian is a vector field related to the gradient of the warp. Most people use the scalar-valued determinant of the Jacobian det(J) (or, even more specifically, log(det(J))) to measure the properties of the warp. The idea is that the magnitude of det(J) tells you about expansions (>1) or contractions (<1).

The warps calculated by AFNI are diffeomorphic and invertible. So, I believe that the whether you calculate det(J) on the warp or its inverse, the information should be equivalent (just inverted: if warp shrinks by a factor, then the inverse warp expands by that same factor), according to this: https://en.wikipedia.org/wiki/Jacobian_matrix_and_determinant#Inverse

So, whether you calculate the Jacobian on a warp or its inverse, shouldn’t deeply matter-- it is probably more a question of which grid you want your information on. And which way you want to think about “expansion”.

Of course, if you want a veeery good answer, we should get Bob’s opinion…

As Paul said, the Jacobian determinant is a measurement at each location of the expansion or contraction of the volume in that location. To measure the overall expansion or contraction of the brain, the simplest method that comes to my brain at this second would be to create brain-only masks of the before and after brain volumes, and then add up the volume of these masks.

Jacobian (and other) values can be computed from a warp in AFNI using the 3dNwarpFuncs program.

So, when I calculate the Jacobian of the warp, I have two options: Using the forward warp or inverse warp.
Imagine I am registering a subject brain to Allen Brain Atlas and I would like to see which parts of the brain are shrunk or enlarged compared to this atlas which is the master dataset as well.
I calculate the Jacobian with the 3dNwarpFuncs function and -bulk option to get “determinant of the Jacobian -1”.
Now, when I use forward/inverse warp for this, I get positive and negative values in exact opposite regions. Let’s say using forward warp Thalamus has + values and with the inverse warp, it has - values.
Which one shows Thalamus is enlarged/shrunk compared to the atlas?

For the local deformations, which warp should be used to get the correct values if a brain is warped to a brain atlas? forward or inverse?
I am using 3dNwarpFuns -bulk and would like to see which parts of the brain are smaller/larger compared to this atlas.
Atlas is the -master dataset.

There are two ways to find out the answer to this question: (a) try it and see, and (b) thinking about it.

(a) I ran '3dQwarp -allineate -iwarp ’ to align a T1w volume (skull stripped earlier) to the MNI template. The MNI template is notoriously larger than typical human brains, due to the average process used in creating the original template back in the 1990s. So at most places, the source T1w volume has to expand to fit the template. From the _WARP output, the bulk distortions are mostly negative, and from the _WARPINV output, the bulk distortions are mostly positive. Therefore, this test indicates that -bulk being negative from the _WARP dataset indicates an expansion from the -source dataset to the -base dataset.

(b) Thinking, of course, is harder work. (Good thing I made raisin-orange bread last night, for fuel.) The _WARP dataset N(x), as explained in the output of 3dNwarpApply -help (in the “Proper Order” section) is defined on the base dataset grid and “reaches out” to the source dataset grid to find where to get data for each output voxel on the base dataset grid. So, if the source dataset is smaller than the base dataset, then reaching out from two nearby base locations x and y will end up at locations x’ and y’ that are CLOSER to each other than x and y are; |x-y| > |x’-y’|. So the Jacobian determinant of N(x) will be less than 1, so -bulk will be negative. This reasoning jibes with the empirical test results above.

The kind of reasoning used in (b) is a little tricky to wrap your mind around, even for me, and I wrote the damn programs. That’s why I also like to empirically test things, to make sure. Here is the relevant section from 3dNwarpApply -help:

The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.