Master LSL with mbtStreamer – some practical examples

  • hyperscanning
  • synchronization

neurobs presentation video

Jelena Jovanovic

December 19, 2023

Synchronizing different physiological and behavioral data can be a challenge. Especially when you want your setup to be light and mobile. That’s where wireless connection, such as LSL, comes in handy!

An EEG study often includes collecting different data modalities, to better understand the person’s behavior.

Alongside EEG, researchers use various sensors to capture other physiological signals. Unique device specifications and sampling rates make precise timing challenging.

Another important aspect is synchronizing EEG data with an external stimulus. Neural responses triggered by specific events can happen within milliseconds after that event. Precise synchronization ensures that the observed neural response accurately reflects the brain’s reaction.

About LabStreamingLayer

One of the easiest ways to synchronize data from multiple systems is by using LabStreamingLayer – LSL. It’s a wireless protocol that handles both networking and time-synchronization of all data streams.

LSL uses standard Internet protocol to send and receive data. With LSL you can synchronize streams from devices or apps connected to the same network (WAN or LAN).

Check out the list of LSL supported apps and hardware .

You can stream continuous data such as EEG, or you can stream participant’s responses to a stimulus in the form of markers.

It’s also possible to send triggers via LSL when presenting a stimulus in a presentation software. This trigger is then used to detect time-locked brain responses – ERPs (event related potentials).

EEG signals with an embedded trigger sent via LSL

In this blog, we’ll first give a simple example on how to open an LSL stream and send some data through that stream. We’ll focus on sending a trigger with a stimulus, but any other data type can be sent the same way (EEG sample, video frame, audio recording, etc.)

Send a trigger using LSL

Programs used for presenting stimuli are called exactly that – presentation software. Some presentation software that you might know are Psychtoolbox (Matlab), PsychoPy (Python), Neurobs Presentation, E-Prime and so on.

In all these programs, and more, you can add an LSL library which allows you to then program sending the triggers.

Neurobs Presentation for example supports LSL by default, so you don’t have to do any additional coding.

Check out our blog on Neurobs Presentation and LSL .

Code example

For this example, we wrote a pseudo-code to show how LSL programing looks like in different software.

First, we need to import the LSL library. You can download the library package from github , for a program of your choosing.

Then, we need to give some information about the stream. You can include:

  • Name of the LSL stream.
  • Stream type refers to content type of the stream. For example, this can be set to ‘EEG’, ‘Markers’ etc.
  • NominalSrate is the sampling rate we expect from the data.
  • Info about channel count, channel format, source ID and so on. But we won’t do this in the example.

Once we define stream info, we open the stream outlet.

Before defining our condition loop, we want to load a certain stimulus. You can load an image or audio recording for example.

We’ll define an endless loop in our example, since the condition of the loop varies depending on the task paradigm. In this loop, we keep presenting the stimulus indefinitely and sending a trigger each time.

To send a trigger, all you need to do is push the trigger name/label through the opened outlet.

For a practical use case on how to code LSL into your study paradigm, you can check out our blog on sending LSL triggers from PsychoPy in Stroop task.

Include triggers in EEG data

Once you open an LSL outlet, the stream is visible on the network.

You can visualize and record triggers in mbtStreamer software, which is used for communicating with our mobile EEG devices . All streams get recorded synchronously in one XDF file.

mbtStreamer software for recording and visualizing EEG and Trigger stream

Now that we’ve covered how to stream triggers via LSL, it’s easier to understand how any data type can be streamed in the same fashion.

In mbtStreamer software, we stream EEG data by default. There’s no need to do any additional coding on that part. This is also the case for many other apps and devices.

Hyperscanning using LSL

We mentioned that any stream can be detected and recorded with EEG data. This also covers Hyperscanning studies! Here, you’d record multiple EEG signals collected with mbt devices.

You can record streams from different devices in one file, as long as all PCs are on the same network.

Hyperscanning setup with EEG devices, including mbtStreamer recording software.

Our devices are completely wireless, so this setup doesn’t need any wiring, extra units, black boxes and so on. However, this can come with a price.

When using too many Bluetooth devices in the same room, interference can occur and cause data loss. EEG stream usually implies a lot of channels + high sampling frequency.

That’s why we developed a dedicated device mode for Hyperscanning studies. We made sure to lower data throughput via Bluetooth, while still keeping the high resolution of EEG data and precise synchronization.

All PRO line devices support Hyperscanning mode, so feel free to contact us if you’d like to know more!

Recommended reading

eye-tracking and EEG mobile systems

Fast and Simple EEG + Eye-Tracking Setup Using a Mobile Phone

A very fast setup is important for any kind of research experiment. In this blog, we’ll cover how to use EEG + eye-tracking with just an Android phone....

May 29, 2024

neurobs presentation video

Exploring Neural Coordination – alpha activity and N400 responses in a natural conversation

This study uses a hyperscanning EEG setup to explore neural coordination between speaker and listener while they converse. It takes a look into the well known N400 response...

BCI VR EEG

Revolutionizing Design: The Power of BCI in Creative Processes

In this innovative study by Qi Yang and team from Cornell University, researchers created an advanced tool. It combines Brain-Computer Interface (BCI) technology with Virtual Reality (VR). This...

neurobs presentation video

Pavle Mijovic

April 17, 2024

We can assist you to choose the product that best fits your needs

Contact sales

:

Presentation

If you've already decided to use Presentation or to try it out, it is strongly recommended that you read this section first. The overview available there is essential to understanding the content in the remainder of the documentation
Contains general information about how to create scenarios, the basic units in a Presentation experiment. Before you start creating your own scenarios, read this section. Information concerning specific functionality is covered separately in the remainder of the documentation, organized by functionality
Describes how sequences of stimuli are organized and how the flow of control proceeds through a scenario
Describes the stimuli that Presentation can present and how to specify them
Describes the response devices that Presentation can use and how they are configured
How Presentation communicates with external hardware excluding response devices
Describes what kind of data Presentation can produce for each scenario
Some special features that are relevant when a scenario is being run
How Presentation handles timing issues. It is very important that you understand this material
How to specify values for parameters and create your own parameters
Contains information on creating and using components that extend Presentation's functionality
Describes the Presentation Python interface (PresPy)
Describes toolkits available to enhance Presentation features
Presentation experiments that are securely packaged for distribution and execution
How to create and run experiments on iOS or Android devices
: :

Chapter 1 - Variables

and run a scenario. Please see and if you do not know how to run a scenario.

Creating a variable in Presentation is a way of reserving memory to store a particular type of information. When you create a variable, or it, you must tell Presentation what of information it will store, whether it be text, an integer, a decimal or something else. Here is an example of how to declare a variable:

Note: In Presentation, the end of a statement is always marked by a semi-colon. This allows you to use more than one line for a statement. If you get an error in your scenario, it oftentimes is because of a missing semi-colon.

Presentation has several types of information that can be stored that are considered basic types. The distinction between basic types and other types should become clearer once other types and their parameters are introduced. This section will only use basic type variables in the examples. The basic types in Presentation are strings, integers (ints), doubles, booleans (bools), and rgb colors (rgb_colors).

Basic Types

begin; begin_pcl; string color = "green"; term.print_line( color );
Note: We will frequently give full scenario examples so you can test out things for yourself. If you are reading this course within the compiled documentation distributed with Presentation, you may open these examples in Presentation by clicking on the links in the example box. We will sometimes use the command term.print( ... ) , which prints to the area labeled "Terminal" in the Editor tab , as a simple way to create output. Also keep an eye on the area labeled "Status", which may have important messages, such as "Press Enter to Start".
begin; begin_pcl; string color = green; #needs quotation marks
begin; begin_pcl; string green = "green"; string color = green; term.print_line( color );
begin; begin_pcl; int num_trials = 24; term.print_line( num_trials );
begin; begin_pcl; double rotate_deg = 50.0; term.print_line( rotate_deg );
begin; begin_pcl; double rotate_deg = .5; #needs to have a number before the decimal point
begin; begin_pcl; double rotate_deg = 0.5; term.print_line( rotate_deg );
begin; begin_pcl; bool already_shown = false; term.print_line( already_shown );
begin; begin_pcl; bool already_shown = "false"; #do not need quotation marks
begin; begin_pcl; rgb_color green1 = rgb_color( 0, 255, 0 ); term.print( green1.red_byte() ); term.print( "\t" ); term.print( green1.green_byte() ); term.print( "\t" ); term.print( green1.blue_byte() ); term.print( "\t" ); term.print_line( green1.alpha_byte() ); rgb_color green2 = rgb_color( 0, 255, 0, 255 ); term.print( green1.red_byte() ); term.print( "\t" ); term.print( green1.green_byte() ); term.print( "\t" ); term.print( green1.blue_byte() ); term.print( "\t" ); term.print_line( green1.alpha_byte() ); rgb_color green3 = rgb_color( 0.0, 1.0, 0.0 ); term.print( green1.red() ); term.print( "\t" ); term.print( green1.green() ); term.print( "\t" ); term.print( green1.blue() ); term.print( "\t" ); term.print_line( green1.alpha() ); rgb_color green4 = rgb_color( 0.0, 1.0, 0.0, 1.0 ); term.print( green1.red() ); term.print( "\t" ); term.print( green1.green() ); term.print( "\t" ); term.print( green1.blue() ); term.print( "\t" ); term.print_line( green1.alpha() );
Note: We have added lines here to print each of the red/green/blue/alpha values separately, with a tab ("\t") between each.
begin; begin_pcl; rgb_color green = rgb_color( 0, 255, 0, 1.0 ); #Cannot mix ints and doubles

To review, a variable may be declared and initialized using the following syntax:

The initizializing, in (), is optional, but it is good practice to do so to avoid unexpected behavior. For example, if you declare an integer variable without giving it an initial value, and then start adding to that variable without checking the starting value, you will be adding to an unknown quantity. If some aspect of your experiment is dependent on the value of that variable, the program may not work as you expect.

Naming variables

You can give your variables whatever names you wish, adhering to the following rules:

  • Variable names should include only letters, numbers, and underscores (_).
  • A variable name must start with a letter.
  • Your variable name cannot be the same as any other special word that is part of PCL, like "begin" or "loop".

For ease of programming, it is best to make variable names easy to remember and clear. For example, if you are working on a gambling task and you want a variable to store the total amount of money the user has earned, you might make a variable called total_money or TotalMoney. It also helps that you remain consistent in how you name your variables (e.g., capitalization, underscores, etc.), as it will help you to remember the name of the variable as you continue to work with it in your code.

Assigning values to variables

begin; begin_pcl; int total_value = 0; term.print_line( total_value ); #other script information here total_value = total_value + 1; term.print_line( total_value );
begin; begin_pcl; string name = "John"; term.print_line( name ); #other script information here name = "Ted"; term.print_line( name );
begin; begin_pcl; int default_total = 5; term.print_line( default_total ); int total = default_total; term.print_line( total );

Changing types

Once you have declared a variable, you cannot change the type of that variable. If you are familiar with programming, you may know that this is not always the case in other programming languages. In Presentation, even though a variable cannot be changed to a different type, there are conversion methods so that you can convert the information held in one variable to another variable. The methods used to convert information from one type to another are called conversion methods . Conversion methods can be useful, for example, if you want to include the value of a number in a string. For instance, if participants play a game for points in your scenario, you might want to display the number of points they had onscreen as text. You can only display strings on screen, so you would need to convert the number of points, stored in an integer variable, into a string. In that case, you might use something like:

begin; begin_pcl; int total_points = 5; string string_value = string( total_points ); term.print( "Total points: " + string_value );

Scope of Variables

The examples above are pretty short, so they don't demonstrate the importance of where you declare your variables. Where a variable is declared will determine where it can be used, or its scope . You must declare a variable before using it. A more complicated point about scope is that if you declare a variable inside a sub-part of your scenario - for example a loop or a function - then you can't use it outside that sub-part. So, if you declare a variable inside an conditional, or if statement, that variable does not exist outside of that statement and results in an error:

begin; begin_pcl; #Set a value randomly between 1 and 5 for i int i = random( 1, 5 ); if i > 2 then int j = 2; end; term.print( j ); #This will not work, because j does not exist outside of the if statement int k = 0; # k declared here if i > 2 then k = 2; end; term.print( k ); #This is fine because k is declared outside of the if statement

In this example, because j was declared inside of an if statement, it cannot be used outside of it. However, because k was declared outside of the if statement, you may use it both inside and outside of the following if statement.

Global scope indicates that a variable exists in all parts of the program after the variable is declared. You can establish a variable with global scope by declaring it outside of any subsections of the scenario. Declaring a variable with narrow scope (only when necessary) avoids having to worry about losing track of different points in the scenario where the variable may be changed.

A variable is used to store information. When you declare your variable, you must specify its type (the sort of information it will store, such as int, string or bool) and you can optionally initialize it (give it a starting value). Once you declare a variable, the type of that variable cannot change, but the value can. There are methods for converting information from one type of variable to another type of variable, for example if you need to use an integer value as a string. Finally, we introduced the concept of scope. Scope refers to where in a program a particular variable exists.

In the following exercises, initialize an appropriate variable for the type of data that will be needed for the described portion of an experiment. Print the value of your variable to the terminal window. You may use the experiment/scenario file below.

Example: You are running a task and want to keep track of the number of blocks you have run.

begin; begin_pcl; #Example int num_blocks = 0; term.print_line( num_blocks ); #Question 1 #Question 2 #Question 3 #Question 4 #Question 5 #Question 6
  • Your paradigm is a go/no-go paradigm. You want to declare a variable to store whether the next stimulus is supposed to be responded to or not. The default case is that the stimulus should not be responded to.
  • You want to have a variable to denote the number of trials of a particular type in your paradigm. There are 32 of those trials in the paradigm.
  • You want to print your participant's name to the screen and need a variable to store the name. His name is John Smith.
  • In your paradigm, you want to set a stimulus to change color based on user response. You need a variable to keep track of the color of the object so you can set the stimulus to that color. The initial color is red. Note: Please see the rgb_color initialization chapters above for how to print the values to the terminal.
  • In your paradigm, you rotate a dot about the origin based on the amount of time the scenario has taken, moving 1.5 degrees every 100 ms. You need a variable to keep track of the current angle of the dot with respect to the origin. The dot starts at a 45 degree angle.
  • In your paradigm, participants earn a point for each trial they respond to correctly, and you want a variable to keep track of the number of points they have. They do not have any points when they start.

Additional relevant documentation readings

The following is a page in the Presentation documentation that may be of use to you in further understanding the material presented in chapter 1.

  • Basic PCL Types

IMAGES

  1. Set up TTL in Neurobs Presentation with Smarting Pro Fully mobile EEG

    neurobs presentation video

  2. Set up TTL in Neurobs Presentation with Smarting Pro Fully mobile EEG

    neurobs presentation video

  3. PPT

    neurobs presentation video

  4. How neurons form long-term memories

    neurobs presentation video

  5. Set up TTL in Neurobs Presentation with Smarting Pro Fully mobile EEG

    neurobs presentation video

  6. Neurobs Presentation

    neurobs presentation video

VIDEO

  1. Intro to Programming

  2. Intro to Programming

  3. Intro to Programming

  4. Intro to Programming

  5. VisGen Features Demo

  6. Nerves Quickstart

COMMENTS

  1. Video Stimuli

    Video may be mixed with other visual or auditory stimuli. Following are some important points about video in Presentation: Specific video format support depends on the decompression filters installed on your system. Playback performance will vary with system capabilities. The display mode must be 32 bit color. Presentation handles its own video ...

  2. Presentation/Video

    < Presentation In terms of video playback, Presentation hands the video off to DirectShow, which hands Presentation frames, which Presentation draws to a texture. Presentation doesn't process or re-route the audio at all, DirectShow just uses the system's default audio device. Any video playback issues you might encounter have no solution to be ...

  3. Advanced Video

    The video::advance method can be used to gain complete control over video presentation (without the video audio track). Display of the frames is done by presenting picture stimuli. The video::position and video::current_frame_end methods provide the necessary timing information for displaying the video at the correct speed. The standard ...

  4. Parsing NeuroBS Presentation logs

    In the context of the Aera experiments for the General Psychology Lab at the University of Hildesheim, here is how to download, decrypt, and parse the logs ...

  5. NBSTraining

    Presentation® is a stimulus delivery and experiment control program for neuroscience. It runs on any Windows PC and delivers auditory, visual, and multimodal...

  6. How Presentation Works

    How Presentation Works. Presentation is an application to allow stimulus generation and experimental control. The production of a Presentation experiment can be divided into the following three steps: ... Presentation can currently display 2-d graphics, compressed videos, sounds, 3-d graphics, and force feedback. Presentation can construct text ...

  7. What is Presentation?

    Presentation is a stimulus delivery and experimental control software system for neuroscience. Presentation runs on Windows and uses standard PC hardware. Presentation was designed for behavioral and physiological experiments that collect fMRI, ERP, MEG, reaction time, and electrophysiological (e.g. single neuron) data. At the same time ...

  8. Presentation License Window

    Presentation will give you a code in box number 3. Go to the web site www.neurobs.com and log in to your account. Click on the "Licenses" link in the "My Account" menu. Then click on the "Activate" link in the box describing the license you wish to use to activate Presentation. Copy and paste the code from box 3 into the website form.

  9. Presentation

    Video. Presentation only supports non-proprietary video formats. Neurobs recommends encoding your videos using h264 or XVID, and using the AVI format. The TSG discourages the use of XVID and AVI, because these standards have become obsolete in recent years, but since we have had little success getting alternative non-proprietary video formats to work in Presentation, it seems the use of AVI is ...

  10. Neurobehavioral Systems

    Presentation® is a stimulus delivery and experiment control program for neuroscience that runs on any Windows PC and delivers auditory, visual and multimodal stimuli with sub-millisecond temporal precision. Presentation® is powerful enough to handle almost any behavioral, psychological or physiological experiment using fMRI, ERP, MEG ...

  11. Set up TTL in Neurobs Presentation with Smarting Pro

    Fig 3. Filling the values for TTL. After you have filled in the values like in the Figure above, just click on Close. Some useful info about setting the ports in Neurobs Presentation can be found on their website: Output Port Settings, Event Port Output Finally, if you want to use the demo examples from Presentation, like the well-known N-Back task, simply add the port as indicated earlier ...

  12. Master LSL with mbtStreamer

    Neurobs Presentation for example supports LSL by default, so you don't have to do any additional coding. Check out our blog on Neurobs Presentation and LSL. Code example. For this example, we wrote a pseudo-code to show how LSL programing looks like in different software. First, we need to import the LSL library.

  13. Neurobehavioral Systems

    The Introduction to Programming video tutorial series is part of our larger set of Youtube video tutorials and demonstrations. The Intro to Programming is designed to teach programming from the very basics to the sorts of complex tasks that most Presentation users will need. We are continuing to add further videos to the series.

  14. PDF Programming with Presentation

    Presentation (www.neurobs.com) is a MS Windows based programming tool that allows experimenters to set up and program all sort of experiments. It is the recommended software for time-accurate experiments and therefore supported by the institutes' (Social Sciences Faculty, the MPI and the Donders Centre for Cognitive Neuroimaging) technical ...

  15. Neurobehavioral Systems

    Presentation... runs on Windows Vista/7/8/10. is optimized for behavioral, psychological and physiological experiments using fMRI, ERP, MEG, single neuron recording, reaction time measures, and other performance measures. is built for precise stimulus delivery and accurate event logging. delivers 2D visual, 3D visual, and auditory stimuli ...

  16. PDF How to interface Brain Products hardware and software from Presentation®

    empty, otherwise Presentation® will respond with a warning message. The Brain Products Marker Sending Demo example experiment (available on the Brain Products Website) demonstrates how markers can be sent from Presentation® to a Brain Products amplifier. www.brainproducts.com Figure 3: Settings for using TriggerBox in Presentation®.

  17. NeuroBS Presentation [LNCD]

    Yearly licensed software for task presentation with precision timing. ($310/year; $40/30 days)

  18. Neurobehavioral Systems

    The complete Presentation documentation is contained in the HTML-help file that accompanies the program. However, since this help file contains all the details of Presentation, it can be somewhat daunting if you have not used the software before. The tutorials can help you quickly learn the basics of Presentation. Introduction to Programming ...

  19. Neurobehavioral Systems

    Board: Presentation : 3D video IMPORTANT NOTE : If you have a new question in any of the topic areas, please use the "Create New Thread" link to start a new thread instead of posting the message in an existing thread.

  20. Research Article OpenSync: An open-source platform for synchronizing

    presentation. Moreover, they work only with specific devices, and it is not straightforward to add new devices to these platforms. - Neurobehavioral Systems Presentation® (Neurobs Presentation) is a neuroscience stimulus delivery and experiment control tool for auditory, visual, and multimodal stimulus presentation and data acquisition.

  21. Presentation

    Information concerning specific functionality is covered separately in the remainder of the documentation, organized by functionality. Stimulus Presentation. Describes how sequences of stimuli are organized and how the flow of control proceeds through a scenario. Stimuli. Describes the stimuli that Presentation can present and how to specify them.

  22. Getting Started

    Presentation Help : Help Guide: Presentation: Prev : Next Getting Started. This section provides an overview of the organization of Presentation and its uses. We recommend that you read this section first, since all of the subsequent sections assume an understanding of these concepts. What You'll Need ...

  23. Chapter 1

    Chapter 1 - Variables. Chapter 1 - Variables. This chapter assumes you are familiar with the Presentation GUI and can use the Editor tab and run a scenario. Please see A First Scenario and Running a Scenario if you do not know how to run a scenario. Creating a variable in Presentation is a way of reserving memory to store a particular type of ...