Using MNI152_2009_template.nii.gz as -tlrc_base changed volreg matrix

Hello AFNI experts,

We recently updated our AFNI_proc.py command according to FMRI processing with AFNI: Some comments and corrections on “Exploring the Impact of Analysis Software on Task fMRI Results”

One difference was that we previously used the default TT_N27 as the standard space template and now changed it to the MNI152_2009_template.nii.gz template. So we altered our afni_proc.py to this:


[b]-tlrc_base MNI152_2009_template.nii.gz \[/b]
    -align_opts_aea \
		-giant_move \
		[b]-cost lpc+ZZ \[/b]
    -volreg_tlrc_warp \
    -tlrc_base MNI152_2009_template.nii.gz \
	-tlrc_NL_warp \
    -volreg_align_to MIN_OUTLIER \

I just realized that making this change altered the image matrix of the volreg-data and forth.

3dinfo on our EPI data: raw, pb00, pb01, pb02 (tcat, despike, tshift,) has the resoluiton:


R-to-L extent:  -109.116 [R] -to-   107.446 [L] -step-     3.438 mm [ 64 voxels]
A-to-P extent:  -102.420 [A] -to-   114.142 [P] -step-     3.438 mm [ 64 voxels]
I-to-S extent:   -37.817 [I] -to-    86.183 [S] -step-     4.000 mm [ 32 voxels]

But the volreg data has:


R-to-L extent:   -94.500 [R] -to-    94.500 [L] -step-     3.000 mm [ 64 voxels]
A-to-P extent:   -94.500 [A] -to-   130.500 [P] -step-     3.000 mm [ 76 voxels]
I-to-S extent:   -76.500 [I] -to-   112.500 [S] -step-     3.000 mm [ 64 voxels]

So by changing the template to MNI from TT_N27 via -tlrc_base MNI152_2009_template.nii.gz the data gets these new strange dimensions. What could be the reason? We obviously want to keep the original EPI grid (minor up sampling by the afni warping due to rounding) of the EPIs and not double the slices and increasing matrix size in the A-to-P direction.

What am I missing?

Thanks!

From the afni_proc.py help under the


-volreg_tlrc_warp       : warp EPI to +tlrc space at volreg step

section:


The resulting voxel grid is the minimum dimension, truncated to 3
            significant bits.  See -volreg_warp_dxyz for details.

… and note that it is not to 3 significant digits, but 3 significant bits. Your minimum voxel resolution is 3.438 mm, and this is being rounded to 3 in the described fashion. We do not recommend huge upsampling in general, and this kind of “slightly increased” resolution is normal; having nonisotropic voxels means that some dimensions are affected more than others, too.

As described in the help, I would expect that you would see this set of dimensions whether using TT_N27 or MNI152_2009_template as a base for nonlinear warping. Can you please check what your final EPI resolution was when using TT_N27 with a nonlinear warp?

Also note that you can further control final resolution wiht the “-volreg_warp_dxyz DXYZ” option in afni_proc.py-- please check out the help for that.

–pt

The resolution of 3x3x3 is fine, that’s some minor default up-sampling (right?).

But the whole grid Y-dimension changes from 64 voxels and the amount of slices (z-dimension) DOUBLES. That cant’ be right?

pb03 (block before volreg):
R-to-L extent: -109.116 [R] -to- 107.446 [L] -step- 3.438 mm [ 64 voxels]
A-to-P extent: -102.420 [A] -to- 114.142 [P] -step- 3.438 mm [ 64 voxels]
I-to-S extent: -37.817 -to- 86.183 [S] -step- 4.000 mm [ 32 voxels]

pb04 (volreg):
R-to-L extent: -94.500 [R] -to- 94.500 [L] -step- 3.000 mm [ 64 voxels]
A-to-P extent: -94.500 [A] -to- 130.500 [P] -step- 3.000 mm [ 76 voxels]
I-to-S extent: -76.500 -to- 112.500 [S] -step- 3.000 mm [ 64 voxels]

The only thing that we change was:
adding -cost lpc+ZZ \ as an align option
adding -regress_motion_per_run
adding -tlrc_base MNI152_2009_template.nii.gz
updated afni from a 2 month older version to the current (as of 1w ago).

Before those were not stated, i.e. defaults.

And I could see with my eyes that it looked different from before, as if the EPI (stats.file) had increased in resolution.

Before we had EPI with the same dimensions:
R-to-L extent: -109.116 [R] -to- 107.446 [L] -step- 3.438 mm [ 64 voxels]
A-to-P extent: -102.420 [A] -to- 114.142 [P] -step- 3.438 mm [ 64 voxels]
I-to-S extent: -37.817 -to- 86.183 [S] -step- 4.000 mm [ 32 voxels]

The pb before volreg had the same dimensions.

And the volreg (and stats file) had the dimensions:
R-to-L extent: -79.500 [R] -to- 79.500 [L] -step- 3.000 mm [ 54 voxels]
A-to-P extent: -79.500 [A] -to- 109.500 [P] -step- 3.000 mm [ 64 voxels]
I-to-S extent: -63.500 [I] -to- 83.500 [S] -step- 3.000 mm [ 50 voxels]

So, I see that those were not identical to the previous pb either but still not as extreme as double the number of slices.

So to re-phrase the question? It’s normal that the grid changes so drastically as from:
64x64x32 to 64x76x64 when the resolution goes from 3x3x4 to 3x3x3 mm (as is the default)?

I see; we are talking matrix size and total field of view (FOV) dimensions?

I don’t view this as your data “doubling” or anything necessarily problematic… From 3dinfo on the MNI152_2009_template.nii.gz volume, the extent, resolution and matrix size is:


R-to-L extent:   -96.000 [R] -to-    96.000 [L] -step-     1.000 mm [193 voxels]
A-to-P extent:   -96.000 [A] -to-   132.000 [P] -step-     1.000 mm [229 voxels]
I-to-S extent:   -78.000 [I] -to-   114.000 [S] -step-     1.000 mm [193 voxels]

In the alignment process, your data is aligned to the above template, and will have data throughout that FOV, at the specified spatial resolution. If you leave afni_proc’s minor upsampling, that would be a final spatial resolution of 3x3x3 mm^3 voxels. Along the x-axis, the MNI template has a FOV of 193x229x193 mm^3; your data will fill that with 3mm iso voxels. Along the x- and z-axes, this would be 193/3 = 64.3333 —> 64 voxels, and along the y-axis this would be 229/3 =76.3333 —> 76 voxels. Those numbers seem correct to me.

If you are following the code here:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/codex/main_det_2018_TaylorEtal.html
… then I assume you are also including this option in afni_proc.py:


-volreg_tlrc_warp                                                       \

See the description in afni_proc.py’s help about this here:


-volreg_tlrc_warp       : warp EPI to +tlrc space at volreg step

                default: stay in +orig space

            With this option, the EPI data will be warped to standard space
            in the volreg processing block.  All further processing through
            regression will be done in standard space.
....

and also under the following heading:


WARP TO TLRC NOTE

Your volreg output data are being taken into the standard/warp space, whereas I am guessing you hadn’t used that flag previously? THat is why the spatial resolutions look different at that stage?

–pt

Thanks Paul!

We do just that, -volreg_tlrc_warp. I’ll just paste our proc here so you can see:


afni_proc.py -subj_id $sub_id \
    -dsets $fmri_data \
    -copy_anat $T1_data \
    -blocks despike tshift align tlrc volreg mask regress \
    -mask_segment_anat yes \
    -mask_segment_erode yes \
    -tshift_opts_ts -tpattern seq+z \
    -align_opts_aea \
		-giant_move \
		-cost lpc+ZZ \
    -tcat_remove_first_trs 0 \
    -volreg_tlrc_warp \
    -tlrc_base MNI152_2009_template.nii.gz \
	-tlrc_NL_warp \
    -volreg_align_to MIN_OUTLIER \
    -regress_motion_per_run \
    -regress_censor_motion 0.3 \
    -regress_censor_outliers 0.1 \
    -regress_apply_mot_types demean deriv \
    -regress_stim_types AM1 \
    -regress_basis 'dmBLOCK' \
    -regress_stim_times $stim/* \
    -regress_stim_labels text shape alc non_alc motor \
	-regress_local_times \
    -regress_anaticor_fast \
    -regress_reml_exec \
....and the glts

When looking back at the old results (prior to our changes mentioned earlier) those volreg matrix dimensions were also different (i.e. the warping alters the matrix size) but I never thought about it since they were not as large (one dimension even decreases), from native 64,64,32 to:

R-to-L extent: -79.500 [R] -to- 79.500 [L] -step- 3.000 mm [ 54 voxels]
A-to-P extent: -79.500 [A] -to- 109.500 [P] -step- 3.000 mm [ 64 voxels]
I-to-S extent: -63.500 [I] -to- 83.500 [S] -step- 3.000 mm [ 50 voxels]

When we changed to the MNI template (I guess with higher resolution) the matrix alterations got bigger and I noticed them (due to 3dMVM having to go through 64 slices instead of the native 62).

But I should not worry? The resolutions (voxelsize) is still the same (3mm^3). Or does this mean that we dilute the data?

Thanks!

Hi Robin,

The voxel size (unless you request otherwise) is determined
as Paul notes, via truncation of the minimum dimension. But
the number of slices is determined by the bounding box of the
template. So the EPI box is mapped inside the template box.

That 2009c template has larger extents than the TT_N27
dataset, so the result is a bigger volume. It will not otherwise
make a difference (since the interpolation points are the same).

The big template box effectively uses more disk space.

  • rick