Jump to content

UserReference:P300ClassifierMethods: Difference between revisions

From BCI2000 Wiki
Cmpotes (talk | contribs)
Cmpotes (talk | contribs)
Line 25: Line 25:
Consider the following example to help you understand the previous mathematical notation. A BCI data set is recorded during a P300 Speller task using a 6 by 6 matrix of characters. Each row and column of the matrix is randomly intensified resulting in 12 different stimuli. The sets of 12 intensification are repeated 15 times for each intended character to spell. For this example, the subject pretend to spell the word "SEND", a total of 4 characters.
Consider the following example to help you understand the previous mathematical notation. A BCI data set is recorded during a P300 Speller task using a 6 by 6 matrix of characters. Each row and column of the matrix is randomly intensified resulting in 12 different stimuli. The sets of 12 intensification are repeated 15 times for each intended character to spell. For this example, the subject pretend to spell the word "SEND", a total of 4 characters.


[[Image:P3SpellerScreen.PNG|center|frame|Figure1: A 6 by 6 speller matrix. Here, the user's task is to spell the word "SEND" (one character at a time).  For each character, all rows and columns in the matrix are intensified 15 times (here, the third row is shown intensified).]]
[[Image:P3SpellerScreen.PNG|center|frame|A 6 by 6 speller matrix. Here, the user's task is to spell the word "SEND" (one character at a time).  For each character, all rows and columns in the matrix are intensified 15 times (here, the third row is shown intensified).]]


The data set is recorded from 8 channels at 256 Hz, and the elapsed time from the start to the end of each intensification is 800 ms. For this example, <math> m = 12x15x4 = 720 </math>, <math> l = 8 </math>, and <math> p = round(256 x 0.800) = 205 </math>. The total number of columns of the above matrix is <math> 8 x 256 = 2048 </math>.
The data set is recorded from 8 channels at 256 Hz, and the elapsed time from the start to the end of each intensification is 800 ms. For this example, <math> m = 12x15x4 = 720 </math>, <math> l = 8 </math>, and <math> p = round(256 x 0.800) = 205 </math>. The total number of columns of the above matrix is <math> 8 x 256 = 2048 </math>.

Revision as of 18:22, 12 September 2009

Load BCI2000 Data Files

Once the BCI2000 data files are check for compatibility, signals are extracted either from each training or testing data file and are arranged in a matrix form as:

𝐗𝐢𝐤(𝐧)=[x11(1)x11(2)x11(p)x1l(1)x1l(2)x1l(p)x21(1)x21(2)x21(p)x2l(1)x2l(2)x2l(p)xm1(1)xm1(2)xm1(p)xml(1)xml(2)xml(p)]

for

i=1,2,,m;

k=1,2,,l;

n=1,2,,p;

being m the total number of observations (stimuli), l the total number of channels, and p=t*Fs the total number of samples recorded for each channel. t is the recording stimulus time, and Fs is the sampling frequency.

Consider the following example to help you understand the previous mathematical notation. A BCI data set is recorded during a P300 Speller task using a 6 by 6 matrix of characters. Each row and column of the matrix is randomly intensified resulting in 12 different stimuli. The sets of 12 intensification are repeated 15 times for each intended character to spell. For this example, the subject pretend to spell the word "SEND", a total of 4 characters.

A 6 by 6 speller matrix. Here, the user's task is to spell the word "SEND" (one character at a time). For each character, all rows and columns in the matrix are intensified 15 times (here, the third row is shown intensified).

The data set is recorded from 8 channels at 256 Hz, and the elapsed time from the start to the end of each intensification is 800 ms. For this example, m=12x15x4=720, l=8, and p=round(256x0.800)=205. The total number of columns of the above matrix is 8x256=2048.

Get P300 Responses

Given the time response window [t1,t2] in (ms), it is computed their corresponding time samples as:

n1=round(t1Fs1000)

n2=round(t2Fs1000)

Signals of interest are extracted from 𝐗𝐢𝐤(𝐧) and are defined only for n1nn2.

The coefficients bi of the filter are found as

bi=1N+1

for i=0,1,2,,N where N is the filter order. The filter order can be computed from the sampling frequency Fs and the provided decimation frequency Df as

N=FsDf

Thus, the impulse response h(n) can be computed as

h(n)=1N+1i=0N1δ(ni).

To filter the selected signals, each channel k and each observation (stimulus) i of the matrix 𝐗𝐢𝐤(𝐧) is convolved () with the impulse response h(n). The next equation shows how to filter a signal for channel k=1 and observation i=1

y11(n)=x11(n)h(n).

The output of the convolution between all the signals —for channels k=1,2,,l and observations i=1,2,,m— and the impulse response, is downsampled by a factor N.

onsider a data vector 𝐝 of m observations, a vector 𝐰 of n model parameters (weights) to estimate, and a matrix 𝐆 representing the linear model. This inverse problem can be written as

𝐆𝐰=𝐝

An approximate solution to this problem can be found by minimizing the difference (residuals) between the actual data 𝐝 and 𝐆𝐰.

𝐫=𝐝𝐆𝐰

The least squares or 2-norm solution has been adopted to minimize these residuals.

𝐰=(𝐆𝐓𝐆)1𝐆𝐓𝐝.

The symbol T represents the transpose of the matrix 𝐆. Note that least squares solution is only valid for overdetermined systems (mn); there must be in the model more observations than variables. If the residuals have a normal distribution, the least squares corresponds to the maximum likelihood criterion.