First, in order to see the information about a .nii file, use the command
fslinfo Filename.nii.gzHere we have a file Class_specific_MI_VTC_CMI_c1.nii.gz, so we use
fslinfo Class_specific_MI_VTC_CMI_c1.nii.gzand 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 FLOAT64dim1 64dim2 64dim3 40dim4 1datatype 64pixdim1 3.7500000000pixdim2 3.7500000000pixdim3 3.5000000000pixdim4 1.0000000000cal_max 0.1781cal_min 0.0000file_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.niidata_type INT16dim1 64dim2 64dim3 40dim4 121datatype 4pixdim1 3.7500000000pixdim2 3.7500000000pixdim3 3.0999999046pixdim4 2.5000000000cal_max 0.0000cal_min 0.0000file_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 1and 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 INT16dim1 64dim2 64dim3 40dim4 1datatype 4pixdim1 3.7500000000pixdim2 3.7500000000pixdim3 3.0999999046pixdim4 2.5000000000cal_max 0.0000cal_min 0.0000file_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.gzNow, 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 FLOAT64dim1 64dim2 64dim3 40dim4 1datatype 64pixdim1 3.7500000000pixdim2 3.7500000000pixdim3 3.0999999046pixdim4 2.5000000000cal_max 0.1781cal_min 0.0000file_type NIFTI-1+That's it!
Now we will have to transform the fMRI into T1 space
clearT1_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