Peak_detection : Detecting local maxima and minima in a signal
- c3dp.analysis.Peak_Detection.peakdetect(y_axis, x_axis=None, lookahead=200, delta=0)[source]
function for detecting local maxima and minima in a signal. Discovers peaks by searching for values which are surrounded by lower or larger values for maxima and minima respectively
keyword arguments: y_axis – A list containing the signal over which to find peaks
- x_axis – A x-axis whose values correspond to the y_axis list and is used
in the return to specify the position of the peaks. If omitted an index of the y_axis is used. (default: None)
- lookahead – distance to look ahead from a peak candidate to determine if
it is the actual peak (default: 200) ‘(samples / period) / f’ where ‘4 >= f >= 1.25’ might be a good value
- delta – this specifies a minimum difference between a peak and
the following points, before a peak may be considered a peak. Useful to hinder the function from picking up false peaks towards to end of the signal. To work well delta should be set to delta >= RMSnoise * 5. (default: 0)
When omitted delta function causes a 20% decrease in speed. When used Correctly it can double the speed of the function
- return: two lists [max_peaks, min_peaks] containing the positive and
negative peaks respectively. Each cell of the lists contains a tuple of: (position, peak_value) to get the average peak value do: np.mean(max_peaks, 0)[1] on the results to unpack one of the lists into x, y coordinates do: x, y = zip(*max_peaks)