The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: EEG signal processing-matlab code
Replies: 18   Last Post: Oct 16, 2017 1:11 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 41
Registered: 3/30/12
EEG signal processing-matlab code
Posted: Apr 3, 2013 12:46 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I have downloaded dataset of eeg from open vibe site.The datasets includes 14 records of left and right hand motor imagery, 11 channels : C3, C4, Nz, FC3, FC4, C5, C1, C2, C6, CP3 and CP4.Each file contains 40 trials where the subject was requested to imagine either left or right hand movements (20 each).
I have taken one such record which is of .csv format.i converted that .csv file to .mat.
I have applied wavelets(dwt) for band separation.I found out the frequencies for each band,but dont know whether correct or not.

Any body please help me .
I want to apply a classifier and should check whether the signal processing/features are ok or not. Is it possible to do classification using this data.

My code for feature extraction is as follows:


s=data(1:2500,3);% taken values from c3 electrode


title('EEG Signal')

fs = 500;

% Sampling frequency


waveletFunction = 'db8';
[C,L] = wavedec(s,8,waveletFunction);

cD1 = detcoef(C,L,1);
cD2 = detcoef(C,L,2);
cD3 = detcoef(C,L,3);
cD4 = detcoef(C,L,4);
cD5 = detcoef(C,L,5); %GAMA
cD6 = detcoef(C,L,6); %BETA
cD7 = detcoef(C,L,7); %ALPHA
cD8 = detcoef(C,L,8); %THETA
cA8 = appcoef(C,L,waveletFunction,8); %DELTA
D1 = wrcoef('d',C,L,waveletFunction,1);
D2 = wrcoef('d',C,L,waveletFunction,2);
D3 = wrcoef('d',C,L,waveletFunction,3);
D4 = wrcoef('d',C,L,waveletFunction,4);
D5 = wrcoef('d',C,L,waveletFunction,5); %GAMMA
D6 = wrcoef('d',C,L,waveletFunction,6); %BETA
D7 = wrcoef('d',C,L,waveletFunction,7); %ALPHA
D8 = wrcoef('d',C,L,waveletFunction,8); %THETA
A8 = wrcoef('a',C,L,waveletFunction,8); %DELTA

Gamma = D5;
figure; subplot(5,1,1); plot(1:1:length(Gamma),Gamma);title('GAMMA');

Beta = D6;
subplot(5,1,2); plot(1:1:length(Beta), Beta); title('BETA');

Alpha = D7;
subplot(5,1,3); plot(1:1:length(Alpha),Alpha); title('ALPHA');

Theta = D8;
subplot(5,1,4); plot(1:1:length(Theta),Theta);title('THETA');

Delta = A8;
%figure, plot(0:1/fs:1,Delta);

D5 = detrend(D5,0);
xdft = fft(D5);
freq = 0:N/length(D5):N/2;
xdft = xdft(1:length(D5)/2+1);
[~,I] = max(abs(xdft));
fprintf('Gamma:Maximum occurs at %3.2f Hz.\n',freq(I));

D6 = detrend(D6,0);
xdft2 = fft(D6);
freq2 = 0:N/length(D6):N/2;
xdft2 = xdft2(1:length(D6)/2+1);
% figure;
[~,I] = max(abs(xdft2));
fprintf('Beta:Maximum occurs at %3.2f Hz.\n',freq2(I));

D7 = detrend(D7,0);
xdft3 = fft(D7);
freq3 = 0:N/length(D7):N/2;
xdft3 = xdft3(1:length(D7)/2+1);
% figure;
[~,I] = max(abs(xdft3));
fprintf('Alpha:Maximum occurs at %f Hz.\n',freq3(I));

D8 = detrend(D8,0);
xdft4 = fft(D8);
freq4 = 0:N/length(D8):N/2;
xdft4 = xdft4(1:length(D8)/2+1);
% figure;
[~,I] = max(abs(xdft4));
fprintf('Theta:Maximum occurs at %f Hz.\n',freq4(I));

A8 = detrend(A8,0);
xdft5 = fft(A8);
freq5 = 0:N/length(A8):N/2;
xdft5 = xdft5(1:length(A8)/2+1);
% figure;
[~,I] = max(abs(xdft5));
fprintf('Delta:Maximum occurs at %f Hz.\n',freq5(I));

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.