TimescalePlots#

class pypillometry.timescale.plots.TimescalePlots(model)[source]#

Bases: object

Plots of a TimescaleModel, used as m.plot (e.g., m.plot.decomposition()).

Parameters:

model (TimescaleModel)

Methods

decomposition

The signal split into its slow part, the fast component and the atoms.

diagnostics

Checks of the fitted model.

interpolation

The original samples with the reconstruction by the model.

slow

The slow part of the signal for several cut-offs.

spectrum

Power spectrum of the data and of the fitted model.

timescales

Standard deviation of each atom: how much the pupil varies at each time scale.

variogram

Semivariogram of the data and of the fitted model.

Details

decomposition(eye=None, cutoff='10 s', plot_range=None, units='min', axes=None, figsize=(12, 8))[source]#

The signal split into its slow part, the fast component and the atoms.

Three panels (in log-%): the data of the model with the slow part (the mean plus the atoms with a time scale of at least cutoff) and two posterior standard deviations around it; the fast component; and the atoms.

Parameters:
  • eye (str, optional) – eye to plot (default: the first eye of the model)

  • cutoff (float, str or Quantity) – time scale from which on the atoms count as slow (plain numbers are ms; default 10 s)

  • plot_range (tuple, optional) – (start, end) of the part of the recording to plot, in units

  • units (str) – unit of the time axis (default “min”)

  • axes (sequence of 3 Axes, optional) – axes to draw on; default: a new figure

  • figsize (tuple) – size of the new figure

Return type:

Figure

diagnostics(eye=None, axes=None, figsize=(13, 3.8))[source]#

Checks of the fitted model.

Three panels: quantiles of the standardised one-step prediction errors against the normal distribution (heavy tails: fast changes or artifacts that a Gaussian model does not expect); their autocorrelation (should be near 0); and the standard deviation of the standardised forecast errors over horizons from 50 ms to 60 s (should be near 1, see TimescaleModel.forecast_calibration()).

Parameters:
  • eye (str, optional) – eye to plot (default: the first eye of the model)

  • axes (sequence of 3 Axes, optional) – axes to draw on; default: a new figure

  • figsize (tuple) – size of the new figure

Return type:

Figure

interpolation(eye=None, plot_range=None, units='sec', data=None, interval=0.95, ax=None)[source]#

The original samples with the reconstruction by the model.

Shows the data at the original sampling rate and in their units: the samples the model used, those it did not use (blinks and other masked artifacts), the expected signal under the model with its posterior interval, and the slow part.

Parameters:
  • eye (str, optional) – eye to plot (default: the first eye of the model)

  • plot_range (tuple, optional) – (start, end) of the part of the recording to plot, in units; default: the first 30 s of the first segment

  • units (str) – unit of the time axis (default “sec”)

  • data (EyeData, optional) – the data (default: the data the model was built from)

  • interval (float) – probability of the posterior interval (default 0.95)

  • ax (matplotlib Axes, optional) – axes to draw on; default: the current axes

Return type:

Axes

slow(eye=None, cutoffs=('3 s', '10 s', '30 s', '100 s'), plot_range=None, units='min', ax=None)[source]#

The slow part of the signal for several cut-offs.

The slow part is the mean plus all atoms with a time scale of at least the cut-off; all atoms are estimated, so the cut-off can be chosen after the fit.

Parameters:
  • eye (str, optional) – eye to plot (default: the first eye of the model)

  • cutoffs (sequence of float, str or Quantity) – cut-offs to compare (plain numbers are ms)

  • plot_range (tuple, optional) – (start, end) of the part of the recording to plot, in units

  • units (str) – unit of the time axis (default “min”)

  • ax (matplotlib Axes, optional) – axes to draw on; default: the current axes

Return type:

Axes

spectrum(eye=None, window='200 s', ax=None)[source]#

Power spectrum of the data and of the fitted model.

The spectrum of the data comes from the windows of the data of the model that have few gaps (see spectrum()). Peaks at the frequency of the trials (responses locked to a fixed rhythm) are not part of the model.

Parameters:
  • eye (str, optional) – eye to plot (default: the first eye of the model)

  • window (float, str or Quantity) – length of the windows (plain numbers are ms; default 200 s)

  • ax (matplotlib Axes, optional) – axes to draw on; default: the current axes

Return type:

Axes

timescales(ax=None)[source]#

Standard deviation of each atom: how much the pupil varies at each time scale.

The bars are approximate 95 % intervals (two standard errors of \(u = \log(v + v_0)\)). Neighbouring atoms are hard to separate in one recording; the sum over the slow atoms (TimescaleModel.slow_sd()) is determined much better.

Parameters:

ax (matplotlib Axes, optional) – axes to draw on; default: the current axes

Return type:

Axes

variogram(eye=None, check=False, n_sim=40, ax=None)[source]#

Semivariogram of the data and of the fitted model.

The square root of the semivariance (the typical size of a change of the signal over a lag, in log-%) on logarithmic axes, with the contribution of each component.

Parameters:
  • eye (str, optional) – eye to plot (default: the first eye of the model)

  • check (bool) – also draw the 95 % envelope of simulations of the model with the gaps of the data (see TimescaleModel.variogram_check()); default False

  • n_sim (int) – number of simulations of the envelope

  • ax (matplotlib Axes, optional) – axes to draw on; default: the current axes

Return type:

Axes