ClockSync#

class pypillometry.ClockSync(offset, slope, src, dst, src_units, dst_units)[source]#

Bases: object

Linear map between two clocks, fitted by sync_clocks().

Maps times t on the source clock (e.g., a behaviour log) to the target clock (e.g., the eye tracker): offset + slope * t. The slope accounts for the unit conversion and for the drift between the clocks.

Calling the object maps times: plain numbers are taken to be in src_units and are returned as an array in dst_units; numbers with units and Events are converted first and returned in dst_units (as Events for Events, which are then no longer marked as needs_sync).

Attributes:
offsetfloat

target time (in dst_units) of source time 0

slopefloat

target units per source unit

driftfloat

Relative drift of the target clock against the source clock.

residualsnp.ndarray

target times minus mapped source times (in dst_units); they are small (around the timing precision) if the pairs are correct

src, dstnp.ndarray

the paired times (in src_units and dst_units)

src_units, dst_unitsstr

units of the source and target times

Examples

>>> sync = sync_clocks([10, 70, 130], [5000, 65000.6, 125001.2],
...                    src_units="sec", dst_units="ms")
>>> round(sync(100.0), 1)
95000.9

Methods

summary

One-line summary of the fit.

Details

summary()[source]#

One-line summary of the fit.

Return type:

str

property drift: float#

Relative drift of the target clock against the source clock.