Currently, I'm working on removing 50 Hz power line interference from an ECG signal. Before trying out notch filters, I decided to try out a simple lowpass filter with a cutoff less than 50 Hz. Here's the MATLAB code I used to make the filter:
Fs=500; %Sampling rate in Hz Ast = 120; %Stopband attenuation Ap = 1; %Passband ripple Fp = 30; %Passband end Fst = 45; %Stopband beginning Hd=fdesign.lowpass('Fp,Fst,Ap,Ast',Fp,Fst,Ap,Ast,Fs); d=design(Hd,'butter'); % Design a butterworth filter with the given characteristics fvtool(d);
The magnitude response of the filter is:
As you can see, the filter has around a 180 dB attenuation at 50 Hz and even more at higher frequencies.
Now, I run this filter on my data. Here's the original data, in the time and frequency domain:
And here's the data after applying the filter:
As you can see, the attenuation at 50 Hz is nowhere near the 180 dB that the filter advertised. For a better look, here's the plot of the magnitude response computed by taking the ratio of the FFTs of the signal before and after filtering:
Clearly, the attenuation is nowhere near the level it is supposed to be at. Is this the way it's supposed to be or am I doing something wrong in the implementation?
Thanks in advance for all the help!
Edit : Here's an enlarged view of a single beat of the ECG after applying the filter. Note the 50Hz noise right after the tall peak.