MICA-MNI / BrainSpace

BrainSpace is an open-access toolbox that allows for the identification and analysis of gradients from neuroimaging and connectomics datasets | available in both Python and Matlab |
http://brainspace.readthedocs.io
BSD 3-Clause "New" or "Revised" License
183 stars 73 forks source link

color_range option not able to specify #34

Closed karan-ganguly closed 3 years ago

karan-ganguly commented 3 years ago

HI, Cool toolbox! I'm not able to set the color_range option for visualization in python. The following line works. plot_hemispheres(surf_lh, surf_rh, array_name=grad, cmap='viridis_r', color_bar=True, label_text=label_text)

But adding color_range= (-0.3, 0.3 ) gived vtk related errors.

Traceback (most recent call last): File "", line 1, in "... brainspace/vtk_interface/decorators.py", line 175, in _wrapper_wrap data = func(args, kwds) "... brainspace/plotting/surface_plotting.py", line 360, in plot_hemispheres interactive=interactive, embed_nb=embed_nb, kwargs) "... brainspace/plotting/surface_plotting.py", line 204, in plot_surf p = Plotter(kwargs) "... brainspace/plotting/base.py", line 437, in init iren=iren, offscreen=offscreen, kwargs) "... brainspace/vtk_interface/decorators.py", line 175, in _wrapper_wrap data = func(args, kwds) "... brainspace/plotting/base.py", line 217, in init self.ren_win.setVTK(kwargs) "... brainspace/vtk_interface/base.py", line 380, in setVTK self._handle_call('set', k, v) "... brainspace/vtk_interface/base.py", line 285, in _handle_call method = self.vtk_map[key][name.lower()]

OualidBenkarim commented 3 years ago

Cannot tell what the problem might be. I can look at it if you can provide some more code

Here's is an example that works fine from tutorial 1, just added color_range


from brainspace.datasets import load_group_fc, load_parcellation, load_conte69
from brainspace.gradient import GradientMaps
from brainspace.utils.parcellation import map_to_labels
from brainspace.plotting import plot_hemispheres

conn_matrix = load_group_fc('schaefer', scale=400)
labeling = load_parcellation('schaefer', scale=400, join=True)

surf_lh, surf_rh = load_conte69()

gm = GradientMaps(n_components=10, random_state=0)
gm.fit(conn_matrix)

mask = labeling != 0
grad = [None] * 2
for i in range(2):
    grad[i] = map_to_labels(gm.gradients_[:, i], labeling, mask=mask, fill=np.nan)

plot_hemispheres(surf_lh, surf_rh, array_name=grad, size=(1200, 400), cmap='viridis_r',
                 color_bar=True, label_text=['Grad1', 'Grad2'], zoom=1.55, color_range=(-0.3, 0.3))