MNE-LSL Integration#
MNE-LSL is a Python package that bridges MNE-Python with the Lab Streaming Layer (LSL) for real-time EEG data streaming, processing, and visualization.
StreamViewer displaying real-time EEG with eyes-closed alpha activity.#
Installation#
Installation Guide - Full documentation with dependencies and troubleshooting
Install MNE-LSL using pip:
pip install mne-lsl
For real-time visualization with StreamViewer, install with Qt backend:
pip install mne-lsl PyQt5
Quick Examples#
View real-time data from your Wearable Sensing headset:
from mne_lsl.stream import StreamViewer
stream_name = "DSI-24" # Or DSI-VR300, DSI-7, WS-default
StreamViewer(stream_name=stream_name).start()
Replay pre-recorded data
This example replays data from an EDF file, such as those exported by DSI-Streamer, as an LSL stream for testing:
import time
from mne.io import read_raw_edf
from mne_lsl.player import PlayerLSL as Player
path_to_edf = "C:/path/to/your/data.edf" # Replace with your EDF file path
raw = read_raw_edf(path_to_edf, preload=True)
player = Player(raw, chunk_size=200, n_repeat=1, name="example-edf-replay").start()
while player.running:
time.sleep(0.5)
del player
Tutorial Sections#
Processing#
Connect a Device - Discover and connect to LSL streams
Filtering - Apply real-time filters
Epoching & Event Handling - Create event-related epochs
Classification#
Brain-Computer Interfaces - Build BCIs with bandpower and machine learning
Visualization#
Stream Viewer - StreamViewer for real-time monitoring