LabStreamingLayer (LSL) already is a well-established tool for recording and accessing EEG and other signals in many labs around the world and interest in it is still growing. LSL makes it possible to combine several data streams into one single XDF file and access the streams with various clients online. These streams can be regular streams with a certain sampling rate, or irregular streams that send data only when needed. LSL is very well explained on its GitHub page and there is a comprehensive online documentation. In addition, we provide instructions here on how to use LSL with Brain Products amplifiers and tools in your experiments.
This post serves as a hub for ideas on how to use LSL in combination with Brain Products equipment, including our amplifiers, the TriggerBox (Plus), and other accessories. We demonstrate how to use LSL and/or hardware triggers via our TriggerBox (Plus) in stimulus presentation software solutions, such as PsychoPy, Presentation®, E-Prime®, and Psychtoolbox for Matlab. Using LSL markers can be an alternative to using hardware triggers, and we want to demonstrate how you can add such software markers to your experiment, in addition to, or even instead of hardware triggers.
Often, it is not enough to simply add LSL markers to an existing setup using hardware triggers, or to add hardware triggers to a setup based on LSL markers, but it is important to easily switch between these options, being able to adapt quickly to the context. Therefore, we want to show how easy activating or deactivating the respective options can be, at the same time also pointing out differences between the different stimulus presentation tools.
An important difference between LSL markers and hardware triggers is the timing. As already covered in this Press Release article, there are some things you need to consider when switching between LSL markers and hardware triggers for synchronizing EEG signals to events. The aforementioned article demonstrates these via PsychoPy. This article expands the examples to include instructions and scripts for E-Prime®, Presentation®, and Psychtoolbox. In addition, we provide instructions on how to analyze the timing, backed with scripts for MATLAB® and Python (MNE), but also making use of MNELAB and Brain Products’ own BrainVision Analyzer 2.
Hardware triggers with Brain Products amplifiers will always have the benefit of being directly bound to EEG data. They are saved along with EEG data immediately and precisely at the time they occur and are therefore the optimum means for synchronizing events and signals. However, they always require some additional equipment, even if it is just a cable connecting the amplifier to a computer or the TriggerBox (Plus). Sometimes, these additional connections are not feasible, for example when requiring markers in a mobile scenario. In this case, using the amplifier without any additional accessories is preferable.
For such scenarios, LSL provides a great solution, and Brain Products provides the necessary LSL connector apps on our GitHub page. With these apps, you can create LSL streams that can be recorded individually or together with other LSL streams. These other LSL streams can contain other signals, but also markers or other contextual information. At any time, it is also possible to connect to all of the streams for online processing or visualization. Because the LSL streams contain time stamps, streams can later be synchronized. However, it is still necessary to be cautious, as there are certain factors that can lead to latencies between LSL streams. For example, a software marker coming from a stimulus presentation software will appear immediately, whereas EEG signals experience a slight delay depending on the nature of the amplifier and other parameters, such as sampling rate and number of channels. On top of that, other timing-sensitive events (unrelated to LSL) may not happen exactly when they are supposed to: the screen might not update immediately but only after additional screen flips, or the sound may need some time to be played by the sound processor. If such events need to be precise, for example to trigger evoked potentials, it is important to minimize such latencies, or at least be aware of them in order to compensate for them in the analysis pipeline.
All examples for the different software tools are based on one and the same paradigm. We create three events in time that can be used for synchronization and verification:
- Visually switching a square on the top left corner between bright and dark every 500 ms. This event can be recorded with a photo sensor as an auxiliary channel when connected to your EEG amplifier.
- At the same time, hardware triggers are sent via the TriggerBox (Plus). The TriggerBox (Plus) is also connected to the EEG amplifier and incoming triggers are sampled along with EEG data.
- At the same time, LSL markers are sent directly via an irregular LSL stream. These markers are not saved directly with EEG data but can be saved along the EEG stream to a single XDF file.
Analyzing data containing many repetitions of these three events can give you some good ideas on when things actually happen and if there is something wrong with your setup.
Please go through all of the featured software tools or skip right to your favorite tool to read the specific instructions. However, please do not miss the sections on how to test LSL markers and hardware triggers with our TriggerBox Test IO and how to record and analyze with different setups along with many examples.