Caret:Operations/Freesurfer to fs LR

From Van Essen Lab

Jump to: navigation, search

Data that have been processed by standard Freesurfer ‘recon-all’ (tested with v5.1, but may work on older versions) can be converted to the 164k_fs_LR mesh using this ‘"freesurfer_to_fs_LR"’ script. NB: This is a BETA version, so please be patient, and email [] if technical problems arise.

This script is a streamlined version of Matt Glasser's script (currently under development for the Human Connectome Project). Several steps were removed: nonlinear spatial normalization (replaced with affine talairach.xfm); brain mask; downsampling; and caret workbench stuff.

This script is used like so: freesurfer-subject-directory

You must have both freesurfer (tested on 5.1, but may work on older versions) and Caret v 5.64 or higher installed for the script to work, as it calls command line utilities in those distributions (e.g., mri_convert, mri_info, caret_command). See "Caret download page" for compatibility information.

Let SUBJECTS_DIR be the parent directory where multiple freesurfer-subject-directory subdirectories are located. (The script was written to be called from $SUBJECTS_DIR, but might work with an absolute path.)

Download into/under $SUBJECTS_DIR.


cp $SUBJECTS_DIR/freesurfer_to_fs_LR/ $SUBJECTS_DIR

Use a text editor to edit $SUBJECTS_DIR/ to reflect your path locations:


Note: Replace $SUBJECTS_DIR with the actual pathname of the parent directory where your freesurfer-subject-directory subdirectories are located.

Check your Freesurfer installation path, too:


If you don't like this name for the output subdirectory, change it:


Save your edits.

chmod +x

Run the script, e.g.: bert

Example where $SUBJECTS_DIR=/mnt/myelin/donna/SAIS

... which has several Freesurfer subject directories under it, e.g.:


The subdirectory contents are read, but not modified (e.g., ?h.white, ?h.pial, ?h.sphere, ?h.sphere.reg, ?h.curv, ?h.sulc, ?h.thickness, orig.mgz, talairach.xfm). Outputs go to $OutputRootDir.

If OutputRootDir=fs_LR_output_directory and you run this command once for each of subject directory, e.g.: SAIS_001 SAIS_002_MR1 SAIS_003 SAIS_004_MR1 SAIS_009_MR1

... then you would get output subdirectories like this:


Each of these subdirectories in /mnt/myelin/donna/SAIS/fs_LR_output_directory would have output files like those listed here.

The real magic of this script is in this command:

 caret_command -surface-sphere-project-unproject \
$OutputRootDir/$Subject/$InitialMeshDirectory/$Subject.$Hemisphere.sphere.reg.initial_mesh.coord.gii \
$OutputRootDir/$Subject/$InitialMeshDirectory/$Subject.$Hemisphere.initial_mesh.topo.gii \
$OutputRootDir/$Subject/$InitialMeshDirectory/$Subject.$Hemisphere.sphere.reg.reg_LR.initial_mesh.coord.gii \
$OutputRootDir/$Subject/fsaverage/$Subject.$Hemisphere.def_sphere.164k_fs_"$Hemisphere".coord.gii \

Its usage is like so:

     caret_command -surface-sphere-project-unproject  
        Transform a spherical surface.
        The input spherical surface is projected to the 
        "project-to" surface using barycentric projections
        and then unprojected using the "unproject-to" 
        spherical surface.  Typically the "unproject-to"
        surface is created during surface-based registration
        of the "project-to" spherical surface to some

Pseudocode for left hemisphere:

1. Project SAIS_001/surf/lh.sphere.reg to $FreeSurferInstallationDirectory/subjects/fsaverage/surf/lh.sphere.reg. (Because we're using sphere.reg, they should be in good geographic agreement, so this is a more of a resampling from initial mesh to the Freesurfer hemisphere-specific 164k mesh.)

2. Unproject the hem-specific 164k sphere onto the hemisphere-independent (fs_LR) sphere using a point projector to transform the vertices.

Repeat for the right. Vertex i on the left fs_LR 164k mesh should be in decent correspondence with vertex i on its right counterpart.

Personal tools
Sums Database