Skip to content

Commit 35662d0

Browse files
WIP: Fix bugs in Brain (#8361)
* Update _add_mesh * Update mne/viz/backends/_pyvista.py Co-authored-by: Eric Larson <larson.eric.d@gmail.com> * Show the plotter when ready * Remove empty line * Fix save_movie action * Fix show Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
1 parent d86b7f9 commit 35662d0

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

mne/viz/_3d.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1839,7 +1839,7 @@ def _plot_stc(stc, subject, surface, hemi, colormap, time_label,
18391839
"views": views, "alpha": brain_alpha,
18401840
}
18411841
if backend in ['pyvista', 'notebook']:
1842-
kwargs["show"] = not time_viewer
1842+
kwargs["show"] = False
18431843
kwargs["view_layout"] = view_layout
18441844
else:
18451845
kwargs.update(_check_pysurfer_antialias(Brain))
@@ -1951,6 +1951,9 @@ def _plot_stc(stc, subject, surface, hemi, colormap, time_label,
19511951
else: # PyVista
19521952
from ._brain import _TimeViewer as TimeViewer
19531953
TimeViewer(brain, show_traces=show_traces)
1954+
else:
1955+
if not using_mayavi:
1956+
brain.show()
19541957

19551958
return brain
19561959

mne/viz/_brain/_timeviewer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def frame_callback(frame, n_frames):
233233
self.brain.save_movie(
234234
filename=filename,
235235
time_dilation=(1. / self.playback_speed),
236-
callback=frame_callback,
236+
callback=partial(frame_callback, fname=None),
237237
**kwargs
238238
)
239239
except (Exception, KeyboardInterrupt):

mne/viz/backends/_pyvista.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from .base_renderer import _BaseRenderer
2424
from ._utils import _get_colormap_from_array, ALLOWED_QUIVER_MODES
25+
from ...fixes import _get_args
2526
from ...utils import copy_base_doc_to_subclass_doc, _check_option
2627
from ...externals.decorator import decorator
2728

@@ -658,6 +659,10 @@ def _add_mesh(plotter, *args, **kwargs):
658659
smooth_shading = kwargs.pop('smooth_shading')
659660
else:
660661
smooth_shading = True
662+
# disable rendering pass for add_mesh, render()
663+
# is called in show()
664+
if 'render' not in kwargs and 'render' in _get_args(plotter.add_mesh):
665+
kwargs['render'] = False
661666
actor = plotter.add_mesh(*args, **kwargs)
662667
if smooth_shading and 'Normals' in mesh.point_arrays:
663668
prop = actor.GetProperty()

0 commit comments

Comments
 (0)