Comb#
- class pypillometry.sim.Comb(rate='15/min', duration='lognormal(70 ms, 80 ms)', interval='lognormal(12 ms, 6 ms)', gap='lognormal(7 ms, 6 ms)', depth='normal(0.045, 0.01)', missing=1.0, binocular=False, eyes=None)[source]#
Bases:
SimStepComb artifacts: bursts of teeth, short dropouts of the pupil with a too-small value on each side, or short drops without missing samples, so that the signal looks like a comb.
The bursts come at random times (rate); in a burst, a tooth starts every interval until the end of the burst (duration). With probability missing, the tracker loses the pupil for gap, and the sample before and the one after the dropout are lowered by depth (a fraction of the pupil); otherwise, the samples of the gap are lowered by depth and are not missing.
d.pupil.mask_comb()finds the lowered samples. The defaults are close to the comb of an EyeLink recording (1000 Hz).- Parameters:
rate (
str) – mean rate of the bursts ("15/min"; plain numbers per minute)duration (
str) – duration of a burst (from the start of its first tooth to the start of its last one)interval (
str) – time from the start of one tooth to the start of the next (at least one sample)gap (
str) – duration of the dropout of a tooth (or of the drop, without missing samples; at least one sample)depth (
str) – how much a lowered sample is lowered, as a fraction of the pupil (drawn for each lowered sample)missing (
float) – share of the teeth with a dropout (default 1); 0: all teeth are drops without missing samplesbinocular (
bool) – if True, the bursts and teeth are the same in all eyes (the depths are drawn for each eye); if False (default), each eye has its owneyes (
tuple|None) – eyes (default: all eyes of the simulation)
Notes
Ground truth:
combper eye (the fraction by which each sample was lowered, 0 elsewhere), and one true event"comb"per burst and eye ind.truth_events(with the metadataeye,durationandteeth, the number of teeth).Examples
A burst of teeth with dropouts (default) and one without (
missing=0):>>> import numpy as np >>> import pypillometry as pp >>> import matplotlib.pyplot as plt >>> fig, axes = plt.subplots(2, 1, figsize=(8, 4.5), layout="constrained") >>> for ax, missing in zip(axes, (1, 0)): ... d = (pp.sim.Simulation("1 min", fs=1000, seed=3).pupil().units(800).noise(0.1) ... .comb(missing=missing).run()) ... te = d.truth_events ... t0 = te.onsets[np.argmax(te.meta["teeth"])] # the longest burst ... win = (d.tx > t0 - 30) & (d.tx < t0 + 200) ... _ = ax.plot(d.tx[win], d.truth["left", "pupil"][win], color="0.7", label="true") ... _ = ax.plot(d.tx[win], d["left_pupil"][win], ".-", ms=3, label="data") ... _ = ax.set(title=f"missing={missing}", xlabel="time (ms)", ylabel="pupil") >>> _ = axes[0].legend()
Methods
change the arrays of the running simulation run
the eyes of the simulation the step applies to
the step from
to_dict()the events and the duration (ms), for steps of stage
"events"name and parameters of the step (numbers, strings, lists, dicts)
Details
- generate(rng)#
the events and the duration (ms), for steps of stage
"events"