Skip to content

Tutorial 1: Getting started with LSL (single stream)

mgbleichner edited this page Dec 21, 2016 · 22 revisions

In this tutorial you get to know the basic building blocks of LSL. You will open an LSL stream of the microphone of your computer, save it to a xdf file using the LabRecorder and load the resulting file data into MATLAB.

For this tutorial you need

The LSL App can be downloaded from the ftp as .zip files.

Make sure that you have connected a microphone to your computer and that it is selected as the "default recording device" (you should be able to set this in your Control Panel).


  • Start AudioCaptureWin.exe
    • You should see a window like the following.

https://raw.githubusercontent.com/wiki/sccn/labstreaminglayer/screenshots/audiocapturewin.png

 * Click the "Link" button to link the app to the lab network. If successful, the button should turn into "Unlink". If a firewall complains, allow the app to connect to the network.

* You should now have a stream on your lab network that has type "Audio" and its name is "AudioCaptureWin". Note that you cannot close the app while it is linked.

* You just created your first LSL stream that captures the microphone of your PC. 
  • Start MATLAB (we use here Version 12) and change to the directory MATLAB viewer

    • Run the vis_stream.m script: type ‘vis_stream’
    • Select the AudioCaptureWin stream, press ‘OK’
    • You now see two lines for the incoming microphone input. The arrow keys allow you the change the figure’s Y -axis (i.e. amplitude, up arrow, down arrow) and the X-axis (i.e. time, left arrow right arrow)
  • Start LabRecorder.exe. The [LabRecorder] (https://github.com/sccn/labstreaminglayer/wiki/LabRecorder.wiki) stores all data streams into a single .xdf file.

    • After you click update you should see a window like the following, but only with one stream

https://raw.githubusercontent.com/wiki/sccn/labstreaminglayer/screenshots/labrecorder-default.png * Select the AudioCaptureWin stream by checking the check box next to it. * The entry in "Storage Location" shows you the file name (or file name template) where your recording will be stored. You can change this by clicking the browse button. * If this string contains any occurrence of %n, it will be replaced by the value in the "Experiment Number“ field. When you start the recorder or load a configuration file, this field will be set automatically to the lowest number for which no directory exists yet * If the string contains any occurrence of %b, it will be substituted by the selected string under "Current experiment block". * If the respective directory does not yet exist, it will be created automatically (except if you do not have the permissions to create it). If the file that you are trying to record to already exists, the existing file will be renamed (the string _oldX will be appended where X is the lowest number that is not yet occupied by another existing file). This way, it is impossible to accidentally overwrite data.
* Record data for some seconds while you are speaking into the microphone * Click "Stop" to end the recording.

  • In MATLAB change to the directory of MATLAB Importer
    • To load the xdf file type data=load_xdf(‘C:\Recordings\CurrentStudy\exp18\untitled.xdf’)

    • Familiarize yourself with the data structure. The structure holds all recorded LSL streams ( in this case only one)

      • .info contains all meta information about the stream
      • .time_stamps contains the timing information
      • .time_series contains the data
    • To see the metadata of the stream type data{1}.info

which will look like this:

           name: 'AudioCaptureWin'
           type: 'Audio'
  channel_count: '2'
  nominal_srate: '44100'
 channel_format: 'float32'
      source_id: 'neuro-st5{3.0.1.00000001}.{A3ED9185-1E02-411C-B11B-05D92F25CEF4}'
        version: '1'
     created_at: '664014.051553344'
            uid: '823b227b-737c-46f5-9d9c-cd52baafbe9a'
     session_id: 'default'
       hostname: 'neuro-st5'
      v4address: [1x1 struct]
    v4data_port: '16572'
 v4service_port: '16572'
      v6address: [1x1 struct]
    v6data_port: '16572'
 v6service_port: '16572'
           desc: [1x1 struct]
  clock_offsets: [1x1 struct]
first_timestamp: '-1'
 last_timestamp: '0'
   sample_count: '0'

  • Visualize the data