Freesurfer Image

Freesurfer Commands

Here are some examples for each of the 25 Freesurfer commands, along with their definitions:

Command Definition Example
recon-all The main pipeline for processing structural MRI images. recon-all -i input.nii.gz -s subject -all
mri_convert Converts MRI data between different file formats. mri_convert input.dcm output.nii.gz
mris_inflate Inflates the cortical surface to better visualize gyral and sulcal patterns. mris_inflate lh.white lh.inflated -n 50
mri_ca_register Registration of an individual subject to a probabilistic atlas. mri_ca_register -subjid subject -hemi lh -align-after talsrcimg.mgz
mri_label2vol Transforms a cortical surface label to a 3D volume. mri_label2vol --label label.lh --temp orig.mgz --o label.nii.gz --identity
mris_calc Performs mathematical operations on the values between two surfaces. mris_calc lh.thickness lh.area lh.volume
mri_vol2surf Projects data from a volumetric file to a cortical surface. mri_vol2surf --src input.nii.gz —hemi lh --o output.nii.gz
mri_watershed Skull-stripping algorithm to remove non-brain tissue from an image. mri_watershed -T1 brain_preprocessed.mgz brain_watershed.mgz
mri_surf2surf Transfers data between different subjects' cortical surfaces. mri_surf2surf --hemi lh --srcsubject source --trgsubject target --sval source.mgz --tval target.mgz
mri_segstats Computes statistics on segmented volumes. mri_segstats --seg aseg.mgz --ctab cortex_labels.txt --summaryout stats.txt
mri_robust_register Robust registration of two MRI images using intensity-based correlation. mri_robust_register --mov source.mgz --dst target.mgz --lta register.lta
mris_smooth Smoothes the cortical surface. mris_smooth -i input.mgz -o output.mgz --n 5
mri_gcaatlas Performs atlas-based segmentation using a Gaussian Classifier Atlas. mri_gcaatlas -t transforms.lta -n 5 -a gcatlas.mgz -o output.mgz
mri_aparc2aseg Combines cortical and subcortical segmentations into a single file. mri_aparc2aseg --s subject --o asegup.mgz
mris_anatomical_stats Computes various anatomical statistics about the cortical surface. mris_anatomical_stats -f output.txt -l label.lh
mri_pose_estimate Estimates the subject's head position within the MRI scanner. mri_pose_estimate --input orig.mgz --output pose.txt
mris_preproc Preprocesses surface data for analysis. mris_preproc --s subject --hemi lh --meancurv --out preprocessed_output.mgz
mri_concat Combines multiple MRI volumes into one. mri_concat --i input1.mgz --i input2.mgz --o combined.mgz
mris_fwhm Computes the full-width at half-maximum smoothness of a surface dataset. mris_fwhm --s subject --hemi lh --smooth-only --fwhm 5
mris_curvature Computes the curvature of a surface. mris_curvature -thresh 0.999 -sulc lh.sulc -output lh.curvature_output.nii.gz
mri_ca_normalize Normalizes intensity values in an MRI volume using a probabilistic atlas. mri_ca_normalize -c ctrl_point.mgz -mask brainmask.mgz -atlas gcaatlas.mgz -o norm_output.mgz
mri_binarize Binarizes an MRI volume by thresholding the intensity values. mri_binarize --i input.mgz --min 50 --max 100 --o binary_output.mgz
mri_label2label Transforms labels between subjects and/or hemisphere surfaces. mri_label2label --srclabel label.lh --srcsubject source --trgsubject target --trglabel target_label.lh --regmethod surface
mri_cvs_register Registers a subject to a common coordinate system used for group analysis. mri_cvs_register --mov input.mgz --cvs cvsatlas --lta output.lta --interp 5
mri_diff Computes the difference between two MRI volumes. mri_diff --in1 input1.mgz --in2 input2.mgz --diff diff_output.mgz

Common Freesurfer Installation Issues

Here are the top problems encountered while trying to install Freesurfer, along with their solutions and Linux-specific commands:

  1. Problem: Compatibility Issues with Operating System
    Solution: Ensure you are using a compatible OS, such as Linux or macOS. For Windows, you can use Windows Subsystem for Linux (WSL) or a virtual machine with a compatible OS.
    Linux Command: Install WSL on Windows by following instructions here: https://docs.microsoft.com/en-us/windows/wsl/install. Then install a compatible Linux distribution from the Microsoft Store.


  2. Problem: Incomplete or Corrupted Download
    Solution: Verify the integrity of the downloaded Freesurfer package. If the downloaded file is incomplete or corrupted, re-download the software from a reliable source.
    Linux Command: Download the Freesurfer package with wget and extract it:
    wget -c https://link/to/freesurfer_download.tar.gz
    tar -zxvf freesurfer_download.tar.gz


  3. Problem: Inadequate Disk Space
    Solution: Make sure you have enough free space (about 8 GB for the software and 2 GB per subject)
    Linux Command: Check available disk space with df -h.


  4. Problem: Environment Variables Not Set Correctly
    Solution: Set the FREESURFER_HOME and SUBJECTS_DIR environment variables, and add Freesurfer binaries to the PATH.
    Linux Command:
    export FREESURFER_HOME=/path/to/freesurfer
    export SUBJECTS_DIR=$FREESURFER_HOME/subjects
    source $FREESURFER_HOME/SetUpFreeSurfer.sh


  5. Problem: Missing Dependencies
    Solution: Install required dependencies such as the tcsh shell and libraries like libjpeg62.
    Linux Command (for Debian-based systems):
    sudo apt-get update
    sudo apt-get install tcsh libjpeg62


  6. Problem: Conflicting Software/Installations
    Solution: Remove or deactivate conflicting software or multiple Freesurfer installations.
    Linux Command: Remove an existing Freesurfer installation:
    rm -rf /path/to/old_freesurfer/


  7. Problem: Limited User Permissions
    Solution: Run the installation with the correct privileges. On Linux, use sudo where needed.
    Linux Command: Install a library with sudo (if required):
    sudo apt-get install some_required_library


  8. Problem: Corrupted/Missing Data
    Solution: Double-check your input data for integrity and completeness.
    Linux Command: Verify the integrity of input data using tools like md5sum or sha256sum:
    md5sum input_file.nii.gz
    sha256sum input_file.nii.gz