layer-fMRI software repositories

There is a long list of software packages that are capable of performing high-resolution MRI analysis.

Some of them are used by multiple groups and some of them are customized for specific studies only.

In this post, I want to give an overview over the most important software packages, their advantages and disadvantages, and their popularity in the field.

My theory, why the number of layer-fMRI softwares out there is inverse proportional to how good they work.

Analysis tools applied in the seminal layer-fMRI studies



Description: Freesurfer is an open source software suite for processing and analyzing (human) brain MRI images. In the resent years, it was further optimized for ultra-high-resolution data. In the field of layer-fMRI it is the most often applied software package.

Advantage: The usage is very  well documented with an extensive Wiki. It is very robust and has a very large user-community.

Disadvantage: It takes quite some time. Some people say it would have a rigid data organization. As a user, it’s not so straight forward to adapt/understand the algorithms and/or build your own tools, It requires a whole brain coverage.

Dependencies: Stand alone, no dependencies. It works well on Unix and Mac.


A layer-fMRI pipeline using Freesurfer in matlab was developed by Kendrick Kay.

My issues with it

I ended up not using it because I found it very hard to include manual corrections in the segmentation. It never works perfectly (especially in M1) and manual corrections can only be made on an integer voxel level. Dependent on the brain area segmentation does not always work perfectly (like in all software packages) and manual corrections are inevitable.

Screenshot 2018-01-05 13.33.33.png
Example of poor segmentation quality in motor cortex.

Freesurfer does the layering based on the WM/GM surface. This results in larger errors and non-linearities towards the cortical surface.

Screenshot 2018-01-05 13.34.08.png
Example of projection errors in Freesurfer. While the layers close to WM (dark red) look smooth, the superficial layers (bright yellow) are spotty and spatially unreliable.

Without further ado, it provides surfaces as meshes in standard space. I never got it to work that I obtain surfaces in voxel space with the original oblique NIFTI orientation.

The mesh density at the surface is very irregular and often less than the voxel size.

Screenshot 2018-01-05 13.34.42.png
Example of irregular mesh. Even, when the mesh density is increased (mris_mesh_subdivide),  there are always wholes and voxels that are missed.


Screenshot 2018-01-05 13.51.54.png

Description: CBS High-Res Brain Processing Tools (CBS Tools) is a software suite optimized for processing of MR images at sub-millimeter resolutions. CBS Tools have been developed in Java as a set of plugins for the MIPAV software package and are controllable from the JIST pipeline environment.

Advantage: It is optimized for layer-fMRI and has the equi-volume layering algorithm included.

Disadvantage: Complicated to install and use (for me). Is requires whole brain data for the segmentation. The layering works with partial brain data, however.

Dependencies: It is used as a collection of plug-ins in MIPAV.


My issues with it

I never got it to work on my machine. This is so despite support from former developers.


Screenshot 2018-01-05 13.43.24.png
Example of Nighres equi-volume layering.

Description: Nighres is a software tool in Python that is built on CBS tools developed by Julia Huntenburg, Christopher Steel and Pierre-Loiuse Bazin. It is specifically designed for high-resolution, layer-dependent MRI analyses.

Advantage: Its open source and very well documented. Its super fast. On my laptop it takes 15 min to get from MP2RAGE data to layers in volume space.

Disadvantage: It is not easily usable on MacOS, just yet. It requires whole brain data for the application of segmentation (it uses whole brain reference atlases). Layering can be done with partial coverage for closed surfaces. Even though it is designed to allow changes made by users, the complicated meta structure of multiple wrappers across multiple programming languages requires advances coding experience.

Dependencies: wrap, JCC, Nimpy, Nibabel


My issues with it

Because I am forced to use a MAC, I can only run it in a Neurodebian virtual box. This makes it more complicated for me. I also found it quite RAM-hungry. I guess I will use it more, when it will be easier available for MAC and when there are more functions being included.


The AFNI suite is also often used in layer fMRI for few sub-steps along the evaluation pipeline.

Afni can be used to isolate the voxels of a given cortical depth with 3dSurf2Vol using Freesurfer GM and WM surfaces as inputNote the arguments –f_p1_fr and -f_pn_fr that defines the range of cortical depth. See an example of how this works in this previous blog post.

Daniel Glen presented a poster at HBM 2018 showing multiple new tools in AFNI that estimate cortical thickness. These algorithms can also be used as a measure of cortical depth.

Advantage: As most other AFNI tools, the layer-tools are also fast and mighty.

Disadvantage: The segmentation is usually obtained form Freesurfer anyway, so it appears natural to do the layering estimation in directly in free surfer too. One thing that I found particularly challenging and that keeps me for applying them on a more regular basis is the problem that it needs some extra work around to work with oblique slices (see line with 3dWarp -card2oblique EPI.nii -verb anat.nii orinentfile.txt in this example)

Dependencies: The installation of AFNI required quite a bit of preparation work and other software to be installed. But it is quite well documented and it succeeded doing it few times already.




Description: Collection of C++ programs developed from Renzo Huber that operate exlusively in voxel-space.

Advantage: Because I wrote it myself, I know what it does and how the algorithms work 😉 Very flexible and application for real-life data with limited FOV. Since its implemented in C++, its super fast.

Disadvantage: Some functions are using ODIN libraries for the reading and writing of Nifties, which requires a unix machine with root access to be installed :-/ This requirement is not easily fulfilled in all labs :-/

Dependencies: Old programs use ODIN libraries for reading and writing nifties. This will hopefully change in the future. Few programs use GSL.

Link (without ODIN dependencies) and (with ODIN dependecies).

My issues with it

I didn’t transfer all the programs to a NIFTI I/O to a standalone C++, just yet. Hence, many programs still depend on ODIN libraries and are only applicable on UNIX machines. The equi-volume layering is still not optimized for oblique slices that are curved in 3D.

It does not have a very robust tissue segmentation algorithm, yet. So I need to use alternative methods and manual corrections.

Brain Voyager

Screenshot 2018-01-05 17.29.14.png
Figure taken from the Brain Voyager website.

Description: Non-open source software developed around Reiner Goebel for MRI analysis. It has a specific focus on laminar and columnar analysis.

Advantage: The 3D-grids to pool voxels across layers and columns is particularly advantageous. A nice description of all the layer-fMRI features are nicely explained by Valentin Kemper in this recent paper:

Kemper, V.G., De Martino, F., Emmerling, T., Yacoub, E., and Goebel, R. (2017). 9.4 Tesla imaging and high resolution data analysis strategies for mesoscale human functional MRI. Neuroimage in press, doi:10.1016/j.neuroimage.2017.03.058.

Disadvantage: Expensive. Its a black box.


My issues with it

Since it is not open source and requires non-cheap licenses, I never used it myself.


User interface of Segmentator, the user can follow in real time how the selection in the 2D-histogram labels respective voxels.
Screenshot 2018-07-05 11.05.03.png
With the right choice of domains in the histogram, Segmentator can even be used to directly obtain estimates of cortical depth. Image taken from the corresponding paper.

Description: Segmentor is an open and freely available Python tool box written by Faruk Gulban and co-developed by Marian Schneider for tissue type classification in high-resolution (layer)-fMRI. Segmentator plots voxels in a 2D-histogram. Every voxels’ signal intensity is plotes vs. its local gradient. Segmentator algorithm take advantage of the fact that non-brain structures (vessels, dura, CSF) have a spatial extent of approximately 0.7mm, which is coincidentally the current limit of routine anatomical images at high fields. Hence, non-brain voxels can be nicely separated from brain voxels in the gradient space.


  • it’s faster than manual segmentation and a first step for manual correction
  • is can work with any volume data-set larger than 3x3x3 voxels.
  • it works with slab-data, surface-coil data, and it doesn’t require whole brain
  • it can be optimized for any desired small brain region of interest.
  • its relatively easy to install


  • it neglects valuable information on a more larger spatial scale: e.g. atlas based segmentation priors, additional conditions about GM ribbon smoothness, etc.
  • it is only a first step toward fully-automated segmentation and still needs to be applied in combination with other methods
  • its biggest potentials need to be validated still. E.g. defining probabilistic templates in histogram space for fully automated segmentation.

DependenciesPython, pip for installation, Matplotlib, Numpy, Nibabel, Scipy


My issues with it

It is only a supporting tool that needs to be applied in combination with other methods. E.g. manual refinements are still often necessary.  It requires relatively high quality data.

RBR (Recursive Boundary Registration)

Screenshot 2018-01-23 08.51.34.png
Figure explaining the working principle of RBR (taken from paper)

RBR is a Matlab suite developed from Tim van Mourik for high-quality non-linear registration between undistorted ‘anatomical’ data and functional (layer) fMRI data. Its algorithm is based on repeatedly cutting the brain in smaller and smaller chunks and registering them with higher quality as it would be possible with larger volumes.

Its is comprehensively described in a resent bioarchive paper

Advantage: It has a higher registration quality than whole-volume registration.

Disadvantage: There is a tradeoff between conserved topology and smoothness of displacement that can restrict the registration quality.

Matlab code:

My issues with it

It is not clear to me how it performs with respect to other methods that are optimized for large distortions. E.g. using a less conservative smoothness penalty in the deformation field of SyN (in ANTS: SyN[0.1,-> x <-,0]). Field distortions are also not so variable across time that TopUp is completely useless. Any within-run registration would be impossible too.

Pipeline of CVN-Lab

This is the pipeline for developed from Kendrick Kay and his lab members for layer-fMRI. It consists of a whole set of layer-fMRI preprocessing tools including: alignment, field-map calculation, distortion-correction, registration, functional analysis and layering. It is written in matlab and called multiple external programs. As such, it uses freesurfer for the segmentation and layering.

This slideshow requires JavaScript.

Advantage: The quality seems to be exceptional. Kendrick’s paper seems to be one of very few that achieve usable segmentation quality without too much manual intervention. The visualisation tools are very instructive and give the user a good feeling on how the data are affected as the go through the evaluation pipeline.

Disadvantage: It is not written in a way to be use from a large user group. I have the feeling that you need to be Kendrick himself to set it up and run is robustly. The repository can be useful to copy code snippets, though.

Matlab code: 

Biggest unresolved issues in layer-fMRI analysis

Registration quality on a sub-voxel accuracy basis

There is no established quantitative measure that provides an estimate of registration quality up to a accuracy level of cortical layers. There are many suggestions, but its not clear which one performs best and whether any methods out there works good enough at all.

  1. Tim van Mourik suggests iterative BBR on smaller and smaller junks of the brain
  2. SyNs in ANTs (me)
  3. 3dQwarp (Yuhui)
  4. SPM (Yinghua)

I think future work should test which of the methods works best. Future work could be focusing on a good parameter set with the best accuracy-efficiency tradeoff. Furthermore future stream-lining work could try to use warp feels across platforms so it can be combined with motion correction.

Segmentation with sub-voxel accuracy

There are multiple ways of doing segmentation and it is not clear which one is the best.

  1. I start with Freesurfer (highres option) segmentation and do a manual corrections.
  2. Running 3dkMeans in AFNI like Allessio Francasso. It works better when you run 3dKmeans for different chunks of the brain separately and then merge them afterwards.
  3. Segmentator from Faruk
  4. ITK-snap with its growing balloon algorythm
  5. Using texture and local entropy like John Schwarz
  6. SPM and manual adjusted “winner-map”

I think future work should go into the direction of finding out which of those methods has the best accuracy-efficieny tradeoff.

Alignment without resolution loss

Every resampling step results in spatial blurring. It also introduces spurious correlations of voxels the time series. There have been three suggestions to account for it:

1.) Apply all registrations in one single resampling step only. Motion correction, alignment of runs, distortion correction, alignment with anatomical reference. As far as I understand. Nobody it using this approach so far. It is not straight forward to combine them in one step because different software packages are used for all those steps.

2.) Only do motion correction in EPI space. And ally the remaining analysis is done in EPI-space. This is what I do. However, freesurfer and AFNI are not making it easy to work in subject-specific distorted space. Future developments should make this easier.

3.) Up-sample all coil-data in k-space at the scanner and apply the analysis on a finder grid than the effective resolution. This approach means that every dataset is now 2^3=8 times larger. Which makes the analysis longer, memory requirements tougher. Data-analysis cannot be done on local laptops anymore and. Data transfer to HPC resources takes hours and is impractical.

I think it is still not established how bad multiple resampling steps reduce the resolution. I think future work should compare different pipelines and see if the layer-peaks are particularly clear for one or the other.

Segmentation of T1-EPI data

T1-EPI has more artifacts than MP2RAGE data. And it usually does not have whole brain coverage, which makes it harder to use it in conventional segmentation and layering pipelines. Since it also has a lower CNR, it requires more manual interventions. It is not established how to preprocess T1-EPI data so conventional segmentation pipelines can deal with them more efficiently.

Streamlining of manual corrections

So far, every respectable layer-fMRI paper does some sort of manual correction. This often happens during the alignment step and/or during GM segmentation.

There are multiple ways how to do manual correction:

  1. ITK-snap allows users to do manual segmentation with inflating balloons. In my opinion it’s quite time consuming.
  2. FSL allows me in my unscaled layer space to shift border lines by 25% of a voxel size. Is takes about 3 hours to do manual corrections as long as I have a good starting point from freesurfer.
  3. Freesurfer has its own way of doing manual correction on an integer voxel basis. Hence, layer position accuracy cannot be better than the voxel size.

I think that future work should go into the direction of combining independent approaches (Segmentator, Freesurfer, 3dclust) to obtain a better starting point for manual corrections.

I think future pipelines should be streamlined to allow manual corrections and it should become easier to incorporate manual corrections into the pipelines.