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: 

Missing peaks in waveform peak detection.vi

Hi there,

 

Although there are quite a few questions relating to peak detection in Labview, I could not manage to find a solution to this problem in the posts.

I am acquring signals fromtwo channels of USB 6008 DAQ at 1000Hz,  one of the channls gives a finger pulse signal which helps measuring heart rate. I am filtering and processing this signal and then passing it to the waveform peak detection.vi.

 There are two problems here.

The first issue is that waveform peak detector.vi misses peaks sometimes and this seems to be random as there seems to be no obvious difference in the peak missed as opposed to peak detected.

The sampling rate is 1000 samples /second and buffer size is 500 so every half a second the data is passed to peak detector vi and the width is 350. I have selected thsi width randomly as this seemed to work. The peak detection works fine for signals where the peaks are at 60-70 HZ but the VI misses peaks when signal is < 50Hz and it misses peaks randomly. Don't know how to get rid of this.

 

Any ideas what could be hapenning. I have attached the signal + peak for reference. Note that this picture does not have a missed peak as it occurs randomly

 

The second issue is that the detected peaks do not correspond to actual peaks. I think this is beacuse of the high width. If I reduce the width, I can detect the proper peak but I also the second small peak in the signal.Any ideas how this can be sorted. I tried reducing the width and putting condition on the second width, but since the data is real time and continuous, this doesnt work always and sometimes proper peaks are missed.


Dont know what to do.

 

Also attaching the VI jpg.

Download All
Message 1 of 22
(7,083 Views)

Hi Jaspal,

 

Once I had the same problem... I wrote a little VI which detects the peaks by building a defined number of subarrays and then reading the maximums and locations of this subarrays.

 

You have to adjust the "Size of Subarray": If you define this to small you will get too much peaks, if you define this to large you will miss some peaks.

  

 

peak detection.JPG

 

peak detection FP.JPG

 

I know this is not the best solution, but its worth a try...

 

 

cheers,

cheggers

 

Sascha
Message 2 of 22
(7,050 Views)

You should read the detailed help dear Jaspal 🙂

 

From the help

Locations contains the index locations of all peaks or valleys detected in the current block of data. Because the peak detection algorithm uses a quadratic fit to find the peaks, it actually interpolates between the data points. Therefore, the indexes are not integers. In other words, the peaks found are not necessarily actual points in the input data but may be at fractions of an index and at amplitudes not found in the input array.

To view the locations in terms of time, use the following equation.
Time Locations[i] = t0 + dt*Locations[i]

 

Because of this interpolation you get the shift.

 

But also because of the large width of 350 points. Now the vi use 350 points to interpolate while you should have enough with only 10 points for a 60Hz signal.

60Hz signal at 1000S/s is 16.7 samples for one period.

So if it was a sine wave you would need only 10 points to detect one peak.

 

Hope this helped 🙂

 

0 Kudos
Message 3 of 22
(7,041 Views)

If you have the LabVIEW Advanced Signal Processing Toolkit, you can use the WA Multiscale Peak Detection VI.  It gives you the exact positions of peaks.  Usually it is more robust than the Waveform Peak Detection VI.

0 Kudos
Message 4 of 22
(7,030 Views)

If you have the LabVIEW Advanced Signal Processing Toolkit, you may of course use it. But this toolkit is not free, and I guess you are a student so your budget is somewhat limited. I will recommend that you do some tuning with the "width" variable. I also have Some other tricks Up My Sleeve. Could you send me some of your data. Then you have a god collection of data in your "peaks" plot copy it to a new VI. Right click on it, and select Data operations-> Make current value default. Then save,zip, and post

Also please stop abusing locals. I shall be nice and not submit your code here 

http://forums.ni.com/ni/board/message?board.id=BreakPoint&thread.id=2634  In this thread we love to giggle about awkward coding style 😉



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 5 of 22
(7,011 Views)

Hi Coq, can you show some of your tricks on this data ?

Even the WA Multiscale peak detection vi has some trouble to "not detect" valleys at the beginning of the data.

 

Please post vi's in LV 8.5 version, thanks a lot.

 

Regards

Alain

0 Kudos
Message 6 of 22
(6,989 Views)

Sorry but I can not se any missing peaks. In the signal all peaks are found after sample nr 4600, before it is just noise. Did you send the correct signal.

 



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 7 of 22
(6,978 Views)

The problem is that it detect valleys at the start of the waveform that aren't valleys, just noise like you said 🙂

Unless you found the correct settings for width & threshold for the valley detection of course.

The vi detects valleys at 1020, 1140 and 1250 with settings threshold: -0.25 & width 64

Whatever settings I try, I get valleys at the start of the data, in the noise area 😞

 

I think the problem is the fact that the threshold input is an absolute value, it should be relative to signal level.

0 Kudos
Message 8 of 22
(6,972 Views)

Hi I have some advices.

You should check if the peaks/valleys and/or the signal is within a valid range.

Use a analog 2 order high-pass filter with cutoff frequency equal to 2Hz, before you sample your data. This should block DC

Process your data in blocks. If you only find 1 peak in a 3 seconds windows something is wrong. You could also use a sliding window. You update your data every second using the data from the past 3 second

 

 



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 9 of 22
(6,969 Views)

Hi Coq Rouge,

 

Thanks for the replies. I went through the detailed help but never really got the width concept clear. I have got the ASPT on university discount and am using it to calculate PSD of the rr plot.

I have access to the Wavelet function for peak detection but it too has a width variable. I will play around to find the best combination.

In the meantime I am attaching some raw data here. I want to detect peaks here. Note that each pulse signal has a peak followed by a smaller peak that is not of interest as you will gain from teh pics posted earlier. Can you please suggest a good way of detecting these.

Since teh samling rate is much higher than necessary, I was trying to downsample but get an Error 1801.  HEnce I gave up downsampling and used this signal to detect peaks.

All ideas welcome.

 

What would I do if I didnt have experts here to assist me.

 

Thanks

0 Kudos
Message 10 of 22
(6,934 Views)