User Tutorial:Obtaining P300 Parameters in a Calibration Session

From BCI2000 Wiki
Jump to: navigation, search

Obtaining P300 Parameters in the Calibration Session

Although the basic properties of the P300 evoked potential are the same for all individuals, the response's latency, width, and spatial pattern varies, and adaptation to individual parameters improves accuracy.

Thus, it is necessary to obtain these individual parameters prior to performing spelling experiments.

Design of Calibration Session

During the calibration session, the subject is asked to spell out a given word by using a P300 character matrix, pictured below. During each run, the subject is asked to focus on the next letter in the word he is spelling, as the rows and columns flash randomly and successively so that sometimes the flashing corresponds to the column or row containing the target character and sometimes it will not. As the subject counts the number of times the desired letter in the word flashes, a P300 response is generated. The purpose of the calibration session is to identify those features that discriminate between the desired and undesired rows/columns. Without that information, it is impossible to interpret the subject's brain signal. Thus, do not expect any correct letter selection during the calibration session.


After the first few runs are collected, we will use the BCI2000 "Offline Analysis" tool to determine which features (in this case, signals at a particular location and time after the stimulus) correspond to the row or column of the desired character.

Performing the Calibration Session

  • Start BCI2000 by running batch/P3Speller_<Your_Amplifier>.bat
  • Press Config, and load the baseline parameters for copy spelling that you made earlier.
  • In the Storage tab:
    • Set SubjectName to the subject's initials.
    • Set SubjectSession to 001
    • Set SubjectRun to 01
  • In the Application tab:
    • Make sure that InterpretMode is set to copy mode, and DisplayResults (directly below InterpretMode) is unchecked
    • Find the TextToSpell field. This should be set to ‘THE’, and you will be changing it after each run.
  • Press Set Config to apply this configuration.
  • Request that the subject sit in a relaxed position, and that the subject not move or speak during the runs.
  • Turning off or dimming the lights can improve the subject's focus and performance.
  • Showing the brain wave readouts to the subject can help understanding how artifact-generating behavior can be detrimental to the data.
  • Press Start to show the flashing character matrix, and describe what the subject is expected to do.
  • After you’ve explained the procedure, click Suspend to stop.
  • Delete that run of data (the file will be found at data\P300\<Subject Initials>001\<Subject Initials>S001R01.dat).
  • Press Start to record the run.
  • Once it has finished automatically, click Config and change the TextToSpell in the Application tab to QUICK.
  • Press Start to record the run.
  • Once it has finished automatically, click Config and change the TextToSpell in the Application tab to BROWN.
  • Press Start to record the run.
  • Once it has finished automatically, click Config and change the TextToSpell in the Application tab to FOX.
  • Press Start to record the run.
  • Once this recording has finished, close BCI2000 and locate the saved data files below the BCI2000 data directory.

Analyzing The Calibration Session with Offline Analysis

We will now use the BCI2000 "Offline Analysis" tool to analyze the subject's initial session.

  • Start the BCI2000 Offline Analysis tool:
    • If you have a version of Matlab installed, run tools/OfflineAnalysis/OfflineAnalysis.bat.
    • Otherwise, follow the instructions provided elsewhere.
  • In the Analysis Domain field, choose Time (P300)
  • In the Acquisition Type field, choose EEG
  • Next to Spatial Filter, choose Common Average Reference (CAR)
  • For Trial Change Condition enter auto
  • For Target Condition 1 enter (states.StimulusCode > 0) & (states.StimulusType == 1)
  • For Target Condition Label 1 enter Attended Stimuli
    • ‘Attended Stimuli’ refers to the letter or character the person is counting the flashes of, and triggers when the desired letter is flashed
  • For Target Condition 2 enter (states.StimulusCode > 0) & (states.StimulusType == 0)
  • For Target Condition Label 2 enter Unattended Stimuli
    • ‘Unattended stimulus’ refers to the letters or characters the person is not counting the flashes of, and triggers when the desired letter is not flashed
  • Click the Add button by Data Files
  • In this new dialog, select all of the data files taken during this configuration session, and click Open
  • Click Generate Plots and wait for the feature plot to appear
  • When this is complete, you will see a feature plot similar to the one to the right. The vertical axis corresponds to the locations while the horizontal corresponds to the time delay after the stimulus. The color coding shows the r-squared value of that datapoint, with dark red colors indicating a high predictability that a response is produced by the desired letter being flashed.
  • The largest of these r-squared values between 250 and 550ms are what we are interested in. Pick the 4 points with the largest r-squared values between these times and record their time points and channels. The plot’s Data Cursor tool (Tools Menu → Data Cursor) allows for discrete identification of time points.
  • With these four points, close the feature plot, and enter the channels of the data points you found into the Waveform Channels field and the time points into the Topo Times field.
    • In the example above, the four best data points have r-squared values 0.02218, 0.02179, 0.01928, and 0.019, occur at times 388.7ms, 392.6ms, 384.8ms, and 365.2ms respectively, and all four are located in channel six. 6, 6, 6, 6 would be entered into Waveform Channels and 388.7, 392.6, 384.8, 365.2 would be entered into the Topo Times field. The order of the data points here does not matter, only that they are in the same order in both fields.
    • If there are less than four points that seem appropriate, either because they are at the wrong electrodes, at the wrong times, or simply have too low of an r-squared value, that is fine, three or two values can work, though the fewer values used the lower the accuracy will be.
    • Additionally, it may be helpful to re-run the analysis by setting the Spatial Filter to None, particularly when few channels are used.
  • Click Generate Plots to create the features plot again with a set of four graphs that show the correlation between the selected times after the desired stimulus is given (the red line) and the brain’s responses to when the desired stimulus is not given (the blue line).
    • As seen below, the attended-stimulus reaction will typically be stronger than for the unattended stimuli, but in some cases the reverse is true. If the ‘unattended’ curve is larger than the ‘attended’ curve then make a note of this before moving on. The waveform seen here is similar to the others generated, only one is shown here for simplicity.
    • Additionally before moving on, determine the location of the response seen. The P300 response is generally observed centered on the Cz electrode, or just behind and directly in between the ears, and does not involve the frontal regions of the brain. Assuming these characteristics are present, it is proper to proceed.

Creating a subject-specific parameter file

Now we will save these customizations to a subject-specific parameter file that will allow the subject to free-spell with good accuracy.

  • Start BCI2000 using batch/P3Speller_<Your_Amplifier>.bat file
  • Click Config, and load the baseline parameters for copy spelling that you used for recording the calibration session
  • Under the Storage tab, set the SubjectSession parameter to "002", and the SubjectName parameter to the subject's initials.
  • Under the Source tab, set the TransmitChList parameter to a list of channels from 1 to the number of channels recorded.
  • Under the Filtering tab, click the Edit Matrix button by Classifier near the bottom
  • Change this matrix to have 4 columns and as many rows as values you are using, and click Set New Matrix Size
    • In the first column, labeled Input Channel, enter the channel of the first value you use
    • In the second column, labeled Input Element (bin), enter the time of the best classification, immediately followed with ms, as in 388.7ms
    • In the third column, enter 1 as the output channel
    • In the fourth column, enter 1 if the Attended line was larger than the Unattended line, -1 if the unattended line was larger than the attended line
    • Repeat these steps for the remaining rows, and close the matrix when finished
  • If a Common Average Reference was used in the analysis, under the Filtering tab change the SpatialFilterType parameter to Common Average Reference (CAR); otherwise, leave it as None.
  • Click Save Parameters to save this file as <SubjectName>_CopySpelling.prm.
  • Use this new parameter file to repeat the configuration session and data analysis a few times, adding new rows to the classifier matrix each time for new data points to be utilized.
  • When accuracy is reliably above 90%, click Config, and click on the Application tab:
    • Delete the contents of the Text to Spell field
    • Set InterpretModeonline free mode
    • Make sure the DisplayResults box is checked
    • Click on Edit Matrix next to TargetDefinitions and scroll to the bottom:
      • In the first column replace 9 with BS (for "backspace")
      • In the second column replace 9 with <BS>
  • Click Save Parameters, and change the CopySpelling portion of this parameter file name to FreeSpelling
  • This parameter file is now ready to use for that specific subject for future P300 spelling experiments


The use of the "Offline Analysis" program was provided to familiarize you with the characteristics of the P300 response. At the same time, manually selecting the best features will typically result in reduced performance compared to when the features are automatically selected. Such automatic selection is performed using the P300Classifier tool that is provided with BCI2000. This stand-alone program determines optimal features (i.e., signal times and channels) and corresponding weights automatically, and outputs those in a classifier matrix. Use of this program streamlines the configuration process at the expense of decreased hands-on experience with BCI data and the BCI2000 program itself.

For instructions on using the P300Classifier, see User Reference:P300Classifier.

Next Step

To continue onto performing P300 spelling experiments, continue to Performing a P300 Spelling Session.

See also

User Tutorial:P300 BCI Tutorial