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.17269 0.3242 13.0 0.74586 -1.83658 0.56446 0.0255 20.0 0.47319 0.65919 2.34075 1.07099 21.0 0.09642 0.4191 -0.95303 -1.04787 34.0 -1.87568 -1.36678 0.63631 -0.90672 58.0 0.47604 1.30366 0.21159 0.59704 ... ... ... ... ... 897.0 -0.98723 -0.49116 -1.20912 1.58914 931.0 -0.75691 -0.87508 -1.32561 -0.77121 942.0 -0.49489 -0.04948 -0.64532 -1.60061 955.0 -1.51457 0.67966 -0.12279 0.64889 957.0 0.78028 0.15108 -1.23173 0.18958 975.0 1.3996 -0.44743 0.34062 -0.01378 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.17269 0.3242 13.0 0.74586 -1.83658 0.56446 0.0255 20.0 0.47319 0.65919 2.34075 1.07099 21.0 0.09642 0.4191 -0.95303 -1.04787 34.0 -1.87568 -1.36678 0.63631 -0.90672 58.0 0.47604 1.30366 0.21159 0.59704 ... ... ... ... ... 466.0 -0.16531 -0.68718 0.06835 -0.40941 474.0 1.88955 -0.6758 -0.91341 -0.45503 475.0 -0.41276 0.59564 -1.99154 0.42603 476.0 -0.54129 0.77682 -0.04764 0.51869 484.0 -0.3914 0.43802 1.66377 -0.73924 491.0 -0.10719 -0.48622 1.59298 -0.43394 dtype: float64, shape: (53, 4)
tsdframe_after is a timestamp table restricted to the epochs.