Caret:Operations/Freesurfer to fs LR

From Van Essen Lab

Revision as of 16:51, 19 March 2012 by Donna (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This script resulted from taking the hatchet to Matt Glasser's script. 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 and Caret installed for it to work, as it calls command line utilities in those distributions (e.g., mri_convert, mri_info, caret_command).

It was written to be called from within the same directory where freesurfer-subject-directory is located, but might work with an absolute path.

Before running, edit this variable location for sure:

CaretAtlasSpaceDirectory=/mnt/myelin/donna/ATLAS/fs_LR/standard_mesh_atlases Note: The standard_mesh_atlases subdirectory is included with this zip file, so point this to where you unpacked it.

Check your Freesurfer installation path, too:


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


Save your edits; chmod +x, if needed; and run the script, e.g.: bert

Note that this command was written to be run in a directory like this:


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

/mnt/myelin/donna/SAIS/SAIS_001 /mnt/myelin/donna/SAIS/SAIS_002_MR1 /mnt/myelin/donna/SAIS/SAIS_003 /mnt/myelin/donna/SAIS/SAIS_004_MR1 /mnt/myelin/donna/SAIS/SAIS_009_MR1

In other words, it might be your Freesurfer $SUBJECTS_DIR directory. One of these is your input to this command; its 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:

/mnt/myelin/donna/SAIS/fs_LR_output_directory/SAIS_001 /mnt/myelin/donna/SAIS/fs_LR_output_directory/SAIS_002_MR1 /mnt/myelin/donna/SAIS/fs_LR_output_directory/SAIS_003 /mnt/myelin/donna/SAIS/fs_LR_output_directory/SAIS_004_MR1 /mnt/myelin/donna/SAIS/fs_LR_output_directory/SAIS_009_MR1

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

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.sphere.164k_fs_"$Hemisphere".coord.gii $OutputRootDir/$Subject/fsaverage/$Subject.$Hemisphere.def_sphere.164k_fs_"$Hemisphere".coord.gii $OutputRootDir/$Subject/fsaverage/$Subject.$Hemisphere.164k_fs_"$Hemisphere".topo.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 or 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. This keeps the nodes the same, so there is no resampling, but the geography gets swapped around, so that node i in both left and right is in decent correspondence. (In the hem-specific spheres, node i might be in the frontal lobe on the left, occipital on the right.)

Repeat for the right.

Personal tools
Sums Database