Importing FreeSurfer subcortical structures into Blender

In a previous article, a method to import cortical meshes from FreeSurfer into Blender and other CG applications was presented. Here it is complemented with a method to import the subcortical structures. These structures are segmented as part of FreeSurfer subcortical stream, and are stored in a volume-based representation. In order to import into Blender, first it is necessary to generate surfaces, then convert to Wavefront OBJ, and finally, do the import. Below is an example of how the output looks like.

An example of a subcortical meshes generated from FreeSurfer subcortical segmentations imported into Blender.

Generating the surfaces for subcortical structures

The surfaces can be generated using FreeSurfer’s own tools. The script aseg2srf automates the task. Suppose you would like to create meshes for all subcortical structures of the subjects named “capitu”, “bentinho” and “ezequiel”. Simply run:

aseg2srf -s "capitu bentinho ezequiel"

The outputs are saved in a directory called ascii, inside each subject’s directory. The script requires that FreeSurfer is installed and working properly, and that the environmental variable ${SUBJECTS_DIR} has been set to point to the location where the subjects are. It is also necessary to have writing permissions to this directory, so that the surfaces can be saved.

If there are many subjects, provide a list from a text file, with one subject per line:

aseg2srf -s list.txt

To make surfaces for just some structures, provide their label numbers with the -l option. For the hippocampus, for instance, the labels are 17 and 53 for left and right respectively:

aseg2srf -s "capitu bentinho ezequiel" -l "17 53"

The script has also a -d option, for debugging, which allows to keep temporary files used during the mesh generation.

List of labels

Below is a list of the label codes for the major structures. A more comprehensive list is in the aseg.stats file, inside the stats directory for each subject, or in the FreeSurferColorLUT.txt file (in the FreeSurfer directory).

Left lateral ventricle 4
Left inferior part of the lateral ventricle 5
Left cerebellum white matter 7
Left cerebellum cortex 8
Left thalamus 10
Left caudate 11
Left putamen 12
Left pallidum 13
Left hippocampus 17
Left amygdala 18
CSF 24
Left accumbens 26
Left ventral diencephalon 28
Left choroid plexus 31
Right lateral ventricle 43
Right inferior part of the lateral ventricle 44
Right cerebellum white matter 46
Right cerebellum cortex 47
Right thalamus 49
Right caudate 50
Right putamen 51
Right pallidum 52
Right hippocampus 53
Right amygdala 54
Right accumbens 58
Right ventral diencephalon 60
Right choroid plexus 63
Corpus callosum, posterior part 251
Corpus callosum, middle posterior part 252
Corpus callosum, central part 253
Corpus callosum, middle anterior part 254
Corpus callosum, anterior part 255
3rd ventricle 14
4th ventricle 15
5th ventricle (CSF sometimes found in the septum pellucidum) 72
Brain stem 16

Conversion to Wavefront OBJ

Once the meshes have been generated, the process of conversion into a format that can be read by CG software is the same as described previously here.

Download

The script is available here: aseg2srf.

Requirements

FreeSurfer must be installed and working properly. The environmental variable ${SUBJECTS_DIR} must point to the directory where the data for each subject is located. It is also assumed that recon-all has been run successfully.

8 thoughts on “Importing FreeSurfer subcortical structures into Blender

  1. Hey Dr. Winkler,

    I’m interested in implementing this subcortical reconstruction in SUMA (http://afni.nimh.nih.gov/afni/suma). I have been able to do this for each individual ascii file that was output from aseg2srf but was wondering how one could combine all the ascii file into one large file. Is this possible to do?
    Thank you for your posting on this site–the methods have been very useful.
    Any help would be gratefully received.
    -Vatche G. Baboyan
    University of Texas Medical School, Houston

  2. Pingback: Merging multiple surfaces | Brainder.

  3. Pingback: Splitting the cortical surface into independent regions | Brainder.

  4. Hi, many thanks for your excellent freesurfer scripts and resources… I’m trying to use your aseg2srf script with Freesurfer 6.0.0 on a dataset (on which I have successfully run recon-all), and I’m running into this error output:

    dyld: lazy symbol binding failed: Symbol not found: ___emutls_get_address
    Referenced from: /Applications/freesurfer/bin/../lib/gcc/lib/libgomp.1.dylib
    Expected in: /usr/lib/libSystem.B.dylib

    dyld: Symbol not found: ___emutls_get_address
    Referenced from: /Applications/freesurfer/bin/../lib/gcc/lib/libgomp.1.dylib
    Expected in: /usr/lib/libSystem.B.dylib

    /Applications/freesurfer/bin/aseg2srf: line 75: 73923 Abort trap: 6 ${FREESURFER_HOME}/bin/mri_tessellate ${SUBJECTS_DIR}/${s}/tmp/${RNDSTR}/aseg_${lab0}_filled.mgz ${lab} ${SUBJECTS_DIR}/${s}/tmp/${RNDSTR}/aseg_${lab0}_notsmooth

    No ascii files are generated, even with the “-d” option… Thanks for any light you can shed!

    • Dear Nicholas,
      Thanks for the message. I haven’t run the script yet with version 6.0. I will have a look into this issue, please allow be a few days and I’ll get back to you.
      Thanks.
      All the best,
      Anderson

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s