Skip to content

Commit

Permalink
MRG: Update backend parameter in stc.plot() (mne-tools#8395)
Browse files Browse the repository at this point in the history
* Deprecate backend parameter

* Skip if any 3d backend is available

* Revert "Skip if any 3d backend is available"

This reverts commit 6e6f9ba.

* Revert "Deprecate backend parameter"

This reverts commit 37839d2.

* Update backend parameter

* Improve coverage

* Update changelog
  • Loading branch information
GuillaumeFavelier authored Oct 22, 2020
1 parent 6934034 commit 71dd449
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
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

0 comments on commit 71dd449

Please sign in to comment.