Timing Synchronization in EEG Experiments

Introduction

The goal of this page is to demonstrate how to properly synchronize events in the context of EEG experiments and to validate that that sychronization has been done correctly.

A key concern in all EEG experiments is to verify that the timing of all data points is known with sufficient precision. Generally EEG analysis triggers off of key points in time, such as a key press, the playing of a sound, or the display of an image on a computer screen. If the timing of these events cannot be well measured, this will cause the loss, reduction, or blurring of any measured quantities triggered by the events.

There are three common types of timing errors. The first is constant offset. This is when an event is believed to have occurred at t, but actually occurred at t+t0, where t0 is constant. If t0 is measured, it can typically be corrected for. The second kind of error is drift. For drift, two devices will be synchronized for short timescales, but as time passes, the difference between the two clocks will increase. Drift is typically either linear (which can be corrected for by rescaling the clock rate of one of the clocks) or random (which cannot be corrected for). The third common kind of timing error is jitter. This is random variations in the timing offset from measurement to measurement. This cannot be corrected for during analysis, so it must be solved prior to acquiring data.

General Principles

1) When possible, it is best to use hardware synchronization. In hardware synchronization, the hardware clock of one data acquisition device (such as those made by National Instruments or a scientific grade EEG device such as those made by BioSemi) is chosen as master. Everything acquired directly into that device is synchronized automatically. In the case of BioSemi, there is an analog input box that allows the collection of additional analog signals, while digital signals can be acquired by the standard receiver. This allows the connection of light and sound meters, and so forth, as long as the output is in volts. Many such devices are available on BioSemi's accessories page. However, with some electronics skill it is often possible to build equivalent accessories 100 times cheaper.

It is also often possible to drive other hardware devices by the means of a timing signal, typically a 5V signal, where every pulse from the master device generates one clock in the slave device.

2) Theoretically, it is always possible to use hardware synchronization. However, this often prevents the use of consumer grade, off-the-shelf technology. For example, if you would like to generate complex and accurately timed visual stimuli with a consumer-grade operating system such Windows, Macintosh or most Linux variants, more creativity is needed. For dealing with situations like these Christian Kothe, of SCCN, has developed the lab streaming layer (LSL). This allows relatively straightforward synchronization of software timing with hardware timing. In general, 50 ms accuracy is achievable with minimal effort, while 1 ms accuracy is achievable with effort.

3) For synchronization, as with most matters, proper behavior must be validated through testing. The reliability of the lab streaming layer is described here.

Validation

With synchronization, as with most technology dependent matters, proper behavior must be verified through testing. First, it is desirable to verify the synchronization capabilities of LSL directly. After that, each modality of interest must be inspected. The following modalities have been tested:

Screen, Psychophysics toolbox

Video, Psychophysics toolbox

Audio, Psychophysics toolbox

Required software

All instructions in this section assume that you have the following software installed. Different setups can be used, but various instructions may need to be modified by you.

Windows 7 64 bit. Other versions of Windows are likely to work without modification. LSL is compatible with other operating systems, but various hardware devices are not.

Matlab R2013a. Unfortunately, Matlab is highly version dependent and other versions are unlikely to work with MoBILAB.

Lab Streaming Layer, 1.0.30

EEGLAB version 13

MoBILAB, a plug in for EEGLAB that supports mobile brain-body experiments.