Normalization of fmri data without changing voxel size

Dear all,

I would like to run the intersubject correlation (ISC) analysis. As far as I understand, I could run the analysis using the data that has its original voxel size (5 x 5 x 7 mm), and upsample only the final ISC maps to 2 mm resolution for visualization of the results (could you please correct me if I am wrong). I have tried to normalize the subjects by transforming them into the MNI152 space without upsampling to the 2mm voxel resolution as follows:

  1. Register functional to anatomical using fslregister
    fslregister –s $subject --mov data.mgh --reg register.dat --maxangle 70 --initxfm

  2. Register anatomical to mni152:
    mni152reg --s $subject
    Creates $SUBJECTS_DIR/$subject/mri/transforms/reg.mni152.2mm.dat

  3. Create registration between functional and mni152
    mri_matrix_multiply -im register.dat -iim reg.mni152.2mm.dat -om reg.mni152.dat

  4. Apply the transformation without resampling:
    mri_vol2vol --targ $FSLDIR/data/standard/MNI152_T1_2mm.nii.gz --mov data.nii --reg reg.mni152.dat --o data.mni152.nii --no-resample

I would be very grateful if someone could help me with the following problems:

  1. I don’t fully understand why --targ is needed in step 4. Shouldn’t reg.mni152.dat include all information needed for the transformation?
  2. I would like to compare the MNI152 template and the transformed data to see if the registration looks correct (e.g. using fslview). However, I think that this would require MNI152 template that has the same voxel resolution as my data. Could someone please let me know how to downsaple MNI152 template from the voxel size of 2 x 2 x 2 mm to the voxel size of 5x5x7 mm?

Best,
Maria

[I can’t write this with 100% certainty] My guess is that reg.mni152.dat is 1) a linear transform and 2) in FSL format. For those two reasons, the transform does not contain any information whatsoever about the target and moving spaces. If this is something you really don’t like, you can generate the corresponding LTA transform (with FreeSurfer), which combines all that information in one file.

Since you are using FreeSurfer, why not giving freeview a go?. Otherwise, I think the new fsleyes viewer will allow you to render differing resolution files as well.

If you still REALLY want to downsample the template, the first thing I can think of is nilearn:

import nibabel as nb
from nilearn.image import resample_img

epinii = nb.load('/path/to/your/epi.nii.gz')
resampled = resample_img(
    'MNI152.nii.gz',
    target_affine=epinii.affine,
    target_shape=epii.shape)
resampled.to_filename('resampled_MNI152.nii.gz')

Alternatively, if you happen to have ANTs installed, you can use antsApplyTransforms using the keyword identity as transforms input, the EPI as reference image and the MNI as moving image.

Many thanks for the answers!

fslview requires that the functional data and the template have the same voxel resolution. However, in freeview, the voxel size is not a problem. Therefore, the easiest solution is to use freeview.

The registration seems to work if I upsample the functional data from 5 x 5 x 7 mm to 2 x 2 x 2 mm voxel resolution as follows:
mri_vol2vol --targ $FSLDIR/data/standard/MNI152_T1_2mm.nii.gz --mov data.nii --reg reg.mni152.dat --o data.mni152.nii

However, if I keep the original voxel size, the template and the functional image are not aligned (the shape and place of the functional image and the template image are different):
mri_vol2vol --targ $FSLDIR/data/standard/MNI152_T1_2mm.nii.gz --mov data.nii --reg reg.mni152.dat --o data.mni152.nii --no-resample
(I have just added “no-resample”)

The freesurfer manual says:
"mri_vol2vol --reg register.dat --mov f.nii.gz --fstarg --o f.new.vox2ras.nii.gz --no-resample

f.new.vox2ras.nii.gz will have the same dimension and voxel size as f.nii.gz, but its vox2ras (sform/qform) matrix will have changed."

Could someone please let me know what might be wrong? I managed to keep the original dimension and voxel size, but the functional data and the template are not aligned. As far as I understand, the functional data should be aligned to the template if its vox2ras matrix is changed.

Best,
Maria

I tried bbregister instead of fslregister and I think that the normalization works relatively well now.

That was my first thought (why not bbregister if she is already using FreeSurfer?), but I did not want to suggest you to change your workflow.