Skip to content

Commit

Permalink
Make Inspector work even if mne-qt-browser is installed
Browse files Browse the repository at this point in the history
We now explicitly request a Matploblib plotting context for
bringing up the Inspector. Otherwise, our MNE will default to
using the qt-browser, and our current implementation of the
Inspector will fail to launch.
  • Loading branch information
hoechenberger committed May 15, 2022
1 parent 14dde85 commit 9c1ada9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Detailed list of changes

- Suppress superfluous warnings about MaxShield in many functions when handling Elekta/Neuromag/MEGIN data, by `Richard Höchenberger`_ (:gh:`1000`)

- The MNE-BIDS Inspector didn't work if ``mne-qt-browser`` was installed and used as the default plotting backend, as the Inspector currently only supports the Matplotlib backend, by `Richard Höchenberger`_ (:gh:`1007`)

:doc:`Find out what was new in previous releases <whats_new_previous_releases>`

.. include:: authors.rst
13 changes: 9 additions & 4 deletions mne_bids/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from mne.utils import logger, verbose
from mne.fixes import _compare_version
from mne.viz import use_browser_backend

if _compare_version(mne.__version__, '<', '1.0.dev0'): # pragma: no cover
from mne.preprocessing import annotate_flat
Expand Down Expand Up @@ -155,10 +156,14 @@ def _inspect_raw(*, bids_path, l_freq, h_freq, find_flat, show_annotations):
flat_chans = []

show_options = bids_path.datatype == 'meg'
fig = raw.plot(title=f'{bids_path.root.name}: {bids_path.basename}',
highpass=l_freq, lowpass=h_freq,
show_options=show_options,
block=False, show=False, verbose='warning')

with use_browser_backend('matplotlib'):
fig = raw.plot(
title=f'{bids_path.root.name}: {bids_path.basename}',
highpass=l_freq, lowpass=h_freq,
show_options=show_options,
block=False, show=False, verbose='warning'
)

# Add our own event handlers so that when the MNE Raw Browser is being
# closed, our dialog box will pop up, asking whether to save changes.
Expand Down

0 comments on commit 9c1ada9

Please sign in to comment.