how to fix geometry of fMRI in FSL
First, in order to see the information about a .nii file, use the command
fslinfo Filename.nii.gz
Here we have a file Class_specific_MI_VTC_CMI_c1.nii.gz, so we use
fslinfo Class_specific_MI_VTC_CMI_c1.nii.gz
and the output would look like
kittipat@genu:~/Dropbox/random_MATLAB_codes/fMRI/mvpa_Haxby_experiment/clustering_on_features/test$ fslinfo Class_specific_MI_VTC_CMI_c1.nii.gz
data_type FLOAT64
dim1 64
dim2 64
dim3 40
dim4 1
datatype 64
pixdim1 3.7500000000
pixdim2 3.7500000000
pixdim3 3.5000000000
pixdim4 1.0000000000
cal_max 0.1781
cal_min 0.0000
file_type NIFTI-1+
Now, let's see the fMRI file info:
kittipat@genu:~/Dropbox/random_MATLAB_codes/fMRI/mvpa_Haxby_experiment/clustering_on_features/test$ fslinfo haxby8_r1.nii
data_type INT16
dim1 64
dim2 64
dim3 40
dim4 121
datatype 4
pixdim1 3.7500000000
pixdim2 3.7500000000
pixdim3 3.0999999046
pixdim4 2.5000000000
cal_max 0.0000
cal_min 0.0000
file_type NIFTI-1+
Notice that the pixdim3 is different on both files. This is where the inconsistency occurs when interpolate from functional to T1. So, we have to fix it...but which one should be changed? I would change the everything to be the same as the fMRI file. So, we have to copy the geometry from the fMRI to the other files.
First we obtain one time slice (0 1 = starts at 0, and get only 1 time slice) from an fMRI file haxby8_r1.nii and save to haxby8_r1_1.
fslroi haxby8_r1.nii haxby8_r1_1 0 1
and if you look at the haxby8_r1_1 you will find that the geometry is
kittipat@genu:~/Dropbox/random_MATLAB_codes/fMRI/mvpa_Haxby_experiment/clustering_on_features/test$ fslinfo haxby8_r1_1.nii.gz
data_type INT16
dim1 64
dim2 64
dim3 40
dim4 1
datatype 4
pixdim1 3.7500000000
pixdim2 3.7500000000
pixdim3 3.0999999046
pixdim4 2.5000000000
cal_max 0.0000
cal_min 0.0000
file_type NIFTI-1+
So, we want to copy the geometry from haxby_r1_1 to Class_specific_MI_VTC_CMI_c1.nii.gz:
fslcpgeom haxby8_r1_1.nii.gz Class_specific_MI_VTC_CMI_c1.nii.gz
Now, see the new geometry info of the file will be the same as the one from haxby_r1_1
kittipat@genu:~/Dropbox/random_MATLAB_codes/fMRI/mvpa_Haxby_experiment/clustering_on_features/test$ fslinfo Class_specific_MI_VTC_CMI_c1.nii.gz
data_type FLOAT64
dim1 64
dim2 64
dim3 40
dim4 1
datatype 64
pixdim1 3.7500000000
pixdim2 3.7500000000
pixdim3 3.0999999046
pixdim4 2.5000000000
cal_max 0.1781
cal_min 0.0000
file_type NIFTI-1+
That's it!
Now we will have to transform the fMRI into T1 space
clear
T1_vol='structural.nii'
infile='Class_specific_MI_VTC_CMI_c1.nii.gz'
outfile='output'
flirt -ref $T1_vol -in $infile -applyxfm -init r1_T1.mat -out $outfile -interp nearestneighbour