Jump to content

UserReference:P300ClassifierMethods

From BCI2000 Wiki

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(0)x11(1)x11(p1)x1l(0)x1l(1)x1l(p1)x21(0)x21(1)x21(p1)x2l(0)x2l(1)x2l(p1)xm1(0)xm1(1)xm1(p1)xml(0)xml(1)xml(p1)]

for

i=1,2,,m;

k=1,2,,l;

n=0,1,,p1;

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).

Assume that the data set is recorded from 8 channels at 256 Hz, the elapsed time from the start to the end of each intensification is 800 ms, and the Decimation Frequency provided by the investigator is 20 Hz. For this example, m=12x15x4=720, l=8, and p=round(256x0.800)=205. The total number of columns (variables) of the above matrix is 8x205=1640.

Get P300 Responses

In this step, it is computed the corresponding time samples of a time Response Window [t1,t2] in (ms). Following the above example, assume that the time Response Window specified by the investigator is [0 800] ms.

n1=round(t1Fs1000)=round(0*2561000)=0

n2=round(t2Fs1000)=round(800*2561000)=205

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

The coefficients bi of the Moving Average (MA) 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=round(FsDf)=round(25620)=13

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 yik(n), result of the convolution between all the extracted signals —for channels k=1,2,,l and observations i=1,2,,m— and the impulse response, is downsampled by a factor N.

Generate Feature Weights for a Linear Model using Stepwise Linear Discriminant Analysis (SWLDA)

Consider a data vector 𝐝 of m observations, a vector 𝐰 of n model parameters (weights) to estimate, and a matrix 𝐆 representing the final 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.