LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem in calculating time between 2 peaks

i am acquiring pulse signal through condensor microphone using ni cdaq. I have to calculate heart rate and for that we are trying to find r-r interval using waveform peak detection.vi, but the problem is that i am not getting correct intervals as r-r interval should be between 0.6-1 sec but the value we are getting is very large. although i had read very forums on this topic but still i am not able to correct my program, i am not getting how should i modify my program so as to get the correct results, i would be very thankful, if anyone could clarify my concept regarding this problem.

 

i am attaching my vi and the image of the graph i am getting , kindly see this and help me to solve the problem.

Download All
Message 1 of 7
(4,834 Views)

Check your threshold. My simple example works fine.

You are also looking at the difference between the first and second peak and these peaks depend on where the signal starts and what the threshold is.

You're not really looking at the interval. Does the signal have regular period? If not, then you may want to look at the average interval over several cycles.

Message 2 of 7
(4,820 Views)

i am not able to open your vi as it's version is 11 and i am having labview 2010, if possible please upload your vi in older version

 

i am confused abt this how to look at the interval, although this seems to be quite simple and i have seen many examples on this but still this is not very clear to me,it would be great help if you could explain this in detail and regardign period yes the period is regular.

 

0 Kudos
Message 3 of 7
(4,810 Views)

hope you can open this

0 Kudos
Message 4 of 7
(4,808 Views)

yes now i am able yo open your vi but it seems you have just have changed the threshold limit, since according to me i am taking the difference of locations between 2 peaks, is this not the method of finding the interval between 2 peaks, or how can i do this, can you please explain me in theory if there is any other method of doing this.

0 Kudos
Message 5 of 7
(4,803 Views)

Couple of things:

 

1. "Locations" output from Waveform Peak Detection.vi is an array of numbers. You are wiring Locations to Index Array twice. The first time you are choosing the zeroth element and the second time you are choosing the first element.

And then you are subtracting the zeroth element from the first element. This only gives you the distance between two x-values corresponding to the initial two peaks in your plot. However, your plot has a bunch of peaks, right?

How about the distance between the second peak and the third peak? What about the distance between third peak and fourth peak? And so on....If the peaks happen at equal distances from each other, then fine you can choose the distance between the first two peaks and you have your interval. However, if the peaks don't happen at equal distances, then you need to calculate the distance between any two consecutive peaks, and then perhaps average all these distances to get some kind of representative interval.

 

2. The theory behind peak detection: Mathematically, your signal is described by some smooth, continuous and differentiabale function, i.e., y = f(x). If you have taken calculus, then you know that the derivative of f(x) is the slope at x. Setting the derivative = 0, and solving for x, tells you at which points the function f(x) has slope zero. These points correspond to minima and maxima of the function.

However, in LabVIEW, you have discrete values. You increment your x by a little and you measure a y-value. Then your plot is described by a 2D array. The first column is x-values and the second column is y-values.

Peak detection works by moving down the y-column and comparing each y-value with the previous y-value. When subsequent y-values keep getting bigger than previous values, you have not reached a peak, then the algorithm continues until the next value is lower than the previous value. Then that is identified as a peak. For that y-value, the algorithm selects the row index and records the value in the x-column. It goes through the data until it finds all peaks and also making sure that each peak is above the give threshold.

 

What I described is a linear brute force peak detection method. There are more clever ways of peak detection. Just Google peak detection algorithms and you'll see a lot of work devoted to this subject, because of its immense importance and applications.

0 Kudos
Message 6 of 7
(4,786 Views)

 

Spoiler
Hi Ritu,

  

thanks for your query. I had a doubt regarding finding the RR interval. I had idea about getting it, but I didn't know about this 'Index Array'. I also got correct output.

 

Thank you so much.   

 

Good Day Smiley Happy 

0 Kudos
Message 7 of 7
(4,555 Views)