TimescalePlots#
- class pypillometry.timescale.plots.TimescalePlots(model)[source]#
Bases:
objectPlots of a
TimescaleModel, used asm.plot(e.g.,m.plot.decomposition()).- Parameters:
model (
TimescaleModel)
Methods
The signal split into its slow part, the fast component and the atoms.
Checks of the fitted model.
The original samples with the reconstruction by the model.
The slow part of the signal for several cut-offs.
Power spectrum of the data and of the fitted model.
Standard deviation of each atom: how much the pupil varies at each time scale.
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:
- 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()).
- 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:
- 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:
- 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.
- 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:
- 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 Falsen_sim (int) – number of simulations of the envelope
ax (matplotlib Axes, optional) – axes to draw on; default: the current axes
- Return type: