downsample#

pypillometry.downsample(fsd, dsfac=False, policy='default')#

Pipeline step for downsample() (d | pp.downsample(...)).

Simple downsampling scheme using mean within the downsampling window.

All data fields and the time-vector are downsampled simultaneously. See pypillometry.signal.baseline.downsample(). The samples that are unusable under the mask policy are left out of the window means (by default, interpolated samples are used, see mask()). A layer is kept for a new sample if it covers more than half of its window. A new sample whose window has no usable sample holds the mean of the stored values (NaN only if they are NaN) and stays unusable.

The new sampling rate is fs/factor, the rate of the decimated data. It differs from fsd if fs/fsd is not an integer (e.g., 1000 Hz with fsd=300 gives factor 3 and 333.3 Hz).

Parameters:
  • fsd (float) – new sampling-rate (in Hz) or decimate-factor

  • dsfac (bool) – if False (default), fsd is the requested sampling rate (the decimate factor is int(fs/fsd); a warning is logged if fs/fsd is not an integer); if True, fsd is the decimate factor (a positive integer)

  • policy (str, MaskPolicy or list of str) – mask policy that decides which samples are used for the window means (see mask()); default "default"

  • inplace (bool or None, optional) – if True, make change in-place and return the object; if False, make and return copy before making changes; if None, use the object-level setting (specified in the constructor)

Return type:

EyeData

Returns:

the downsampled object (self or a copy, depending on inplace)

Raises:
  • TypeError – if fsd is not a number

  • ValueError – if the sampling rate fsd is not above 0 and at most fs, or the decimate factor is not a positive integer