how can i remove Baseline wander of an ECG signal by two-stage moving-average filter?

6 views (last 30 days)
i have an ECG siganl
fs = 360Hz
the first and second-stage averaging window
lengths are set to be 1/3 and 2/3 of the length of the
input signal in samples.

Accepted Answer

William Rose
William Rose on 7 Dec 2021
At each point, you replace the original signal with the orignal signal minus the moving average of the signal in that neighborhood.
If x(k)=original signal, k=1..N, and h(k)=moving average filter, k=1..M (where M is odd and M<N),
then you can make a new signal y(k):
y(k)=x(k)-sum{j=-(M-1)/2...+(M-1)/2 of h(j)*x(k+j)}
You'll have to do something at the edges to avoid issues.
  4 Comments
William Rose
William Rose on 7 Dec 2021
@Naor p, You are welcome.
@Star Strider is correct (as always) that the usual way to remove baseline wander is with a "standard" high-pass filter. Subtracting the moving average IS a form of high-pass filtering, but it is not standard. I can't see Star Strider's answer now. It was a good answer.
Star Strider
Star Strider on 7 Dec 2021
Thank you!
I removed it because it didn’t address the ‘moving average’ issue. (It exists plentifully elsewhere, since that’s my usual approach to these problems.)
Also, @Naor p needs to Accept your Answer because it correctly addreses the baseline filtering problem using the requested approach. (That’s the other reason I reomoved mine.) I’m voting for it in the interim.
.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!