1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| close all ;
clear all;
clc
% Récuperation du signal a traiter
[fileout,pathout] =uigetfile('*.CSV');% affiche les fichiers à sélectionner puis retourne le chemin choisi
sample = importdata(strcat(pathout,fileout))
chemin = [pathout,fileout]
Valeurs=xlsread(chemin);
A=size(Valeurs)-1;
Fs=200;
ts=1/Fs;
t1=0:ts:(A/Fs);
t1=t1';
%Transformé du fourier du signal EEG
L=length(Valeurs);
V_HannWnd = Valeurs .* hanning (L);
N=length(V_HannWnd);
f=LINSPACE(-Fs/2,Fs/2,length(t1));
X= fftshift(fft(V_HannWnd)*ts);
V= abs (X);
figure (1),subplot(221),plot (t1, Valeurs)
title ('signal EEG ');
xlabel ('Time,s');
ylabel ('eeg(t)');
subplot(222),plot(f,abs (X),'r');
title ('FFT du signal EEG');
xlabel ('Fréquence (Hz)');
ylabel ('| EEG(f) |');
grid on
axis([0 100 0 1000]);
%Filtrage
Fc1=0.4;
Fc2=60;
Wn1=2.*Fc1./Fs;
Wn2=2.*Fc2./Fs;
[b,a]= butter(7,[Wn1 Wn2],'Bandpass');
% freqz(b,a,f,Fs);
signal1=filter(b,a,X);
subplot(223),plot (f, signal1)
title ('signal filtré');
xlabel ('Fréquence (Hz)');
ylabel ('| EEG(f) |');
axis([0 100 0 1000]); |
Partager