• Stars
    star
    242
  • Rank 167,048 (Top 4 %)
  • Language
    C++
  • Created over 9 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Multi-modal time-synched data transmission over local network

This is not what you want!

This repo is a snapshot of what once was sccn/labstreaminglayer on 11.23.2018. For the current repository, please go to sccn/labstreaminglayer.

Summary

The lab streaming layer (LSL) is a system for the unified collection of measurement time series in research experiments that handles both the networking, time-synchronization, (near-) real-time access as well as optionally the centralized collection, viewing and disk recording of the data.

The LSL distribution consists of:

  • The core transport library (liblsl) and its language interfaces (C, C++, Python, Java, C#, MATLAB). The library is general-purpose and cross-platform (Win/Linux/MacOS, 32/64) and forms the heart of the project.
  • A suite of tools built on top of the library, including a recording program, online viewers, importers, and apps that make data from a range of acquisition hardware available on the lab network (for example audio, EEG, or motion capture).

There is an intro lecture/demo on LSL here: http://www.youtube.com/watch?v=Y1at7yrcFW0 (part of an online course on EEG-based brain-computer interfaces).

You may also wish to subscribe to the LSL mailing list

Hosted here is only the source code for the project. Developers will want to clone this repo, then run 'python get_deps.py' to download all the 3rd party libraries from our ftp.

Download Binary Releases

You can find old releases on our FTP site: ftp://sccn.ucsd.edu/pub/software/LSL/.

These releases are out of date. We are working toward an automated build and deployment system but it is not ready yet.

Streaming Layer API

The liblsl library provides the following abstractions for use by client programs:

  • Stream Outlets: for making time series data streams available on the lab network. The data is pushed sample-by-sample or chunk-by-chunk into the outlet, and can consist of single- or multichannel data, regular or irregular sampling rate, with uniform value types (integers, floats, doubles, strings). Streams can have arbitrary XML meta-data (akin to a file header). By creating an outlet the stream is made visible to a collection of computers (defined by the network settings/layout) where one can subscribe to it by creating an inlet.

  • Resolve functions: these allow to resolve streams that are present on the lab network according to content-based queries (for example, by name, content-type, or queries on the meta-data). The service discovery features do not depend on external services such as zeroconf and are meant to drastically simplify the data collection network setup.

  • Stream Inlets: for receiving time series data from a connected outlet. Allows to retrieve samples from the provider (in-order, with reliable transmission, optional type conversion and optional failure recovery). Besides the samples, the meta-data can be obtained (as XML blob or alternatively through a small built-in DOM interface).

  • Built-in clock: Allows to time-stamp the transmitted samples so that they can be mutually synchronized. See Time Synchronization.

Reliability

The following reliability features are implemented by the library (transparently):

  • Transport inherits the reliability of TCP, is message-oriented (partitioned into samples) and type safe.

  • The library provides automatic failure recovery from application or computer crashes to minimize data loss (optional); this makes it possible to replace a computer in the middle of a recording without having to restart the data collection.

  • Data is buffered both at the sender and receiver side (with configurable and arbitrarily large buffers) to tolerate intermittent network failures.

  • Transmission is type safe, and supports type conversions as necessary.

Time Synchronization

The lab streaming layer comes with a built-in synchronized time facility for all recorded data which is designed to achieve sub-millisecond accuracy on a local network of computers. This facility serves to provide out-of-the-box support for synchronized data collection but does not preclude the use of user-supplied alternative timestamps, for example from commercial timing middleware or high-quality clocks.

The built-in time synchronization is designed after the widely deployed Network Time Protocol (NTP) and implemented in the LSL library.

This feature is explained in more detail in the TimeSynchronization section.

File Format

The transport API itself does not endorse or provide a particular file format, but the provided recording program (LabRecorder) records into the XDF file format (Extensible Data Format). XDF was designed concurrently with the lab streaming layer and supports the full feature set of LSL (including multi-stream container files, per-stream arbitrarily large XML headers, all sample formats as well as time-synchronization information).

Coding Guides

The distribution includes a range of code examples in C, C++, Python, MATLAB, Java, and C# including some very simple sender and receiver programs, as well as some fairly extensive demo apps.

Sending Random Data in C++

#include "lsl_cpp.h"
#include <stdlib.h>
using namespace lsl;

/**
 * This is an example of how a simple data stream can be offered on the network. 
 * Here, the stream is named SimpleStream, has content-type EEG, and 128 channels.
 * The transmitted samples contain random numbers (and the sampling rate is irregular 
 * and effectively bounded by the speed at which the program can push out samples).
 */

int main(int argc, char* argv[]) {

	// make a new stream_info (128ch) and open an outlet with it
	stream_info info("SimpleStream","EEG",128);
	stream_outlet outlet(info);

	// send data forever
	float sample[128];
	while(true) {
		// generate random data
		for (int c=0;c<128;c++)
			sample[c] = (rand()%1500)/500.0-1.5;
		// send it
		outlet.push_sample(sample);
	}

	return 0;
}

Receiving Data in C++

#include "lsl_cpp.h"

/**
 * This is a minimal example that demonstrates how a multi-channel stream (here 128ch) 
 * of a particular name (here: SimpleStream) can be resolved into an inlet, and how the 
 * raw sample data & time stamps are pulled from the inlet. This example does not 
 * display the obtained data.
 */

int main(int argc, char* argv[]) {
	using namespace lsl;

	// resolve the stream of interest & make an inlet to get data from the first result
	std::vector<stream_info> results = resolve_stream("name","SimpleStream");
	stream_inlet inlet(results[0]);

	// receive data & time stamps forever (not displaying them here)
	float sample[128];
	while (true)
		double ts = inlet.pull_sample(&sample[0],128);
	
	return 0;
}

How to get support

If you are having trouble with LSL, there are few things you can do to get help. First, search this GitHub repository's issues list, including closed issues. If you don't find what you are looking for, then you can create a new issue. Try to include as much information as possible about your device (if applicable), your computing environment (operating system, processor achitecture), what you have tested so far, and also provide logs or other error messages if available. If you end up creating a new issue, please close it once the issue is solved.

You can also try joining the LabStreamingLayer #users channel on Slack. Invite Link. Someone there may be able to get to the bottom of your problem through conversation.

Acknowledgements

The original version of this software was written at the Swartz Center for Computational Neuroscience, UCSD. This work was funded by the Army Research Laboratory under Cooperative Agreement Number W911NF-10-2-0022 as well as through NINDS grant 3R01NS047293-06S1.

More Repositories

1

eeglab

EEGLAB is an open source signal processing environment for electrophysiological signals running on Matlab and developed at the SCCN/UCSD
MATLAB
574
star
2

labstreaminglayer

LabStreamingLayer super repository comprising submodules for LSL and associated apps.
HTML
529
star
3

BCILAB

MATLAB Toolbox for Brain-Computer Interface Research
HTML
198
star
4

liblsl

C++ lsl library for multi-modal time-synched data transmission over the local network
C++
110
star
5

xdf

Python
86
star
6

ICLabel

Automatic EEG IC classification plugin for EEGLAB
MATLAB
52
star
7

eeg_pipelines

MATLAB
52
star
8

clean_rawdata

Cleaning Raw EEG data
MATLAB
42
star
9

roiconnect

ROI connectivity analysis in EEG
HTML
39
star
10

PACTools

EEGLAB plug-in to compute Phase-Amplitude Coupling using different methods
MATLAB
35
star
11

SNAP

Simulation and Neuroscience Application Platform
Python
30
star
12

SIFT

SIFT is an EEGLAB-compatible toolbox for analysis and visualization of multivariate causality and information flow between sources of electrophysiological (EEG/ECoG/MEG) activity. It consists of a suite of command-line functions with an integrated Graphical User Interface for easy access to multiple features. There are currently six modules: data preprocessing, model fitting and connectivity estimation, statistical analysis, visualization, group analysis, and neuronal data simulation.
MATLAB
30
star
13

mobilab

MoBILAB toolbox for MATLAB is an analysis and visualization platform for Mobile Brain/Body data.
MATLAB
26
star
14

amica

Code for AMICA: Adaptive Mixture ICA with shared components
Fortran
23
star
15

bva-io

Routines for loading and saving data files in Brain Vision Data Exchange format (export and import of Brain Vision Analyzer MATLAB files developed by Arnaud Delorme)
MATLAB
23
star
16

EEG-BIDS

MATLAB
21
star
17

cleanline

Clean Line
MATLAB
13
star
18

neuroscanio

Function to import Neuroscan data into EEGLAB
MATLAB
10
star
19

groupSIFT

MATLAB
10
star
20

fMRIb

fMRI artifact correction
MATLAB
9
star
21

practical_MEEG

MATLAB
9
star
22

eeglab_tutorial_scripts

Scripts for the EEGLAB tutorial
MATLAB
8
star
23

nsgportal

EEGLAB plugin for NSG
MATLAB
8
star
24

PowPowCAT

MATLAB
7
star
25

NFT

Neuroelectromagnetic Forward Modeling Toolbox
MATLAB
6
star
26

eeglab_musemonitor_plugin

MATLAB
5
star
27

winPACT

MATLAB
5
star
28

NEMAR-pipeline

MATLAB
5
star
29

get_chanlocs

Electrode localization using 3D head image. EEGLAB plug-in using Fieldtrip toolbox
MATLAB
5
star
30

deep-channel-harmonization

Python
5
star
31

viewprops

EEGLAB plugin with improved pop_prop and more
MATLAB
4
star
32

sccn.github.io

Host web content of EEGLAB wiki
HTML
4
star
33

imat

Independent Modulators Analysis Toolbox
MATLAB
4
star
34

trimOutlier

MATLAB
4
star
35

relica

A method for estimating the reliability of independent components (Artoni et al. 2014)
MATLAB
4
star
36

PACT

MATLAB
3
star
37

erpsource

ERP source analysis plugin for EEGLAB
MATLAB
3
star
38

binica

Binary Infomax ICA in C using LAPACK
C
3
star
39

dipfit

Dipfit plugin for source localization in EEGLAB
MATLAB
3
star
40

sound2meg

Jupyter Notebook
2
star
41

REST

REST plugin
MATLAB
2
star
42

postAmicaUtility

Plugin to plot AMICA solutions in EEGLAB
MATLAB
2
star
43

eegstats

MATLAB
2
star
44

IClabel-Update

Automatically update the ICLabel plugin to incorporate all submitted labels to date.
Python
2
star
45

eeglab_gpu_func

Some GPU compatible EEGLAB functions
MATLAB
2
star
46

ARfitStudio

MATLAB
1
star
47

Mutual_Info_Clustering

MATLAB
1
star
48

FASTER

MATLAB
1
star
49

fitTwoDipoles

MATLAB
1
star
50

eeglab_tests

MATLAB
1
star
51

ANTeepimport

ANTeepimport plugin
MATLAB
1
star
52

testica

MATLAB
1
star
53

eeglab-testcases

MATLAB
1
star
54

EEG_RF

MATLAB
1
star
55

iirfilt

Non linear filter
MATLAB
1
star
56

eeglab_musedirect

MATLAB
1
star
57

HBN-rest-DL

MATLAB
1
star
58

ICAquality

1
star
59

Miyakoshi-et-al-2021-PAC-Pipeline

Automated Pipeline for Preprocessing Scalp-Recorded EEG Data for Phase-amplitude Coupling Analysis of Infantile Spasms
MATLAB
1
star
60

dl_sccn_demo

1
star
61

std_clust2ch

MATLAB
1
star
62

reorder19channels

MATLAB
1
star
63

NIMA

MATLAB
1
star
64

emotivimport

MATLAB
1
star