[BUG] `mne.viz.Brain` raises cryptic error when plotting 'seghead', works for `mne.viz.plot_alignment`
See original GitHub issueHere’s some minimally reproducible code:
import os.path as op
from mne.datasets import sample
import mne
data_path = sample.data_path()
sample_dir = op.join(data_path, 'MEG', 'sample')
subjects_dir = op.join(data_path, 'subjects')
evoked = mne.read_evokeds(op.join(sample_dir, 'sample_audvis-ave.fif'))[0]
trans = mne.read_trans(op.join(sample_dir, 'sample_audvis_raw-trans.fif'))
mne.viz.plot_alignment(evoked.info, trans, subject='sample', subjects_dir=subjects_dir, surfaces=['seghead']) # works
mne.viz.Brain('sample', 'lh', 'seghead', subjects_dir=subjects_dir) # raises error
Stack trace
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/alexrockhill/projects/mne-python/mne/viz/_brain/_brain.py", line 523, in __init__
mesh.add_overlay(
File "/Users/alexrockhill/projects/mne-python/mne/viz/_brain/_brain.py", line 178, in add_overlay
self._apply()
File "/Users/alexrockhill/projects/mne-python/mne/viz/_brain/_brain.py", line 194, in _apply
self._renderer._set_mesh_scalars(
File "/Users/alexrockhill/projects/mne-python/mne/viz/backends/_pyvista.py", line 699, in _set_mesh_scalars
mesh.point_arrays[name] = scalars
File "/Users/alexrockhill/software/anaconda3/envs/mne/lib/python3.9/site-packages/pyvista/core/datasetattributes.py", line 57, in __setitem__
self.append(narray=value, name=key)
File "/Users/alexrockhill/software/anaconda3/envs/mne/lib/python3.9/site-packages/pyvista/core/datasetattributes.py", line 211, in append
raise ValueError(f'narray length of ({narray.shape[0]}) != required length ({array_len})')
ValueError: narray length of (155407) != required length (267122)
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
mne.viz.plot_alignment — MNE 1.2.2 documentation
Plot head, sensor, and source space alignment in 3D. Parameters: info mne. ... For single layer BEMs it is recommended to use 'brain'...
Read more >[BUG] mne.viz.Brain volume rendering doesn't show up #10519
I thought about it a bit more and maybe a major refactoring isn't the best use of time either, since stc.plot and stc.plot_3d...
Read more >Problems running mne.viz.plot_alignment() from within Spyder
I'm trying to use mne.viz.plot_alignment (which doesn't have “block=” argument). The only way I've found to keep the plot window open is to...
Read more >Colorbar for mne.viz.plot_topomap ? Python - Stack Overflow
Here is the answer to this question: https://mne.discourse.group/t/mne-viz-plot-topomap-and-color-bar/3141/4.
Read more >Averaging ERPs: Creating MNE Evoked objects
import mne mne.set_log_level('error') # reduce extraneous MNE output # Participant ID ... We use the function mne.viz.plot_compare_evokeds() , which plots ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Can you open an issue for this and ping @GuillaumeFavelier to consider after the
coreg
class refactor is done at some point? One way to make this simple is to have each method return a list of VTK actors, and theBrain
instance can keep track internally of a list of actors it has added. Then we can just have abrain.remove(actors)
method that.pop
s each actor from the internal list and removes it from each plotter.I would really rather not add a new parameter to the Brain constructor, the signature is already too long. Plus there are options one might want to specify (which surface/density/filename, color, opacity) so a dedicated add_head method seems better to me
I would raise an error for surface=seghead, I’m not sure if there are other surfaces that are incompatible