hello i'm arnold delorme and this presentation is about recording data using the lab streaming layer
also known as lsl we will record eg data of course which is what lsl was originally designed for
i'm going to do a short demo here first we will see the easy way to collect data using live
streaming layer and the matlab viewer recorder eg lab plugin then we will see the standard way
using the lab recorder program i've turned on my muse eeg headset and i put it on here i will use
a muse headset because it's simple to demo and a lot of people have one but you can use any headset
supported by the lsl protocol there is a website showing the more than 100 device supported by lsl
here you can select your device you can download the lsr software to connect to it i put a link
to the website in the description then i start the lsl software to connect to the muse headset
each eg device and each device in general that can produce an event stream as its own software often
provided by the manufacturer i then start matlab and eglab and then i installed the matlab viewer
recorder plugin using the eeg lab plugin manager i search for lsl after installing the plugin
i select the plugin menu to connect the lsl stream i will it will automatically detect
all streams available and uh i can select the stream if there are several i will just use the
default here the progr the program connects to the stream and i can now see my data
i can then press the record button to record it data is not great there is one bad channel here
this is just for demo i'm going to press the stop button and enter the file name to save the data
and i now have a regular app data set that i can use as i would any other eglab data set
first i'm going to load it and then i'm going to plot it
i need to change the scaling and also remove the dc offset sometimes you might have the
last eg channel containing event markers it's not the case here if i had an event channel
i can use this eeg lab menu to import events so this previous solution has limitations you can
only visualize and save a single stream i'm going to show you the approach most people use we will
record the eeg streams using a tool called the lab recorder that saves files in the xdf format i put
the link to download this to on description then we are going to import the data in eg lab so we
have not stopped the streaming eeg data i start the lab recorder program select the eeg stream
then start recording this is not a matlab program it's a python program when i use the
lab recorder program i cannot see the eeg if i wanted to visualize the eeg i can use
other tools such as the matlab viewer i just showed you also i'm using the mac version but
there is a windows in the linux version now i'm stopping the data acquisition this saves the data
as a file in the xdf format so what do we do with this file well we go back to eglab and we
can install the xtf importer there's two ways to import xda files i will show you both here
first we'll use the xtf plugin this one can only import one stream of eeg data you just select the
files we just created and import it and we're also going to plot it so this is similar to plotting
the previous data and the main difference here so we have to remove the dc offset scale the data the
main difference is with this solution is that with the lab recorder you can record multiple streams
so now we're going to try the other way which is using the mobile plugin
first we need to install the plugin of course this plugin will allow you to select different
streams and align them to resample them to match the eeg sampling rate so here i'm
going to select the file with multiple streams this is actually synchronizing two eeg headsets
and we also have even streams and other synchronized devices i will select the two
eeg streams in the right column and the even stream in the left column and then press ok
now i can plot the data and scroll the data i'm going to remove the dc offset i'm also going to
select the larger event window of 32nd you can see the two synchronized eeg streams and the event as
vertical line the first 16 eeg channels are the eeg for the first person and the next each 16
eg channels are the eg for the second person if you're serious about synchronizing streams using
lsl this is the way to do it we're going to go into a little bit more details about the way
things work in lsl first what is the lsl protocol the lsl protocol was developed by christian koff
who was an application programmer in our laboratory at ucsd lsl is a real-time streaming
protocol that allows synchronizing different data streams at different sampling rates so we may have
an eg stream at 512 hertz and an eye tracking stream at 50 hertz and lsl will ensure that
these are synchronized lsl can handle streams with uniform sampling rates and stream with non-uniform
sampling rates such as event streams you can also collect data on different computers connected
to the same local network you can streams from a mac to your pc through the network and vice versa
in general for the sake of stability windows is usually better supported when using the xda
format to save streams as we've done before some synchronization information is saved
so each stream is recorded with sub-millisecond accuracy by the computer that collects it
as the stream is dispatched to the network there is also some synchronization information included
lsl uses a ping mechanism to synchronize streams so let's imagine this setup where
we record eeg from two headsets on different computers then as lsl stream data through
the local wi-fi network we want to save them in the xdf file using the lab recorder application
not that here i have free computers but the same could happen on sale on computer that would
run lsl apps for each of the two headsets and run the lab recorder applications simultaneously
each recorder will transfer the data to the local network but in addition to the data
the lab recorder application will save ping time with each of the two lsl apps every couple of
seconds these ping times are stored in the xda files and may be used to synchronize the stream
when imported in eg lab or other software now a word about even streams mouse click and keyboard
events can be recorded with even streams and they're also synchronized with other streams
in theory you can achieve sub-millisecond precision synchronization but this really depends
on your settings in one of our settings for example we recorded the actual latency of events
and lsl events latency and you can see a pretty large jitter up to a 20 millisecond shown here
which is very large considering eg experiment this is probably an extreme example but do
not assume that the synchronization is perfect and more importantly test the synchronization
manufacture can affect synchronization such as the architecture of your network your router
the load of your network the load of the computer the way lsl apps record events etc if you're using
continuous streams with fixed sampling rates it's not so important since the sampling rates
are fixed you simply have to align them the best you can using all the available ping times so if
you have jitter on some of the pings it's not a big deal as they'll be averaged out however
if you have streams with irregular sampling rates such as discrete events it's important
to check that your setup support uh proper synchronization using lsl this is why i personally
still record events in the eeg data channel and not as an lsl event stream hopefully as
lsl is increasing in popularity there will be more tools to look into these synchronization issues
what is what is this cloud doing here so i hope you've enjoyed this video
press the bell button to be notified when new videos are released and thanks for watching