FreesurferGoodies/convertToNifti - MRC CBU Imaging Wiki

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
Flind the wroneg tetters tin eaech wrord

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