From 9c1ada95055f9bc58946b4bb93cdce3c23e690b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20H=C3=B6chenberger?= Date: Sun, 15 May 2022 13:50:52 +0200 Subject: [PATCH] Make Inspector work even if mne-qt-browser is installed 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. --- doc/whats_new.rst | 2 ++ mne_bids/inspect.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/doc/whats_new.rst b/doc/whats_new.rst index f86c2fc0d..bda6a7b72 100644 --- a/doc/whats_new.rst +++ b/doc/whats_new.rst @@ -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 ` .. include:: authors.rst diff --git a/mne_bids/inspect.py b/mne_bids/inspect.py index 15df15189..0c6fec6b7 100644 --- a/mne_bids/inspect.py +++ b/mne_bids/inspect.py @@ -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 @@ -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.