raw.plot() slow or can't scroll/scrub

I’m having a familiar problem, but the usual solutions don’t seem to be working and I can’t figure out why!

When using raw.plot(), everything on the GUI that pops up is extremely slow. For instance I can’t smoothly drag the scroll/pan bar, but rather it takes ~2-3 seconds to update with each move.

The solutions from similar threads don’t seem to be working this time. Further, it’s working just fine on one my macbooks (M1 with Sequoia), but not on my other (M2 with Tahoe).

I’m now using pycharm, but I had the same problem in VSCode (which is what worked on the other one). The other difference is I set up a new venv in pycharm whereas the first/working computer is using a conda env, but I wouldn’t expect these differences to change performance?

import mne
from mne.viz import set_browser_backend
set_browser_backend("qt")
import matplotlib
import matplotlib.pyplot as plt

mne.sys_info()


raw_file = mne.io.read_raw_fif(fname, verbose=True, preload=False)
raw_file.load_data()

n_show = max(1, total_chs // 2)

raw_file.plot(block=True, use_opengl=False,
    n_channels=n_show,
    scalings=dict(block=True, mag=1e-12, grad=4e-11, eeg=350e-6, eog=150e-6, ecg=5e-4,
                  emg=1e-3, ref_meg=1e-12, misc=1e-3, stim=1,
                  resp=1, chpi=1e-4, whitened=1e2),   
)

The mne.sys_info() for the non-working computer:

Using qt as 2D backend.
Platform             macOS-26.0.1-arm64-arm-64bit
Python               3.11.9 (v3.11.9:de54cf5be3, Apr  2 2024, 07:12:50) [Clang 13.0.0 (clang-1300.0.29.30)]
Executable           ~/PyCharmMiscProject/.venv/.venv/bin/python
CPU                  Apple M2 Max (12 cores)
Memory               64.0 GiB

Core
├☑ mne               1.10.2 (unable to check for latest version on GitHub, SSL error)
├☑ numpy             2.3.4 (unknown linalg bindings (threadpoolctl module not found: No module named ‘threadpoolctl’))
├☑ scipy             1.16.2
└☑ matplotlib        3.10.7 (backend=module://backend_interagg)

Numerical (optional)
├☑ pandas            2.3.3
└☐ unavailable       sklearn, numba, nibabel, nilearn, dipy, openmeeg, cupy, h5io, h5py

Visualization (optional)
├☑ qtpy              2.4.3 (PyQt5=5.15.14)
├☑ pyqtgraph         0.13.7
├☑ mne-qt-browser    0.7.3
└☐ unavailable       pyvista, pyvistaqt, vtk, ipympl, ipywidgets, trame_client, trame_server, trame_vtk, trame_vuetify

The mne.sys_info() for the working computer:

Platform macOS-10.16-x86_64-i386-64bit
Python 3.9.13 (main, Aug 25 2022, 18:29:29) [Clang 12.0.0 ]
Executable ~/anaconda3/envs/EEGenv/bin/python
CPU i386 (10 cores)
Memory 16.0 GB

Core
├☒ mne 1.8.0 (outdated, release 1.10.2 is available!)
├☑ numpy 1.23.4 (OpenBLAS 0.3.20 with 10 threads)
├☑ scipy 1.9.2
└☑ matplotlib 3.6.2 (backend=MacOSX)

Numerical (optional)
├☑ sklearn 1.1.2
├☑ nibabel 5.3.2
├☑ pandas 1.5.0
├☑ h5py 3.7.0
└☐ unavailable numba, nilearn, dipy, openmeeg, cupy, h5io

Visualization (optional)
├☑ qtpy 2.4.3 (PySide2=5.15.2)
├☑ ipympl 0.9.2
├☑ pyqtgraph 0.13.7
├☑ mne-qt-browser 0.6.3
├☑ ipywidgets 8.0.2
└☐ unavailable pyvista, pyvistaqt, vtk, trame_client, trame_server, trame_vtk, trame_vuetify

Ecosystem (optional)
└☐ unavailable mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline, neo, eeglabio, edfio, mffpy, pybv

This is a known problem with pyqtgraph 0.13.7 ( v0.7.3 unusable on macOS · Issue #377 · mne-tools/mne-qt-browser · GitHub ), and the workaround is currently to downgrade to PySide6 6.9.3 (or use `set_browser_backend(“matplotlib”)`). Once pyqtgraph makes a new release (either 0.13.8 or 0.14.0), everything will work again even with the latest version of PySide6 (i.e., ≥ 6.10.0).

Solved, thank you! I also had to set use_opengl=True, interesting because prior to downgrading I had to do use_opengl=False to even get the plot to open at all and my understanding was mac has deprecated opengl. I also did a lot of searching on the mne forums and couldn’t find that one particular link, maybe an mne-qt-browser megathread to collect would be helpful?

1 Like

Although Apple has deprecated OpenGL, macOS is still the only platform where PyOpenGL is required to achieve good performance. The default should be use_opengl=True though.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.