TimescalePupil#

class pypillometry.sim.TimescalePupil(params=None, timescales=('3 s', '10 s', '30 s', '100 s', '300 s'), nu=1.5, binocular=False, cutoff='10 s', eyes=None)[source]#

Bases: SimStep

Latent pupil size from the timescale model (see TimescaleModel): a fast component (Matérn-3/2) and slow components (“atoms”) at fixed time scales, in log-%.

Parameters:
  • params (dict | None) – parameters on their natural scale, as for one unit in TimescaleModel.params: fast_sd (log-%), fast_ell (ms) and the standard deviation of each atom (sd_3s, sd_10s, …; log-%); for two eyes with binocular also diff_sd, diff_ell (the difference between the eyes) and gain (of the common components in the second eye relative to the first). Missing parameters are the centre of the general prior (see general_prior()); the noise (noise_sd) is ignored (see WhiteNoise).

  • timescales (tuple) – time scales of the atoms (plain numbers are ms); default 3, 10, 30, 100 and 300 s

  • nu (float) – smoothness of the atoms (default 1.5)

  • binocular (bool) – if True, the eyes share the fast component and the atoms and differ by a difference component (needs two eyes); if False (default), each eye is drawn independently with the same parameters

  • cutoff (str) – time scale from which on the atoms count as slow, for the ground truth log_slow (plain numbers are ms; default 10 s)

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

Notes

Ground truth per eye (log-%): log_size (the latent signal), log_fast, one entry per atom (log_3s, …), log_slow (the atoms from cutoff) and, if binocular, log_diff; log_size is the sum of the components.

Examples

The components of five minutes of the latent pupil size:

>>> import pypillometry as pp
>>> d = pp.sim.Simulation("5 min", fs=20, seed=1, name="TimescalePupil").pupil().run()
>>> fig = d.plot.plot_components()
../../_images/pypillometry-sim-TimescalePupil-1.png

Methods

apply

change the arrays of the running simulation run

bank

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"

theta

parameter vector of bank (the noise is negligible)

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]

theta(bank)[source]#

parameter vector of bank (the noise is negligible)

Return type:

ndarray

to_dict()#

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

Return type:

dict[str, Any]