syncWithHeadsetClock
This method lets you synchronize the monotonic clock of your application with the monotonic clock of Cortex. It is an important step if you want to inject markers with a high precision.
Cortex uses a different clock for each headset and it initializes this clock when the headset is connected by Bluetooth or USB dongle. This means that:
You must call “syncWithHeadsetClock” after the headset is connected, not before.
You must provide a headset id.
If the headset is disconnected and connected again, then you must call this method again.
The simplest solution is to call this method just before .
Cortex sets the timestamps of each EEG sample using the of the computer. It is more reliable than using the system clock, because the system clock is subject to unpredictable variations, notably because of the synchronization.
When you to a record, Cortex uses the parameter "time" of your request to associate the marker with the EEG sample that has the closest timestamp. So if you want to have accurate markers, you should set the time of your markers using the monotonic clock, not the system clock.
Most programing languages provide a function to get a monotonic time. But in general, the point of origin of this time is undefined. So you need to synchronize the monotonic clock of your application with the monotonic clock used by Cortex. This is the purpose of this Cortex API method.
This method takes 3 parameters:
Name
Type
Required
Description
The result is a JSON object with these fields:
To synchronize your clock, you must add the “adjustment” to your monotonic times. If the “adjustment” is positive, then it means your clock is late compared to the Cortex clock. If the “adjustment” is negative, then your clock is ahead of the Cortex clock.