1
votes

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: magnitude response of the filter

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:

The original data

And here's the data after applying the filter:

The filtered data

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:

The FFT ratio

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!

1

1 Answers

0
votes

Its hard to tell because of the plot scaling, but it looks like your problem is just from the way you're estimating the PSD. The window function that you use can allow leakage from high energy frequencies into neighboring frequency bins: https://en.wikipedia.org/wiki/File:Window_functions_in_the_frequency_domain.png

The Hann window is a good default choice (used in pwelch.m). If you plot the outputs of pwelch for the signal before and after filtering on the same plot, you should see the filtering action. From the Wikipedia plot, you can see that even for a Hann window, you would have to use an FFT window of at least 10 seconds to see much attenuation at 50 Hz.