FreeSurfer is a set of automated tools for subcortical segmentation, reconstruction of the cortical surface and overlay of functional data onto the reconstructed surface, produced at MGH, Boston. We have worked together to make interoperation of FSL and FreeSurfer as easy as possible. Two applications of using the two packages together are:


This section gives a very brief overview of running FreeSurfer. We strongly recommend that you also read the much more detailed official FreeSurfer documentation. The example commands are for subject name blobby.

Setup the necessary FreeSurfer environment variables.
tcsh users:
setenv FREESURFER_HOME <wherever_you_installed_freesurfer>
setenv SUBJECTS_DIR <wherever_you_want_to_do_the_analysis>
source ${FREESURFER_HOME}/SetUpFreeSurfer.csh
bash users:
export FREESURFER_HOME=<wherever_you_installed_freesurfer>
export SUBJECTS_DIR=<wherever_you_want_to_do_the_analysis>

Convert and orient the structural.
Convert your high resolution structural into compressed NIFTI format. If you are using dicom, then:
mri_convert one-dicom-file-from-series blobby.nii.gz

Make sure that its orientation is correct by using tkmedit, eg:
tkmedit -f blobby.nii.gz

Check each cardinal direction and make sure it is oriented like the small C, H and S icons (click on each to check). You will need to prove to yourself that left-right is oriented properly as that is often difficult to tell (but mri_convert usually does the right thing when dicoms are input).

Run the fully automated FreeSurfer pipeline.
recon-all -i blobby.nii.gz -subjid blobby -all

FreeSurfer options and manual intervention. For other options in the recon-all, or for instructions on how to do manual correction when the automated pipeline fails or is inaccurate, see the FreeSurfer webpages (wiki and online manuals) at:


Note: help can be obtained for almost all of the FreeSurfer programs by running it with --help or -help.

Analyze your data using FEAT, including registration to the subject's brain-extracted structural and standard space.

Register your functionals to anatomicals.
reg-feat2anat --feat featdir --subject blobby
where featdir is the output feat directory, and blobby is the freesurfer name of the subject. This will create registration files that FreeSurfer needs in featdir/reg/freesurfer. See reg-feat2anat --help for more info; in particular, you should use the --dof option to set the functional to structural degrees-of-freedom to be the same as what you found worked well in FEAT.

Manually inspect the registration.
reg-feat2anat --feat featdir --subject blobby --manual
This will bring up the FreeSurfer tkregister2 interface. Hit the "compare" button to make sure that the volumes are in register. See tkregister2 --help for more info.

Overlay zmap onto the orig volume.
Set the threshold at z=1.3
tkmedit blobby orig.mgz lh.white -overlay ./featdir/stats/zstat1.nii.gz \
    -overlay-reg ./featdir/reg/freesurfer/anat2exf.register.dat \
    -fthresh 1.3 -fmid 2.3 -fslope 1

Resample onto the surface.
feat2surf --feat featdir

This will create featdir/reg_surf-lh-blobby/stats with surfaces value files.

View on native inflated surface.
tksurfer blobby lh inflated -overlay featdir/reg_surf-lh-blobby/stats/zstat1.nii.gz


Resample the FreeSurfer automatic subcortical segmentation (aseg) to the FEAT functional space.
aseg2feat --feat featdir

To view the segmentation in the functional space:
tkmedit -f featdir/example_func.nii.gz \
    -segmentation featdir/reg/freesurfer/aseg.nii.gz

Construct a binary mask.
For example, of the left putamen, with:
avwmaths featdir/reg/freesurfer/aseg.nii.gz \
    -thr 12 -uthr 12 \

Repeat for cortical segmentation.
The above can also be done for the cortical segmentation (aparc) in the same way as for the sub-cortical segmentation (aseg), using aparc2feat.


To completely flatten a part of the cortex you first need to setup some "cuts" both to outline the part which you wish to flatten and, inside this, to allow flattening to take place with not too much distortion. This is described fully on the FreeSurfer wiki.


There can be advantages in doing multi-subject statistical analysis on the spherical cortical surface rather than in (registered) 3D.

Group analysis on the surface can be performed with either FreeSurfer or FSL tools, but the FSL tools have not been extensively tested on surface-based data. Group analysis in FreeSurfer can be accomplished from feat directories in five stages:

1. Combine runs together for each subject separately:
mris_preproc --out subj1-lh.mgz --target fsaverage --hemi lh --mean \
    --iv subj1.run1.feat/stats/cope1.nii.gz subj1.run1.feat/reg/freesurfer/anat2exf.register.dat \
    --iv subj1.run2.feat/stats/cope1.nii.gz subj1.run2.feat/reg/freesurfer/anat2exf.register.dat \

Do this for each subject in the study, creating a subjN-lh.mgz for each one. The data will be sampled to the common surface space (namely, fsaverage).

2. Concatenate the subjects together:
mri_concat subj1-lh.mgz subj2-lh.mgz ... subjN-lh.mgz --o allsubjs-lh.mgz

3. Apply surface-based smoothing:
mri_surf2surf --sval allsubjs-lh.mgz --s fsaverage --fwhm 20 --tval allsubjs-lh-sm20.mgz
It is possible to convert the file allsubjs-lh-sm2.mgz to nifti format (with mri_surf2surf) in order to run randomise or other non-spatial processing at this point, if desired.

4. Create design matrix for fsgd file and run mri_glmfit:
mri_glmfit --surf fsaverage lh --y allsubjs-lh-sm20.mgz --X X.mat --glmdir mystudy-lh-sm20 --C c.mat

5. Correct for multiple comparisons:
Run permutation or monte carlo simulations (more calls to mri_glmfit plus calls to mri_surfcluster). See the FreeSurfer Wiki.

Written by Steve Smith, Mark Jenkinson, and Doug Greve.

FreeSurfer (last edited 13:04:43 04-09-2012 by MatthewWebster)