Skip to main content

A new backend based on pyqtgraph for the 2D-Data-Browser in MNE-Python

Project description

mne-qt-browser

A new backend based on pyqtgraph for the 2D-Data-Browser in MNE-Python.

Screenshot of mne-qt-browser

This repository hosts the code for an alternative backend for plotting 2D-Data with MNE-Python.

The backend is based on pyqtgraph which uses Qt's Graphics View Framework for the plotting. Development started as a 2021's Google Summer of Code Project.

Installation

Install full MNE-Python version 1.0 or greater with the instructions provided here or install minimal MNE-Python with

pip

pip install "mne>=1.0" matplotlib mne-qt-browser

or

conda

conda install -c conda-forge mne-base matplotlib mne-qt-browser

Update

Refer to the MNE-Python documentation for updating MNE-Python. To update this package, do:

pip install -U mne-qt-browser

To update this package to the development version, do:

pip install -U --no-deps https://github.com/mne-tools/mne-qt-browser/archive/refs/heads/main.zip

Usage

The backend supports plotting for the following MNE-Python methods:

In the following example, we'll read M/EEG raw data from the MNE sample dataset and plot it using the qt-backend. (For mne-version >= 1.0 the qt-backend will be the default)

from pathlib import Path
import mne

sample_dir = mne.datasets.sample.data_path()
raw_path = Path(sample_dir) / 'MEG' / 'sample' / 'sample_audvis_raw.fif'
raw = mne.io.read_raw(raw_path)

mne.viz.set_browser_backend('qt')  # Enable mne-qt-browser backend if mne < 1.0
raw.plot(block=True)

If the plot is not showing, search for solutions in the troubleshooting section below.

This will use the mne-qt-browser for the current Python session. If you want to make this change permanent, so you don't have to use the set_browser_backend() each time after restarting Python, run the following line to modify your MNE configuration file:

import mne
mne.set_config('MNE_BROWSER_BACKEND', 'qt')

Troubleshooting

Running from a script

If you are running a script containing raw.plot() like

python example_script.py

the plot will not stay open when the script is done.

To solve this either change raw.plot() to raw.plot(block=True) or run the script with the interactive flag

python -i example_script.py

IPython

If the integration of the Qt event loop is not activated for IPython, a plot with raw.plot() will freeze. Do avoid that either change raw.plot() to raw.plot(block=True) or activate the integration of the event loop with

%gui qt5

Report Bugs & Feature Requests

Please report bugs and feature requests in the issues of this repository.

Development and testing

You can run a benchmark locally with:

pytest -m benchmark mne_qt_browser

To run the PyQtGraph tests you have to run:

pytest mne_qt_browser/tests/test_pg_specific.py

Additionally, clone mne-python, and then run:

pytest -m pgtest ../mne-python/mne/viz/tests

If you do not have OpenGL installed, this will currently raise errors, and you'll need to add this line to mne/conftest.py after the error:: line:

    ignore:.*PyOpenGL was not found.*:RuntimeWarning

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mne_qt_browser-0.6.3.tar.gz (60.7 kB view details)

Uploaded Source

Built Distribution

mne_qt_browser-0.6.3-py3-none-any.whl (76.1 kB view details)

Uploaded Python 3

File details

Details for the file mne_qt_browser-0.6.3.tar.gz.

File metadata

  • Download URL: mne_qt_browser-0.6.3.tar.gz
  • Upload date:
  • Size: 60.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.4

File hashes

Hashes for mne_qt_browser-0.6.3.tar.gz
Algorithm Hash digest
SHA256 22bac360d9adb0143c5b768dca04138eaf19b571d8e6bf24684fc9b56f730278
MD5 07c16ce17b0b476b52f2ee779e2cf653
BLAKE2b-256 c3e8b88c4893c8cc05d4b95770cac93a6ebe406eb812b46d1b44079422c63962

See more details on using hashes here.

File details

Details for the file mne_qt_browser-0.6.3-py3-none-any.whl.

File metadata

File hashes

Hashes for mne_qt_browser-0.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b865ae2d36344e33d9b10fb14074b322d9e762131f46a7b6e2a389c713069e83
MD5 71ef22828c04540d2f10682ede8d83ea
BLAKE2b-256 fb4e3535911f725155f5511e430cb26f15773213f2018404bac6c33e4cb29948

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page