Skip to content

Commit

Permalink
API: Change name to qt (mne-tools#10323)
Browse files Browse the repository at this point in the history
* API: Change name to qt

* FIX: Links [skip azp] [skip actions]
  • Loading branch information
larsoner authored Feb 11, 2022
1 parent 356dde9 commit 3ccb6c0
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 49 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ stages:
- script: python -c "import mne; mne.datasets.testing.data_path(verbose=True)"
displayName: 'Get test data'
- script: pytest -m "ultraslowtest or pgtest" --tb=short --cov=mne --cov-report=xml --cov-report=html -vv mne
displayName: 'Run ultraslow and PyQtGraph mne-qt-browser tests'
displayName: 'Run ultraslow and mne-qt-browser tests'
- bash: bash <(curl -s https://codecov.io/bash)
displayName: 'Codecov'
condition: succeededOrFailed()
Expand Down
2 changes: 2 additions & 0 deletions doc/changes/latest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ API changes
- The ``verbose`` attribute of classes (e.g., :class:`mne.io.Raw`, `mne.Epochs`, etc.) has been deprecated. Explicitly pass ``verbose`` to methods as necessary instead. (:gh:`10267` by `Eric Larson`_)
- In :func:`mne.viz.set_browser_backend`, the `mne-qt-browser <https://github.com/mne-tools/mne-qt-browser>`__-based backend is now called ``'qt'`` rather than ``'pyqtgraph'`` for simplicity (:gh:`10323` by `Eric Larson`_)
Dependencies
~~~~~~~~~~~~
Numerous external dependencies that used to be bundled with MNE-Python are now
Expand Down
6 changes: 3 additions & 3 deletions mne/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,19 +408,19 @@ def _check_pyqtgraph():
def pg_backend(garbage_collect):
"""Use for pyqtgraph-specific test-functions."""
_check_pyqtgraph()
with use_browser_backend('pyqtgraph') as backend:
with use_browser_backend('qt') as backend:
yield backend
backend._close_all()


@pytest.fixture(params=[
'matplotlib',
pytest.param('pyqtgraph', marks=pytest.mark.pgtest),
pytest.param('qt', marks=pytest.mark.pgtest),
])
def browser_backend(request, garbage_collect):
"""Parametrizes the name of the browser backend."""
backend_name = request.param
if backend_name == 'pyqtgraph':
if backend_name == 'qt':
_check_pyqtgraph()
with use_browser_backend(backend_name) as backend:
yield backend
Expand Down
6 changes: 3 additions & 3 deletions mne/utils/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1575,15 +1575,15 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75):
.. versionadded:: 0.24
"""

# Visualization with pyqtgraph
# Visualization with Qt
docdict['precompute'] = """
precompute : bool | str
Whether to load all data (not just the visible portion) into RAM and
apply preprocessing (e.g., projectors) to the full data array in a separate
processor thread, instead of window-by-window during scrolling. The default
``'auto'`` compares available RAM space to the expected size of the
precomputed data, and precomputes only if enough RAM is available. ``True``
and ``'auto'`` only work if using the PyQtGraph backend.
and ``'auto'`` only work if using the Qt backend.
.. versionadded:: 0.24
"""
Expand All @@ -1592,7 +1592,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75):
use_opengl : bool | None
Whether to use OpenGL when rendering the plot (requires ``pyopengl``).
May increase performance, but effect is dependent on system CPU and
graphics hardware. Only works if using the PyQtGraph backend. Default is
graphics hardware. Only works if using the Qt backend. Default is
None, which will use False unless the user configuration variable
``MNE_BROWSER_USE_OPENGL`` is set to ``'true'``,
see :func:`mne.set_config`.
Expand Down
62 changes: 33 additions & 29 deletions mne/viz/_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def _process_data(self, data, start, stop, picks,
"""Update self.mne.data after user interaction."""
# apply projectors
if self.mne.projector is not None:
# thread is the loading-thread only available in pyqtgraph-backend
# thread is the loading-thread only available in Qt-backend
if thread:
thread.processText.emit('Applying Projectors...')
data = self.mne.projector @ data
Expand Down Expand Up @@ -618,6 +618,8 @@ def _get_browser(**kwargs):

def _check_browser_backend_name(backend_name):
_validate_type(backend_name, str, 'backend_name')
backend_name = backend_name.lower()
backend_name = 'qt' if backend_name == 'pyqtgraph' else backend_name
_check_option('backend_name', backend_name, VALID_BROWSE_BACKENDS)
return backend_name

Expand All @@ -633,7 +635,9 @@ def set_browser_backend(backend_name, verbose=None):
----------
backend_name : str
The 2D browser backend to select. See Notes for the capabilities
of each backend (``'matplotlib'``, ``'pyqtgraph'``).
of each backend (``'matplotlib'``, ``'qt'``). The ``'qt'`` browser
requires `mne-qt-browser
<https://github.com/mne-tools/mne-qt-browser>`__.
%(verbose)s
Returns
Expand All @@ -649,32 +653,32 @@ def set_browser_backend(backend_name, verbose=None):
.. table::
:widths: auto
+--------------------------------------+------------+-----------+
| **2D browser function:** | matplotlib | pyqtgraph |
+======================================+============+===========+
| :func:`plot_raw` | ✓ | ✓ |
+--------------------------------------+------------+-----------+
| :func:`plot_epochs` | ✓ | |
+--------------------------------------+------------+-----------+
| :func:`plot_ica_sources` | ✓ | |
+--------------------------------------+------------+-----------+
+--------------------------------------+------------+-----------+
| **Feature:** |
+--------------------------------------+------------+-----------+
| Show Events | ✓ | ✓ |
+--------------------------------------+------------+-----------+
| Add/Edit/Remove Annotations | ✓ | ✓ |
+--------------------------------------+------------+-----------+
| Toggle Projections | ✓ | ✓ |
+--------------------------------------+------------+-----------+
| Butterfly Mode | ✓ | ✓ |
+--------------------------------------+------------+-----------+
| Selection Mode | ✓ | ✓ |
+--------------------------------------+------------+-----------+
| Smooth Scrolling | | ✓ |
+--------------------------------------+------------+-----------+
| Overview-Bar (with Z-Score-Mode) | | ✓ |
+--------------------------------------+------------+-----------+
+--------------------------------------+------------+----+
| **2D browser function:** | matplotlib | qt |
+======================================+============+====+
| :func:`plot_raw` | ✓ | ✓ |
+--------------------------------------+------------+----+
| :func:`plot_epochs` | ✓ | |
+--------------------------------------+------------+----+
| :func:`plot_ica_sources` | ✓ | |
+--------------------------------------+------------+----+
+--------------------------------------+------------+----+
| **Feature:** |
+--------------------------------------+------------+----+
| Show Events | ✓ | ✓ |
+--------------------------------------+------------+----+
| Add/Edit/Remove Annotations | ✓ | ✓ |
+--------------------------------------+------------+----+
| Toggle Projections | ✓ | ✓ |
+--------------------------------------+------------+----+
| Butterfly Mode | ✓ | ✓ |
+--------------------------------------+------------+----+
| Selection Mode | ✓ | ✓ |
+--------------------------------------+------------+----+
| Smooth Scrolling | | ✓ |
+--------------------------------------+------------+----+
| Overview-Bar (with Z-Score-Mode) | | ✓ |
+--------------------------------------+------------+----+
.. versionadded:: 0.24
"""
Expand Down Expand Up @@ -742,7 +746,7 @@ def use_browser_backend(backend_name):
Parameters
----------
backend_name : {'matplotlib', 'pyqtgraph'}
backend_name : {'matplotlib', 'qt'}
The 2D browser backend to use in the context.
"""
old_backend = set_browser_backend(backend_name)
Expand Down
2 changes: 1 addition & 1 deletion mne/viz/backends/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

VALID_BROWSE_BACKENDS = (
'matplotlib',
'pyqtgraph'
'qt',
)

VALID_3D_BACKENDS = (
Expand Down
8 changes: 4 additions & 4 deletions mne/viz/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def plot_raw(raw, events=None, duration=10.0, start=0.0, n_channels=20,
Whether to halt program execution until the figure is closed.
Useful for setting bad channels on the fly by clicking on a line.
May not work on all systems / platforms.
(Only pyqtgraph) If you run from a script, this needs to
(Only Qt) If you run from a script, this needs to
be ``True`` or a Qt-eventloop needs to be started somewhere
else in the script (e.g. if you want to implement the browser
inside another Qt-Application).
Expand Down Expand Up @@ -193,9 +193,9 @@ def plot_raw(raw, events=None, duration=10.0, start=0.0, n_channels=20,
By default, the channel means are removed when ``remove_dc`` is set to
``True``. This flag can be toggled by pressing 'd'.
.. note:: For the pyqtgraph backend to run in IPython with ``block=False``
.. note:: For the Qt backend to run in IPython with ``block=False``
you must run the magic command ``%%gui qt5`` first.
.. note:: To report issues with the pyqtgraph-backend, please use the
.. note:: To report issues with the qt-backend, please use the
`issues <https://github.com/mne-tools/mne-qt-browser/issues>`_
of ``mne-qt-browser``.
"""
Expand Down Expand Up @@ -346,7 +346,7 @@ def plot_raw(raw, events=None, duration=10.0, start=0.0, n_channels=20,
scalebars_visible=show_scalebars,
window_title=title,
bgcolor=bgcolor,
# pyqtgraph-specific
# Qt-specific
precompute=precompute,
use_opengl=use_opengl)

Expand Down
14 changes: 7 additions & 7 deletions mne/viz/tests/test_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _annotation_helper(raw, browse_backend, events=False):
fig._fake_click(xy, fig=ann_fig, ax=ann_fig.mne.radio_ax,
xform='data')
else:
# The modal dialogs of the pyqtgraph-backend would block the test,
# The modal dialogs of the Qt-backend would block the test,
# thus a new description will be added programmatically.
ann_fig._add_description('BAD test')

Expand Down Expand Up @@ -272,7 +272,7 @@ def test_plot_raw_selection(raw, browser_backend):
assert len(fig.mne.traces) == len(sel_dict['Misc']) # 1
# switch to butterfly mode
fig._fake_keypress('b', fig=sel_fig)
# ToDo: For pyqtgraph-backend the framework around RawTraceItem makes
# ToDo: For Qt-backend the framework around RawTraceItem makes
# it difficult to show the same channel multiple times which is why
# it is currently not implemented.
# This would be relevant if you wanted to plot several selections in
Expand Down Expand Up @@ -318,7 +318,7 @@ def test_plot_raw_selection(raw, browser_backend):
fig._click_ch_name(ch_index=1, button=1) # mark good
assert lasso.ec[:, 0].sum() == 0 # all channels black
# test lasso
# Testing lasso-interactivity of sensor-plot within pyqtgraph-backend
# Testing lasso-interactivity of sensor-plot within Qt-backend
# with QTest doesn't seem to work.
want = ['MEG 0121', 'MEG 0122', 'MEG 0123']
if ismpl:
Expand Down Expand Up @@ -387,7 +387,7 @@ def test_plot_raw_child_figures(raw, browser_backend):
# test child fig toggles
_child_fig_helper(fig, '?', 'fig_help', browser_backend)
_child_fig_helper(fig, 'j', 'fig_proj', browser_backend)
# In pyqtgraph, this is a dock-widget instead of a separated window.
# In Qt, this is a dock-widget instead of a separated window.
if ismpl:
_child_fig_helper(fig, 'a', 'fig_annotation', browser_backend)
assert len(fig.mne.child_figs) == 0 # make sure the helper cleaned up
Expand Down Expand Up @@ -478,7 +478,7 @@ def test_plot_raw_traces(raw, events, browser_backend):
assert labels == [raw.ch_names[5], raw.ch_names[2], raw.ch_names[3]]
for _ in (0, 0):
# first click changes channels to mid; second time shouldn't change
# This needs to be changed for pyqtgraph, because there scrollbars are
# This needs to be changed for Qt, because there scrollbars are
# drawn differently (value of slider at lower end, not at middle)
yclick = 0.5 if ismpl else 0.7
fig._fake_click((0.5, yclick), ax=vscroll)
Expand Down Expand Up @@ -531,7 +531,7 @@ def test_plot_raw_groupby(raw, browser_backend, group_by):
fig._fake_click((0.5, 0.5), ax=fig.mne.ax_vscroll) # change channels
if browser_backend.name == 'matplotlib':
# Test lasso-selection
# (test difficult with pyqtgraph-backend, set plot_raw_selection)
# (test difficult with Qt-backend, set plot_raw_selection)
sel_fig = fig.mne.fig_selection
topo_ax = sel_fig.mne.sensor_ax
fig._fake_click([-0.425, 0.20223853], fig=sel_fig, ax=topo_ax,
Expand Down Expand Up @@ -662,7 +662,7 @@ def test_remove_annotations(raw, hide_which, browser_backend):
def test_plot_raw_filtered(filtorder, raw, browser_backend):
"""Test filtering of raw plots."""
# Opening that many plots can cause a Segmentation fault
# if multithreading is activated in pyqtgraph-backend
# if multithreading is activated in Qt-backend
pg_kwargs = {'precompute': False}
with pytest.raises(ValueError, match='lowpass.*Nyquist'):
raw.plot(lowpass=raw.info['sfreq'] / 2., filtorder=filtorder,
Expand Down
2 changes: 1 addition & 1 deletion mne/viz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _show_browser(show=True, block=True, fig=None, **kwargs):
block : bool
If to block execution on showing.
fig : instance of Figure | None
Needs to be passed for pyqtgraph backend,
Needs to be passed for Qt backend,
optional for matplotlib.
**kwargs : dict
Extra arguments for :func:`matplotlib.pyplot.show`.
Expand Down

0 comments on commit 3ccb6c0

Please sign in to comment.