Skip to main content

Module sync

Module sync 

Source
Expand description

Aligning clocks. A camera, an ephys probe and a behaviour rig each count time on their own oscillator: the same moment reads differently on each, and the difference drifts (tens of parts per million is common). Rigs share sync pulses: one TTL line recorded by every device. The times of the same pulses on two clocks give the map between them, a line:

t_reference = slope · t_source + offset

fit finds it from the two lists of pulse times, without assuming they start together or that no pulse was lost: the pulses are paired by their intervals (irregular intervals, a “barcode”, pair unambiguously; perfectly regular pulses are paired from the first one), the line is fitted by least squares, pulses that sit off it are dropped, and the line is fitted again. The Alignment keeps how good it is (residuals), so a view can say “aligned to 0.2 ms” or warn.

Plain data (serde): an alignment is saved as an artifact beside the sources, with its provenance, and every app and the orchestrator use the same one.

Structs§

Alignment
A map from a source’s clock to the reference clock.

Enums§

SyncError
Why clocks could not be aligned.

Functions§

fit
The map from source pulse times to reference pulse times (both sorted, seconds).
rising_edges
The rising edges of a digital line sampled at rate Hz, in seconds: where it goes from false to true. start is the time of the first sample.
threshold_edges
The rising edges of an analog channel crossing threshold upwards.