LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Find peak regions in an array

Hi,

 

I have a question on how to detect peak region. Let's say I have a parameters named floor value ( for example 0.0002 ) in the following graph.

As you can see there are 2 regions above that floor value ( graph number of points is 64 )

How can I detect peak regions ( 2 in this example ) because if I search for values above 0.0002 there are many points

 

How can I get the following data from this graph>>>>> peak 1  , starts from 18 to 26 . peak 2 starts from 32 to 37

 

THanks

 

graph.jpg

0 Kudos
Message 1 of 8
(3,761 Views)
0 Kudos
Message 2 of 8
(3,754 Views)

In this case you can use the Boolean Crossing PtByPt vi with the greater than threshold comparison. You can set the crossing to F to T and then to T to F.

 

Ben64

0 Kudos
Message 3 of 8
(3,737 Views)

Hi Zwired1. Thank you for your reply

 

I don;t think this function gives me what I need. I would like to detect consecutive numbers above a certain value and bundle them into 1 peak regoin , then goto the next one  . I don't want just the peak value and it's index.

 

 

for example in that graph I have 2 peak regions 

 

Peak 1 region, starts from X value 18 to 26

Peak 2 regoin, starts from X value 32 to 37 

0 Kudos
Message 4 of 8
(3,721 Views)

Missed the part about wanting the x ranges where y was above threshold rather than just the peak locations.

 

Depending on how much data you have to go through the attached may be faster than Boolean crossing pt by pt.  The attached tests the entire data array for ">threshold?"  and the while loop only has to loop once for each crossing.  Boolean crossing pt by pt. would require you to loop for each point in your array.   This presumes, of course, that you have all of your data before you start your analysis.

0 Kudos
Message 5 of 8
(3,717 Views)

Have you considered a simple for loop?

 

Start iterating through loop, once you get above a threshold start adding positions to an array, then once you get below threshold again generate a new array. 

 

 

[EDIT]

So I found a solution. And it works pretty well although there is probably a better way of tidying up the logic.

Peak Detector.png

0 Kudos
Message 6 of 8
(3,707 Views)

Interesting.  Hadn't tried conditional tunnels yet. 

 

Attached is a VI I wrote before I saw your last.  It runs it three different ways on 100k data points.  Not a lot of difference, and I can't imagine milliseconds will make a difference here, but it illustrates the power of operating on arrays instead of one by one.

 

0 Kudos
Message 7 of 8
(3,690 Views)

Also note that the special case when the last point is greater than the threshold value need to be taken care of. As an exemple if we have the following array 0,0,0,0,0,1,1,1,1,1,1 none of the method suggested will indicate a "peak" between index 5 and 10. Note that this can depend of what we define as a peak in this case.

 

Ben64

0 Kudos
Message 8 of 8
(3,644 Views)