Value Error when plotting source estimates (stc.plot)

Hello,

I’m trying to plot source estimates and getting the the following value error:


In [46]: brain = stc.plot(
    ...:     subject=subject, 
    ...:     subjects_dir=subjects_dir, 
    ...:     initial_time=0.1,
    ...:     )
Using control points [2.20729315 2.39808605 3.85679797]
Traceback (most recent call last):

  File "/var/folders/b9/9yyh_p_j1ns_3029525bq5y9d57vt1/T/ipykernel_11947/1984105511.py", line 1, in <cell line: 1>
    brain = stc.plot(

  File "/Applications/MNE-Python/.mne-python/lib/python3.10/site-packages/mne/source_estimate.py", line 650, in plot
    brain = plot_source_estimates(

  File "<decorator-gen-174>", line 12, in plot_source_estimates

  File "/Applications/MNE-Python/.mne-python/lib/python3.10/site-packages/mne/viz/_3d.py", line 1924, in plot_source_estimates
    return _plot_stc(

  File "/Applications/MNE-Python/.mne-python/lib/python3.10/site-packages/mne/viz/_3d.py", line 1995, in _plot_stc
    brain = Brain(**kwargs)

  File "/Applications/MNE-Python/.mne-python/lib/python3.10/site-packages/mne/viz/_brain/_brain.py", line 550, in __init__
    mesh.add_overlay(

  File "/Applications/MNE-Python/.mne-python/lib/python3.10/site-packages/mne/viz/_brain/_brain.py", line 173, in add_overlay
    self._apply()

  File "/Applications/MNE-Python/.mne-python/lib/python3.10/site-packages/mne/viz/_brain/_brain.py", line 189, in _apply
    self._renderer._set_mesh_scalars(

  File "/Applications/MNE-Python/.mne-python/lib/python3.10/site-packages/mne/viz/backends/_pyvista.py", line 740, in _set_mesh_scalars
    _point_data(mesh)[name] = scalars

  File "/Applications/MNE-Python/.mne-python/lib/python3.10/site-packages/pyvista/core/datasetattributes.py", line 218, in __setitem__
    self.set_array(value, name=key)

  File "/Applications/MNE-Python/.mne-python/lib/python3.10/site-packages/pyvista/core/datasetattributes.py", line 597, in set_array
    vtk_arr = self._prepare_array(data, name, deep_copy)

  File "/Applications/MNE-Python/.mne-python/lib/python3.10/site-packages/pyvista/core/datasetattributes.py", line 751, in _prepare_array
    raise ValueError(f'data length of ({data.shape[0]}) != required length ({array_len})')

ValueError: data length of (158257) != required length (159040)

I am using the following:

  • MNE version:1.0.3
  • operating system: macOS 10.14.6

Any idea what the issue could be? Advice would be greatly appreciated :slight_smile:

hi,

Can you check that the stc matches the subject for plotting?

Alex

Hi Alex- thanks for your response. Yes, stc.subject and subject are the same.

I don’t see any other possible cause for this.

How did you produce the overlay array?

Alex