LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

respiratory rate

Hi,

I have a data acquisition vi. I dislay respiration signals and trying to calculate respiratory rate per minute. In order to calculate RPM(respiratory perminute) I’ve used a threshold peak detector. I calculate the difference of the index of the first peak and the index of the second peak,the result generates the number of total samples between two consecutive counts. To count respiratory rate I divided the sample rate by the number of samples per breathing.Then I’ve multipiled the result by 60 to generate RPM.

I ‘ve put the width value for the threshold detector 30.

You can see the frontpanel of my vi and diagram as attachment.

The problem is everything is ok while fast breathing however, while breathing slowly the difference of the index of the first peak and the index of the second peak(you can see in the front panel as x-y ) is negative. Thus the RPM is negative.Also the RPM values lower than 30 is always negative.

What should I do?
0 Kudos
Message 1 of 49
(6,177 Views)
Here are two things to try. First, take the derivative of the respiratory signal and then process it. The peaks will occur at the greatest slope and they may be higher in magnitude and narrower. If this isn't enough then further processing will be in order.

Take this signal and perform a Hilbert Transform on it. If you consider the signal the real part and the Hilbert Transformed signal the imaginary part, then the magnitude of this complex signal may be easier to process.

At each step compare it to the original signal to see how the signal changes.
Randall Pursley
Message 2 of 49
(6,152 Views)
Thanks for your reply. I'm not well experienced in LabVIEW.
Would you please send me an example vi of what you said.
I don't know how to take the derivative of the respiratory signal and process it.
Also I don't have any idea about Hilbert Transform .
I'm using LAbview 6.0i
Thanks for your help
0 Kudos
Message 3 of 49
(6,141 Views)
Here are some links to the Hilbert Transform:

calculus link

link with lots of info


Some code from the net:

// hilbert.c

#include

#include "hilbert.h"

#define PI 3.14159265

void hilbert(int n, double delta[], double kappa[])
{
double d1, d2, d3, d4;
int i1, i2;

for (i1 = 0; i1 < n; i1++)
{
kappa[i1] = 0.;
for (i2 = 1; i2 < n; i2++)
{
d1 = (i1+i2 d2 = (i1-i2>=0)? delta[i1-i2]: 0.;
d3 = (i1+i2+1 d4 = (i1-i2-1>=0)? delta[i1-i2-1]: 0.;

kappa[i1] -= 0.5 * (d1-d2) / i2 + 0.5 * (d3 - d4) / (i2 + 1);
}
kappa[i1] /= PI;
}
}


// hilbert.h

void hilbert(int, double[], double[]);


- JLV -
Message 4 of 49
(6,135 Views)
Here are some more links to Hilbert Transform.

:informative link
:Math World Link
:another calculus link

Feldman wrote several books on this.

Hope this helps.

😉

- JLV -
Message 5 of 49
(6,136 Views)
After doing some analysis, this approach helps some, but maybe not enough to help you.

Essentially the Hilbert Transform does the following. Perform an FFT on your signal, negate the negative frequency values and perform an inverse FFT to get back to the time domain. This relates and even signal to its corresponding odd counterpart (i.e. the Hilbert transform of a cosine signal is a sine signal and vice versa).

Here is a procedure that works for the simulated data that I have.

1. Subtract the value of the first point of data from all of your data to make your first point equal to zero.
2. Use a Butterwork Filter (filter type = Bandpass, order = 2, fh = .1, fl = 0.005) to filter your data (Advanced Analysis->Filters).
3. Use the Derivative function to take the derivative of your data (Advanced Analysis -> Time Domain)
4. Use the Peak Detect function to capture the peaks (Advanced Analysis -> Time Domain)

This will hopefully enhance the peaks in your respiration data making it easier to capture them with the peak detection function.

If you have data you can send me to work with I can see if it works well. I am using LabVIEW 7.1 so I will attach a JPG of the code.
Randall Pursley
Message 6 of 49
(6,126 Views)
Hi,
Thanks for your reply.
I've tried what you said but it didn't work:( Amplitude decreased instead of increase. Attached you can find what I've find. Would you please check if I made a mistake or not.Also I'm sending the saved resp. data and graph of the processed signal.
0 Kudos
Message 7 of 49
(6,107 Views)
Here is the saved data
0 Kudos
Message 8 of 49
(6,106 Views)
Here is the processed data
0 Kudos
Message 9 of 49
(6,105 Views)
Thanksss
0 Kudos
Message 10 of 49
(5,890 Views)