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.