I have a signal that has both AC and DC components and both a re varying with time. How can I extract the varying DC wave from the signal?
eg: A PPG (Photopletysmography) signal extracted from a healthy patient.
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It only takes a minute to sign up.
Sign up to join this communityI have a signal that has both AC and DC components and both a re varying with time. How can I extract the varying DC wave from the signal?
eg: A PPG (Photopletysmography) signal extracted from a healthy patient.
DC, by definition, is the non-varying part of the signal. To find the DC component you simply average the entire signal.
How can I extract the varying DC wave from the signal?
This sounds more like you want to extract the low frequency part of the signal. The most basic filter for this is a moving average filter. However, I would recommend a smoother filter, such as a Gaussian filter. Start with $\sigma$ about 1/6 the period of the low frequency oscillations you are interested in and modify to suit.
You could also solve an optimization problem.
If the data is given by the vector $ y $ the following optimization problem would work:
$$ \hat{x} = \arg \min_{x} \left \{ {\left \| x - y \right \|}_{2}^{2} + \lambda {\left \| Lx \right \|}_{1} \right \} $$
Where the $ L $ matrix enforces smoothness.
For instance is could be:
$$ \hat{x} = \arg \min_{x} \left \{ {\left \| x - y \right \|}_{2}^{2} + \lambda \sum_{i = 1}^{N - 1} {\left \| {x}_{i} - {x}_{i - 1} \right \|}_{1} \right \} $$
Now, by choosing large ennough $ \lambda $ the solution enforces the derivative to be zero -> DC.
It would even work with $ {\ell}_{2} $ regularization.
Though if the model is DC jumps, the $ {\ell}_{1} $ would be a much better choice.
You can try to perform FFT on the signal and extract the first sample, or zero index of the FFT array (assuming it is zero-based index array). This is a direct approach to observe DC signal in comparison to other method of curve fitting with smoothing algorithm. For example, Savitzky-Golay can smooth out high frequency and obtain the pedestal shape of the signal.