Smoothing within layers

Smoothing within layers can be advantageous for multiple reasons:

  • Increasing the CNR without loosing spatial information across cortical depths.
  • Visualization of striping pattern across columnar structures.
  • Avoiding leakage of physiological noise from CSF space into GM tissue.



I first heard about directional smoothing at the E-poster presentation from Jonathan Polimeni (2015) at ISMRM in Toronto. Based on what he showed there in surface space, I tried to implement a corresponding smoothing in voxel space for the following ISMRM (Huber et al. 2016). In the same year Anna Blazejewska (2016) implemented it in surface space in Freesurfer.

Usage of LAYNII program: LN_LAYER_SMOOTH


There are two datasets required for LN_LAYER_SMOOTH:

  1. Layer mask in voxel space. E.g. generated as described here. This file is a nii-volume dataset, where every voxel has the value of the cortical depth. There is a layer mask file example included in github.

    Example of layer file: It should be a nii file with integer values as layers. If it has non-intager values, the program will truncate it to integers.
  2. Activation map with the same dimensions as the layer file.
Example activation map that should be smoothed.

Getting software

The program LN_LAYER_SMOOTH can be downloaded from github LAYNII as follows:

 git clone

Compile it in the LAYNII folder with:



./LN_LAYER_SMOOTH -layer_file equi_dist_layers.nii -input activity_map.nii -FWHM 1.0 <span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"></span>


Screenshot 2018-03-15 14.12.16.png


  • The output file name is smoothed.nii.
  • The argument -FWHM is given in mm, so it should be made sure that the nii header should are correct.
  • The layer-mask file should have positive values only. Negative values are ignored.
  • Per default, voxels that are not included in the layer mask are not smoothed. They are just copied to the new ‘smoothed*.nii’ file (e.g. see bottom left of the top figure).
  • The optional -mask option will set everything outside the layer mask to zero. The default is that this option is switched of.
  • Smoothing is done along the cortical ribbon with a Gaussian kernel.
  • Smoothing can be done in 2D and in 3D. The default is 3D. Use the optional “-twodim” option if you want to to 2D smoothing only. Note that the smoothing is done in units of mm not voxels. Hence, for lower slice resolution than in-plane resolution, the 3D-smoothing will be weaker across neighboring slices compared to neighboring voxels in-plane.


Polimeni, J.R., Mianciardi, M., Keil, B., and Wald, L.L. (2015). Cortical depth dependence of physiological fluctuations and whole-brain resting-state functional connectivity at 7T. In Proceedings of the International Society of Magnetic Resonance in Medicine, p. 592.

Huber, L., Handwerker, D.A., Hall, A., Jangraw, D.C., Gonzalez-castillo, J., Guidi, M., Ivanov, D., Poser, B.A., and Bandettini, P.A. (2017). Cortical depth-dependent fMRI: heterogeneity across tasks, across participants, across days and along the cortical ribbon. In Proceedings of the International Society of Magnetic Resonance in Medicine, p. 237.

Blazejewska, A., Hinds, O., and Polimeni, J.R. (2016). Improved tSNR of high-resolution fMRI with surface-based cortical ribbon smoothing. Annu. Meet. Organ. Hum. Brain Mapp. 1728.

Kiebel, J et al. (1999), Anatomically Informed Basis Functions Stefan, Neuroimage, vol. 11, pp. 656-667.

Jo, HJ et al. (2007), Spatial accuracy of fMRI activation influenced by volume- and surface-based spatial smoothing techniques, Neuroimage, vol. 34, pp 550-564.

Jo, HJ et al. (2009), Surface-based functional magnetic resonance imaging analysis of partial brain echo planar imaging data at 1.5 T, MRI, vol. 27, pp. 691-700. 5.