LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best approach to peak detection problem?

Phil,

If I understand correctly you want to test an array of times of peaks to meet the scaling criterion that Ti/i = constant.

I put together a VI (LV8.0) which takes the array and calculates Ti/i in a for loop. Since LV arrays are zero based and your algorithm has your array starting at one, I add one to the index before dividing. Then in another for loop I check to see which peak times are within 5% of the first one. The boolean array "matched peaks" has a true element for each peak which meets the criteria.

Since you appear to have the possibility of false first peaks and various spurious peaks, you would need to apply this concept to your data in a while loop with various peaks removed to get what you want. You know your real data bettor than anyone else and can test it, so that part will be up to you.

Lynn
Message 11 of 12
(864 Views)
Since your peaks of interest are all multiples of each other, some sort of line fit algorithm may work for you.  Given the small number of points, you can get away with n-squared or worse algorithms.  Try some variant of the following:
  1. Run a line fit using the point index for X values, the position for Y.
  2. If you have extra points, you will get a kink in the actual data for each extra point and your slope will be less than you expect.
  3. If the slope or sum of residuals (sum or errors) from the fit is not within what you expect, run the fit again on a subset of your data consisting of the original data minus one point.  Iterate through all the points.  When you hit an extra point, your slope or residual sum will improve and you can permanently delete that point.  One pass through should find all your extra points.
There are a few things I would probably do to make the setup a bit more robust:
  1. If you are having noise issues, do not use a linear least-squares fit.  I usually use a lorentzian distribution fit using the downhill simplex minimizer.  See Numerical Recipes in C for an explanation of this technique.  This may be overkill, but I am usually a bit paranoid about fitting, having been burned more than once.
  2. You will need to establish "good" values for slope and/or residual sum errors.
  3. If you use the sum of residuals, normalize it with the number of points so you can use a constant value when the number of points changes.  Using residual sum allows you to function when you don't know the expected slope.
Good luck.
Message 12 of 12
(844 Views)