pynapple.TsdTensor.decimate#

TsdTensor.decimate(down, order=8, filter_type='iir', ep=None)#

Downsample the time series by an integer factor after an antialiasing filter.

As default, applies an antialiasing Chebyshev type I filter and downsample. The filter is a low pass-filter, if filter_type is set to “fir”, applies a 30 point filter with Hamming window.

Parameters:
  • down (int) – The down-sampling factor.

  • order (int, optional) – The order of the filter. Default is 8.

  • filter_type (literal, "iir" or "fir".) – The filter type. Default is “iir”.

  • ep (IntervalSet) – The epoch over which applying the decimate algorithm.

Example

>>> import pynapple as nap
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> noisy_data = np.random.rand(100) + np.sin(np.linspace(0, 2 * np.pi, 100))
>>> tsd = nap.Tsd(t=np.arange(100), d=noisy_data)
>>> new_tsd = tsd.decimate(down=4)
>>> plt.plot(tsd, color="k", label="original")
[<matplotlib.lines.Line2D at ...
>>> plt.plot(new_tsd, color="r", marker="o", label="decimate")
[<matplotlib.lines.Line2D at ...
>>> plt.plot(tsd[::4], color="g", marker="o", label="naive downsample")
[<matplotlib.lines.Line2D at ...
>>> plt.legend()
<matplotlib.legend.Legend at ...
>>> plt.show()

(Source code, png, hires.png, pdf)

../_images/pynapple-TsdTensor-decimate-1.png

Downsample with decimate#