pynapple.core.ts_group.TsGroup.restrict#

TsGroup.restrict(ep)[source]#

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

Parameters:

ep (IntervalSet) – the IntervalSet object

Returns:

TsGroup object restricted to ep

Return type:

TsGroup

Examples

>>> import pynapple as nap
>>> import numpy as np
>>> tmp = { 0:nap.Ts(t=np.arange(0,200), time_units='s'),
1:nap.Ts(t=np.arange(0,200,0.5), time_units='s'),
2:nap.Ts(t=np.arange(0,300,0.25), time_units='s'),
}
>>> tsgroup = nap.TsGroup(tmp)
>>> ep = nap.IntervalSet(start=0, end=100, time_units='s')
>>> newtsgroup = tsgroup.restrict(ep)

All objects within the TsGroup automatically inherit the epochs defined by ep.

>>> newtsgroup.time_support
   start    end
0    0.0  100.0
>>> newtsgroup[0].time_support
   start    end
0    0.0  100.0