pynapple.core.ts_group.TsGroup.getby_intervals#
- TsGroup.getby_intervals(key, bins)[source]#
Return a list of TsGroup binned.
- Parameters:
key (str) – One of the metainfo columns name
bins (numpy.ndarray or list) – The bin intervals
- Returns:
A list of TsGroup
- Return type:
list
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, alpha = np.arange(3)) Index Freq. (Hz) alpha ------- ------------ ------- 0 1 0 1 2 1 2 4 2
This exemple shows how to bin the TsGroup according to one metainfo key.
>>> newtsgroup, bincenter = tsgroup.getby_intervals('alpha', [0, 1, 2]) >>> newtsgroup [ Index Freq. (Hz) alpha ------- ------------ ------- 0 1 0, Index Freq. (Hz) alpha ------- ------------ ------- 1 2 1]
By default, the function returns the center of the bins.
>>> bincenter array([0.5, 1.5])