LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need Help with peak detection

Hello,

 

I am in need of some help using the peak detection. I have an array of values that I need to find the centroid (peak) of. I am only interested in finding the centroid of a large peak. The problem I keep having is that the peak detection VI finds every little peak above the threshold when I really want the overall average peak. Please look at the graph in the picture file to see what I mean.You can see that the main peak has jagged edges. The peak detection in Labview will find every one of these jagged edges and report the location back as a peak. I am only interested in the overall shape of the peak. How can I filter out the multiple peaks and only report the centroid of the desired shape? There is an example program in the labview package called "advanced peak detection point by point" but I cannot figure out how to employ it in this application.

 

Thanks in advance for any help.

 

-Mark

 


0 Kudos
Message 1 of 9
(5,308 Views)

If I were you, I wouldn't even use peak detection.
The point of peak detection is to find multiple peaks, like in a sine wave, etc.

 

If you just want the maximum:

Just use 'Array Max & Min'

The 'max value' equates to your y-value.

The 'max index' can be used to find your x-value

Message Edited by Cory K on 05-07-2009 11:52 AM
Cory K
0 Kudos
Message 2 of 9
(5,285 Views)

The Peak detector has a width input.  From your graphic I cannot tell how many samples you have, but I would guess that setting the width to 10 or 20 might get rid of all the little peaks.

 

If the noise is still a problem, try a smoothing filter or fit a parabola to points around the maximum amplitude point.

 

Lynn 

0 Kudos
Message 3 of 9
(5,273 Views)

One of the inputs to the peak detect VI is the width control.  Have you tried increasing this value?  Peak detector uses a sliding quadratic fit.  By increasing the width you are increasing the number of points used in each sliding fit, effectively filtering the data as part of the process.

 

Also, it looks like your data has a nice structure.  Do you have a model for the peaks?  It looks like there are two peaks, perhaps Gaussian or Lorentzian? You could always treat this as a fitting problem.  Fit to the model, and extract the peak from the identified model.

 

-Jim

0 Kudos
Message 4 of 9
(5,269 Views)
These are some good thoughts. The only problem with the max/min is that I am looking more for the centroid of the large peak. I am not really interested in the absolute maximum value. Opening up the width may help, I really did not try that because I was worried about missing the peak entirely (not all of my data will be so defined as the example I gave). The small peaks at the beginning are garbage that I really don't want included in any calculations. That is the problem with the centroid calculation. I can find the centroid of an array, but the garbage peaks are included which skews the data I really want. I did apply a gaussian fit which so far looks like the best solution, but I still have trouble finding the centroid, peak is no problem, but centroid is inaccurate.
0 Kudos
Message 5 of 9
(5,263 Views)

If you want the centroid of the large peak but do not want to include the garbage, then use a simple technique - any of those mentioned in this thread - to locate the peak approximately and then take an array subset that includes the peak and the sides down to some threshold above the baseline.  Calculate the centroid of the subset.  Add the index of the start of the subset to the centroid to get the X-axis location of the centroid referred to the original dataset.

 

Lynn 

0 Kudos
Message 6 of 9
(5,254 Views)

One way I did something like this was the following:

 

1) Find the max

2) Go forward until you are at N units below peak.  Get the array index

3) Go backward from peak until you are N units below peak.  Get the array index.

4) Repeat the following until the variation is small (use whatever test you want)

    A) Take the midpt of the low index and high index

    B) Determine the variation

    C) Take one step closer to the center (both low and high index)

 

If you plot it, eventually you'll see that the midpt calculation stops changing (much).

 

It's kind of a centroid, but with the axes flipped.

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




Message 7 of 9
(5,251 Views)

If the small peak is noise you might still be able to model and fit it along with the larger peak.  This would make the large gaussian fit more accurate.  You could also get creative with the weighting of the datapoints.  For example, weight the larger Y values more (maybe log(|Y|)?).  This would reduce the influence of the smaller peak on the fit.

 

It is hard to tell from your image, but your data seems somewhat asymetric abouut the peak.  Could the model be more complex than a simple Gaussian?  

 

-Jim

0 Kudos
Message 8 of 9
(5,220 Views)

hi, i agree with the dspguy,.. it is more complex than a simple gaussian. you can use a Voigt or such asymetric function to fit the peak, then you get the equation and calculate whatever you want...

N

0 Kudos
Message 9 of 9
(5,212 Views)