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

**URL:** <https://mne.discourse.group/t/is-there-a-way-to-plot-raw-eeg-signal-from-lsl-server-in-mne/6176>\
**Category:** Support & Discussions\
**Tags:** eeg, visualization, mne-realtime\
**Created:** [January 10, 2023, 12:57pm UTC](https://mne.discourse.group/t/is-there-a-way-to-plot-raw-eeg-signal-from-lsl-server-in-mne/6176 "2023-01-10T12:57:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mukil](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@Mukil](https://mne.discourse.group/u/Mukil)\
**Post date:** [January 10, 2023, 12:57pm UTC](https://mne.discourse.group/t/is-there-a-way-to-plot-raw-eeg-signal-from-lsl-server-in-mne/6176/1 "2023-01-10T12:57:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [January 10, 2023, 3:25pm UTC](https://mne.discourse.group/t/is-there-a-way-to-plot-raw-eeg-signal-from-lsl-server-in-mne/6176/2 "2023-01-10T15:25:58Z")

</div>

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](https://labstreaminglayer.readthedocs.io/info/viewers.html)

Or you can use BSL, which can both access the data window by window (epoch) and has a viewer: [https://bsl-tools.github.io/](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

---

<div class="post-metadata">

**Author:** ![Mukil](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@Mukil](https://mne.discourse.group/u/Mukil)\
**Post date:** [January 10, 2023, 5:19pm UTC](https://mne.discourse.group/t/is-there-a-way-to-plot-raw-eeg-signal-from-lsl-server-in-mne/6176/3 "2023-01-10T17:19:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [January 11, 2023, 9:16am UTC](https://mne.discourse.group/t/is-there-a-way-to-plot-raw-eeg-signal-from-lsl-server-in-mne/6176/4 "2023-01-11T09:16:43Z")

</div>

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](https://github.com/dbdq/neurodecode)  
A modified version can be found here: [GitHub - fcbg-hnp/NeuroDecode: A framework for real-time brain-machine interface](https://github.com/fcbg-hnp/NeuroDecode)  
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](https://mne.tools/mne-realtime/auto_examples/plot_compute_rt_decoder.html#sphx-glr-auto-examples-plot-compute-rt-decoder-py)  
And you can also look at `brandeocde`: [Braindecode — Braindecode 0.7 documentation](https://braindecode.org/stable/index.html)

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

---

<div class="post-metadata">

**Author:** ![Mukil](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@Mukil](https://mne.discourse.group/u/Mukil)\
**Post date:** [January 13, 2023, 5:25am UTC](https://mne.discourse.group/t/is-there-a-way-to-plot-raw-eeg-signal-from-lsl-server-in-mne/6176/5 "2023-01-13T05:25:22Z")

</div>

Thank you so much @mscheltienne
