Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

EEG signal processing-matlab code

1,254 views
Skip to first unread message

Rak

unread,
Apr 3, 2013, 12:46:05 AM4/3/13
to
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:

load('Signal1.mat');

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

figure;p=plot(s);

title('EEG Signal')


fs = 500;

% Sampling frequency

N=length(s);


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);
subplot(5,1,5);plot(1:1:length(Delta),Delta);title('DELTA');


D5 = detrend(D5,0);
xdft = fft(D5);
freq = 0:N/length(D5):N/2;
xdft = xdft(1:length(D5)/2+1);
figure;subplot(511);plot(freq,abs(xdft));title('GAMMA-FREQUENCY');
[~,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;
subplot(512);plot(freq2,abs(xdft2));title('BETA');
[~,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;
subplot(513);plot(freq3,abs(xdft3));title('ALPHA');
[~,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;
subplot(514);plot(freq4,abs(xdft4));title('THETA');
[~,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;
subplot(515);plot(freq3,abs(xdft5));title('DELTA');
[~,I] = max(abs(xdft5));
fprintf('Delta:Maximum occurs at %f Hz.\n',freq5(I));
%%%%%%%%%%%%%%%

nguyen hoa

unread,
Feb 10, 2014, 3:06:09 PM2/10/14
to
you can send signal1.mat for me? i need it, please!

Aarthi

unread,
Feb 26, 2014, 11:25:08 PM2/26/14
to
Hi friends

I am working in EEG signal analysis. I need the matlab code to split my input .wav file into windows with 50% overlap. Can you help me pls..
Message has been deleted

venky

unread,
Mar 16, 2015, 2:35:27 AM3/16/15
to
"Srey" wrote in message <kjgc6d$168$1...@newscl01ah.mathworks.com>...

hamza khalid

unread,
Apr 15, 2015, 3:40:53 AM4/15/15
to
hi rak i have seen your code do you get further information regarding to feature extraction are your frequencies matched and what about feature classification plz tell me i am waiting for your updates
regards
hamza

deepika kharbanda

unread,
May 2, 2015, 2:35:49 PM5/2/15
to
hi RAK,
Could you elaborate on your experiment with EEG signals. My team and I are conducting a similar experiment and I'd like to exchange notes on this.
Thanks

sravanth kumar

unread,
May 8, 2015, 7:00:05 AM5/8/15
to
"deepika kharbanda" wrote in message <mi35dv$4n7$1...@newscl01ah.mathworks.com>...
> hii,
i am also doing same thing i extract EEG signal in frequency bands and classifying in emotions in offline but i am trying in online using wireless EEG kit.

kamesh pedada

unread,
May 28, 2015, 1:11:59 PM5/28/15
to
Sir I want to EEG signal data please send data anybody please please please

sercan dogan

unread,
Jun 17, 2015, 6:45:03 AM6/17/15
to
please can you send "signal1.mat" about eeg signal?Very important.

sercan dogan

unread,
Jun 17, 2015, 6:46:03 AM6/17/15
to
"nguyen hoa" <anhoa1...@yahoo.com.vn> wrote in message <ldbbfg$8pf$1...@newscl01ah.mathworks.com>...
> you can send signal1.mat for me? i need it, please!
Can you send "signal1.mat" please??

sercan dogan

unread,
Jun 17, 2015, 6:48:02 AM6/17/15
to
"Srey" wrote in message <kjgc6d$168$1...@newscl01ah.mathworks.com>...
can you send "signal1" please???

sercan dogan

unread,
Jun 17, 2015, 6:59:02 AM6/17/15
to

Steven Lord

unread,
Jun 17, 2015, 9:15:24 AM6/17/15
to


"sercan dogan" <sercand...@gmail.com> wrote in message
news:mlrj8u$dos$1...@newscl01ah.mathworks.com...
> "Srey" wrote in message <kjgc6d$168$1...@newscl01ah.mathworks.com>...
>> 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).

*snip*

> can you send "signal1" please???

Google searching for "open vibe" is your friend. See the last button on this
page.

http://openvibe.inria.fr/downloads/

--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

liza thomas

unread,
Mar 10, 2016, 2:19:09 AM3/10/16
to
"nguyen hoa" <anhoa1...@yahoo.com.vn> wrote in message <ldbbfg$8pf$1...@newscl01ah.mathworks.com>...
> you can send signal1.mat for me? i need it, please!
Answer:
U can use any EEG signal as the input

Aaron Karlo Maranan

unread,
Feb 15, 2017, 10:47:08 AM2/15/17
to
"Srey" wrote in message <kjgc6d$168$1...@newscl01ah.mathworks.com>...
hi may ask something about the line
> s=data(1:2500,3);% taken values from c3 electrode, what do you mean by the ratio (1:2500,3) and i have encountered error such as "Undefined function 'data' for input arguments of type 'double'. when i run such line.

Also may you please send to my email Signal.mat for our reference.
thank you very much in advance.

Jana123

unread,
Apr 1, 2017, 2:28:14 AM4/1/17
to
"Aaron Karlo Maranan" wrote in message <o81t5n$pm7$1...@newscl01ah.mathworks.com>...
Hi I have got the same issue "Undefined function 'data' for input arguments of type 'double'" Has anybody resloved this issue? Thanks

Divya Savale

unread,
Aug 17, 2017, 11:58:19 PM8/17/17
to
I m a student of MTech 2nd year from GH Raisoni college of engineering Nagpur. My project is Human stress detection through EEG signal. Can anyone provide me the database of the EEG signal. As it is very urgently required for my project.

VENKATA PHANIKRISHNA B

unread,
Oct 16, 2017, 1:11:18 PM10/16/17
to
Please provide the information about decomposing levels. here u are using 8. how to choose 8. Is there any relation between the sampling frequency and decomposition levels.
0 new messages