pynapple.core.ts_group.TsGroup.getby_threshold#

TsGroup.getby_threshold(key, thr, op='>')[source]#

Return a TsGroup with all Ts/Tsd objects with values above threshold for metainfo under key.

Parameters:
  • key (str) – One of the metainfo columns name

  • thr (float) – THe value for thresholding

  • op (str, optional) – The type of operation. Possibilities are ‘>’, ‘<’, ‘>=’ or ‘<=’.

Returns:

The new TsGroup

Return type:

TsGroup

Raises:

RuntimeError – Raise eror is operation is not recognized.

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)
  Index    Freq. (Hz)
-------  ------------
      0             1
      1             2
      2             4

This exemple shows how to get a new TsGroup with all elements for which the metainfo frequency is above 1.

>>> newtsgroup = tsgroup.getby_threshold('freq', 1, op = '>')
  Index    Freq. (Hz)
-------  ------------
      1             2
      2             4