- MNE version: e.g. 0.24.0
- operating system: macOS 12
Hi, everyone. add_head() method in mne.viz.Brain yielded TypeError. I would like to know what is causing this.
Here is an example. I got TypeError after following the example in mne.
import os.path as op
import matplotlib.pyplot as plt
import matplotlib as mpl
import mne
from mne.datasets import sample
brain_kwargs = dict(alpha=0.1, background='white', cortex='low_contrast')
brain = mne.viz.Brain('sample', subjects_dir=subjects_dir, **brain_kwargs)
stc = mne.read_source_estimate(op.join(sample_dir, 'sample_audvis-meg'))
stc.crop(0.09, 0.1)
kwargs = dict(fmin=stc.data.min(), fmax=stc.data.max(), alpha=0.25,
smoothing_steps='nearest', time=stc.times)
brain.add_head()
brain.show_view(distance=500,view='sagittal')
The detailed description of the error is:
TypeError Traceback (most recent call last)
Input In [31], in <cell line: 2>()
1 from matplotlib import pyplot as plt
----> 2 brain.add_head()
3 brain.show_view(distance=500,view=‘sagittal’)
File ~/opt/anaconda3/envs/3dbrain/lib/python3.9/site-packages/mne/viz/_brain/_brain.py:2421, in Brain.add_head(self, dense, color, alpha)
2418 color = _to_rgb(color, alpha, alpha=True)
2420 for _ in self._iter_views(‘vol’):
→ 2421 actor, _ = self._renderer.mesh(
2422 *verts.T, triangles=triangles, color=color,
2423 opacity=alpha, reset_camera=False, render=False)
2424 self._add_actor(‘head’, actor)
2426 self._renderer._update()
File ~/opt/anaconda3/envs/3dbrain/lib/python3.9/site-packages/mne/viz/backends/_pyvista.py:333, in PyVistaRenderer.mesh(self, x, y, z, triangles, color, opacity, shading, backface_culling, scalars, colormap, vmin, vmax, interpolate_before_map, representation, line_width, normals, polygon_offset, **kwargs)
331 triangles = np.c[np.full(len(triangles), 3), triangles]
332 mesh = PolyData(vertices, triangles)
→ 333 return self.polydata(
334 mesh=mesh,
335 color=color,
336 opacity=opacity,
337 normals=normals,
338 backface_culling=backface_culling,
339 scalars=scalars,
340 colormap=colormap,
341 vmin=vmin,
342 vmax=vmax,
343 interpolate_before_map=interpolate_before_map,
344 representation=representation,
345 line_width=line_width,
346 polygon_offset=polygon_offset,
347 **kwargs,
348 )
File ~/opt/anaconda3/envs/3dbrain/lib/python3.9/site-packages/mne/viz/backends/_pyvista.py:304, in _PyVistaRenderer.polydata(self, mesh, color, opacity, normals, backface_culling, scalars, colormap, vmin, vmax, interpolate_before_map, representation, line_width, polygon_offset, **kwargs)
302 rgba = kwargs[“rgba”]
303 kwargs.pop(‘rgba’)
→ 304 actor = _add_mesh(
305 plotter=self.plotter,
306 mesh=mesh, color=color, scalars=scalars,
307 rgba=rgba, opacity=opacity, cmap=colormap,
308 backface_culling=backface_culling,
309 rng=[vmin, vmax], show_scalar_bar=False,
310 smooth_shading=self.figure.smooth_shading,
311 interpolate_before_map=interpolate_before_map,
312 style=representation, line_width=line_width, **kwargs,
313 )
315 if polygon_offset is not None:
316 mapper = actor.GetMapper()
File ~/opt/anaconda3/envs/3dbrain/lib/python3.9/site-packages/mne/viz/backends/_pyvista.py:881, in _add_mesh(plotter, *args, **kwargs)
879 if ‘render’ not in kwargs and ‘render’ in _get_args(plotter.add_mesh):
880 kwargs[‘render’] = False
→ 881 actor = plotter.add_mesh(*args, **kwargs)
882 if smooth_shading and ‘Normals’ in _point_data(mesh):
883 prop = actor.GetProperty()
File ~/opt/anaconda3/envs/3dbrain/lib/python3.9/site-packages/pyvista/plotting/plotting.py:2175, in BasePlotter.add_mesh(self, mesh, color, style, scalars, clim, show_edges, edge_color, point_size, line_width, opacity, flip_scalars, lighting, n_colors, interpolate_before_map, cmap, label, reset_camera, scalar_bar_args, show_scalar_bar, multi_colors, name, texture, render_points_as_spheres, render_lines_as_tubes, smooth_shading, split_sharp_edges, ambient, diffuse, specular, specular_power, nan_color, nan_opacity, culling, rgb, categories, silhouette, use_transparency, below_color, above_color, annotations, pickable, preference, log_scale, pbr, metallic, roughness, render, component, **kwargs)
2172 prop.EdgeVisibilityOn()
2174 rgb_color = parse_color(color, default_color=self._theme.color)
→ 2175 prop.SetColor(rgb_color)
2176 if isinstance(opacity, (float, int)):
2177 prop.SetOpacity(opacity)
TypeError: SetColor argument 1: expected a sequence of 3 values, got 4 values