Skip to content

Real time streaming with LSL

aortega255 edited this page Dec 12, 2022 · 4 revisions

ninjaGUI allows real-time streaming of the data acquired by the GUI (fNIRS channels, manual triggers and auxiliaries) using Labstreaming layer (LSL). LSL is a popular data streaming library commonly used in neuroscience experiments to capture and synchronize data from multiple hardware and software sources in a single file. Instruments and software used in neuroscience commonly provide native LSL support. For example, a common application is to use LSL to broadcast the triggers from a task presenting program (say, one built with PsychoPy) via hardware without needing cables; then, a third, custom made program can capture the LSL streams for the triggers and the fNIRS data and easily synchronize the triggers with the fNIRS data with the timestamps provided by LSL.

ninjaGUI broadcasts the data as a single stream called "ninjaNIRS" (there is currently no option to rename the stream). This streams contains all the data acquired from the GUI: first the fNIRS channel data organized in the same order as in the measurementlist or probe file; then the auxiliaries (ordered by their corresponding number), and finally the manual triggers generated by pressing the "Stim mark" button on the GUI.

To enable LSL streaming, the "Data streaming" option from the "Options" menu needs to be checked. Currently, the option is enabled by default. Note that streaming will be disabled regardless of the checkmark if LSL is not properly installed.

To install LSL, follow the instructions in Matlab LSL readme file. This is necessary to obtain binary files that will work with your platform. Once the binaries have been added to the "liblsl-Matlab" folder, copy the "liblsl-Matlab" folder to the ninjaGUI folder. If everything went well, a message indicating that a stream was created will be displayed when ninjaGUI is next run (alternatively, if not installed correctly, the message: "Labstreaming layer not found or not installed correctly" will be generated when starting ninjaGUI.

Note that generating the binaries sometimes does not work in some computers (depending on their configurations). The simplest solution to not deal with this is to copy the "liblsl-Matlab" folder with the binaries from another computer. Unfortunately, binaries generated for a given Matlab version might not work on a computer with a different version, and thus generating the binaries is the best way to ensure compatibility.