Trouble using Common Spatial Patterns

1 view (last 30 days)
John Doe
John Doe on 10 Aug 2013
Hello, I'm trying to use CSP on multiple trials of EEG data but I am unsure if it is correct. There are two classes, think left and think right.
I am using the data set and CSP method described in this paper: http://www.ncbi.nlm.nih.gov/pubmed/23204288
For every trial I calculate this value:
C = (xl*xl')/trace(xl*xl');
where xl is the EEG trial data NxP where N is the number of channels and P the data samples.
Then I get the average of all the values of C for think Left and again for think Right. Then I sum those 2 averages together to get the matrix "CC". Then I do this:
CC = CbarL + CbarR;
[V,D] = eig(CC); %V*D*V'==CC
[lamda, ind] = sort(diag(D),'descend');
V = V(:,ind);
P = sqrt(inv(diag(lamda))) * V';
S1 = P*CbarL*P'; % eig(P*CC*P')==ones
S2 = P*CbarR*P';
[B,I] = eig(S1, S2);
[I,ind] = sort(diag(I));
B = B(:,ind);
W = (B'*P);
Finally
W*xl
gets me my filtered trials. Is this all correct so far?

Answers (0)

Categories

Find more on EEG/MEG/ECoG in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!