From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Peak detection algorithm based on derivatives

I'm attempting to build a peak detection algorithm based on the derivative being equal to zero. I've used a case structure and array max and min point by point to locate the peaks but it struggles to resolve a double peak in the data. I would like to include the second derivative being negative into the conditions for the case structure but I'm struggling to get it to work.

Does anyone have ideas of how to make this work or how to improve the peak detection?

 

I have attached my vi and some data. The last loop is removes duplicate values and the first three are a boxcar smoothing algorithm.

 

Thank you

Download All
0 Kudos
Message 1 of 5
(3,049 Views)

Hi swilson8,

 

What is your actual goal here? Do you want code that accurately finds peaks, or is the point to do the computations manually? 

 

If you're just looking to find the peaks, LabVIEW has a Peak Detector VI that handles all of the 1st and 2nd derivative work for you and you can choose to find peaks or valleys. You would just run your smoothed signal through this VI and it will output the locations and amplitudes of all peaks above the threshold value. 

Regards,
0 Kudos
Message 2 of 5
(3,013 Views)

My aim is to find the locations of the peaks most importantly, although amplitude is useful aswell.

I am developing my own algorithm to compare it to the inbuilt vi (which is fairly accurate), but I'm having difficulties making it accurate. I have it so it detects peaks to some extent but it definitely isn't too accurate across all peaks.

0 Kudos
Message 3 of 5
(3,010 Views)

Did you ever try the code I posted here?  https://forums.ni.com/t5/LabVIEW/Condition-reset-after-data-goes-below-a-certain-value/td-p/3856488

 

I've had a bit of time to play with that method today, and its actually a simple but impressive way to detect peaks.

 

Craig

0 Kudos
Message 4 of 5
(2,975 Views)

You should look into "Savitzky-Golay" methods (there are VIs in LabVIEW for it) for determining derivatives for identifying overlapping peaks.

0 Kudos
Message 5 of 5
(2,957 Views)