FreesurferGoodies/convertToNifti - MRC CBU Imaging Wiki
location: FreesurferGoodies / convertToNifti

#
# this is an example of a script that will convert the freeSurfer orig.mgz high resolution, 
# to a nifti format (anat.nii) that will be readable by spm. This will allow coregistration 
# of the freeSurfer reference anatomical (anat.nii) to the source image (spm native space 
# anatomical image) and any other image of your choice (e.g. mean*.nii)

## variables

## Freesurfer directory
thePath='/imaging/yourusername/yourproject/subjects'

subjects=(
'CBUXXXXXX' \  
'CBUYYYYYY' \ 
)

## Processing:

nsubjects=${#subjects[*]}
lastsubj=`expr $nsubjects - 1`

for m in `seq 0 ${lastsubj}`
do
        echo "======================================================="
        echo " "
        echo " converting high resolution T1 image from .mgz to .nii"
        echo " "
        echo "======================================================="  

cd ${thePath}/${subjects[m]}/mri/
echo "the current directory is `pwd`"

mri_convert \
 orig.mgz \
 anat.nii
done # converting .mgz to nifti format

CbuImaging: FreesurferGoodies/convertToNifti (last edited 2013-06-25 10:22:20 by IanCharest)