LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting cycles

Sorry if this is a dumb question, newcomer to LV. I need to develop an application that monitors breathing. I have acquired a signal that represents air flow in and out of the mouth. Among other things I need to be able to count the number of breaths per minute, or per ten minutes, or per 30 seconds, or etc (user selectable), and stream this to disc. The signal roughly resembles a sine wave, but the frequency and amplitude vary somewhat with time...the subject might hold his breath for some reason, or take a large breath periodically. A "valid" breath has to have an inhalation phase and an expiration phase (to exclude random movements etc). Counting peaks or every time the signal exceeds a threshold value works, but that is only half of the inhale-e
xhale cycle, and also counts non-valid breaths. I can't seem to get the extract frequency vis that come with labview to work (perhaps because they object to the inconstant frequency?). Any thoughts gratefully received. (We have a very old DOS based system for doing this, but it doesn't do everything we want, and I would prefer to develop my own than purchase off the shelf).
0 Kudos
Message 1 of 6
(3,193 Views)
Would it be possible for you to post some test data that include the different cases you mention (especially the non-valid breaths), either as labVIEW front panel data saved as default or as f.ex a text file?
0 Kudos
Message 2 of 6
(3,193 Views)
....A
> "valid" breath has to have an inhalation phase and an expiration phase
> (to exclude random movements etc). Counting peaks or every time the
> signal exceeds a threshold value works, but that is only half of the
> inhale-exhale cycle, and also counts non-valid breaths. I can't seem
> to get the extract frequency vis that come with labview to work

This isn't really my cup of tea, but here is the way I'd go about it.

Look at the data looking for transitions between rising and falling
data. These apices are either the transition between an exhale and
inhale, or vice-versa. The likely problem is that there will be some
electrical noise, and some sensor noise that introduces smaller spikes
which aren't real breaths.

It will be necessary to determine the difference between valid and
invalid transitions. First off, it seems like a valid breath has a
minimum length. For adult humans, if the transition happens more than a
few times per second, that seems like noise, not rapid breathing. On
the other end, what is the difference between holding breath, and
determining that the unit is no longer connected, or respiration has
ceased. You will have to determine the numbers, but my guess is that
you should discard the transitions that take less than 100ms, and on the
other end 20 or 30 seconds is a long time between breaths. It also
seems like a valid breath has to have a given volume, perhaps a few
cc's. Value changes smaller than these are likely electrical noise.

Eliminating invalid transitions can probably be done in multiple ways, a
median filter will get rid of the high frequency jitter, as will other
low-pass filters. I'm not sure about using a bandpass for frequencies
that low, but perhaps Alain will have the anser for that. I think you
can measure all transitions, then loop through keeping the mins and maxs
that are large enough in amplitude and far enough apart in time.

Hopefully someone else will have something better than my adhoc
approach, but if not, I suspect it would work reasonably well since you
are only interested in frequency content.

Greg McKaskle
0 Kudos
Message 3 of 6
(3,193 Views)
Something you could try is to differentiate the airflow signal. This will
give you the rate of change of the airflow. Subtract each sample from one
before it. This will give you positive values when airflow is increasing in
one direction and negative values with increases in the other direction. The
amplitude of the differentiated signal can be manipulated by changing the
time between the two values in the subtraction. That is, try subtacting each
sample from the fifth one before it or the tenth one. It really depends on
your sample rate and respiration rate as to what the best time differential
to use will be.
Once you have a good differential, then you could use positive and negative
threshold detection for true inhale and exhale.
Hope this helps.


--
remove yours
hoes to reply

Ben
0 Kudos
Message 4 of 6
(3,193 Views)
Sorry for the delay: I had to be elsewhere yesterday. Attached.
Download All
0 Kudos
Message 5 of 6
(3,193 Views)
Jon,

Following Ben's track, you can also differentiate your signal using a high-pass filter. Then to remove some of the noise generated by the differentiator you can apply a low-pass filter. Overall this is equivalent to a band-pass filter with a pass-band well above your "cycle" frequency. The attached VI shows the resulting differentiated signal.

I don't know if that makes your life easier, but you can try to play with the filter parameters (but only for order = 1) and see if that works for you.
0 Kudos
Message 6 of 6
(3,193 Views)