Wiki

Clone wiki

SimBSI / Synchronization of multimodal data in closed-loop systems

When we use LSL to record multiple streams of data, they often have offsets that can be introduced by 1) differences in computer clocks, 2) random network delays, 3) different sampling rates. This is not a problem when the data collected are analyzed offline, as the XDF file importer can deal with this issue using the metadata collected by LSL.

In real-life closed-loop systems involving multiple streams of data, however, time delays need to be determined and corrected for online. The purpose of this section is to determine the effect of time delays introduced by our implementation of the LSL blocks in Simulink.

Simulation

Simulation setup:

  • To minimize the confounding effect of random network delays, we only used one computer running both sender and receiver apps.
  • Computer specs: CPU i7-7700HQ at 2.8 GHz x8, RAM 16 Gb, running Ubuntu 16.04.
  • Two independent MATLAB sessions running the sender and receiver apps respectively as shown below.
  • The sender app simulated an EEG streaming device emitting 32-channels signal sampled at 128 Hz.
  • The EEG and event marker data were pulled from the eeglab_data.set file that comes with EEGLAB.
  • A single clock in the sender was used to timestamp all the outgoing samples.
Sender Receiver
sender.png receiver.png
Open in MATLAB with open(fullfile(simbsi.rootDir,'examples','Sender.slx')) Open in MATLAB with open(fullfile(simbsi.rootDir,'examples','Receiver.slx'))

Result

The figure shows the histogram of the time delays of the samples emitted by the markers streams with respect to those emitted by the EEG stream. The x and y-axis represent the time delay in milliseconds and the number of samples received respectively. As we can see, most time delays are around zero and all others are within -7 ms and 7 ms. Since the sampling rate of the sender is 128, the maximum time delays correspond to a misalignment of 1 sample, which for most EEG applications may be negligible.

sim_sim.png

Updated