MICA-MNI / ENIGMA

The ENIGMA Toolbox is an open-source repository for accessing 100+ ENIGMA statistical maps, visualizing cortical and subcortical surface data, and relating neuroimaging findings to micro- and macroscale brain organization. 🤠
https://enigma-toolbox.readthedocs.io
BSD 3-Clause "New" or "Revised" License
128 stars 31 forks source link

subcortical plotting with 2D array #21

Closed ethompson93 closed 1 year ago

ethompson93 commented 1 year ago

Hi, firstly thanks so much for making this great toolbox!

I'm having an issue plotting multiple subcortical maps at once (ie. plotting each row of an array on a different row in the figure). I've done the same with cortical data and it works no problem, so I'm wondering if it's a bug in the code. My command is below, where subcortical_arr is a numpy array of shape (5,14):

plot_subcortical(array_name=subcortical_arr, ventricles=False, size=(800, 400), color_bar=True,
                 interactive=False, embed_nb=True, color_range=(0.2, 0.8))

I get this error message:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [53], in <cell line: 1>()
----> 1 plot_subcortical(array_name=subcortical_arr, ventricles=False, size=(800, 400), color_bar=True,
      2                  interactive=False, embed_nb=True, color_range=(0.2, 0.8))

File /opt/miniconda3/lib/python3.9/site-packages/enigmatoolbox-2.0.2-py3.9.egg/enigmatoolbox/plotting/surface_plotting.py:640, in plot_subcortical(array_name, ventricles, color_bar, color_range, label_text, cmap, nan_color, zoom, background, size, interactive, embed_nb, screenshot, filename, scale, transparent_bg, **kwargs)
    638 for an in array_name:
    639     if isinstance(an, np.ndarray):
--> 640         name = surf_lh.append_array(an[:n_pts_lh], at='p')
    641         surf_rh.append_array(an[n_pts_lh:], name=name, at='p')
    642         array_name2.append(name)

File /opt/miniconda3/lib/python3.9/site-packages/enigmatoolbox-2.0.2-py3.9.egg/enigmatoolbox/vtk_interface/wrappers/data_object.py:213, in BSDataSet.append_array(self, array, name, at, convert_bool, overwrite)
    210         raise ValueError('Array shape is not valid.')
    212 if at in ['point', 'p']:
--> 213     _array_overwrite(self.PointData, to_point)
    214 elif at in ['cell', 'c']:
    215     _array_overwrite(self.CellData, to_cell)

File /opt/miniconda3/lib/python3.9/site-packages/enigmatoolbox-2.0.2-py3.9.egg/enigmatoolbox/vtk_interface/wrappers/data_object.py:210, in BSDataSet.append_array.<locals>._array_overwrite(attributes, has_same_shape)
    207         warnings.warn('Array was not appended. Array name already '
    208                       'exists.')
    209 else:
--> 210     raise ValueError('Array shape is not valid.')

ValueError: Array shape is not valid.

Any help would be much appreciated, thanks!

saratheriver commented 1 year ago

Hi, unfortunately this isn't an option yet (like it is for plot_cortical). Thanks for pointing this out, though, we'll think about adding this feature in the next release. In the meantime, what I do, is to generate them separately and combine them in gimp.