TrackerLoss#

class pypillometry.sim.TrackerLoss(rate='0.5/min', duration='lognormal(150 ms, 200 ms)', binocular=False, eyes=None)[source]#

Bases: SimStep

Losses of the pupil by the tracker: stretches of missing samples at random times, without a transient.

Parameters:
  • rate (str) – mean rate ("0.5/min"; plain numbers per minute)

  • duration (str) – duration of a loss

  • binocular (bool) – if True, the losses are the same in all eyes; if False (default), each eye has its own

  • eyes (tuple | None) – eyes (default: all eyes of the simulation)

Notes

Ground truth: one true event "loss" per loss and eye in d.truth_events (with the metadata eye and duration).

Examples

Ten seconds with losses (shaded):

>>> import pypillometry as pp
>>> import matplotlib.pyplot as plt
>>> d = (pp.sim.Simulation("10 s", fs=500, seed=1)
...      .pupil().units(800).loss(rate="20/min", duration="300 ms").noise(0.1).run())
>>> t = d.tx / 1000
>>> fig, ax = plt.subplots(figsize=(8, 3), layout="constrained")
>>> _ = ax.plot(t, d.truth["left", "pupil"], color="0.7", label="true")
>>> _ = ax.plot(t, d["left_pupil"], label="data")
>>> for onset, dur in zip(d.truth_events.onsets, d.truth_events.meta["duration"]):
...     _ = ax.axvspan(onset / 1000, (onset + dur) / 1000, alpha=0.2)
>>> _ = ax.set(xlabel="time (sec)", ylabel="pupil")
>>> _ = ax.legend()
../../_images/pypillometry-sim-TrackerLoss-1.png

Methods

apply

change the arrays of the running simulation run

eyes_in

the eyes of the simulation the step applies to

from_dict

the step from to_dict()

generate

the events and the duration (ms), for steps of stage "events"

to_dict

name and parameters of the step (numbers, strings, lists, dicts)

Details

static from_dict(d)#

the step from to_dict()

Return type:

SimStep

apply(run, rng)[source]#

change the arrays of the running simulation run

Return type:

None

eyes_in(run)#

the eyes of the simulation the step applies to

Return type:

tuple[str, ...]

generate(rng)#

the events and the duration (ms), for steps of stage "events"

Return type:

tuple[dict[str, ndarray], float]

to_dict()#

name and parameters of the step (numbers, strings, lists, dicts)

Return type:

dict[str, Any]