LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I encountered a problem with Peak Detector.vi:

My sample data array contains 1 large peak and several smaller peaks on both sides of the large peak. Peak Detector.vi didn't detect all of the peaks (width = 3), but some peaks are listed twice in the output arrays 'locations' and 'amplitude'. Could there be something I am doing wrong, or could it be that my version of the vi is corrupted or outdated?
0 Kudos
Message 1 of 12
(3,651 Views)
Message 2 of 12
(3,650 Views)
Thank you Jeremy for your reply.

If I understand the algorithm of Peak Detector.vi
correctly, then every peak in a array of data should
be detected when the width is 3. Would you agree with that statement? The definition of a peak being: every data point, for which the two adjacent data points on each side are smaller in value, would be a peak. If I am correct with my statement, isn't there something wrong with the vi I am using? Are there any upgrades available?

If I don't understand the algorithm correctly and Peak Detector.vi is not supposed to necessarily detect all the peaks, is there a vi that would do it?

Thanks very much.
0 Kudos
Message 3 of 12
(3,651 Views)
What version of LabVIEW do you have? Is it possible to post your VI, along with some information about what peaks you expect to find?

If your data is fairly "rough" you might try smoothing it or resampling to have more points. LabVIEW 7.0 has some nice resampling VIs. I have had success with troublesome datasets by resampling by 10x or so, and then passing the resampled data to the peak detector.
0 Kudos
Message 4 of 12
(3,651 Views)
Thank you very much for your reply and for your willingness to look at my vi. I have attached it. Please let me know if you should have problems opening it. I am using LabVIEW 6.1.
When you open it and run it you will see the sample data set appear in the graph window. The two arrays on the right list the location and the amplitude of the peaks found. When I ran it it only found 11 peaks, although the data contains 23 peaks. When trying other data sets, sometimes the vi would list one peak twice, but still leaving out some of the other peaks.

Thanks for your suggestion of smoothing the data, but in my application I can't smooth the data, because I would like to detect all the peaks if they are noise or real.

Regards,

Jerome.
0 Kudos
Message 5 of 12
(3,651 Views)
When I set your threashold terminal to 0.0015 and a width of 3, I got 7 peaks with the appropriate corresponding amplitudes. If you want more peaks, then decrease the threashold. When I set it to 0.00004, I got 23 peaks.

Since you are interested in getting all the peaks, I think you need a different algorithm. You should scan through the array and count points larger than the two adjacent points. This way, you know exactly what is going on and you will get every single local maximum.
0 Kudos
Message 6 of 12
(3,651 Views)
Thank you, Jeremy, for your reply. When I set the threshold terminal to 0.0015 and the width to 3, I get 4 peaks and when I set the threshold to 0.00004 I get 11 peaks.

I noticed that Peak Detector.vi uses lvanlys.dll. Is it possible for you to send me your lvanlys.dll file?

If this doesn't help and if you don't have any further insight, I will take your advice to write my own vi.

Regards,

Jerome.
0 Kudos
Message 7 of 12
(3,651 Views)
Giving you the lvanlys.dll would be stealing. I double checked in 6.1 and you are right about the values. I had been using LV 7.0. It looks like the functionality of Peak Detector.vi changed slightly in LV 70.

I went ahead and wrote the algorithm in LV 6.1. Be sure to double check its results before you make it more complicated (and harder to troubleshoot). Enjoy!!
0 Kudos
Message 8 of 12
(3,651 Views)
Thank you very much for your effort in writing the code in LV6.1. I tested it on my computer and it seems to work fine. Thanks again and Happy Easter,

Jerome.
0 Kudos
Message 9 of 12
(3,371 Views)
I actually wanted rate Jeremy's later replies in the discussion. But I didn't how to do that.
His comments were very helpful.
0 Kudos
Message 10 of 12
(3,651 Views)