pynapple.Tsd.restrict#
- Tsd.restrict(iset)[source]#
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:
Examples
>>> import pynapple as nap >>> import numpy as np; np.random.seed(42) >>> t = np.unique(np.sort(np.random.randint(0, 1000, 100))) # random times >>> tsd_before = nap.Tsd(t=t, d=np.random.rand(len(t)), time_units='s') >>> tsd_before Time (s) ---------- --------- 1.0 0.449754 13.0 0.39515 20.0 0.926659 21.0 0.727272 34.0 0.326541 58.0 0.570444 71.0 0.520834 ... 875.0 0.0648922 897.0 0.253915 931.0 0.246876 942.0 0.696304 955.0 0.712271 957.0 0.148087 975.0 0.99774 dtype: float64, shape: (94,)
tsd_before is a timestamp object with data.
>>> ep = nap.IntervalSet(start = 0, end = 500, time_units = 's') >>> ep index start end 0 0 500 shape: (1, 2), time unit: sec.
ep is an IntervalSet object defining the epochs.
>>> ep = nap.IntervalSet(start = 0, end = 500, time_units = 's') >>> tsd_after = tsd_before.restrict(ep) >>> tsd_after Time (s) ---------- -------- 1.0 0.449754 13.0 0.39515 20.0 0.926659 21.0 0.727272 34.0 0.326541 58.0 0.570444 71.0 0.520834 ... 459.0 0.110891 466.0 0.439337 474.0 0.201719 475.0 0.895764 476.0 0.47537 484.0 0.563276 491.0 0.695516 dtype: float64, shape: (53,)
tsd_after is a timestamp object restricted to the epochs.