User Tutorial:Obtaining P300 Parameters in a Calibration Session
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 volunteer is asked to spell out a given word by using a P300 character matrix, pictured below. During each run, the volunteer is asked to focus on the next letter in the word they are 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 volunteer 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.
After the first few runs are collected, an analysis tool will be used to generate a configuration file with weights that will determine what portions of the input data correspond to selecting the desired letter. These weights are applied to the configuration session for one more run, and then the data from this run is also analyzed with the MatLab tool, and the number of flashes needed to ensure 100% accuracy is determined. The second configuration file generated and applied. This final set of parameters are saved as that volunteer’s parameter file for future spelling sessions.
Performing the Configuration 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 volunteer’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 volunteer sit in a relaxed position, and that the volunteer not move or speak during the runs.
- Turning off or dimming the lights can improve volunteer focus and performance.
- Showing the brain wave readouts to the volunteer can drive in the message of how artifact-generating behavior can be detrimental to the data.
- Press Start to show the flashing character matrix, and describe what the volunteer is expected to do.
- After you’ve explained the procedure, click Suspend to stop the process.
- Delete that run of data (The file should be named data\P300\<Volunteer's Initials>001R01.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
Analyzing The Calibration Session with Offline Analysis
We will now perform an ‘Offline Analysis’ with a tool provided with the BCI2000 system.
- Run tools/OfflineAnalysis/OfflineAnalysis.bat
- In the Analysis Domain field, choost Time (P300)
- In the Acquisition Type field, choose EEG
- Next to Spatial Filter, choose None
- For Trial Change Condition enter states.StimulusBegin == 1
- 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 correct stimulus is shown
- 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 an incorrect stimulus is shown
- 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, the darker the color indicating a higher predictability that it is produced by the desired letter being flashed.
- The darkest 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 channel numbers 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 detected by 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 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.
- Set the Spatial Filter to Common Average Reference (CAR)
- 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 stimuli is given (the red line) and the brain’s responses to when the desired stimuli is not given (the blue line).
- As seen below, the attended-stimuli reaction will typically be stronger than 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.
- Now we will save these customizations to a volunteer-specific parameters file that will allow the volunteer to free-spell with very high accuracy.
- Start BCI2000 using batch/P3Speller_<Your_Amplifier>.bat file
- Click Config, and load the P300_copy_speller_<Your_Amplifier>.prm made previously
- Under the Filtering tab, click the Edit Matrix button by Classifier near the bottom
- Change this matrix to have 4 columns and however many rows as values as 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
- Close this matrix, and click Save Parameters to save this file, naming it however you deem fit
- Use this new parameter file to repeat the configuration session a few times, adding new rows to the classifier matrix each time for the new data points to be utilized.
- When accuracy is reliably above 90%, click Config, and click on the Application tab:
- NumberOfSequences to this number as well
- Delete the contents of the Text to Spell field
- Set InterpretMode → online 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
- In the second column replace 9 with <BS>
- Click Save Parameters, and change the copy_spell portion of this parameter file name to free_spell
- This parameter file is now ready to use for that specific volunteer for future P300 spelling experiments
One program contributed to, and provided with, the BCI2000 system is the P300 GUI. This program utilizes MatLab R2007a to automatically sift through data files for datapoints indicative of a positive P300 reaction, and build a classifier matrix with those datapoints. The largest benefit to using this program is the obviated need for repeat configuration sessions, at the expense of decreased hands-on experience with the BCI2000 program itself. For a tutorial on how to perform the offline analysis with this GUI program, please click here.
To continue onto performing P300 spelling experiments, continue to Performing a P300 Spelling Session.