Untethered Data Synchronization
Overview
When taking an untethered recording using SpikeGadgets Data Logging Headstages, neural data is recorded directly to the headstage’s onboard SD card, while the record of environmental events is recorded by the main Control Unit (MCU) and saved to your computer. Following the conclusion of a recording session these recordings must be merged in order for neural activity to be correlated to environmental data. Furthermore, this must be done with extremely high temporal accuracy, and consistency. Below is an overview of how SpikeGadgets systems maintain this precision during untethered recordings.
NOTE: Control unit (MCU and Logger Dock) communication with untethered headstages is unidirectional. The control unit transmits commands to the headstage, but the headstage does not send signals/feedback to the control unit.
Radio-frequency (RF) Sync Pulses
When starting or stopping an untethered recording the SpikeGadgets control unit uses a RF transceiver to transmit a Start/Stop command to the headstage. When the headstage receives the command it starts or stops recording neural data to the onboard SD card at the sampling rate specified by the user. The RF signal operates with microsecond precision ensuring the control unit and headstage start and stop times are functionally simultaneous. The start and stop commands flag the current data sample in the recorded data on both the local computer and the headstage.
During the recording, the control unit transmits RF sync pulses to ensure that data synchronization can be maintained throughout the entire session. For most setups these RF sync pulses occur at a 10-second interval. The RF sync pulses and Start/Stop commands are used to maintain data synchronization when dropped packets and/or drift occurs.
Dropped Packets
In most situations where large volumes of data are being transferred within a device, or streamed between devices, data is transferred in packets. When these packets are transferred, it is not uncommon for a small number of packets to be lost, or “dropped”. This can be minimized or eliminated by using the appropriate hardware setup, but can still occur in most electronic systems. In this case, the packets being discussed are recording data and each packet contains header data and 1 sample from each channel being recorded. When synchronization between multiple electronic systems is important, dropped packets must be accounted for, as a missing packet in one record will cause a mismatch in packet/sample count between systems. When a mismatch does occur due, synchronization is achieved by adding or removing packets to realign the data.
Importantly, SpikeGadgets systems give preference to neural data. This means that packets are never added or subtracted from the neural data, and all packet-level adjustments are made to the environmental record:
If a packet is dropped from the neural recording, a packet will be removed from the same position in the environmental record.
If a packet is dropped from the environmental record, the missing packet will be replaced with a duplicate of the directly preceding packet from the environmental record.
SpikeGadgets systems detect and flag dropped packets. This ensures that packet adjustments occur in the correct position. This is a crucial aspect of maintaining accurate synchronization.
Drift
Most electronic devices rely on an internal clock to operate. These clocks are often used as the basis for multi-device synchronization in the absence of a wired connection between devices. One issue inherent to synchronizing devices this way is drift. Drift is the gradual desynchronization that occurs over time between the clocks. It is caused by small fluctuations in clock timing that occur from moment to moment and accumulates over time. Drift is unavoidable under most circumstances, and therefor strategies exist to correct timing errors and maintain alignment precision between clocks. One common strategy is to make small adjustments over time. This is done by systematically adding or subtracting environmental data packets to maintain alignment.
Importantly, this approach to maintaining synchronization is most effective when many shared reference points are present in both recorded timecourses. This allows timing between reference points to be compared so that small local adjustments can be made to maintain synchronization. This approach results in many very small adjustments rather than one large adjustment; greatly improving synchronization precision.
SpikeGadgets systems use RF sync pulses to facilitate this. The control unit transmits RF pulses at a regular interval that are recorded by both the headstage and Trodes. Because RF pulses are recorded simultaneously by both devices, the number of packets between each pair of pulses can be compared. This allows small local timing adjustments to be made systematically throughout the recording when necessary. If a discrepancy in sample count is identified, environmental record samples can either be added or subtracted at the end of a given sync period to realign the data.
The MCU transmit RF pulses at 2 Hz, and most headstages can receive them at up to 1 Hz. Over a 10-second period, it is normal to see adjustments of up to a few dozen packets/samples, amounting to 1-2 milliseconds of drift correction, or an expected timing alignment precision of the same value. Packet drops on the order of hundreds or thousands in a similar time period can be indicative of an error in hardware or with the SD card used to record.
Headstage equipped with status monitoring capabilities via 2-way Radio Link, such as the Sprite32 and Pixie384 operate using a 10 Hz RF protocol. This further increases synchronization precision greatly.