Parcellize brain surfaceΒΆ

Parcellize the brain surface using .annot files. This example use Nibabel to read the .annot file.

See for files used in this example.

import numpy as np

from visbrain import Brain
from visbrain.objects import BrainObj
from import download_file

file1 = 'lh.aparc.a2009s.annot'
file2 = 'rh.aparc.annot'

# Download files if needed :
path_to_file1 = download_file(file1)
path_to_file2 = download_file(file2)

# Define a brain object :
b_obj = BrainObj('inflated', hemisphere='both', translucent=False,
                 cblabel='Parcellates example', cbtxtsz=4.)

"""Parcellize the left hemisphere using the Destrieux Atlas. By default, no
parcellates are selected
b_obj.parcellize(path_to_file1, hemisphere='left')

"""If you want to get the list of all predefined parcellates, use the
`get_parcellates` method which returns a pandas DataFrame with the index, the
name and the color associated to each parcellates
df = b_obj.get_parcellates(path_to_file2)
# print(df)

"""Select only some parcellates. Note that this parcellization is using an
other atlas (Desikan-Killiany atlas)
select = ['insula', 'paracentral', 'precentral', 'precuneus', 'frontalpole',
          'temporalpole', 'fusiform', 'cuneus', 'inferiorparietal',
          'inferiortemporal', 'precentral', 'superiorfrontal',

"""Instead of using predefined colors inside the annot file, we use some data
data = np.arange(len(select))
b_obj.parcellize(path_to_file2, hemisphere='right', select=select, data=data,

"""Finally, pass the brain object to `Brain` and disply the GUI

Total running time of the script: ( 0 minutes 0.000 seconds)

Gallery generated by Sphinx-Gallery