Lab Streaming Layer: Difference between revisions

From biophysics
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 9: Line 9:
- Store all incoming data in a single, well‑organized format
- Store all incoming data in a single, well‑organized format


==LSL in Matlab==
==LSL in Matlab (biofysica toolbox)==


Generic lsl functions can be found in the biofysica toolbox in the directory <..biofysica\liblsl\liblsl-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.
*Each lsl-device can have one or more lsl-streams.
*An lsl-stream is identified by a type and a name.  
*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.  
*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 the session.  
*When the stream is found you must add it to a session.  
*The session controls the actual data-acquisition with start and stop.  
*The session controls the actual data-acquisition with start and stop.  
*The data is read from the stream.
*The data is read from each stream object.


==Matlab Example==
==Matlab Example==
Line 25: Line 25:
  type = 'EyeSeeCam @ dcn-pl04';
  type = 'EyeSeeCam @ dcn-pl04';
  name = 'EyeSeeCam SCI Data';
  name = 'EyeSeeCam SCI Data';
type = 'Digital Events @ lslder01';
name = 'Digital Events 1';
  lslString = sprintf('type= ''%s'' and name= ''%s''', type, name);
  lslString = sprintf('type= ''%s'' and name= ''%s''', type, name);
  info=lsl_resolver(lslString);
  info=lsl_resolver(lslString);
Line 43: Line 41:
  data = lslStream.read;
  data = lslStream.read;


In the directory <...biofysica\liblsl\liblsl-Matlab\examples>
In the directory <...biofysica\liblsl\liblsl-Matlab\examples> you can find more examples (with descriptions in the readme.md file).

Latest revision as of 11:15, 1 April 2026

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 (biofysica toolbox)

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';
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).