pynapple.core.time_series.Ts.restrict#

Ts.restrict(iset)#

Restricts a time series object to a set of time intervals delimited by an IntervalSet object

Parameters:

iset (IntervalSet) – the IntervalSet object

Returns:

Tsd object restricted to ep

Return type:

Ts, Tsd, TsdFrame or TsdTensor

Examples

The Ts object is restrict to the intervals defined by ep.

>>> import pynapple as nap
>>> import numpy as np
>>> t = np.unique(np.sort(np.random.randint(0, 1000, 100)))
>>> ts = nap.Ts(t=t, time_units='s')
>>> ep = nap.IntervalSet(start=0, end=500, time_units='s')
>>> newts = ts.restrict(ep)

The time support of newts automatically inherit the epochs defined by ep.

>>> newts.time_support
    start    end
0    0.0  500.0