File Exchange

pickpeaks(V,select,​display)

version 1.6.0.0 (6.66 KB) by
Find peaks in data using a scale-space approach. It is efficient and requires very few parameters.

Updated 20 Jan 2015

-------------------------------------------------------------
Scale-space peak picking
------------------------
This function looks for peaks in the data using scale-space theory.
input :
* V : data, a vector
* select : either:
- select >1 : the number of peaks to detect
- 0<select<1 : the threshold to apply for finding peaks
the closer to 1, the less peaks, the closer to 0, the more peaks
* display : whether or not to display a figure for the results. 0 by
default
* ... and that's all ! that's the cool thing about the algorithm =)
outputs :
* peaks : indices of the peaks
* criterion : the value of the computed criterion. Same
length as V and giving for each point a high value if
this point is likely to be a peak
The algorithm goes as follows:
1°) set a smoothing horizon, initially 1;
2°) smooth the data using this horizon
3°) find local extrema of this smoothed data
4°) for each of these local extrema, link it to a local extremum found in
the last iteration. (initially just keep them all) and increment the
corresponding criterion using current scale. The
rationale is that a trajectory surviving such smoothing is an important
peak
5°) Iterate to step 2°) using a larger horizon.

At the end, we keep the points with the largest criterion as peaks.
I don't know if that kind of algorithm has already been published
somewhere, I coded it myself and it works pretty nice, so.. enjoy !
If you find it useful, please mention it in your studies by referencing
the following report:

@techreport{liutkus:hal-01103123,
TITLE = {{Scale-Space Peak Picking}},
AUTHOR = {Liutkus, Antoine},
URL = {https://hal.inria.fr/hal-01103123},
TYPE = {Research Report},
INSTITUTION = {{Inria Nancy - Grand Est (Villers-l{\`e}s-Nancy, France)}},
YEAR = {2015},
MONTH = Jan,
HAL_ID = {hal-01103123},
}

running time should be decent, although intrinsically higher than
findpeaks. For vectors of length up to, say, 10 000, it should be nice.
Above, it may be worth it though.
---------------------------------------------------------------------
(c) Antoine Liutkus, 2015
---------------------------------------------------------------------

Cite As

Antoine Liutkus (2020). pickpeaks(V,select,display) (https://www.mathworks.com/matlabcentral/fileexchange/42927-pickpeaks-v-select-display), MATLAB Central File Exchange. Retrieved .

ba chen

Jordy W

Thanks, this one works smoothly in my scenarios. What is the exact definition of the threshold?

Laurent de Ryck

Richard Zschech

very nice.....thank you

ZGMLS

Dear Liutkus:
thanks for you code,it is very help!
Unfortunately, I can not understand the process of the fourth 'link it to a local extremum found in
the last iteration, increment the
corresponding criterion using current scale. The
rationale is that a trajectory surviving such smoothing is an important
peak ' .would you mind explaining it in a simple language?

thanks a lot!

Antoine Liutkus

Nice to know that ! thanks for the feedback =)

Conleth O'Loughlin

Saved me some time and effort, thanks!

Yiftach Katzir

nice and elegant!

Laurent Duval

Antoine Liutkus

Hi Burooj, thanks for your interest. Earlier version of Matlab do not suppot this "~" syntax for unrequired outputs. In those lines, just change the "~" by some arbitrary new variable name, like "useless". I updated the script so that it should work now.

Burooj Ghani

Hi, I'm using Matlab 7.5.0. When I use this method, it gives me the following error:

Error: File: pickpeaks.m Line: 132 Column: 7
Expression or statement is incorrect--possibly unbalanced (, {, or [.

The error is in this line of code: [~,posMax] =max(tempMat,[],2);

 20 Jan 2015 1.6.0.0 updated the script for compatibility with earlier matlab versions 14 Jan 2015 1.5.0.0 added reference in description 14 Jan 2015 1.4.0.0 Added a reference to research report to cite for this technique. 5 Aug 2013 1.3.0.0 Several bugfixes and improvements to handle large datasets.
MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux