User Tutorial:Performing a Time-Domain Offline Analysis of EEG Data

From BCI2000 Wiki
Jump to navigation Jump to search

Although the basic properties of the P300 evoked potential are the same for all individuals, the response's latency, width, and spatial pattern are unique for each individual. In order to facilitate P300 classification, we must determine the typical values for these properties. BCI2000 Offline Analysis is a helpful tool for performing analyses of offline data in order to characterize a given subject.

Experimental Design

This tutorial will make use of the eeg2_1.dat and eeg2_2.dat sessions that are included with BCI2000 which can be found in data/samplefiles/. In these sessions, the subject was placed in front of a monitor displaying a P300 speller matrix. A test sequence, consisting of a string of letters with a single letter highlighted, was also displayed. In each run of the experiment, the subject was asked to focus on the symbol in the speller matrix that was currently highlighted in the test sequence. This way, it was possible to label evoked responses according to whether they occurred for the highlighted symbol or for some other symbol in the matrix. Such labels can be attached to BCI2000 data using state variables. In the case of the eeg2 data, we've used the state variable StimulusType such that StimulusType is equal to 1 when the letter that flashes is the letter that the subject is focused on (i.e., the letter that is currently highlighted). When the symbol that flashes is not the symbol of focus, StimulusType will not be equal to 1. If you are relatively new to BCI2000, you may find it helpful to inspect the data files we'll be using with the BCI2000 Viewer. Using this tool, you will be able to see how state variables change with respect to the data over time. For instruction on how to inspect data using the BCI2000 Viewer, please see User Reference:BCI2000Viewer.


The Feature Plot

BCI2000 Offline Analysis generates three plots that will aid you in your analyses. One of these plots, the feature plot, provides an overview of the data. Let's begin by generating this plot:

  1. Open BCI2000 Offline Analysis. If this is your first time using BCI2000 Offline Analysis, you may want to review the instructions on how to install and run this application: User Reference:BCI2000 Offline Analysis.
  2. Set the analysis parameters as follows:
    1. Analysis Domain: Choose "Time (P300)" in order to perform a time-domain analysis
    2. Acquisition Type: Choose "EEG" since the data we'll be working with in this section was recorded using an EEG.
    3. Data Files: Click the "Add" button and navigate to data/samplefiles/. From there, select the files eeg2_1.dat and eeg2_2.dat and click "Open". To select multiple files, you'll need to first click on any one file and then, while holding down the control button on your keyboard, click the remaining files.
    4. Montage File: Leave this blank. The reason for doing so will be explained shortly.
    5. Target Condition 1: Enter the MATLAB-syntax statement "(states.StimulusCode > 0) & (states.StimulusType == 1)" which should be the default value after selecting "Time (P300)" as the analysis domain. This statment instructs BCI2000 Offline Analysis that condition 1 should correspond to the data where the symbol that the subject was focused on corresponded to one of the letters that was flashing.
    6. Target Condition Label 1: The text entered here will be used to label data that is specific to condition 1. So, we will enter the string "Correct" as in the correct (i.e., highlighted) letter was one of the letters flashing.
    7. Target Condition 2: Enter the MATLAB-syntax statement "(states.StimulusCode > 0) & (states.StimulusType == 0)" which should be the default value after selecting "Time (P300)" as the analysis domain. This instructs BCI2000 Offline Analysis that condition 2 should correspond to the data where the symbol the subject was focused on did not corresponded to one of the letters that was flashing.
    8. Target Condition Label 2: The text entered here will be used to label data that is specific to condition 2. So, we will enter the string "Incorrect" as in the correct (i.e., highlighted) letter was not one of the letters flashing.
    9. Trial Change Condition: Enter the value "states.StimulusBegin == 1". This instructs BCI2000 Offline Analysis that the trial edges correspond to data samples where the state variable StimulusBegin becomes 1 or is 1 and becomes something else.
    10. Waveform Channels: Leave this blank. The reason for doing so will become clear.
    11. Topo Times: Leave this blank. The reason for doing so will become clear.
    12. Spatial Filter: Choose "None". Because P300 responses are typically detected on a number of channels, CAR filtering is not typically effective.
    13. Ignore Warnings: Leave this field unchecked. For more information on this field, please see User Reference:BCI2000 Offline Analysis.
    14. Overwrite existing plots: If you have not yet run any analyses, this field should be disabled. If it is enabled, it is best for the purposes of this tutorial to leave it checked. Unchecking this box will instruct BCI2000 Offline Analysis to open new figures whenever it plots. This is useful if you want to compare the results of one analysis against another.
  3. Click "Generate Plots".

Once the analysis has completed, you should see a feature plot similar to the one below. This plot displays the r-squared (coefficient of determination) values for the two distributions (i.e., the average signal for condition 1 and the average signal for condition 2) as a function of time and channel.

Eeg2Feature.png

The feature plot is an overview of the possible features. Thus, it is typically the best place to start your analysis. From this plot, we can find the best features by looking for clusters of high r-squared values. In our feature plot, we notice that all of the clusters appear to be aligned at about 503ms. The biggest of these clusters - with the largest r-squared values - appears to be centered over electrode 51. We will now use BCI2000 Offline Analysis to produce two additional plots that will help us to take a more detailed look at this time and channel.

Waveform Plots and Topographies

BCI2000 Offline Analysis provides - in addition to the feature plot - waveform plots and topographies. Waveform plots are useful for investigating specific channels while topographies are useful for investigating specific time windows. In order to generate the topographies we will need to communicate the manner in which the electrodes were arranged. This is done with a montage file. While there is a montage file included with BCI2000 that is suitable for the data we'll be analyzing here, you will likely need to create or modify montage files for future analyses. For that reason, we recommend that you take the time now to familiarize yourself with the Eloc Helper if you have not already done so. In User Tutorial:Designing an Eloc File, you will learn how to create a new montage file and modify an existing one so that you ultimately have your own montage file to use to complete this analysis. If you prefer not to complete the Eloc Helper tutorial at this time, you will still be able to complete this tutorial using one of the montage files that comes with BCI2000.

If you have finished designing your montage file or decided to use the one that's provide, please proceed to the steps below. Note that these steps pick up from the steps outlined in the previous section for generating the feature plot:

  1. Set the analysis parameters as follows:
    1. Montage File: Click the "Browse" button next to the field labeled "Montage Files" and browse to data/samplefiles/. If you completed the Eloc Helper tutorial and would like to use the montage file you created, double-click myeeg64.loc. Otherwise, double-click eeg64.loc to use the montage file that comes with BCI2000.
    2. Waveform Channels: In the previous section we found that channel 51 may be an effective classification feature for facilitating online control. To generate the waveform plot for this channel, enter "51" into this field.
    3. Topo Times: In the previous section we found that 503 ms may be an effective classification feature for facilitating online control. To generate a topography for this time, enter "503" into this field.
  2. Click "Generate Plots".

Once the analysis is complete, you will see the same feature plot as was generated in the previous section. Additionally, you will see a waveform plot and topography similar to those below. In the waveform plot, we expect to see a peak response at approximately 300 ms. For this particular subject, however, we can see the peak response at approximately 503 ms as indicated by the feature plot which is reasonably close. In the adjacent r-squared waveform plot we can see that the r-squared values also peak approximately at this time. P300 topographies can vary significantly. In the generated topography, we see that the response is located mainly over the parietal and temporal lobes, which is consistent with the P300 response found in other studies (Sellers et. al.: A P300 event-related potential brain–computer interface (BCI): The effects of matrix size and inter stimulus interval on performance. Biological Psychology 70(2006):242-252. April 2006). However, there is significant variance in the spatial distribution of the response across different subjects in P300 experiments. Regardless, it appears that the (503 ms, Channel 51) feature would indeed serve as an effective recognition feature for facilitating online control.

Eeg2Waveform.png

Eeg2Topo.png

Next Step

At this point you should understand how to use the BCI2000 Offline Analysis plots to help you choose effective P300 features. You might like to proceed to User Tutorial:Performing a Time-Domain Offline Analysis of ECoG Data for a similar tutorial using data recorded using an ECoG.

See also

User Tutorial:Obtaining P300 Parameters in a Calibration Session