The first step to display data on the cerebellar surface is to map it to the flatmap.

# Import the Suit package
import SUITPy.flatmap as flatmap
import matplotlib.pyplot as plt
import nibabel as nb
%reload_ext autoreload
%autoreload 2
%matplotlib inline

The following command maps an example functional volume to the surface. The mapped data is returned as a numpy array.

funcdata = flatmap.vol_to_surf('MDTB08_Math.nii')
print('Output is a np.array of size:',funcdata.shape)
Output is a np.array of size: (28935, 1)

The function takes either a filename, a list of filenames, or a list of nibable.NiftiImage to be mapped.

Atlas space

By default, the function assumes that the data is mapped to SUIT space. You can specify the normalization space with the optional input argument space. Options are:

  • ‘SUIT’: SUIT space

  • ‘FSL’: FNIRT alignment to FSL standard

  • ‘SPM’: Segmentation to SPM standard

  • ‘MNISymC’: Alignment to MNINLin_Symmetric2009

# Signals the function that the volume was mapped to SUIT space (default):
funcdata = flatmap.vol_to_surf('MDTB08_Math.nii',space='SUIT')

Mapping ROI labels

By default the function vol_to_surf assumes that the data is continuous functional data. It therefore averages the data across voxels at a specific location of the map. If you want to map a segmentation volume that contains discrete labels, you can specify to use the mode, rather than the mean.

vol = 'Buckner_17Networks.nii'
labeldata = flatmap.vol_to_surf(vol,stats = 'mode')

Mapping many volumes

You can also map a whole set of volumes by passing a list to vol_to_surf. This will be faster than mapping all volumes seperately.

vols = ['Buckner_7Networks.nii','Buckner_17Networks.nii']
labeldata = flatmap.vol_to_surf(vols,stats = 'mode')
print('Output is a np.array of size:',labeldata.shape)
Output is a np.array of size: (28935, 2)

Saving data as a gifti file

If you want to save the mapped data as a gifti file, you can create a corresponding GIFTI image and save it to disk using nibabel.

funcdata = flatmap.vol_to_surf('MDTB08_Math.nii',space='SUIT')
# Make gifti image with the right column names
funcgifti  = flatmap.make_func_gifti(funcdata,column_names=['Math'])
# You can also make a label gifti:
labelgifti = flatmap.make_label_gifti(labeldata),'MDTB08_Math.func.gii')


Choosing a renderer (Matplotlib or Plotly)

SUITPy uses either matplotlib or plotly for rendering. matplotlib is slower, but allows the use of the familiar Matplotlib environment to generate subplot and to set figure sizes. plotly renders the figure through WebGL, allowing the figures to be viewed in a web-browser. For subplot control or additions to the plot, familiarity with plotly is required. The renderer is set through the optional input parameter render.

Plotting of functional overlays

The functional data that we just mapped can be plotted with the functional flatmap.plot. The main input argument can be a np-array with the data to plot, a gifti image object, or the name of a gifti file to load. The upper and lower threshold are set with threshold.

For full funtion reference see the function reference for the flatmap module.

flatmap.plot(data=funcdata, cmap='jet', \
    threshold=[0.01, 0.12], \
    new_figure=True, \
    colorbar=True, \

Colorbars (Matplotlib) and Hover information (Plotly)

For Matplotlib, the color bar can be switched on and off by setting colorbar to True or False. For Plotly, the color bar option is not yet implemented, but if you can hover your mouse over the the map to get the value. The format of the hover information is dictated by hoverinfo, which can be "auto", "value", or None. The Numberformat for colorbar and hover information can be set with cbar_tick_format.

# And the same plot, rendered with Plotly:
flatmap.plot(data=funcdata, cmap='jet', \
    threshold=[0.01, 0.12], \

Data type cannot be displayed: application/vnd.plotly.v1+json

Plotting Label data

For label data choose overlay_type = 'label' and set the colormap to a qualitative (categorical) color map.

flatmap.plot(labeldata, overlay_type='label', cmap='tab10', colorbar=True, render='matplotlib')
<Figure size 504x504 with 0 Axes>

Plotting directly from a gifti file

You can also plot directly from a gifti file. When you choose ‘label’, suit.flatmap.plot will also extract the color map from the label.gii file and use it.

    new_figure=True, \

Combining flatmaps in subplots (Matplotlib only)

By default, flatmap.plot renders the flatmap into the current axis of matplotlib. This enables the user to combine combine different flatmaps in one figure using different subplots.

fig = plt.figure(figsize=(12,6))
flatmap.plot(data=funcdata, cmap='jet', threshold=[0.01, 0.12],new_figure=False)


Adjusting style and color of the borders

By setting the optional parameters bordersize and bordercolor, and backgroundcolor you can modify the appearance of the (lobular) boundaries and the figure background to generate graphs that work well on black background.

    bordersize=2.5, \