mne.preprocessing.peak_finder

mne.preprocessing.peak_finder(x0, thresh=None, extrema=1, verbose=None)[source]

Noise-tolerant fast peak-finding algorithm.

Parameters
x01d array

A real vector from the maxima will be found (required).

threshfloat

The amount above surrounding data for a peak to be identified (default = (max(x0)-min(x0))/4). Larger values mean the algorithm is more selective in finding peaks.

extrema{-1, 1}

1 if maxima are desired, -1 if minima are desired (default = maxima, 1).

verbosebool, str, int, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more). If used, it should be passed as a keyword-argument only.

Returns
peak_locarray

The indices of the identified peaks in x0.

peak_magarray

The magnitude of the identified peaks.

Notes

If repeated values are found the first is identified as the peak. Conversion from initial Matlab code from: Nathanael C. Yoder (ncyoder@purdue.edu)

Examples

>>> import numpy as np
>>> from mne.preprocessing import peak_finder
>>> t = np.arange(0, 3, 0.01)
>>> x = np.sin(np.pi*t) - np.sin(0.5*np.pi*t)
>>> peak_locs, peak_mags = peak_finder(x) 
>>> peak_locs 
array([36, 260]) 
>>> peak_mags 
array([0.36900026, 1.76007351]) 

Examples using mne.preprocessing.peak_finder