Skip to main content

Module peaks

Module peaks 

Source
Expand description

Peak finding in one-dimensional signals: local maxima selected by height, threshold, distance, prominence and width, following SciPy’s find_peaks, peak_prominences and peak_widths.

A peak is a sample (or a flat run of samples, a plateau) larger than its neighbours on both sides. Real signals have many such points, most of them noise, so peaks are filtered by properties that describe how much they stand out:

  • height: the value itself;
  • threshold: the drop to the immediate neighbours;
  • distance: the gap to a taller peak (the shorter of two close peaks is removed);
  • prominence: how far the peak rises above the higher of the two lowest points that separate it from taller terrain on each side (the topographic prominence of a mountain);
  • width: the peak’s width at a given fraction of its prominence below the summit.

See the book entry Peak finding.

Structs§

Bounds
An inclusive range [min, max]; either end may be open.
PeakOptions
The selection criteria of find_peaks; None disables a criterion. The defaults select every local maximum.
Peaks
The result of find_peaks: the indices of the peaks, and the properties computed while selecting them (only those the options required, as in SciPy).
Prominences
Prominences of peaks and the bases they were measured from.
Widths
Widths of peaks: the width, the height at which it was measured, and the interpolated positions of its left and right ends.

Functions§

find_peaks
The peaks of x that satisfy the criteria in options (SciPy’s find_peaks).
local_maxima
Local maxima of x, with the left and right edges of each plateau. A flat run counts once, at its middle sample (rounded down), when the samples on both sides of it are lower. The end samples are never peaks.
peak_prominences
The prominence of each peak (SciPy’s peak_prominences).
peak_widths
The width of each peak at rel_height of its prominence below the summit (SciPy’s peak_widths): from the peak, walk outwards until the signal drops below that height (or a base is reached), and interpolate linearly between the two samples that straddle it. rel_height = 0.5 gives the full width at half prominence; 1.0 the width at the key col.