How to filter an EEG signal from eye blinking, electrodes movement and calculate the evoked potential?

27 vues (au cours des 30 derniers jours)
Hi this is my code: can you help me, because the filtering does not work
load 'eeg4.mat'
sig = eeg;
fs = 256;
t=linspace(0,length(sig)/fs,length(sig));
figure()
plot(t,sig/max(sig));
grid
title('Signal in Time Domain');
xlabel('Time(s)');
ylabel('Amplitude');
figure()
sig=sig-mean(sig); % Per visualizzare meglio lo spettro
f=linspace(-fs/2,fs/2,length(sig));
plot(f,fftshift(abs(fft(sig))));
title('Signal in Frequency Domain');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
%remove eye blinking
eyes = smooth(sig, 20); % artefacts 20Hz
sig = sig - eyes; % noise
%Filtering
[b,a]=butter(4,[41,43]/(fs/2),'stop');
sig_f=filtfilt(b,a,sig);
figure()
plot(f,fftshift(abs(fft(sig_f))));
title('Signal Filtered in Frequency Domain');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
[h,i]=butter(1,0.05/(fs/2),'high');
eeg=filtfilt(h,i,sig);
figure()
plot(f,fftshift(abs(fft(eeg))));
title('EEG Filtered in Frequency Domain');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
figure()
plot(t,eeg/max(eeg))
title('EEG Filtered in Time Domain')
% evoked potential????
load 'Evoked Potential3.mat'
Error using load
Unable to find file or directory 'Evoked Potential3.mat'.
[seg,corr_avg] = correllated_average_1(e_p,trigger,ie_p);

Réponses (1)

Star Strider
Star Strider le 17 Juin 2023
The EEG signal does not need filtering. It is not significantly noisy, and it is obvious that a 50 Hz mains interference peak has already been filtered out. This is a normal signal and spectrum for a single-channel EEG.
It is not obvious what you want to do with the 'EvokedPotential3.mat' file, since it appears to have nothing in common with the 'eeg4.mat' file.
LD1 = load('eeg4.mat');
EEG = LD1.eeg;
L1 = numel(EEG);
LD2 = load('EvokedPotential3.mat');
e_p = LD2.e_p;
ie_p = LD2.ie_p;
trigger = LD2.trigger;
Fs = 256;
t1 = linspace(0, L1-1, L1)/Fs;
figure
plot(t1, EEG)
grid
xlabel('Time')
ylabel('Amplitude')
title('EEG')
figure
plot(t1, EEG)
grid
xlabel('Time')
ylabel('Amplitude')
title('EEG (Detail)')
xlim([0 1])
Fn = Fs/2;
NFFT = 2^nextpow2(L1)
NFFT = 8192
FTEEG = fft((EEG-mean(EEG)).*hann(L1), NFFT)/L1;
Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, abs(FTEEG(Iv))*2)
grid
xlabel('Frequency')
ylabel('Magnitude')
title('EEG Spectrum')
.

Catégories

En savoir plus sur EEG/MEG/ECoG dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by