Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MRG: Update backend parameter in stc.plot() #8395

Merged
merged 7 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/changes/latest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,5 @@ API changes
- The ``n_pca_components`` argument of :class:`~mne.preprocessing.ICA` has been deprecated, use ``n_pca_components`` in :meth:`~mne.preprocessing.ICA.apply` by `Eric Larson`_ (:gh:`8356`)

- The ``trans`` argument of :func:`mne.extract_label_time_course` is deprecated and will be removed in 0.23 as it is no longer necessary by `Eric Larson`_

- Update the ``backend`` parameter of :func:`mne.viz.plot_source_estimates` to integrate ``pyvista`` by `Guillaume Favelier`_
12 changes: 8 additions & 4 deletions mne/viz/_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1701,9 +1701,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 @@ -1747,11 +1747,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