neuromodulation / py_neuromodulation

Real-time analysis of intracranial neurophysiology recordings.
https://neuromodulation.github.io/py_neuromodulation/
MIT License
41 stars 9 forks source link

Merge main into LSL branch #318

Closed toni-neurosc closed 1 month ago

toni-neurosc commented 2 months ago

I reviewed the merge conflicts between the refactored main branch and the LSL branch, there were actually not so many of them, check the changes and merge please.

EDIT: So I have made a bunch more changes needed to fix the tests, some of them are temporary and need to be addressed:

PS. The Qt dependency is introduced by mne_lsl class StreamViewer. Are you using this class only for testing purposes @SamedVossberg? I think we should not rely on third party GUI apps/widgets when we start developing our own GUI, otherwise we will be forced to use the same backend/library as the tools we depend on (in this case Qt5)

toni-neurosc commented 2 months ago

So at some point I had it working... but now it for some reason it's crashing, and the crash dumps suggest it has to do with the Xorg server, but XVFB was working fine at some point, not sure why it suddently started crashing the Github runners...

PS. So when running multithreaded pytest with pytest-xdist, 87% of the tests manage to be completed, I guess because the workers that don't crash pick up the tests that don't cause crashing and complete them. The tests that crash are: FAILED tests/test_all_examples.py::test_run_through_all_test[example_filename0] FAILED tests/test_all_examples.py::test_run_through_all_test[example_filename2] FAILED tests/test_all_examples.py::test_run_through_all_test[example_filename5] FAILED tests/test_all_examples.py::test_run_through_all_test[example_filename6]

PS2. the example scripts that crashed are:

What all those have in common is pyplot.figure, which goes to matplotlib/backends/backend_qt.py and then it crashes when it hits _create_qApp I can imagine the version of Qt that I put in the dependencies is breaking matplotlib somehow, perhaps?

toni-neurosc commented 2 months ago

Alright, problem solved, I changed the matplotlib backend to Tkinter in init.py

import matplotlib

# Set matplotlib backend to TkAgg because it crashes with the Qt5 install we're using for LSL
matplotlib.use("tkagg")

Well that was a real pain in the ass to figure out... but good to know for the future

I also made it so that the environment variable for liblsl shared library files (MNE_LSL_LIB) is set within init.py, that should help distributing the libraries together with the whole Python package