3d clusterize - mask and stat.test don't match in [0] dimensions

Hi Afni experts,

I’m trying to extract the coordinates of the peak activation from a statistical map in native space (generated by afni_proc.py) within a mask (downloaded from NeuroSynth website - and converted into subject’s native space).
I used 3dClusterize command with those 2 inputs however it returns: “mask and stat.test don’t match in [0] dimension”.

However, when I plot the mask and the functional image on the T1, everything look ok. Can someone help me with understanding what is going on.

Thank you very much in advance.


How did you convert the mask to subject space? With alignment of some kind?

To check if the grid is really the same and get a list of detailed comparisons, you can run this, putting in your statistical and mask dsets, respectively:

3dinfo -same_all_grid -prefix DSET_STAT DSET_MASK

It might also be useful to know:

3dinfo -space -av_space -prefix DSET_STAT DSET_MASK


Thank you for your answer,
I used 3dAllineate, first by moving the MNI space to native space in order to generate the transformation matrix and I then applied this matrix to convert the mask into native space

This is the output from 3dinfo -same_all_grid:

0 0 1 1 1 stats.test
0 0 1 1 1 WenickeinNative

That is the output from 3dinfo -space:
ORIG +orig stats.test
ORIG +orig WernickeinNative


OK, so there are 2 zeros there, meaning that of the 5 grid properties tested, the 2 are not matched between the dsets.

From the help of this option in 3dinfo:

-same_grid: Output 1 if the grid is identical between two dsets
                      0 otherwise. 
               For -same_grid to be 1, all of -same_dim, -same_delta,
               -same_orient, -same_center, and -same_obl must return 1
   -same_dim: 1 if dimensions are the same between dset pairs
   -same_delta: 1 if voxels sizes are the same between dset pairs
   -same_orient: 1 if orientation is the same between dset pairs
   -same_center: 1 if geometric center is the same between dset pairs
   -same_obl: 1 if obliquity is the same between dset pairs
   -same_all_grid: Equivalent to listing all of -same_dim -same_delta
                   -same_orient, -same_center, and -same_obl on the 
                   command line.

… we can see that “-same_dim” and “-same_delta” are not True, meaning that the matrix dimensions and the size of the voxels are not matched.

Can you please post your 3dAllineate commands? Those sounds like the right kind of steps for using 3dAllineate, but I wonder if the “-master” option wasn’t used in the application of the affine parameters, in the 2nd part.

Also, it depends how close of alignment/matching you want between the datasets, but you would likely have a much better alignment quality if you used nonlinear alignment, rather than just 3dAllineate. 3dAllineate will do a pretty good job aligning 2 different brains (e.g., your subj and the MNI template), but there is only so much it can do with 12 DOF applied globally—we typically use it to align datasets from the same subj to each other (e.g., EPI to anatomical). For between-subject processing, nonlinear gives a much better alignment result. You can evaluate if 3dAllineate’s output is good enough for your current purposes by overlaying the aligned dset to the base.


Hmm I see, but I guess the voxel size will be different since the EPI might have lower resolution than the T1, no?
Also this will be done only on a subject-to-subject basis, it’s just for individualized targeting approaches.

Here is the command

3dAllineate -base ${anat} -input ${maskdir}/MNI152_2009_template.nii -prefix ${wdir}/MNIinNative_formatrix -1Dmatrix_save transformation_matrix

and then:
3dAllineate -base ${anat} -input ${maskdir}/language_comprehension_fromNeuroSynth.nii -prefix ${wdir}/WernickeinNative -1Dmatrix_apply ${wdir}/transformation_matrix.aff12.1D

I think you would want the second command to be this:

3dAllineate \
    -master ${anat}  \
    -input ${maskdir}/language_comprehension_fromNeuroSynth.nii \
    -prefix ${wdir}/WernickeinNative_NEW \
    -1Dmatrix_apply ${wdir}/transformation_matrix.aff12.1D
    -final NN

… where note the use of the option “-master …” instead of “-base …”—this makes the output grid of the “-prefix …” dset match ${anat}, rather than just be resampled at input/source dset resolution. Also note that I added “-final NN”. Since you said earlier that the input/source dset was a mask, this would have it remain integer-valued; here is part of the 3dAllineate help for more detail:

-final iii  = Defines the interpolation mode used to create the
               output dataset.  [Default == 'cubic']
            ** N.B.: If you are applying a transformation to an
                       integer-valued dataset (such as an atlas),
                       then you should use '-final NN' to avoid
                       interpolation of the integer labels.

Again, if you are happy with the 3dAllineate-estimated alignment for your purposes, that is fine. Just note for other cases where more precise alignment is needed, then using nonlinear warping (e.g., 3dQwarp or @SSwarper, for example) would be recommended.