Off-Line EEG Analysis of BCI Experiments With MATLAB V2.12.01
Off-Line EEG Analysis of BCI Experiments With MATLAB V2.12.01
What is Brain-Computer-Interface?
An Electroencephalogram based Brain-Computer-Interface (BCI) provides a new communication
channel between the human brain and a computer. Patients who suffer from severe motor
impairments (late stage of Amyothrophic Lateral Sclerosis (ALS), severe cerebral palsy, head trauma
and spinal injuries) may use such a BCI system as an alternative form of communication by mental
activity.
Physiological background
It is a well known phenomenon that EEG rhythmic activities, observed over motor and related areas of
the brain, disappear about 1 second prior to a movement onset. Hence one can predict from the
spatio-temporal EEG pattern that, for example, a hand movement will be performed. It has also been
shown by various groups of researchers that this so-called desynchronized EEG is also observed for
an imagination of a hand movement.
The activation of hand area neurons either by the preparation for a real hand movement or by
imagination of a hand movement is accompanied by a circumscribed ERD over the hand area.
Depending on the type of motor imagery different EEG patterns can be obtained. Hence, one finds
also a circumscribed ERD over the foot area in foot movement and foot imagination experiments.
Experimental paradigm and recording setup for the BCI data acquisition
Experimental paradigm
The data set used for classification was acquired during a brain-computer interface experiment with
feedback. The session was divided into 4 experimental runs of 40 trials with randomized directions of
the cues (20 down and 20 right) and lasted about 1 hour (including electrode application, breaks
between runs and experimental preparation). The subject sat in a comfortable armchair 1.5 meters in
front of a computer-monitor and was instructed not to move, keep both arms and hands relaxed and to
maintain the fixation at the center of the monitor throughout the experiment.
The experimental paradigm started with the display of a fixation cross that was shown in the center of
a monitor. After two seconds a warning stimulus was given in form of a "beep". From second 3 until
4.25 an arrow (cue stimulus), pointing down or to the right was shown on the monitor. The subject was
instructed to imagine a foot or right hand movement depending on the direction of the arrow. Between
second 4.25 and 8, the EEG was classified on-line and the classification result was translated into a
feedback stimulus in form of a horizontal bar that appeared in the center of the monitor. If the person
imagined a right movement the bar, varying in length, extended to the right and vice versa (correct
classification assumed). The subject's task was to extend the bar toward the bottom or right boundary
of the monitor as indicated by the arrow cue. One trial lasted 8 seconds and the time between two
EEG recording
Two bipolar recordings overlaying the left and central sensorimotor area were placed on the subject's
head as indicated in figure 2. The ground electrode was attached to the forehead.
The amplified EEG was band pass filtered by an analog filter between 0.5 and 30 Hz and sampled at
128 Hz. The resolution was 12 bits. A notch filter was used to suppress the 50 Hz power line
interference.
Running g.BSanalyze
3. Pressing OK yields
5. Select Concatenate SAMPLES. Output preview shows the expected result of the merging
process. Press the button OK.
The new data-set consists now of 3 channels, 1 trial and about 4 times more samples as a single data-
set (176841 samples).
2. Define the Time before trigger as 2000 ms and Time after trigger as 6000 ms
3. Select channel 3 in Physical channel as trigger channel and set the Threshold level to 90 % of
maximum
4. Select e.g. the name TRIGGER in Assign attribute to resulting trials and press button add to
list ->
The status bar in the editor windows shows the result: the number of trials is 160 and one trial has a
length of 1024 samples.
2. Click on Edit CHANNEL ATTRIBUTE and enter TRIGGER under Create new. Press the button
Add to list. Click on button purple to assign a new color
The Load Class Information window is used to assign trial attributes to the data from a given *.mat,
or ASCII-file. The loaded class information vector must match the number of trials. Assume that you
have loaded a data file with 3 trials into g.BSanalyze. An appropriate class information vector would be
0 1 0. Load class information would assign an attribute to the second trial.
3. Search for the class information file class160.mat in the same directory. The Import Wizard
shows the variables stored in the file and gives a truncated preview of the class information.
4. Click Finish to assign the attributes to the data trials. The window shows the attribute name 4 for
the first row of the loaded class matrix and 5 for the second row.
6. Close the window with OK. The attributes are assigned to your trials.
The assignment of attributes to the trials can be seen if you change to the trial x channel mode
in the section PRESENT in the Data Editor. As can be seen the session started with 3 foot movement
imageries. The first trial with a right motor imagery is trial number 4.
4. Set Reference interval starts at to 500 ms and Action interval starts at to 6000 ms
5. Click on Select trials/chan. and exclude the channels with attribute TRIGGER from the
following calculation. Confirm the settings and close the window with OK.
3. Click on Design filter and create a Butterworth filter with order 5 and a lower cutoff frequency
of 14 Hz and an upper cutoff frequency of 18 Hz. Assign the Name BETANEW, press add to
list and press button OK
5. Click on Select trials/chan. and exclude the TRIGGER channel. Include only the FOOT trials.
Close the window with OK
7. Repeat steps 5-6 and include only trials with the attribute RIGHT
Channel 1, C3 Channel 2, Cz
The figure below shows ERD/ERS calculated between 14 and 18 Hz for trials with attribute RIGHT. It
can be seen that the subject shows an ERD over the contralateral area (C3) during the imagination of
the right hand movement.
Channel 1, C3 Channel 2, Cz
1. Click on Bandpower under the Parameter Extraction menu to open the following window:
3. Specify the length of the estimation interval as 128 samples with overlap of 127 samples.
Attention: No other overlap is allowed in the DEMO mode
4. Click on select channels and add the EEG channels C3 and Cz to the list. Confirm the settings
with the OK button
2. Set the classification interval to Start at 1000 ms, End at 8000 ms and Step to 500 ms
4. Click on Select feature channels and select channel 1 and 2 for classification
5. Select Linear Discriminant Analysis (LDA) from the Classification method pull-down
menu
6. Press Start
3. Press Start
To further improve the classification result calculate also the bandpower in the alpha range of the
EEG. Identify the optimal frequency range from the ERD analysis results.
Reference:
This forces g.BSanalyze to report all calculations in the MATLAB command window. After finishing the
analysis open a New M-file and copy and paste all commands into the file.
mybatch
For further data-sets just replace the input data file to perform the same analysis.
Analyze and classification methods produce specific objects that can be viewed with g.Result2d and
stored to harddisk. To open such an object from the command line type
R_O = CreateResult2D(A_O_S);
then enter
gResult2d(R_O);
gResult2d(R_O,print);
To start g.BSanalyze from the MATLAB command line and to open immediately a file use
dataedit(filename);
gbsanalyze
Load the acquired data file session1.mat for the calculation of a new weight vector for the next on-
line experiment with feedback.
Then open the Appearance Settings window from the Options menu and browse for the user
directory under
Select the BCIBatch to automatically process the data. Use the MATLAB editor to investigate or
modify the processing steps.
After a few seconds the analysis batch shows automatically a BCI experiment report containing a
description of the BCI experiment and an error rate time curve. The best time point is indicated by a
red circle.
WV