FreeSurfer

FreeSurfer is an open-source neuroimaging toolkit available as a Lmod module on Klone.

Important

Currently, FreeSurfer must run from a container with sufficient library dependencies. We recommend using FreeSurfer from a VNC session with hyakvnc.

Checking available versions

module avail freesurfer

Using FreeSurfer (from escience)

Load the default version with module load escience/freesurfer,

or load a specific version with module load escience/freesurfer/<version>.

After loading the module, FreeSurfer should have its environment set up for normal use.

Installing a different version

Note

This is tested from a VNC Apptainer environment with sufficient dependencies.

  1. Go to https://surfer.nmr.mgh.harvard.edu/fswiki/DownloadAndInstall and download the latest FreeSurfer tar archive for CentOS 8

  2. Extract the .tar.gz archive to /sw/contrib/labname-src/freesurfer/<version>/.

For example, if installing version 7.3.2 of FreeSurfer, then run the following:

LABNAME=escience
VERSION=7.3.2
mkdir -p "/sw/contrib/$LABNAME-src/freesurfer/$VERSION"
tar -xzf freesurfer-linux-centos8_x86_64-$VERSION.tar.gz \
    --strip-components=1 \
    -C "/sw/contrib/$LABNAME-src/freesurfer/$VERSION"
  1. Create an Lmod .lua module file for the new release with a text editor:
/sw/contrib/modulefiles/mylabname/freesurfer/7.3.2.lua
help(myModuleName())
local base = pathJoin(
    "/sw/contrib",
    string.gsub(myModuleName(), "/.*$", "-src"),
    string.gsub(myModuleName(), "^.*/", ""),
    myModuleVersion()
)
--FreeSurfer 7.x requires MATLAB R2014b
depends_on("forsyth/matlab/r2014b")

setenv("FREESURFER_HOME", base)
prepend_path("PATH", pathJoin(base, "bin"))
source_sh("bash", pathJoin(base, "SetUpFreeSurfer.sh"))

whatis("Name: " .. string.gsub(myModuleName(), "^.*/", ""))
whatis("Version: " .. myModuleVersion())
  1. Check that the module is available and load it:

    module -I spider mylabname/freesurfer
    module load mylabname/freesurfer/7.3.2
    1
    Lmod takes some time to cache available modules. You can use the -I option to force Lmod to check for new modules.
  2. Request a free license from https://surfer.nmr.mgh.harvard.edu/registration.html if not already.

Note

This license is not tied to a specific version of FreeSurfer and can be copied from a previous installation.

  1. Download license.txt from the registration email and copy it to /sw/contrib/labname-src/freesurfer/<version>/license.txt.

  2. For FS-FAST support, create a link to a supported MATLAB release (R2014b for FreeSurfer 7.x):

module -I load labname/freesurfer/<version>
cd "$FREESURFER_HOME"
ln -s /gscratch/psych-src/matlab/R2014b MCRv84