Synchronizing your EEG recordings

So you’ve got tons of mega bytes of EEG data from a big recording campaign with several volunteers. You persuaded them to wear your EEG recording device for 40 minutes, performing several mental tasks and receiving all types of external stimuli. You are now ready to process the data and confirm your breakthrough hypothesis.


Photo credit: Ben Earwicker

Well, yes, but did you invest effort in having the appropriated synchronization system for your recordings? If the answer is no you might end just having a bunch of disorganized EEG data where it would be impossible to know when the subjects were performing each of the mental tasks or when the stimuli were presented to them. Your breakthrough then would have to wait to the next recording campaign.

In this post I’d like to explain different ways of synchronizing your EEG recordings using available behavioral experiment software and what things need to be considered according to the type of experiment and the type of EEG recording system you are using.


The classic (old?) way: hardware synchronization

You have got a wired EEG recording system like Biosemi and a behavioral experiment software like Presentation or E-Prime. Then you connect both the computer where the software runs and the EEG device with a parallel port.

The behavioral experiment software can be programmed to send different codes through the parallel port every time you need to mark something relevant in your experiment (like the subject being asked to close his/her eyes, the presentation of an image or a sound, etc.).

The EEG recording system synchronously samples the EEG signal from the electrodes and the signal from the parallel port so they are perfectly aligned.

Using this approach you can look for EEG events that happens just a few milliseconds after a stimulus presentation (like an auditory ERP which appears 100 ms after the stimulus).

An alternative way: software synchronization

What if I don’t have a wired EEG amplifier to which I can connect the parallel port of my computer? or what if the computers I usually work with don’t have a parallel port any more? or what if I don’t even know what a parallel port is? Don’t worry, you’re not alone. Luckily, there are alternative ways of synchronizing your experiment using software techniques.

When your experiment doesn’t require high synchronization accuracy you only need that your behavioral experiment software sends a message to the EEG recording software every time something relevant needs to be marked. This very simple approach is available for instance in NIC, the software that controls the Enobio EEG device. By using a TCP/IP connection, any behavioral experiment software can send their event codes to NIC. You can use this type of synchronization when you don’t mind if the message might be received hundreds of milliseconds after the event was really generated. For instance when you want to signal different phases on your experiment like the starting and finishing of a mental task which lasts tens of seconds or minutes.

In case your experiment deals with events whose brain response is expected to be in the millisecond range (like the ERPs explained in this post) the approach explained above is obviously not valid. In that case the EEG recording software needs to precisely know exactly when the behavioral experiment signaled an event or produced a stimulus.

This is the whole process: the behavioral experiment software produces a message anytime something relevant happens; the message includes the event code and the current time according to the machine where the software is running; the message is received by the recording EEG program; and the recording program then needs to match the exact time included in the message to the clock of the local machine.

In other words, the clocks from both computers need to be synchronized. There are different ways of achieving the synchronization needed by using standard Internet protocols like the NTP (Network, Time Protocol). The implementation of this protocol is used for instance by the Lab Streaming Layer library. This is an opensource library that can currently be integrated, for instance, into Presentation. The NIC software also integrates the Lab Streaming Layer so it can receive events from behavioral experiment programs which include this library. We have tested it here at Neuroelectrics getting great results that allow synchronizing at millisecond level (check this white paper out). We also know that some of our clients have successfully integrated this library in their projects using PsycoPy or Unity.

All in all, software synchronization is a very convenient solution when you are using wireless EEG amplifiers like Enobio or modern computers with no access to old parallel port hardware. And the Lab Streaming Layer is a nice and neat implementation solution that allows us to achieve synchronization with millisecond precision.


Captura de pantalla 2015-10-22 a las 15.42.59

Leave a Reply

NEUROELECTRICS BARCELONA, S.L.U. collects and processes personal data in accordance with the EU General Data Protection Regulation (GDPR).