LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best approach to peak detection problem?

Hi,
 
I have a peak detection problem and i'm wondering what is the best approach to solving it.
 
Basically i've got a flat line around zero with noise to 0.1 and with peaks protruding up to 0.9. Typically i set the threshold to 0.3-0.4. I can detect the peaks no problem, but sometimes i get spurious ones appearing and i want to teach the program how to figure out which peaks are the ones of interest (looking at the waveform i can visually see which ones are the relevant ones beacuse of experience of looking at them). I typically find up to a maximum of 5 peaks. I am only interested in the time that they occur, not the amplitudes (the amplitudes can vary considerably). There are several tests that i can apply to figure out which peak is the one that i want but i'm not sure whether to just build a vi to do this or try something like mathscript to do it.
 
Correct peaks occur at multiples of time. I.e. time to peak 1 is half time to peak 2 (within an error band of ~ 5%). Thus: time1=(time2/2)=(time3/3)=..... etc. However if 1, 2, 3, 4 or 5 or any combination are false peaks i need to figure out which is a real one (ones) and which is not. I can do this by testing if the peaks are occuring at muliples/divisables of other peaks, or if the time between various peaks corresponds to the time between other peaks or the time at which peaks occur etc. The problem is that if i use case structures then i quickly end up with 40 or 50 case structures for all the tests and then telling the program if this then this, if this then this etc. It quickly becomes unwieldly and if i don't put in a test i later need it gets crazy. Combine this with stepping through various thresholds to check if there is a valid peak below the current threshold means that i am going to spend an awful lot of time and a sore head trying to think this through.
 
What do people think about using a mathscript node to do this testing? Should i go down the road of a neural network? Are there any other obvious tricks that i should explore?
 
Thanks.
0 Kudos
Message 1 of 12
(4,295 Views)
Post some sample data and images.
0 Kudos
Message 2 of 12
(4,280 Views)
Also, please indicate what you're currently doing in terms of LabVIEW code. If you can post the code that would be even better.
0 Kudos
Message 3 of 12
(4,272 Views)

Hi,

I'm currently on-site with a customer but once i get home in a week or so i'll be able to extract and post some of the data. I'll try and get a screen grab or two of the peaks.

I can post a bit of code later, but it is really off the cuff so you'll have to excuse it Smiley Surprised

Thanks.

0 Kudos
Message 4 of 12
(4,262 Views)
Hi Guys,

Here are some screen grabs.

Peak detection shows some of the stuff i very quickly threw together to test if the detected peaks related to other detected peaks.

Peaks of interest show the peaks that i want to detect. I've put three waveforms on the graph. There is no data from 0 to 100 as i cut it out because it just contains noise (well actually it contains the very first peak but it is far below the noise threshold and thus unusable). As can be seen from the picture the peaks appear at different points in each waveform. The three waveforms shown are very clean nice waveforms. Many are worse than this.

To explain where the peaks should occur - t1 = t2/2 = t3/3 ....... = tn/n, where t1, t2, t3......, tn is the time to that peak. Thus the gaps between real peaks should be the same. In practice using the peak detection vi the peaks do occur at approximately +/- 1% of the multiples of each other.

For example take the blue waveform. Say the threshold is set to 0.4. The first peak will be detected at about 222, the second at 296, third at 370 and the fourth at about 444. Thus the gap between each is about 74. This means that there should be a peak at 74 and another one at 148. What i need to be able to do is automatically figure out all this so that i know what absolute number each peak should be.

One problem is that incorrect peaks may appear and be of greater magnitude than the peaks that i am interested in. There may be multiple relevant peaks or perhaps only one (i suspect this will be the most difficult case to test if there are a bunch of wrong peaks mixed in). If there is only one peak though it will occur past 250.

I can post the raw data if it would be of any use.

Does anyone have any suggestions on the best way to go on this. I need some suggestions as to the best direction because i have a huge amount of data that i need to examine and i want to automate the process.

Thanks,

Phil
Download All
0 Kudos
Message 5 of 12
(4,233 Views)
Ummm... OK.... Have you looked at the Peak Detector function that ships with LabVIEW?
0 Kudos
Message 6 of 12
(4,205 Views)
Hi,

I can detect the peaks no problem (see my first post in this thread).

I need to figure out how to test for the correct peaks and ignore the wrong ones.

Thanks
0 Kudos
Message 7 of 12
(4,200 Views)
Yes, I know you said you can detect the peaks. However, it seems to me that your brute force approach can be done just as easily by just using the built-in LabVIEW function. It would certainly simplify your coding.
0 Kudos
Message 8 of 12
(4,186 Views)
Hi,

I don't think you've understood my problem (i probably haven't explained it very well). I can detect the peaks (i use the peak detection vi that ships with LV to do this). Once i have my peaks i then need to figure out which peak is which (i.e. just because the first peak that i detect is the first peak detected, it does not mean that it is the first peak in the real world (for example it may be in the region 0-100 where i cannot measure any peaks), or just because i detect the first peak does not mean it is a true peak (could be because of noise) because it does not conform to t1=t1/1, t2=t2/2, t3=t3/e etc.).

The problem is a question of 'testing' rather than pure 'detection' (i.e. test each peak and figure out if it is a real peak or a false peak (and thus ignored)).

I hope that helps.

Phil.
0 Kudos
Message 9 of 12
(4,158 Views)

You might be able to do some mask and limit testing for the peak locations if they are always in the same position. Then shift your signal based on where it finds the first peak.

The peak detect vi's should send out some peak location data if you want to do it all with mathematics and wiring.

0 Kudos
Message 10 of 12
(4,145 Views)