Chebyshev Type 2 filter not working as expected
5 views (last 30 days)
Show older comments
I have some EEG data and I designed a 20th order bandpass chebyshev type 2 filter with a stopband of 10hz and passband of 4hz. I filtered my signal with this filter however the response I obtained does not seem to be making sense. Can anyone help/identify what I am doing wrong?
EEGdata = load('EEGdata.csv');
Fs = 1200; % Sampling frequency
T = 1/Fs; % Sampling period
L = length(EEGdata); % Length of signal
t = [0:(L-1)]*T; % Time vector
%now using bandpass chebyshev type 2 filter
[A,B,C,D] = cheby2(10,40,[4 10]/600);
d = designfilt('bandpassiir','FilterOrder',20, ...
'StopbandFrequency1',4,'StopbandFrequency2',10, ...
'StopbandAttenuation',40,'SampleRate',1200);
sos = ss2sos(A,B,C,D);
% fvt = fvtool(sos,d,'Fs',1200);
% legend(fvt,'cheby2','designfilt')
%filtering original data
EEG_filt = filtfilt(d,EEGdata);
figure();
subplot(2,1,1)
plot(t,EEGdata); title('EEGdata.csv before filtering'); grid on; axis tight; xlim([0 20]);
xlabel('Time in seconds'); ylabel('Amplitude/\muV');
subplot(2,1,2)
plot(t,EEG_filt); title('EEGdata.csv after filtering'); grid on; axis tight; xlim([0 20]);
xlabel('Time in seconds'); ylabel('Amplitude/\muV');
2 Comments
Cris LaPierre
on 7 Jan 2022
Could you expain more on why your results are incorrect, or perhaps describe what you think the results should look like?
Answers (1)
Cris LaPierre
on 7 Jan 2022
You have a ringing artifact because you have such a high order filter. Notice that the y axis of your filtered data is scaled by 10^5. You can scale this to see what you expect.
EEGdata = load('EEGdata.csv');
Fs = 1200; % Sampling frequency
T = 1/Fs; % Sampling period
L = length(EEGdata); % Length of signal
t = [0:(L-1)]*T; % Time vector
%now using bandpass chebyshev type 2 filter
[A,B,C,D] = cheby2(10,40,[4 10]/600);
d = designfilt('bandpassiir','FilterOrder',20, ...
'StopbandFrequency1',4,'StopbandFrequency2',10, ...
'StopbandAttenuation',40,'SampleRate',1200);
sos = ss2sos(A,B,C,D);
%filtering original data
EEG_filt = filtfilt(d,EEGdata);
figure();
plot(t,EEG_filt); title('EEGdata.csv after filtering'); grid on; axis tight; xlim([0 20]);
xlabel('Time in seconds'); ylabel('Amplitude/\muV');
ylim([-10 10])
2 Comments
Cris LaPierre
on 7 Jan 2022
Things improve if you drop your filter order
EEGdata = load('EEGdata.csv');
Fs = 1200; % Sampling frequency
T = 1/Fs; % Sampling period
L = length(EEGdata); % Length of signal
t = [0:(L-1)]*T; % Time vector
%now using bandpass chebyshev type 2 filter
[A,B,C,D] = cheby2(10,40,[4 10]/600);
d = designfilt('bandpassiir','FilterOrder',8, ...
'StopbandFrequency1',4,'StopbandFrequency2',10, ...
'StopbandAttenuation',40,'SampleRate',Fs);
sos = ss2sos(A,B,C,D);
%filtering original data
EEG_filt = filtfilt(d,EEGdata);
plot(t,EEG_filt); title('EEGdata.csv after filtering'); grid on; axis tight; xlim([0 20]);
xlabel('Time in seconds'); ylabel('Amplitude/\muV');
ylim([-10 10])
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!