# Adaptive Band pass filter for extracting respiratory waveform from accelerometer data

I am recording data from an accelerometer attached to the chest (1000Hz). I need to extract the respiratory waveform. I tried an adaptive bandpass filter based on a dominant frequency in my signal based on https://cutt.ly/j24zdj.

Steps in brief: Take frequency spectra, find dominant freq f0, Make a bandpass filter as [max(0.1,f0-0,4), 0.4+rm]

The respiration rate could be between anything from 0.1 to 2 Hz. For deep and normal breathing, the filter works just fine. But for rapid and shallow breathings (low amplitude but high freq), it fails. It identifies the dominant freq incorrectly and thus the entire filter goes wrong.

For example in the image below: The dominant freq should have been around 0.6, but is identifies as 1.7 (Slight diff in amplitude). So filter works badly.

1) How do I design a filter for this? Any suggestions. I can't control the noise in this freq range. The person is as still as possible.

2) The red line is spectra after filtering. Why has the amplitude of certain frequencies increased? I am using the 'spec' function in R: uses the hanning window for computing.

It's not the issue with plotting. The amplitudes have actually increased.

• Can I please ask if this was resolved?
– A_A
Commented Sep 6, 2019 at 8:58

Under the extremely controlled conditions required to measure respiratory rate using this method, you can try to use the autocorrelation (which is more robust in the presence of noise) to determine the "dominant" frequency in your signal.

2) The red line is spectra after filtering. Why has the amplitude of certain frequencies increased? I am using the 'spec' function in R: uses the hanning window for computing.

If that is not a mere rescaling of the waveform as it gets plotted over the same figure (?), then it would be safe to assume that the filter included some overall gain.

Hope this helps.

• Is that normal or ok to have such overall gain? Commented Aug 1, 2019 at 5:42
• @RutujaChhajed Overall gain at that point does not matter much. It is trivial to set it to any value you like by multiplying the filter response by a factor. Do you see this as something to worry about it?
– A_A
Commented Aug 1, 2019 at 6:00
• That is true! Nothing to worry about that. Commented Aug 14, 2019 at 6:33
• I need a little more help in this. Can I contact you somewhere? Commented Aug 14, 2019 at 6:34
• @RutujaChhajed You are contacting me here or we might talk about this on the DSP Chat (?)
– A_A
Commented Aug 14, 2019 at 10:07