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.


The script is available here: aseg2srf.


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.

15 thoughts on “Importing FreeSurfer subcortical structures into Blender

  1. Hey Dr. Winkler,

    I’m interested in implementing this subcortical reconstruction in 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.
      All the best,

        • Hi Nicholas,
          I haven’t forgotten you. I’m putting to run a dataset on FS6 (I hadn’t yet) to see if I can reproduce the same issue. Hope to have feedback on this soon.
          All the best,

        • Hi Nicholas,

          I run a subject in full through the FS 6.0.0 pipeline (recon-all finished without error), and run the script, in a Mac, and couldn’t replicate the same issue. The call to aseg2srf was:

          aseg2srf -s subjid

          That was all… not sure what may be going on there, perhaps it’s a local issue, not sure…

          All the best,


        • Hi Anderson,

          Thank you for looking into this. I’ve tried again with the same result… most strange. Is there a chance that your script expects another executable that I have not installed, by any chance?

          In any case, thank you so much for trying…

        • Hi Nicholas,

          Hmm, the only thing that isn’t FS-specific is the command md5 (or md5sum in Linux), but if that were the issue, it would give a message about that. This seems more a problem with the FS binaries and the libraries in your system somehow aren’t agreeing. It’s odd… Do you have a Linux computer lying around? Perhaps try running from that one (?).

          All the best,


        • Hi Anderson,

          Lokking around for other examples of the “dyld: lazy symbol binding failed: Symbol not found: ___emutls_get_address” error, it looks like it might have to do with linking to discordant versions of GCC libraries, and/or possibly system integrity protection on recent versions of Mac OS X. I may try disabling system integrity protection to see if it runs then…

        • Hi Anderson,

          I disabled system integrity protection (in Mac OS X 10.12.4), and the script ran fine!

          So, the problem seems to be related to Apple’s aggressive prevention of linking against older versions of system libraries…

Leave a Reply

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

You are commenting using your 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