Jump to content

User Tutorial:Performing an Offline Analysis of EEG Data

From BCI2000 Wiki

Although the basic properties of the Mu rhythm are identical for all humans, its spatial pattern and its exact frequency will differ. BCI2000 Offline Analysis helps to determine the frequencies and locations that correlate best with a given instruction.

Experimental Design

This tutorial will make use of the eeg1_1.dat, eeg1_2.dat and eeg1_3.dat sessions that are included with BCI2000 and can be found in data/samplefiles/. In these sessions, the subject was asked to move both hands and both feet in a predefined pattern. The resulting data was recorded using BCI2000 and labeled using the TargetCode state variable such that TargetCode is equal to 1 when the subject is responding to the instruction to move both hands, 2 when the subject is responding to the instruction to move both feet and 0 when the subject is responding to the instruction to rest. 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

Let's begin with an offline analysis of the data resulting from action movement (i.e., eeg1Mov.dat, eeg2Mov.dat and eeg3Mov.dat).

  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 "Frequency" in order to perform a frequency-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 eeg1Mov.dat, eeg2Mov.dat and eeg3Mov.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 value "states.TargetCode == 0". This instructs BCI2000 Offline Analysis to search the data for sections where the TargetCode indicates that the subject was responding to the instruction to rest.
    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 "Rest".
    7. Target Condition 2: Enter the value "states.TargetCode == 2". This instructs BCI2000 Offline Analysis to search the data for sections where TargetCode indicates that the subject was responding to the instruction to move both feet.
    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 "Both Feet".
    9. Trial Change Condition Enter the value "states.IntertrialInterval == 1". This instructs BCI2000 Offline Analysis that the trial edges correspond to data samples where IntertrialInterval becomes 1 or is 1 and becomes something else.
    10. Spectra Channels: Leave this blank. The reason for doing so will become clear.
    11. Topo Frequencies: Leave this blank. The reason for doing so will become clear.
    12. Spatial Filter: Choose "Common Average Reference (CAR)". Typically, for frequency domain analyses, filtering the data with a simple spatial filter such as CAR filter results in sharper, more useful plots.
    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 frequency and channel.

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 (coefficient of determination) values. In our feature plot, we notice some clusters centered around (31 Hz, Channel 18), (31 Hz, Channel 10), (19 Hz, Channel 10) and (19 Hz, Channel 16). Before concluding that these coordinates are good features for on-line control, however, we must first look at the data in more detail.

Spectra and Topographies

As was mentioned earlier, the feature plot is useful for gaining an overview of the data and determining some of the more potentially useful features. BCI2000 Offline Analysis provides two more plots that allow us to look at the data in more detail. To see how the data behaves at specific electrodes, we'll generate the spectra - a plot of energy versus frequency - at those electrodes. To see how the data behaves at a specific frequency, we'll generate the topographies - a plot of the r-squared values at each electrode - at those frequencies. In order to generate the topographies we will need to communicate to BCI2000 Offline Analysis approximately how the electrodes we recorded from were distributed. We do this by specifying 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. In User Tutorial:Eloc Helper, 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 can skip to the steps below that will show you how to use BCI2000 Offline Analysis to generate the spectra and topographies. 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. Spectra Channels: In the previous section we found - by inspection of the feature plot - three channels that show considerable promise: 10, 16 and 18. To generate spectra for these channels, enter "10 16 18" into this field.
    3. Topo Frequencies: In the previous section we found - by inspection of the feature plot - two frequencies that show considerable promise: 19 and 31 Hz. To generate topographies for these frequencies, enter "19 31" into this field.
  2. Click "Generate Plots".

Once the analysis has completed, you will see the same feature plot as was generated in the previous section. Additionally, you will see spectra and topographies for the channels and frequencies similar to the ones below.

Next Step

Now that you know how to use BCI2000 Offline Analysis to generate useful plots for choosing good features, let's continue on to User Tutorial:Interpreting the Results to learn how to use these plots to pick the best features for on-line control.

See also

User Tutorial:Obtaining Mu Rhythm Parameters in an Initial Session