Code covered by the BSD License  

Highlights from
iPeak: Interactive Peak Detector (Version 3.9)

4.75

4.8 | 4 ratings Rate this file 140 Downloads (last 30 days) File Size: 95.41 KB File ID: #23850
image thumbnail

iPeak: Interactive Peak Detector (Version 3.9)

by Tom O'Haver

 

21 Apr 2009 (Updated 09 May 2012)

Interactive peak detector function.

| Watch this File

File Information
Description

Keyboard-operated Interactive Peak Finder for time series data. P=ipeak(DataMatrix) where DataMatrix = x,y vectors or 2-column matrix. Returns the peak table in P (Peak #, Position, Height, Width, Area)
http://terpconnect.umd.edu/~toh/spectrum/PeakFindingandMeasurement.htm
T. C. O'Haver (toh@umd.edu), Version 3.9.
   
EXAMPLE 1: x=[0:.1:100];
             y=(x.*sin(x)).^2;
             ipeak(x,y); Data in separate x and y vectors
  
EXAMPLE 2: datamatrix=[x;y];
             ipeak(datamatrix); Data in two columns of a matrix
 
EXAMPLE 3: x=[0:.1:100];
             y=5+5.*cos(x)+randn(size(x));
             ipeak(x,y,10);
         or ipeak(datamatrix,10);
The additional argument - 10 in this case - is an estimate of the maximum number of peaks that would fit into the data record). Small values detect fewer peaks; larger values > more peaks.

EXAMPLE 4: As above, but specifies initial values of AmpT, SlopeT, SmoothW, and FitW (see findpeaks subfunction for explanation)
             >> ipeak([x;y],0,.5,.0001,20,20);

EXAMPLE 5: As above, but also specifies initial values of pan (xcenter) and zoom (xrange) in optional input arguments 7 and 8. In this example, a 0.7 unit region centered on 249.7 units is displayed in the upper window:
             >> load data.mat
             >> ipeak(Sample1,0,110,0.06,3,4,249.7,0.7);

EXAMPLE 6: As above, but also specifies MaxError, Positions, and Names in optional input arguments 8, 10, and 11, for peak identification function.
             >> load data.mat
             >> ipeak(Sample1,0,120,0.06,3,6,296,5,.1,Positions,Names);

Keyboard Controls:
 Pan left and right..........Coarse pan: < and >
                    Fine pan: left and right cursor arrows
                    Nudge: [ ]
 Zoom in and out.............Coarse zoom: / and "
                    Fine zoom: up and down cursor arrows
 Resets pan and zoom.........ESC
 Change plot color...........Enter (cycles through standard colors)
 Adjust AmpThreshold.........A,Z (Larger values ignore short peaks)
 Adjust SlopeThreshold.......S,X (Larger values ignore broad peaks)
 Adjust SmoothWidth..........D,C (Larger values ignore sharp peaks}
 Adjust FitWidth.............F,V (Adjust to cover just top part of peaks
 Baseline subtraction........B, then click baseline at 8 points
 Restore original signal.....G to cancel previous background subtraction
 Invert signal...............- Invert (negate) the signal (flip + and -)
Set minimum to zero.........0 (Zero) Sets minumun signal to zero
 Print report................R prints Peak table and parameters
 Print peak table............P Peak #, Position, Height, Width, Area
 Normal peak fit.............N Fit peaks in upper window with peakfit.m
 Multiple peak fit...........M Fit all peaks in signal with peakfit.m
 Print keyboard commands.....K prints this list
 Print findpeaks arguments...Q prints findpeaks function with arguments
 Print ipeak arguments.......W prints ipeak function with all arguments
 Peak labels ON/OFF..........L displays peak parameters on upper graph
 Peak ID ON/OFF..............I Identifies closest peaks in Names database.
 Print table of peak IDs.....O Prints Name, Position, Error, Amplitude

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Peak finding and measurement

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (14)
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.

17 Feb 2010 Andre Guy Tranquille  
24 Mar 2011 Aurora

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

25 Mar 2011 Tom O'Haver

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

26 Apr 2011 Tom O'Haver

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

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.

14 Jun 2011 Tom O'Haver

Version 1.4 fixed a problem with missing functions.

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.

01 Sep 2011 Tom O'Haver

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

06 Sep 2011 mohammad

wonderful code !!!

08 Mar 2012 Eric Diaz

Great code Tom!

08 Mar 2012 Eric Diaz

Wonderfully documented!

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.

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

Please login to add a comment or rating.
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.

Tag Activity for this File
Tag Applied By Date/Time
analytical chemistry Tom O'Haver 21 Apr 2009 14:23:31
chemistry Tom O'Haver 21 Apr 2009 14:23:31
instrumental analysis Tom O'Haver 21 Apr 2009 14:23:31
physics Tom O'Haver 21 Apr 2009 14:23:31
peak detection Tom O'Haver 21 Apr 2009 14:23:31
signal processing Tom O'Haver 21 Apr 2009 20:08:27

Contact us at files@mathworks.com