Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Surface projection


This repository contains matlab code to:

  • Project 3D volumetric nifti images in 2mm isotropic MNI space (see example file in folder 'volumetric') to the HCP MMP surface
  • Extract values of each parcel in the Glasser atlas
  • Create null maps by spherical rotation
  • Test spatial correlation between maps and compute p-values that take into account spatial autocorrelation in the maps via spherical rotation ("spin testing").*

See example.m for syntax.

This code will not run out of the box. You'll need:

Surface projection will allow you to do the following:

Spin testing works as follows:

Correlate_surface(); does the spin testing. It requires two input arguments, of which at least one is vertex-level data. In case one of the input surfaces is pre-parcellated, use the 'glasser' option. In this case, use the parcellated map as the first input, and the vertex-level map as the second input. The medial wall of the original surface as well as the rotated surrogate surfaces (white parts in the figure above) are blanked out and excluded from correlation, so each correlation in the null distribution will have a slightly different number of parcels / vertices that are included.

Code to compute and plot parcel-wise median values of a T1 / T2 contrast (myelin map) is also provided. The myelin map as well as the surface files are from the HCP S1200 release ( The file 'mvals.csv' also contains the parcel-wise median values of the myelin map. The file 'tvals.csv' contains parcel-wise median values of a cortical thickness map.

Labels to atlas parcels can be found in Glasser_labels.csv.

List of functions:

  • glasserize_nifti: produce parcel-wise median values for a volumetric nifti (.nii) file
  • glasserize_cifti: produce parcel-wise median values for a surface file
  • glasserize_surface: produce parcel-wise median values for a surface vector
  • surface_project: project a volumetric file to the cortical surface, and return spatially z-scored vertex-wise values
  • surface_project_raw: project a volumetric file to the cortical surface, and return the raw vertex-wise values
  • correlate_surface: correlate two surface vectors while controlling for spatial autocorrelation
  • sphere_rotate: produce spherically rotated surrogate maps
  • cortsurfl: plot data onto the cortical surface of the left hemisphere
  • cortsurfr: plot data onto the cortical surface of the right hemisphere
  • pathfindr: function to set paths
  • inferno: the inferno color map


  • Alexander-Bloch, AF, Shou, H, Liu, S, Satterthwaite, TD, Glahn, DC, Shinohara, RT, Vandekar, SN, Raznahan, A, (2018) On testing for spatialcorrespondence between maps of human brain structure and function. Neuroimage 178, 540-551. doi:10.1016/j.neuroimage.2018.05.070


Code for projecting volumetric nifti files to HCP surface and Glasser atlas parcel-wise value extraction







No packages published