01-13-2014 04:48 AM
Hi,
I have plotted the spectral data in XY graph indicator using a .txt file. Now I need to detect the peaks present in this spectrum, their locations and amplitude. I have used Peak Detector .vi in the code. However, it is not generating relevant peaks but displaying approximated values with wrong locations(x values). Is there a better and accurate way to detect the peaks? Please refer attachments for the code.
Let me know.
Thank you.
01-13-2014 11:41 AM
It looks to me like your threshold value is too low. Your control only goes up to 2000. I got good results with a threshold of 6000 and a width around 9.
01-13-2014 11:51 AM
No, I dont think its about the control limits. Try changing the threshold limits and then see the results.
The problem is not with getting results but with the values. Check the peak locations and amplitudes, they are different.
The max amplitude obtained is : 7379.18, however if you set the threshold slightly below this value no peak is detected, which is an error. Both x & y values are different from what obtained using 'peak detector' & using 'Array Max & Min'.
Thank you.
01-13-2014 12:30 PM - edited 01-13-2014 12:35 PM
Have you read the LabVIEW Help file (when looking at the BD, type Ctrl-H, then go to the "Detailed help" at the bottom of the popup) about the peak detection function?
"Locations contains the index locations of all peaks or valleys detected in the current block of data. Because the peak detection algorithm uses a quadratic fit to find the peaks, it actually interpolates between the data points. Therefore, the indexes are not integers. In other words, the peaks found are not necessarily actual points in the input data but may be at fractions of an index and at amplitudes not found in the input array.
To view the locations in terms of time, use the following equation.
Time Locations[i] = t0 + dt*Locations[i] ...
... This Peak Detector VI is based on an algorithm that fits a quadratic polynomial to sequential groups of data points. The number of data points used in the fit is specified by width."
Your input data is so noisy that getting as results the actual points from this function that visually seem to be "peaks" is virtually impossible. Not to mention that there is such an offset at the begining of the data that you are getting gazillions of false positives here. You really need to clean things up before you let LabVIEW loose (at least the Peak Detector VI) on it if you want meaningful answers.
BTW, setting "the threshold slightly below [7379.18]" would not necessarily result in a peak depending on your definition of "slightly," because your data has no points below 180.041, making the highest possible peak 7199.139.
Cameron