Splitting the cortical surface into independent regions

FreeSurfer offers excellent visualisation capabilities with tksurfer and FreeView. However, there are endless other possibilities using various different computer graphics software. In previous posts, it was shown here in the blog how to generate cortical and subcortical surfaces that could be imported into these applications, as well as how to generate models with vertexwise and facewise colours, and even a description of common file formats. It was also previously shown how to arbitrarily change the colours of regions for use with FreeSurfer own tools. However, a method to allow rendering cortical regions with different colours in software such as Blender was missing. This is what this post is about.

The idea is simple: splitting the cortical surface into one mesh per parcellation allows each to be imported as an independent object, and so, it becomes straightforward to apply a different colour for each one. To split, the first step is to convert the FreeSurfer annotation file to a data-per-vertex file (*.dpv). This can be done with the command annot2dpv.

./annot2dpv lh.aparc.annot lh.aparc.annot.dpv

Before running, be sure that ${FREESURFER_HOME}/matlab is in the Octave/matlab, path. With the data-per-vertex file ready, do the splitting of the surface with splitsrf:

./splitsrf lh.white lh.aparc.annot.dpv lh.white_roi

This will create several files names as lh.white_roi*. Each corresponds to one piece of the cortex, in *.srf format. To convert to a format that can be read directly into computer graphics software, see the instructions here.

The annot2dpv and splitsrf are now included in the package for areal analysis, available here.

With the meshes imported, let your imagination and creativity fly. Once produced, labels can be added to the renderings using software such as Inkscape, to produce images as the one above, of the Desikan-Killiany atlas, which illustrates the paper Cortical Thickness or Gray Matter Volume: The Importance of Selecting the Phenotype for Imaging Genetics Studies.

Another method is also possible, without the need to split the cortex, but instead, painting the voxels. This can be done with the command replacedpx, also available from the package above. In this case each region index is replaced by its corresponding statistical value (or any other value), then maps are produced with the dpx2map, shown in an earlier blog post, here. This other method, however, requires that the label indices are known for each region, which in FreeSurfer depends on the rgb colors assigned to them. Moreover, the resulting maps don’t have as sharp and beautiful borders as when the surface is split into independent pieces.

22 thoughts on “Splitting the cortical surface into independent regions

  1. Thanks for posting this. A lot of your posts have been super helpful in the work I’m currently doing (ECoG imaging/visualization).

    I can’t get annot2dpv to run though. I’m on ubuntu 12/linux, using freesurfer 5.3.0.
    I run ./annot2dpv lh.aparc.annot lh.aparc.annot.dpv and get ./annot2dpv: Command not found.
    I have $FREESURFER_HOME defined correctly, and source as well (with annot2dpv executable in cwd). I have also: setenv MATLABPATH $FREESURFER_HOME/matlab/

    Any idea on what could be going wrong?

    Thanks for your help.

  2. Hi Dr. Winkler,
    I’m pulling up an error when I attempt ./splitsrf lh.white lh.aparc.annot.dpv lh.white_roi

    error: fgets: invalid stream number = -1
    error: called from:
    error: …/areal/share/srfread.m at line 18, column 1
    error: …/areal/bin/splitsrf at line 60, column 10


  3. This is a really nice service to the community interested in making nice looking figures from their data – thanks! I was wondering if you would be willing to share what kind of shader/rendering settings you had for the Karlsgodt et al paper? – I really like that semi-transparent blue look, but from lots of fiddling around in Blender I haven’t been able to get anything even close!

  4. Hi Dr. Winkler, I am looking to import tractography data (.vtk files) into Blender. Right now, I am converting the .vtk into .stl with Slicer. I am wondering if you have any other suggestions. Also, since the tractography files are just a series of 3D (x,y,z) coordinates, is there a way to have these points connected into Blender?


    • Hi Kevin,
      I don’t have any tool available that would do that, sorry. It should be possible, though.
      All the best,

  5. Hi Dr. Winkler, I am running the annot2dpv

    but I receive this error message:

    warning: function name `Read_Brain_Annotation’ does not agree with function file name `/usr/apps/freesurfer/matlab/read_annotation.m’
    Reading from version 2
    colortable with 36 entries read (originally /autofs/space/terrier_001/users/nicks/freesurfer/average/colortable_desikan_killiany.txt)
    error: `dpxwrite’ undefined near line 74 column 1

    What should I do? Thanks

      • Hi Kevin, I am now facing exactly the same problem. I tried to use addpath(“/usr/local/freesurfer/matlab”) and savepath() to add the matlab path. But the error is still there. What steps did you take to fix it?

      • Hi Kevin, I am not facing the same problem. I used addpath(“/usr/local/freesurfer/matlab”) and savepath() in octave but the error still appear. What steps did you take to fix this?

  6. Hello. It seems as though srfread.m (called by splitsrf) is not able to read the surface file generated by Freesurfer 5.3 (lh.white). Is this correct?

    • Hi Tyler,
      Yes, correct. That function will only open after files have been converted to ASCII. You’d use mris_convert to convert.
      Hope this helps!
      All the best,

  7. Hi Dr. Winkler, are your functions expected to work for Freesurfer 5.3 surface data? I am having issues reading the faces and vertices in srfread.

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 )

Facebook photo

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

Connecting to %s