Skip to content

Commit

Permalink
Fix backend='pyvista' in stc.plot() (#8395) (#8417)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoechenberger committed Oct 24, 2020
1 parent 4eb2997 commit 74041b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions doc/changes/0.21.inc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Bugs

- Fix bug in :func:`mne.viz.plot_alignment` where ECoG and sEEG channels were not plotted and fNIRS channels were always plotted in the head coordinate frame by `Eric Larson`_ (:gh:`8393`)

- Fix bug in :func:`mne.viz.plot_source_estimates`, which wouldn't accept the valid parameter value ``backend='pyvista'``, by `Guillaume Favelier`_
.. _changes_0_21:
Version 0.21
Expand Down
12 changes: 8 additions & 4 deletions mne/viz/_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1703,9 +1703,9 @@ def plot_source_estimates(stc, subject=None, surface='inflated', hemi='lh',
time_unit : 's' | 'ms'
Whether time is represented in seconds ("s", default) or
milliseconds ("ms").
backend : 'auto' | 'mayavi' | 'matplotlib'
backend : 'auto' | 'mayavi' | 'pyvista' | 'matplotlib'
Which backend to use. If ``'auto'`` (default), tries to plot with
mayavi, but resorts to matplotlib if mayavi is not available.
pyvista, but resorts to matplotlib if no 3d backend is available.
.. versionadded:: 0.15.0
spacing : str
Expand Down Expand Up @@ -1749,11 +1749,15 @@ def plot_source_estimates(stc, subject=None, surface='inflated', hemi='lh',
subjects_dir = get_subjects_dir(subjects_dir=subjects_dir,
raise_error=True)
subject = _check_subject(stc.subject, subject, True)
_check_option('backend', backend, ['auto', 'matplotlib', 'mayavi'])
_check_option('backend', backend,
['auto', 'matplotlib', 'mayavi', 'pyvista'])
plot_mpl = backend == 'matplotlib'
if not plot_mpl:
try:
set_3d_backend(_get_3d_backend())
if backend == 'auto':
set_3d_backend(_get_3d_backend())
else:
set_3d_backend(backend)
except (ImportError, ModuleNotFoundError):
if backend == 'auto':
warn('No 3D backend found. Resorting to matplotlib 3d.')
Expand Down
1 change: 1 addition & 0 deletions mne/viz/tests/test_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ def test_plot_source_estimates(renderer_interactive, all_src_types_inv_evoked,
)
if pick_ori != 'vector':
kwargs['surface'] = 'white'
kwargs['backend'] = renderer_interactive._get_3d_backend()
# Mayavi can't handle non-surface
if kind != 'surface' and not is_pyvista:
with pytest.raises(RuntimeError, match='PyVista'):
Expand Down

0 comments on commit 74041b7

Please sign in to comment.