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§
- Sync
Error - Why clocks could not be aligned.
Functions§
- fit
- The map from
sourcepulse times toreferencepulse times (both sorted, seconds). - rising_
edges - The rising edges of a digital line sampled at
rateHz, in seconds: where it goes fromfalsetotrue.startis the time of the first sample. - threshold_
edges - The rising edges of an analog channel crossing
thresholdupwards.