5 · Stream to other apps (LSL)
Goal: send live EEG to any program that speaks Lab Streaming Layer, the standard for neuroscience software. Examples: MATLAB, Python, PsychoPy, OpenViBE, NeuroPype and LabRecorder.
Step 1: Send from OpenBCI GUI
- Start a session and the data stream as in tutorial 3.
- Add the Networking widget, choose LSL, and set:
- data type TimeSeriesFilt (filtered) or TimeSeriesRaw
- a stream name, for example
NeuroNode - type
EEG
- Click Start LSL Stream.
Step 2: Receive in Python
python3 -m pip install pylsl
from pylsl import StreamInlet, resolve_byprop
streams = resolve_byprop("type", "EEG", timeout=10)
if not streams:
raise SystemExit("No EEG stream found. Is 'Start LSL Stream' on?")
inlet = StreamInlet(streams[0])
print("Connected to", streams[0].name(), "with", streams[0].channel_count(), "channels")
while True:
chunk, timestamps = inlet.pull_chunk(timeout=1.0)
if timestamps:
print(len(timestamps), "samples, first channel:", round(chunk[-1][0], 1), "µV")
Step 3: Record everything together
LabRecorder (from the LSL project) saves every LSL stream on the network into one .xdf file, with all clocks synchronised. Typical streams are EEG, your experiment's markers, and eye tracking. Load the file in Python with pyxdf, or in MATLAB with load_xdf.
Step 4: Send markers from your experiment
from pylsl import StreamInfo, StreamOutlet
markers = StreamOutlet(StreamInfo("Markers", "Markers", 1, 0, "string", "my-experiment"))
markers.push_sample(["stimulus_left"])
Alternative: send from BrainFlow
If your experiment already uses BrainFlow (tutorial 4), it can publish the stream itself, so you don't need the GUI. See the BrainFlow docs on "streamer" / LSL.
✅ Done. Next: Your first BCI: SSVEP →