How do i design a bandpass filter that is used to eliminate the low and high frequency noises of an eeg signal with a cut off frequency of 0.1- 25 Hz

 Réponse acceptée

Star Strider
Star Strider le 25 Oct 2020

0 votes

See if the bandpass fucntion works for you.

10 commentaires

Temisanren Okotie
Temisanren Okotie le 26 Oct 2020
Thank you.
Star Strider
Star Strider le 26 Oct 2020
As always, my pleasure!
Filters are straightforward to design using more basic functions in MATLAB, however for a single signal and a single filter run, the bandpass and related functions are easiest. If you intend to filter more signals, request the second output of bandpass (the digital filter object) and use it with other signals and the filtfilt function to do this most efficiently, otherwise bandpass re-designs the filter each time, and that is both inefficient and slow.
Temisanren Okotie
Temisanren Okotie le 26 Oct 2020
Thank you very much!
load Subject00_before_fp1.mat;
fs = 500;
N = length(Subject00_before_fp1);
N2 = 12000;
t = (1:N)/fs;
subplot(2,1,1);
plot(t,Subject00_before_fp1);
fc = [0.1 25]/fs/2;
y = bandpass(Subject00_before_fp1,[0.1 25],fs);
subplot(2,1,2);
plot(t,y,'k');
figure;
P = nextpow2(12000);
n = 2^P;
X = fft(y(1:N2),n);
X_mag = abs(X);
X_power = (abs(X).^2)/N;
f = (0:N-1)*fs/N;
plot(f(1:N2),20*log10(X_power(1:N2)),'k');
I am trying to plot the PSD using fft function. The value of N is 91000 which is quite large and Matlab wasn't able to process it. I used the first 12000 samples. The result i get after plotting the PSD is still quite noisy. I don't know if my code is right. I'm new to Matlab
This worked when I tried it (increasing the lower passband frequency to 0.5 Hz):
fs = 500;
Subject00_before_fp1 = randn(91000,1);
N = length(Subject00_before_fp1);
t = (1:N)/fs;
[y,df] = bandpass(Subject00_before_fp1,[0.5 25],fs);
figure
subplot(2,1,1)
plot(t,Subject00_before_fp1)
grid
subplot(2,1,2)
plot(t,y)
grid
This designs a very long (23093) FIR filter, according to the ‘df’ object I requested so that I could see what bandpass was designing. The original filter designed an order elliptic filter (the sort I would design myself) however the extremely low lower passband of 0.1 Hz is a nearly impossible task for any filter, even with a sampling frequency of 500 Hz.
Temisanren Okotie
Temisanren Okotie le 26 Oct 2020
I took your suggestion and made the changes but the PSD plot still looks thesame, maybe that part of the code is wrong? I attached a copy of the signal and the picture of the graphs I got if that would help. Thank you very much.
Star Strider
Star Strider le 26 Oct 2020
It appears to be the PSD of an appropriately-filtered signal.
What were you expecting?
Temisanren Okotie
Temisanren Okotie le 26 Oct 2020
This is the paper I'm basing my work on, the PSD graphs look quite different.
They actually do not look much different.
Use:
xlim[0 25])
with your plot and they should look reasonably similar to those in the paper.
Please do not expect to reproduce the results in any specific paper exactly. There are simply too many considerations involved, specifically the filter the paper uses and its characteristics, such as transition-region width, filter type (Butterworth, elliptic, FIR, none of which I can find stated in the paper) or other details. Frequently, ‘close enough is good enough’.
Temisanren Okotie
Temisanren Okotie le 26 Oct 2020
Thank you for your help, using the limits narrowed it down. I think I'll reduce the number of samples to make t cleaner. Thanks again.
Star Strider
Star Strider le 26 Oct 2020
As always, my pleasure!
I definitely wish you success with your workload studies! I was involved in stress responses to workload variations decades ago.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by