Hello NeuroStars,
I am trying to run “brainspace“ for computing/visualizing the gradient flow. Please see the following article.
https://doi.org/10.1038/s42003-020-0794-7
To begin I started their sample (Python) code from the official page, below.
However, I ran into following error.
This happens when I set “color_bar=True“ in function “plot_hemispheres.“
Does anyone know how to address this issue?
Please see the sample code that I am running, below.
from brainspace.datasets import load_group_fc, load_parcellation, load_conte69
import vtk
from brainspace.vtk_interface import wrap_vtk
### First load mean connectivity matrix and Schaefer parcellation
conn_matrix = load_group_fc(‘schaefer’, scale=400)
labeling = load_parcellation(‘schaefer’, scale=400, join=True)
mask = labeling != 0
### and load the conte69 hemisphere surfaces
surf_lh, surf_rh = load_conte69()
import numpy as np
from brainspace.gradient import GradientMaps
from brainspace.plotting import plot_hemispheres
from brainspace.utils.parcellation import map_to_labels
kernels = [‘pearson’, ‘spearman’, ‘normalized_angle’]
gradients_kernel = [None] * len(kernels)
for i, k in enumerate(kernels):
gm = GradientMaps(kernel=k, approach=‘dm’, random_state=0)
gm.fit(conn_matrix)
gradients_kernel[i] = map_to_labels(gm.gradients_[:, i], labeling, mask=mask,fill=np.nan)
label_text = [‘Pearson’, ‘Spearman’, ‘Normalized\nAngle’]
plot_hemispheres(surf_lh, surf_rh, array_name=gradients_kernel, size=(1200, 600),cmap=‘viridis_r’, color_bar=True, label_text=label_text, zoom=1.45)
Thank you very much for your time and assistance.
Soheil
