Skip to content

backend parameter of viz._3d.plot_source_estimates needs some love #8394

@hoechenberger

Description

@hoechenberger

Describe the bug

Passing backend='pyvista' to plot_source_estimates() currently is not supported, although we do support PyVista:

_check_option('backend', backend, ['auto', 'matplotlib', 'mayavi'])

Also, the backend parameter is not used for anything except for checking whether we should use Matplotlib or not; if backend != 'matplotlib', we simply use _get_3d_backend() to retrieve the backend to use. This means that e.g.if you have PyVista installed, passing backend='mayavi' will still use the pyvista backend.

mne-python/mne/viz/_3d.py

Lines 1751 to 1762 in 6f16c37

plot_mpl = backend == 'matplotlib'
if not plot_mpl:
try:
set_3d_backend(_get_3d_backend())
except (ImportError, ModuleNotFoundError):
if backend == 'auto':
warn('No 3D backend found. Resorting to matplotlib 3d.')
plot_mpl = True
else: # 'mayavi'
raise
else:
backend = _get_3d_backend()

Expected results

  • backend should be allowed to be 'pyvista' as well
  • the value of backend should be honored

Additional information

Also wondering if the backend param should be deprecated or changed. Maybe it could only support matplotlib and 3d or so, and 3d would select the default 3D backend?

Or we deprecate it and if we cannot detect a valid 3D backend, we fall back to Matplotlib. (We already kind of do that, if I'm reading the code correctly)

cc @GuillaumeFavelier

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions