1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
"""
==================
Display ROI Values
==================
Here we demonstrate how to take the results of an ROI analysis performed within
each region of some parcellation and display those values on the surface to
quickly summarize the analysis.
"""
import os
import numpy as np
import nibabel as nib
from surfer import Brain
print(__doc__)
subject_id = "fsaverage"
hemi = "lh"
surf = "inflated"
"""
Bring up the visualization.
"""
brain = Brain(subject_id, hemi, surf, background="white")
"""
Read in the automatic parcellation of sulci and gyri.
"""
aparc_file = os.path.join(os.environ["SUBJECTS_DIR"],
subject_id, "label",
hemi + ".aparc.a2009s.annot")
labels, ctab, names = nib.freesurfer.read_annot(aparc_file)
"""
Make a random vector of scalar data corresponding to a value for each region in
the parcellation.
"""
rs = np.random.RandomState(4)
roi_data = rs.uniform(.5, .8, size=len(names))
"""
Make a vector containing the data point at each vertex.
"""
vtx_data = roi_data[labels]
"""
Handle vertices that are not defined in the annotation.
"""
vtx_data[labels == -1] = -1
"""
Display these values on the brain. Use a sequential colormap (assuming
these data move from low to high values), and add an alpha channel so the
underlying anatomy is visible.
"""
brain.add_data(vtx_data, .5, .75, thresh=0, colormap="rocket", alpha=.8)
|