pynapple.TsdFrame.restrict#
- TsdFrame.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))) >>> tsdframe_before = nap.TsdFrame(t=t, d=np.random.randn(len(t), 4), time_units='s') >>> tsdframe_before Time (s) 0 1 2 3 ---------- ---------- ---------- --------- ---------- 1.0 -2.17833 -1.0439 0.172694 0.324199 13.0 0.74586 -1.83658 0.564464 0.0255007 20.0 0.473193 0.659191 2.34075 1.07099 21.0 0.0964165 0.419102 -0.953028 -1.04787 34.0 -1.87568 -1.36678 0.636305 -0.906721 58.0 0.476043 1.30366 0.211587 0.597045 71.0 -0.896335 -0.111988 1.46894 -1.1239 ... 875.0 0.366909 0.209497 -0.875562 -0.234848 897.0 -0.987229 -0.491164 -1.20912 1.58914 931.0 -0.756906 -0.875079 -1.32561 -0.771205 942.0 -0.494893 -0.0494796 -0.645322 -1.60061 955.0 -1.51457 0.67966 -0.122789 0.648893 957.0 0.780275 0.15108 -1.23173 0.189585 975.0 1.3996 -0.447428 0.340615 -0.013778 dtype: float64, shape: (94, 4)
tsdframe_before is a timestamp table 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.
>>> tsdframe_after = tsdframe_before.restrict(ep) >>> tsdframe_after Time (s) 0 1 2 3 ---------- ---------- --------- ---------- ---------- 1.0 -2.17833 -1.0439 0.172694 0.324199 13.0 0.74586 -1.83658 0.564464 0.0255007 20.0 0.473193 0.659191 2.34075 1.07099 21.0 0.0964165 0.419102 -0.953028 -1.04787 34.0 -1.87568 -1.36678 0.636305 -0.906721 58.0 0.476043 1.30366 0.211587 0.597045 71.0 -0.896335 -0.111988 1.46894 -1.1239 ... 459.0 0.656797 -1.4359 -1.18327 0.494996 466.0 -0.16531 -0.687175 0.0683513 -0.409409 474.0 1.88955 -0.675805 -0.913413 -0.455033 475.0 -0.412762 0.595644 -1.99154 0.426026 476.0 -0.541285 0.776823 -0.0476437 0.518694 484.0 -0.391402 0.438023 1.66377 -0.739236 491.0 -0.107194 -0.486217 1.59298 -0.433942 dtype: float64, shape: (53, 4)
tsdframe_after is a timestamp table restricted to the epochs.