Is there a way to plot raw eeg signal from LSL server in MNE?

I need to plot my raw EEG signal coming over the LSL server. I could connect to LSL with mne_realtime.LSLClient but couldn’t get the raw data. I could only find mne_realtime.LSLClient.get_data_as_epoch in the doc. Since my signals don’t contain event information, i couldn’t make use of it.

Thank you in advance

Hello,

With the LSLClient in mne_realtime, you should be able to access the data, epoch by epoch.
You can use one of the many viewer to visualize the data stream in real-time: Viewers — Labstreaminglayer 1.13 documentation

Or you can use BSL, which can both access the data window by window (epoch) and has a viewer: https://bsl-tools.github.io/ Note: I am refactoring this library and the python-binding for LSL, thus the API will change soon. Version 1.0 will not be backward compatible with version 0.5.

Mathieu

2 Likes

Hi Mathieu,

Basically, I have written my code using MNE python and the whole point of mine is to do motor imagery classification in real-time. So, I need a continuous raw signal (please correct me if I am wrong) for detecting online.

Or could you please share any reference material for the online detection of motor imagery?

Thank you,
Mukil

NeuroDecode was design specifically for Motor Imagery. It is a couple years old, and it is not maintained, but it was performant on motor imagery task.

The original version is here: GitHub - dbdq/neurodecode: A framework for real-time brain-machine interface
A modified version can be found here: GitHub - fcbg-hnp/NeuroDecode: A framework for real-time brain-machine interface
BSL that I shared before, is based on it. It drops the decoding aspects specific to motor imagery and retained the LSL features.

Alternatively, you can develop your own real-time decoder. I would personally go this way, since new tools are now available and since NeuroDecode is not maintained.
You can look at the decoding tutorial in mne_realtime: Decoding real-time data — MNE-Realtime 0.3.dev0 documentation
And you can also look at brandeocde: Braindecode — Braindecode 0.7 documentation

For any of those, you will:

  • Acquire a window of a given size (e.g. the 2 last seconds), which can be also called a single epoch.
  • Preprocess the acquisition window, run some signal quality test to make sure the data is good in this window.
  • Run your decoder on the acquisition window.

Mathieu

1 Like

Thank you so much @mscheltienne