Hyperscanning series part 3:
How to do hyperscanning with LabStreamingLayer (LSL)

by Dr. Alex Kreilinger
Strategic Product Manager (Brain Products)

In the previous articles of our hyperscanning series, we outlined our gold standard recommendation for hyperscanning with BrainAmps, as well as showed you how to perform hyperscanning wirelessly with CGX Quick headsets and StimTrigger. Part 3 introduces a more general approach, which is based on LabStreamingLayer (LSL).

Emblem HyperscanningLSL is gaining more and more importance in the field of neuroscience because it enables you to easily stream EEG data to the network and connect to it with various clients. Such EEG streams can be combined with other streams for online processing or for recording and synchronization. Other streams can contain any type of signal, for example regular continuous signals or irregular signals without a stable sampling rate. Most importantly, the streams can originate from other EEG sources, which makes LSL a suitable tool for hyperscanning. Any EEG amplifier can be used if there is a corresponding LSL connector. Each LSL EEG stream in the network comes with its own time stamps that are linked to each data point. When the streams are recorded in LabRecorder, all the selected streams are saved in one single XDF file and can later be synchronized based on these time stamps.

LSL connectors for Brain Products amplifiers

Logo GitHubFortunately, we have LSL connectors for all our current amplifiers on the Brain Products GitHub page. Just find the corresponding amplifier and download the latest release. If you still have an older amplifier, such as a V-Amp, or if you simply want to use BrainVision Recorder in parallel you can instead use the LSL-BrainVisionRDA connector. Please look at our article on https://bci.plus to find out more about how to use LSL with Brain Products equipment. You can also use CGX Quick systems with Recorder for CGX which allows to output an LSL stream.

Setting up hyperscanning with LSL

First, make sure that all the involved computers are in the same local network. You will need computers running the LSL connectors, a recording computer with LabRecorder, and, if your experiment requires, a computer running an experiment control software to manage the paradigm and to send LSL markers for later analysis. All these computers can be different computers, but this is not necessary. That said, it is good to run a few test recordings before beginning the actual experiment.

As we are relying on LSL in this setup, you do not need any hardware for sending triggers as software markers can be streamed directly to the network. However, it is still possible to send hardware triggers to the individual amplifiers, which will in turn be streamed together with the EEG. This way, you can have both individual and global triggers/markers. With our BrainVision LSL Viewer you can conveniently connect to the streams (make sure to have one instance per EEG stream) and monitor the signal quality online. The basic scheme can be seen in Figure 1.

How to do hyperscanning with LabStreamingLayer (LSL)

Figure 1 (click to open .pdf version): For every participant, you can create LSL EEG streams with LSL connectors corresponding to the selected amplifier; either directly, or via BrainVision Recorder’s Remote Data Access (RDA) output. These streams can contain EEG and hardware trigger information. In addition, you can add other optional individual sources, such as keyboard or mouse inputs. In the shared network, an LSL stream with contextual information may be added from the Experiment Control PC and, potentially, other global sources. All the streams can be monitored with BrainVision LSL Viewer instances in the same network and all the streams can be recorded to a single XDF file in LabRecorder.

Some things to consider

  • If possible, always go for a wired network and try to minimize the load of the network. For example, do not run any streams with a high bit rate in the background.

  • Use similar settings for every participant. For example, using different amplifiers or different computer hardware may cause different latencies for the time stamps that are needed for synchronization, so try to be as consistent as possible. While it is possible to use different sampling rates, later analyses will be simpler if you use the same values for all participants.

  • Consider the latency of hardware EEG streams when combining the EEG streams with LSL marker streams. As software markers are sent immediately, they are recorded in LabRecorder without delay, whereas LiveAmp, for example, usually has a delay of around 13 ms (referring to EEG data and triggers). This may not be relevant for frequency-based analyses but should be taken into consideration if you want to investigate ERPs or other time sensitive measures. For further reading, please, also look at this issue’s article on “How to verify timing in your EEG setup“.

Analyzing the data

Every time you use LabRecorder, you end up with an XDF file that includes all the streams you selected before starting the recording. This means you have at least one EEG stream for every participant and one stream including your LSL markers. Of course, you might have other streams in there, such as keyboard inputs or any other signals that may provide relevant information. You can import the recorded XDF file with MATLAB via “load_xdf.m” or in Python using pyxdf with a function of the same name. Because the time stamps of all the recorded streams are synchronized and every sample or marker has a corresponding time stamp, you can analyze data with these respective tools. You can also look at MoBILAB which is a useful plugin for EEGLAB to load XDF files with multiple EEG streams and export the data to BrainVision Core Data format.

Once the data is in this compatible format, it can be analyzed with the ease and convenience of BrainVision Analyzer 2. Stay tuned for one of the upcoming issues of the hyperscanning series to read about how.

A potential hyperscanning scenario

The possibilities with LSL are basically endless, but we want to give you some idea of how a hyperscanning setup with LSL might look like:

  • There are four participants each having their EEG recorded with a LiveAmp.
  • Each participant sits in front of a computer with a standard keyboard.
  • The computers are connected to a wired network via a switch. Separate LSL connectors stream keyboard output and EEG data to the network.
  • The experiment control software is running on an additional computer, with a big screen that every participant observes. The software sends global markers to the network, informing every connected client about the current state of a game.
  • All participants can enter inputs corresponding to the state of the game.
  • Another computer, or more than one, is/are used to run several instances of LSL Viewer to monitor all the participants’ EEG signals.
  • All streams are recorded with LabRecorder and saved to an XDF file. Now, you can analyze all the EEG streams with all the necessary context, such as individual inputs and global markers.

Of course, this is just a very basic example but maybe it can give you an idea what can be done. Please don’t hesitate to reach out to us if you have any questions regarding such a setup or if you have an exciting idea and want to make sure it is feasible.

All articles of the hyperscanning series
Want to know more? … Get in touch!