Lab Streaming Layer
Introduction
Lab Streaming Layer (LSL) is an open‑source software framework designed to make it easy to send, receive, and synchronize data streams in real time. It acts like a universal “data highway” that different devices and programs can use to communicate with each other.
LSL is commonly used in research settings—especially in neuroscience, psychology, and human‑computer interaction—to collect data from multiple sources at the same time. For example, you can stream EEG signals, motion‑tracking data, eye‑tracking data, and experiment events through LSL and keep them perfectly time‑aligned. It is typically used to: - Connect different sensors and software tools without worrying about compatibility - Record synchronized data from multiple devices - Build experiments that require real‑time data exchange - Store all incoming data in a single, well‑organized format
LSL in Matlab
Generic lsl functions can be found in the biofysica toolbox in the directory <..biofysica\liblsl\liblsl-Matlab>.
- Each lsl-device can have one or more lsl-streams.
- An lsl-stream is identified by a type and a name.
- The function lsl_resolver checks if it can find the requested lslStream on the intranet.
- When the stream is found you must add it to a session.
- The session controls the actual data-acquisition with start and stop.
- The data is read from each stream object.
Matlab Example
- Open a stream to the EyeSeeCam
type = 'EyeSeeCam @ dcn-pl04';
name = 'EyeSeeCam SCI Data';
type = 'Digital Events @ lslder01';
name = 'Digital Events 1';
lslString = sprintf('type= %s and name= %s', type, name);
info=lsl_resolver(lslString);
lslStream = lsl_istream(info{1});
- Open a session and add the stream to the session.
session = lsl_session; session.add_stream(lslStream);
- Start and stop the session and get the data from the stream.
session.start; ....wait some time.... session.stop; data = lslStream.read;
In the directory <...biofysica\liblsl\liblsl-Matlab\examples> you can find more examples (with descriptions in the readme.md file).