Code covered by the BSD License  

Highlights from
iPeak: Interactive Peak Detector (Version 6)

4.75

4.8 | 8 ratings Rate this file 76 Downloads (last 30 days) File Size: 187 KB File ID: #23850
image thumbnail

iPeak: Interactive Peak Detector (Version 6)

by

 

21 Apr 2009 (Updated )

Keypress operated interactive peak detector function.

| Watch this File

File Information
Description

iPeak is a keyboard-operated Interactive Peak Finder for time series
  data. 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')
  ipeak(DataMatrix,PeakD,AmpT,SlopeT,SmoothW,FitW,xcenter,xrange,MaxError,positions,names) Adding peak ID')
 
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 6 adds an ensemble averaging function (Shift-E).
http://terpconnect.umd.edu/~toh/spectrum/PeakFindingandMeasurement.htm
  

Acknowledgements

This file inspired Demo Functions For Peak Detection And Fitting..

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (29)
09 Jun 2014 arnold

what is the "width" this function gives for a gaussian fit i.e.? it is not n*sigma, so I'm at a loss ATM.

=======
nevermind, I got it .... FWHM

19 Feb 2014 Jochen

Fantastic work! Thanks a lot!

19 Feb 2014 Jochen  
10 Feb 2014 Tom O'Haver

Oops, I forgot to include that function. I'll fix it, but in the meantime, here it is:

function [index,closestval]=val2ind(x,val)
% Returns the index and the value of the element of vector x that is closest to val
% If more than one element is equally close, returns vectors of indicies and values
% Tom O'Haver (toh@umd.edu) October 2006
% Examples: If x=[1 2 4 3 5 9 6 4 5 3 1], then val2ind(x,6)=7 and val2ind(x,5.1)=[5 9]
% [indices values]=val2ind(x,3.3) returns indices = [4 10] and values = [3 3]
dif=abs(x-val);
index=find((dif-min(dif))==0);
closestval=x(index);

10 Feb 2014 aoli ao

Thanks so much for sharing this useful toolbox. I have a question here. when I tried to run ipeakdemo2.m or DemoFindPeaksb.m, it kept saying
??? Undefined function or method 'val2ind' for input arguments of type 'double'.

so how should do with this problem? Thanks for your help!

05 Feb 2014 Tom O'Haver

iPeak version 5.9, submitted this morning, adds the percent fitting as the 6th column of the peak table. Thanks to helin for making this suggestion. Also available on http://terpconnect.umd.edu/~toh/spectrum/PeakFindingandMeasurement.htm

01 Feb 2014 helin

Thanks for your quick answer. I believe an estimate of fitting error would be extremely useful, so that we can have a quantified understanding of goodness of fit quickly. Thanks again.

01 Feb 2014 helin

Thanks for your quick answer. I believe an estimate of fitting error would be extremely useful, so that we can have a quantified understanding of goodness of fit. Thanks again.

01 Feb 2014 Tom O'Haver

In iPeak, the fitting error is calculated only when you perform a curve fit (N or M keys). It's displayed in the x-axis label of the upper panel. You don't need to specify estimated/known peaks because it gets that info from the peak table.
But if you mean peak parameter error instead of fitting error, then you must use my ipf.m or peakfit.m programs instead, which include a bootstrap error estimate capability.
Would it be useful to add an estimate of fitting error to the usual peak parameter results?

01 Feb 2014 helin

Thanks for this great code. I want to learn if there is a way to calculate fitting error if we do not have any estimated/known peaks in contrast to 11-input case.

04 Jul 2013 Tom O'Haver

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 Bernhard

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 Tom O'Haver

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 Robert

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 Tom O'Haver

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 Tom O'Haver

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 Kenric Lam

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 Eric Diaz

Wonderfully documented!

08 Mar 2012 Eric Diaz

Great code Tom!

06 Sep 2011 mohammad

wonderful code !!!

01 Sep 2011 Tom O'Haver

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

27 Jun 2011 Tom O'Haver

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 Tom O'Haver

Version 1.4 fixed a problem with missing functions.

09 Jun 2011 Tom O'Haver

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 Tom O'Haver

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

25 Mar 2011 Tom O'Haver

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

24 Mar 2011 Aurora

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

17 Feb 2010 Andre Guy Tranquille  
27 Apr 2009 Tom O'Haver

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.

Updates
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
discrimination, adds log y (Y key), autozero mode (T key), jump to next/previous peak (Space/Tab keys).

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.

05 Feb 2014

Version 5.9 adds relative % fitting error as 6th column of peak table

19 Mar 2014

Version 5.96 adds interpolation function (Shift-I).

25 Jun 2014

Version 6 adds an ensemble averaging function (Shift-E).

Contact us