LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extraction of main peaks from a signal

qureshi000_0-1747802669873.pngqureshi000_1-1747802709784.png

I’ve attached two images for reference. In the first image, you can see two main peaks that I want to identify and extract the values of (both x and y). However, the issue arises when I zoom into one of the peaks as shown in the second image where multiple smaller peaks appear around the main one. The scenario I’ve shared currently contains two prominent peaks, but this can vary. Sometimes there may be no significant peaks, while in other cases, there could be five or six or even more. I’m looking for a method to accurately extract the values (both x and y) of the main peaks as shown in the first image.

I’ve also attached a sample VI file with saved data for better understanding. Kindly guide me on how to approach this.

0 Kudos
Message 1 of 9
(590 Views)

Ask yourself : What is your criteria/rules to define  main peaks?

Well, is is higher than the others...

but wait...  maybe it's just higher than the surrounding ones...   relative? absolute to ?? 

 

so find and define the rules!  after that, convert these rules to code 🙂

 

Maybe it's just

find all peaks , choose the top 20%(or XX%)   (by count or value) ,

or have a look at a peak value histogram, maybe that give you an idea..

more specific: if one high peak is identified , in what x axis range lower peaks should be ignored?

 

This type of task is very common in analysing spectra , so look for algorythms/methods used in this (wide) area. (well, usually they don't want to ignore peaks....)

 

If you later know the rules you want to apply

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 2 of 9
(550 Views)

here is maybe one solution:

I used peak search with a relative threshold and peak width of 3 sample , give more peaks ...

next take the list of peaks and within peak distance (scaled to your x)  decide wheater to take the bigger one of to add it to the result.

Testing 2.png

peak search use a square fit over peak width sample, so the x value can be fraction of sample ... and the max peak value is not equal to the max sample value.  

If your crosscorrelation is due to sine sweep and response (lock-in amp ?)  the shape of the peak result migth be an absolute of sync function. By fitting that you can get even better results 😉  

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 3 of 9
(528 Views)

One possibility would be to integrate the signal, find the flat levels and find where the integral trace crosses the halfway point between them to get the position (and the step size will give you the area).

 

(sorry, cannot open your Vi unless you do a "save for previous", 2020 or below)

0 Kudos
Message 4 of 9
(518 Views)

There are tools already built into LabVIEW to help you do what you are looking for. See blow:

 

aeastet_0-1747850179156.png

 

Tim
GHSP
Message 5 of 9
(516 Views)

I do not understand what are you doing inside the for loop and then in case structure. Kindly explain it. What I understand is that you are taking all the peak values whether minimum distance between peak is satisfied or peak lies above the threshold despite minimum distance condition is not satisfied. In conditional tunnel you are passing old values saved in shift register when minimum distance condition is not satisfied. I have also attached the pic of the code.

qureshi000_0-1750057015737.png

 

0 Kudos
Message 6 of 9
(209 Views)

Check out peakdet and see if that does what you want.

_____________
Creator of the BundleMagic plugin for LabVIEW!
0 Kudos
Message 7 of 9
(162 Views)

qureshi000_0-1750057015737.png

This code is correctly working in my certain case. I just want to understand the encircled portion of the code. I do not understand what is happening inside the for loop and then in case structure. Kindly someone explain it. What I understand is that it is taking all the peak values whether minimum distance between peak is satisfied or peak lies above the threshold despite minimum distance condition is not satisfied. In conditional tunnel it is passing old values saved in shift register when minimum distance condition is not satisfied.

0 Kudos
Message 8 of 9
(142 Views)

Sorry, was offline two weeks, sailing 🙂

I wrote a coarse explanation in my post....

Used auto indexing to loop through the list of found peaks.

Two shift registers to remember the last peak value and position.

A conditional array loop out is used to store valid peaks.

In-between the logic test for distance and for peak value to decide wether to keep or replace the value.

If distance condition is met, store last value.

If actual peak is within distance and higher put it in the buffer 

Extra case check for last value in list. 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 9 of 9
(112 Views)