About FindPeak

I'm trying to use FindPeak to find the first positive peak of my data, but it return me a negative value, which is even a peak value, that really make me confuse.

Attached file "test.txt" is my data.

Macro as following :

Macro test()
LoadWave/E=0/D/G/A/P=test "test.txt"
FindPeak wave1
EndMacro
test.txt (17.05 KB)

Read the documentation carefully:

DisplayHelpTopic "FindPeak"

Here FindPeak returns a minimum. Maybe you want:

FindPeak/M=0 wave1

to define a "peak" to be something larger than 0.

In reply to by ChrLie

Thanks for your reply.

Attached file is my full data, while I use "FindPeak", only wave14 and wave33 return negative peak, but take wave0 as example, first peak isn't it should be minimum at row 4 or 5 for value -2.66 ?

test2.txt (355.74 KB)

FindPeak finds maxima unless you use the /N flag.

I loaded your second file into Igor 8 and then used FindPeak on several of the waves:

FindPeak wave14
  V_Flag= 0; V_PeakLoc= 381; V_PeakVal= 3.102;
  V_LeadingEdgeLoc= 379; V_TrailingEdgeLoc= 383; V_PeakWidth= 4;
FindPeak wave1
  V_Flag= 0; V_PeakLoc= 377; V_PeakVal= 2.78;
  V_LeadingEdgeLoc= 372; V_TrailingEdgeLoc= 380; V_PeakWidth= 8;
FindPeak wave33
  V_Flag= 0; V_PeakLoc= 359; V_PeakVal= 3.048;
  V_LeadingEdgeLoc= 353.5; V_TrailingEdgeLoc= 360;
  V_PeakWidth= 6.5;
FindPeak wave0
  V_Flag= 0; V_PeakLoc= 377.5; V_PeakVal= 2.812;
  V_LeadingEdgeLoc= 376; V_TrailingEdgeLoc= 378.667;
  V_PeakWidth= 2.66667;

These all have found the obvious first positive peak.

In reply to by johnweeks

Thanks for your reply.

I think I make some mistake while typing the wave name

Following is what I got with FinkPeak by Igor Pro 6.22A

*FindPeak wave13
  V_Flag= 0; V_PeakLoc= 2; V_PeakVal= -2.742; V_LeadingEdgeLoc= 2; 
  V_TrailingEdgeLoc= 2; V_PeakWidth= 0; 
*FindPeak wave32
  V_Flag= 0; V_PeakLoc= 3; V_PeakVal= -2.808; 
  V_LeadingEdgeLoc= 1.5; V_TrailingEdgeLoc= 3; V_PeakWidth= 1.5; 

 

It seems like a small 'drop in intensity', so to speak, at the beginning of this particular data confuses FindPeak (which looks in the derivate data). The solution here is to increase the box size for the sliding average or flat-out define a minimum level which needs to be crossed for a peak:

FindPeak/M=0 wave13
  V_Flag= 0; V_PeakLoc= 368; V_PeakVal= 2.858;
  V_LeadingEdgeLoc= 364; V_TrailingEdgeLoc= 374; V_PeakWidth= 10;
FindPeak/B=2 wave13
  V_Flag= 0; V_PeakLoc= 368.5; V_PeakVal= 2.858;
  V_LeadingEdgeLoc= 365; V_TrailingEdgeLoc= 446; V_PeakWidth= 81;

FindPeak/M=0 wave32
  V_Flag= 0; V_PeakLoc= 358; V_PeakVal= 2.978;
  V_LeadingEdgeLoc= 355; V_TrailingEdgeLoc= 358.5; V_PeakWidth= 3.5;
FindPeak/B=2 wave32
  V_Flag= 0; V_PeakLoc= 360; V_PeakVal= 2.979;
  V_LeadingEdgeLoc= 315; V_TrailingEdgeLoc= 375; V_PeakWidth= 60;

I don't know why, but these two approaches give slightly different results. See what works best for you.

For people coming to this topic later, I'd like to note that nearly all data has noise that needs smoothing out before FindPeak's simple derivative algorithm works well.

That means either use FindPeaks on data you have already smoothed, or always use the /B=boxPointsToSmooth flag.

And /M=minLevel (thresholding) is usually a good idea.

These ideas are used in the simple automatic peak-finder implemented in the procedure file:
 

#include <Peak AutoFind>

 

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More