I'm very new to signal processing, and have been struggling this far. I've a rather messy signal measuring respiration using some chest bands and would like to focus solely on the inspiratory half of the data - ie. set the beginning of each inspiration to zero while maintaining the inspiratory amplitude of each breath.

I've attached an example (upslope is inspiration, downslope is expiraion), and have tried various ways of detecting the change in slope indicating the beginning and end of inspiration but keep getting tripped up by small deviations/noise in the signal. Any help would be appreciated.

Edit: https://docs.google.com/open?id=0B84oZTKp4RZ3LS1mdTBCLTJRdEU

Edit: pictures, hopefully better description:

When everything's going smoothly the it should be recording roughly 10-20breaths per minute.

Clean sample

But when the patient coughs/moves it looks something like:

Messy sample

Since I'm mostly interested in the magnitude of each breath, my thinking is that resetting each the start of each breath to zero is an easy (so to speak) way to rid of that upward drift after a cough.

In the worst cases I lose the respiratory signal all together. This I'd like to discard and pick up any redeemable signal as soon as possible.

Messiest sample

Please let me know if there's anything else I can provide for an answer!

Thanks muchly.

  • $\begingroup$ Could you add a plot of the signal to your question? $\endgroup$
    – Jim Clay
    Oct 5 '12 at 13:56
  • $\begingroup$ What toolboxes do you have at your disposal, person157? $\endgroup$
    – Spacey
    Oct 7 '12 at 23:41
  • 1
    $\begingroup$ I'm running R2009b, with a whole bunch of toolboxes courtesy of work (if only I knew how to use them, I'm new to Matlab too). Ones that might be relevant: Signal Processing, Wavelets, Filter Design, Image Processing... the list goes on. $\endgroup$
    – person157
    Oct 7 '12 at 23:56
  • $\begingroup$ can you post a link to some example data? $\endgroup$ Oct 10 '12 at 13:37
  • $\begingroup$ Yep, there's a link in the post but I've made it more obvious. $\endgroup$
    – person157
    Oct 10 '12 at 21:25

I think using quadrature filters would go well here.

Apply your favourite bandpass filter to the signal. This will be necessary because of the noise that is present.

Calculate the analytic signal. In matlab this is:

f_a = hilbert(f);

where $f_a$ is the analytic signal and $f$ is your bandpassed signal.

Calculate amplitude, $a$, and phase, $p$, of the analytic signal. In matlab this is:

a = abs(f_a);
p = atan2(imag(f_a),real(f_a));

The phase will give you a good idea where the peaks ($p = 0$) and troughs ($p = \pm\pi$) are. The amplitude will give you a good idea of the magnitude of the breath, and will help identify regions where the signal has been lost (low amplitude).


I would not do slope detection, I have spend a lot of time solving a similar problem and slope detection didn't work for me.

I have a few suggestions:

  • Do a moving average, this would act as a filter and smooth the signal. Especially, your signal is slow, so you can oversample and easily do a moving average. Realize, this will shift your peaks.

  • If you must get the peaks in precision, do a BPF, this would take out all HF noise and DC.

  • Assuming you are measuring lung capacity, seek out the peak and dip points and subtract them to find out the magnitude, don't assume a bias and try to calculate from there. It sounds like you have a virtual zero point and your try to see how much the amplitude of the signal. You can divide the result by two to get what you want.

You can do BPF and last together and you can get a clean measurement out of it.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.