User Tutorial:Obtaining P300 Parameters in a Calibration Session: Difference between revisions
(39 intermediate revisions by 5 users not shown) | |||
Line 7: | Line 7: | ||
==Design of Calibration Session== | ==Design of Calibration Session== | ||
During the calibration session, the | 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. In our example, each letter will flash 30 times in total (15 rows and 15 columns). 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. | ||
[[Image:P3SpellerMatrix.PNG| | [[Image:P3SpellerMatrix.PNG|450px]] | ||
After the first few runs are collected, | 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 | ==Performing the Calibration Session== | ||
*Start BCI2000 by running <tt>batch/P3Speller_<Your_Amplifier>.bat</tt> | *Start BCI2000 by running <tt>batch/P3Speller_<Your_Amplifier>.bat</tt> | ||
*Press '''Config''', and load the baseline parameters for copy spelling that you made earlier. | *Press '''Config''', and load the baseline parameters for copy spelling that you made earlier. | ||
*In the '''Storage''' tab: | *In the '''Storage''' tab: | ||
**Set ''SubjectName'' to the | **Set ''SubjectName'' to the subject's initials. | ||
**Set ''SubjectSession'' to <tt>001</tt> | **Set ''SubjectSession'' to <tt>001</tt> | ||
**Set ''SubjectRun'' to <tt>01</tt> | **Set ''SubjectRun'' to <tt>01</tt> | ||
*In the '''Application''' tab: | *In the '''Application''' tab: | ||
**Make sure that ''InterpretMode'' is set to <tt>copy mode</tt>, and ''DisplayResults'' (directly below InterpretMode) is unchecked | **Make sure that ''InterpretMode'' is set to <tt>copy mode</tt>, and ''DisplayResults'' (directly below InterpretMode) is unchecked | ||
**Find the ''TextToSpell'' field. This should be set to | **Find the ''TextToSpell'' field. This should be set to ‘THEQUICKBROWNFOX’, and you will be changing it after each run. | ||
*Press '''Set Config''' to apply this configuration. | *Press '''Set Config''' to apply this configuration. | ||
*Request that the | *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 | *Turning off or dimming the lights can improve the subject's focus and performance. | ||
*Showing the brain wave readouts to the | *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 | |||
*After you’ve explained the procedure, click '''Suspend''' to stop | |||
*Delete that run of data ( | [[Image:RecordingEnd.PNG|right|500px]] | ||
*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 <tt>data\P300\<Subject Initials>001\<Subject Initials>S001R01.dat</tt>). | |||
{| | |||
|height="200px"| | |||
|} | |||
*Press '''Start''' to record the run. | *Press '''Start''' to record the run. | ||
*Once | *Once this recording has finished, close BCI2000 and locate the saved data files below the BCI2000 <tt>data</tt> directory. | ||
==Analyzing The Calibration Session with Offline Analysis== | ==Analyzing The Calibration Session with Offline Analysis== | ||
We will now | We will now use the BCI2000 "Offline Analysis" tool to analyze the subject's initial session. | ||
[[ | *Start the [[User Reference:BCI2000 Offline Analysis|BCI2000 Offline Analysis]] tool: | ||
* | **If you have a version of Matlab installed, run <tt>tools/OfflineAnalysis/OfflineAnalysis.bat</tt>. | ||
*In the ''Analysis Domain'' field, | **Otherwise, follow the instructions provided [[User_Reference:BCI2000_Offline_Analysis#Systems_that_do_not_have_MATLAB_installed_or_with_versions_that_predate_MATLAB_v7.0|elsewhere]]. | ||
[[Image:OfflineGUI.PNG|right|500px]] | |||
*In the ''Analysis Domain'' field, choose '''Time (P300)''' | |||
*In the ''Acquisition Type'' field, choose '''EEG''' | *In the ''Acquisition Type'' field, choose '''EEG''' | ||
*Next to ''Spatial Filter'', choose '''Common Average Reference (CAR)''' | *Next to ''Spatial Filter'', choose '''Common Average Reference (CAR)''' | ||
*For '''Trial Change Condition''' enter <tt> | *For '''Trial Change Condition''' enter <tt>auto</tt> | ||
*For '''Target Condition 1''' enter <tt>(states.StimulusCode > 0) & (states.StimulusType == 1)</tt> | *For '''Target Condition 1''' enter <tt>(states.StimulusCode > 0) & (states.StimulusType == 1)</tt> | ||
*For '''Target Condition Label 1''' enter <tt>Attended Stimuli</tt> | *For '''Target Condition Label 1''' enter <tt>Attended Stimuli</tt> | ||
**‘Attended Stimuli’ refers to the letter or character the person is counting the flashes of, and triggers when the | **‘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 <tt>(states.StimulusCode > 0) & (states.StimulusType == 0)</tt> | *For '''Target Condition 2''' enter <tt>(states.StimulusCode > 0) & (states.StimulusType == 0)</tt> | ||
*For '''Target Condition Label 2''' enter <tt>Unattended Stimuli</tt> | *For '''Target Condition Label 2''' enter <tt>Unattended Stimuli</tt> | ||
**‘Unattended stimulus’ refers to the letters or characters the person is not counting the flashes of, and triggers when | **‘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'' | *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''' | *In this new dialog, select all of the data files taken during this configuration session, and click '''Open''' | ||
Line 67: | Line 72: | ||
[[Image:FeaturesPlot.PNG|right|500px]] | [[Image:FeaturesPlot.PNG|right|500px]] | ||
*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, | *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 | *The largest of these r-squared values between 250 and 550ms are what we are interested in. Pick 2-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 | *With these 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, | **In the example above, three data points have r-squared values <tt>0.032</tt>, <tt>0.055</tt>, and <tt>0.021</tt>, occur at times <tt>250ms</tt> around channel Po7, Po8, and Oz. <tt>6, 7, 8</tt> would be entered into ''Waveform Channels'' and <tt>250</tt> would be entered into the ''Topo Times'' field. | ||
*Click '''Generate Plots''' to create the features plot again with a set of three 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). Topographies is also given at <tt>250ms</tt>. | |||
*Click '''Generate Plots''' to create the features plot again with a set of | **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. | ||
**As seen below, the attended- | **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 (example below), and does not involve the frontal regions of the brain. Assuming these characteristics are present, it is proper to proceed. | ||
**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. | |||
[[Image:Waveform.PNG|center|800px]] | [[Image:Waveform.PNG|center|800px]] | ||
==P300Classifier== | |||
The use of the "Offline Analysis" program was provided to familiarize you with the characteristics of the P300 response. The feature graph above inspects the quality of the Calibration Session. Once the results above seams reasonable, we can obtain a subject specific parameter file using the ''P300Classifier'' under the <tt>tools/P300Classifier</tt> folder. 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 [[User Tutorial:Performing a P300 Spelling Session|Performing a P300 Spelling Session]]. | |||
==See also== | |||
[[User Tutorial:P300 BCI Tutorial]] | |||
[[Category:Tutorial]] | |||
Latest revision as of 20:09, 23 July 2019
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. In our example, each letter will flash 30 times in total (15 rows and 15 columns). 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 ‘THEQUICKBROWNFOX’, 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 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 2-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 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, three data points have r-squared values 0.032, 0.055, and 0.021, occur at times 250ms around channel Po7, Po8, and Oz. 6, 7, 8 would be entered into Waveform Channels and 250 would be entered into the Topo Times field.
- Click Generate Plots to create the features plot again with a set of three 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). Topographies is also given at 250ms.
- 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 (example below), and does not involve the frontal regions of the brain. Assuming these characteristics are present, it is proper to proceed.
P300Classifier
The use of the "Offline Analysis" program was provided to familiarize you with the characteristics of the P300 response. The feature graph above inspects the quality of the Calibration Session. Once the results above seams reasonable, we can obtain a subject specific parameter file using the P300Classifier under the tools/P300Classifier folder. 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.