pynapple.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)

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

>>> newtsgroup = tsgroup.getby_threshold('rate', 1, op='>')
>>> newtsgroup
  Index     rate
-------  -------
      1  1.33445
      2  4.00334