LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Peak Detection with Base package

Hello,

I'm constrained by a budget so I can't purchase the analysis package
just for peak detection. Does anyone have any hints on how to search a
1-D array for peaks without using the pre-made VI's? I've been pulling
my hair out over this one for a week!

Thanks in advance.
0 Kudos
Message 1 of 7
(3,859 Views)
Jason,

I would suggest looking online for a "peak detection" algorithm. There are a number of ways to do it. The LabVIEW peak detector using a least squares quadratic fit to find the peaks, with a filter of amplitude and width. This can also be done much simpler ways. You can try applying a smoothing filter (use a moving or windowed average) and then look for peaks that way.

Please post if you need more assistance. Also, what are you trying to do with the peak detection. This would be helpful in providing further assistance.

Good luck
0 Kudos
Message 2 of 7
(3,859 Views)
Labviewguru wrote in message news:<506500000005000000B1560000-1007855737000@exchange.ni.com>...
> Jason,
>
> I would suggest looking online for a "peak detection" algorithm.
> There are a number of ways to do it. The LabVIEW peak detector using
> a least squares quadratic fit to find the peaks, with a filter of
> amplitude and width. This can also be done much simpler ways. You
> can try applying a smoothing filter (use a moving or windowed average)
> and then look for peaks that way.
>
> Please post if you need more assistance. Also, what are you trying to
> do with the peak detection. This would be helpful in providing
> further assistance.
>
> Good luck

Labviewguru

Thanks for the advice. Yeah, the NI home page tells me that th
ey use a
least square quadratic fit to find the peaks. I'm not sure on how to
implement that. I'll do a web search on that one. I'm not dealing with
a very noisy signal so I don't think that I need to do a moving
average. The amplitude filter seems pretty easy, I just compare each
point to a preset threshold. However my peaks are composed of more
than one sample so each peak gives me a bunch of "true" values. I only
want one count per peak. The way I thought of doing it was using
hysteresis and starting a subroutine when the upper limit boolean went
hi, then resetting the subroutine when the lower limit boolean went
hi. So essentially i need to have labview look for a high, THEN look
for a low, THEN reset over and over again until the sample array is
finished. I'd love to work on this for days but I've already put too
much thought into it.
0 Kudos
Message 3 of 7
(3,859 Views)
Hi Jason,

I was in the same boat a few years ago, and so I came up with this algothym that worked quite well.

With this method you have shift through the data looking at 3 points at a time, n, n-1 and n-2. (Done with shift
registers)

You know you have a peak when:
[A(n-2) = A(n-2)]
The peak will be at point n-1

I don't know what method this is because I came up with it emp...







































0 Kudos
Message 4 of 7
(3,859 Views)
Jason,
Here is one way of solving your problem. Basically what I do is what you said in your comment; I use a shift register to "remember" the previous value. This allows me to determine if the current point should be considered a peak (i.e. previous point was NOT a peak AND the current point is above the threshold value). This means that we only count the first point in every peak sequence.

I always prefer answers with attached vi's that shows the solution. That takes longer time to create for us here on DE but with questions like yours (well formulated) I think it is well worth the effort. I hope this helps. /Mikael Garcia
0 Kudos
Message 5 of 7
(3,859 Views)
I forgot to mention that the method I present works well for signals that are not too noisy. If we add noise to the problem we have to extend the analysis. However, that does not seem to be the case for you right now. I just wanted to mention it to others that might read this as well. Also, what LabVIEWguru posted in his answer is the way to go if you want more than just a peak counter. /Mikael
0 Kudos
Message 6 of 7
(3,859 Views)

I found this old thread because I was having the same problem doing peak detection with only the base package.

 

My solution uses the algorithm 'if value n and value n-2 are both less than value n-1 then n-1 is peak'

This could be expanded over 5 values instead of 3 thus: n-4 < n-3 < n-2 > n-1 > n and peak is at n-2

Expand over any odd number of values to improve noise immunity.

 

I have attached my VI, that also includes a calculation of the mean of the peaks.

This reads 100 dummy data points from a file and should show 13 peaks.

Download All
0 Kudos
Message 7 of 7
(3,096 Views)