Code covered by the BSD License

### Highlights from iPeak: Interactive Peak Detector (Version 5.8)

4.66667

4.7 | 6 ratings Rate this file 76 Downloads (last 30 days) File Size: 167 KB File ID: #23850

# iPeak: Interactive Peak Detector (Version 5.8)

21 Apr 2009 (Updated 14 Nov 2013)

Keypress operated interactive peak detector function.

File Information
Description

iPeak is a keyboard-operated Interactive Peak Finder for time series
data, based on the "findpeaks.m" function. Expected input forms:
ipeak(y); % Data in single y vector')
ipeak(x,y); % Data in separate x and y vectors')
ipeak(DataMatrix); % Data in two columns of DataMatrix')
ipeak(x,y,10), ipeak([x;y],10) or ipeak(y,10), specifying peak density, PeakD
ipeak(DataMatrix,PeakD,AmpT,SlopeT,SmoothW,FitW) specifying peak density, AmpT, SlopeT, SmoothW, FitW')
ipeak(DataMatrix,PeakD,AmpT,SlopeT,SmoothW,FitW,xcenter,xrange) Adding pan and zoom settings ')
ipeak(DataMatrix,PeakD,AmpT,SlopeT,SmoothW,FitW,xcenter,xrange,Autozero) Adding Autozeo as 9th argument')

EXAMPLE 1: One input argument; data in single vector
>> y=cos(.1:.1:100);ipeak(y)

EXAMPLE 2: One input argument; data in two columns of a matrix
>> x=[0:.01:5]';y=x.*sin(x.^2).^2;M=[x y];ipeak(M);

EXAMPLE 3: Two input arguments; data in separate x and y vectors
>> x=[0:.1:100];y=(x.*sin(x)).^2;ipeak(x,y);

EXAMPLE 4: Additional input argument (after the data) to control peak
sensitivity.
>> x=[0:.1:100];y=5+5.*cos(x)+randn(size(x));ipeak(x,y,10);
or >> ipeak([x;y],10); or >> ipeak(humps(0:.01:2),3)
or >> x=[0:.1:10];y=exp(-(x-5).^2);ipeak([x' y'],1)

T. C. O'Haver (toh@umd.edu), Version 5.8: Includes version 4.2 of peakfit.m, adds Voigt profile shape and flat baseline mode for iterative least-squares fits.

Acknowledgements

Peak Finding And Measurement inspired this file.

This file inspired Demo Functions For Peak Detection And Fitting. and I Signal 2.9.

MATLAB release MATLAB 7.8 (R2009a)
04 Jul 2013

Thanks, Bernhard, that's good advice. I'll look into "namespace" and "nlimt".

I do not believe "findpeaks" was a basic built-in function when I first created my function (back in Matlab 6.5), but I agree that I should change the name of my function to avoid the conflict.

04 Jul 2013

Great and very useful work!
The only drawbacks are that the function findpeaks already comes with MATLAB and you make heavy use of global variables (can lead to bad side effects when used in conjunction with other code).
Consider using a namespace or rename the function and generally check mlint results (this should also improve performance).

01 Feb 2013

Thanks, Robert. After doing an iterative curve fit, the best-fit parameters are printed out in the command window. Or did you mean something else by "write the outcome"?

31 Jan 2013

Hi Tom, thanks for sharing this wonderful code. It is not possible to write the outcome obtained after iterative curve fitting to a variable or am I missing something?

29 Aug 2012

Version 4 is now available from http://terpconnect.umd.edu/~toh/spectrum/PeakFindingandMeasurement.htm. It adds the 'H' key that more easily detects 'shoulders' and poorly-resolved peaks.

09 May 2012

Kenric Lam, thanks for the heads-up. That bug has been tracked down and fixed in iPeak version 3.9, just uploaded to the file exchange and also available at http://terpconnect.umd.edu/~toh/spectrum/ipeak3.zip

12 Apr 2012

It is a big trap that there is a subfunction 'findpeaks' in 'ipeak.m' that is the same to the separate file 'findpeaks.m', but the results given are different.

08 Mar 2012

Wonderfully documented!

08 Mar 2012

Great code Tom!

06 Sep 2011

wonderful code !!!

01 Sep 2011

Version 3 adds iterative curve fitting of the detected peaks with selectable peak shapes.

27 Jun 2011

Version 2.0, June 24, 2011, adds two main new features. You can set the initial values of pan and zoom in optional input arguments 7 ('xcenter') and 8 ('xrange'). There is also an optional "peak identification" function if optional input arguments 9 ('MaxError'), 10 ('Positions'), and 11 ('Names') are included. Type Help ipeak for more info.

14 Jun 2011

Version 1.4 fixed a problem with missing functions.

09 Jun 2011

Version 1.3 has improved input argument flexibility, accepts signals as separate x and y vectors or a two-column or two-row matrix. Adds a function to restore the original signal after the baseline has been subtracted. Adds peak area to the peak table.

26 Apr 2011

Version 1.2 (April 2011) has improved graphic performance on recent versions of Matlab.

25 Mar 2011

That should work, Aurora. Download the iPeak function, put it in the Matlab path, then type "help ipeak".

24 Mar 2011

I want to use it to detect density peaks in my 1 dimensional data. How to do this? Thanks!

17 Feb 2010
27 Apr 2009

Version 1.1 posted 25 Apr 2009 adds keypress command "L" which toggles ON and OFF peak labels in the upper panel (zoomed-in segment). Each peak in that segment is labeled with peak position, height, and width. The labels change in real-time as the peak detection parameters are modified.

21 Apr 2009

Revised description

25 Apr 2009

Version 1.1 adds "L" keypress to toggle peak labels in upper panel ON and OFF. Peak shown in the upper panel (zoom-in view) are labeled with peak position, height, and width, which changes in real-time as the peak detection parameters are varied.

26 Apr 2011

Improved graphics performance on Matlab 7.8 (R2009a)

09 Jun 2011

Several enhancements to UI and input argument flexibility. Added baseline restore function.

14 Jun 2011

Includes embedded functions that were omitted in previous version.

17 Jun 2011

Improved keyboard error handling

24 Jun 2011

Version 2 allows specifying the initial values of pan and zoom. Also the 'IDpeak' function compares the found peak positions (maximum x-values) to a database of known peaks and identifies matching peaks in the signal.

30 Jun 2011

Edited description

01 Sep 2011

Version 3 adds iterative least-squares curve fitting with selected peak shapes.

12 Sep 2011

Version 3.2 has better noise

20 Sep 2011

Bug fixes

26 Sep 2011

Version 3.7, Adds valley detection mode (U key)

22 Oct 2011

Version 3.8 adds manual entry of AmpT after entering number of click points for background subtraction; '0' key to set minimum to zero.

09 May 2012

Version 3.9: Bug fixes; replaced internal findpeaks function with version 4; FitWidth now equals number of points, not number of intervals.

09 May 2012

Version 3.9: Bug fixes; replaced internal findpeaks function with version 4; FitWidth now equals number of points, not number of intervals.

09 May 2012

Typo correction.

29 Aug 2012

Version 4.0, August, 2012, adds 'H' key to help in detecting 'shoulders' and poorly-resolved peaks.

24 Sep 2012

Version 4.1: peakfit internal function updated to version 3.3. Bug fixes.

28 Dec 2012

Version 5: Faster jump between peaks with spacebar and tab keys; other small bug fixes

26 Apr 2013

Version 5.3 adds table of summary statistics of the maximum, minimum, average, percent standard deviation, and displays histograms of the peak intervals (the x-axis interval between adjacent detected peaks), heights, widths, and areas.

14 Nov 2013

Version 5.8: Includes version 4.2 of peakfit.m, adds Voigt profile shape and flat baseline mode for iterative least-squares fits.