detect_onset#

pyCGM2.Signal.detector.detect_onset(x, threshold=0, n_above=1, n_below=0, threshold2=None, n_above2=1, show=False, ax=None)#

Detects onset in data based on amplitude threshold.

Parameters:
  • x (np.ndarray) – Data to analyze.

  • threshold (float, optional) – Minimum amplitude of x to detect. Default is 0.

  • n_above (int, optional) – Minimum number of continuous samples >= threshold to detect. Default is 1.

  • n_below (int, optional) – Minimum number of continuous samples below threshold that will be ignored in the detection. Default is 0.

  • threshold2 (float, optional) – Minimum amplitude of n_above2 values in x to detect. Default is None.

  • n_above2 (int, optional) – Minimum number of samples >= threshold2 to detect. Default is 1.

  • show (bool, optional) – If True, plots data in matplotlib figure. If False, doesn’t plot. Default is False.

  • ax (plt.Axes, optional) – A matplotlib Axes instance for the plot. Default is None.

Returns:

np.ndarray – 2D array [indi, indf] with initial and final indices of the onset events.

Notes

  • Signal-to-noise characteristic of the data might require tuning of parameters.

  • See the referenced IPython Notebook for more information.

References

Examples

>>> x = np.random.randn(200)/10
>>> # various examples using the function with different parameters
Version history:
  • ‘1.0.7’: Part of the detecta module - [Detecta PyPI](https://pypi.org/project/detecta/)

  • ‘1.0.6’: Deleted ‘from __future__ import’, added parameters threshold2 and n_above2