Running P300 Speller Experiment with Emotiv and BCI2000. Step-by-Step.

 

ملاحظة: تمت كتابة هذه التدوينة باللغة الإنجليزية لاختصاصها

In this post, we will discuss how to run your first P300 speller experiment using the Emotiv EEG headset and BCI2000. 

P300 spellers are independent Brain-Computer Interface (BCI) spellers that allow you to communicate through your brain signals.

To run a P300 speller experiment, we need the following:

- An EEG device, such as Emotiv Epoc flex or Epoc +.

- A BCI script or software, such as BCI2000.

Therefore, this post will guide you through running your first P300 speller experiment using the Emotiv device and BCI2000.

Step 1: Register in BCI2000

First, you need to create an account on the BCI2000 website by entering https://www.bci2000.org/useradmin/ .
The registration is needed to download the binary files.
Note: you can follow the registration instructions mentioned here.

Step 2: Download the BCI2000 source code

Choose the suitable with-contribution version from here, then click on its link and enter your username and password to download the .exe file. 
Follow the guidelines till you have your BCI2000 folder successfully downloaded on your drive.
Note: BCI2000 runs only on Windows OS. Moreover, the contribution version supports connecting with Emotiv devices.

Step 3: Connect your P300 speller with your EEG device

An Analog-to-Digital Converter (ADC) file should be run to connect any hardware device with the software. Due to that, BCI2000 provide an ADC file for each EEG device company. 
To link Emotiv devices to P300 speller, do the following:
- Make a copy of the P3Speller_SignalGenerator.bat file in the batch folder. 
- Rename it as P3Speller_Emotiv.bat, and open it in a text editor, e.g. notepad++. 
- Change the signal generator file to an Emotiv file which is an ADC file that contains all the information needed for connecting Emotiv devices with BCI2000 software. 
Figure 1. The steps for generating the P3Speller_Emotiv.bat file

Step 4: Configure the P300 speller

Congratulations, now your hardware and software are connected. 
Let's start customizing and configuring the P300 speller. To perform P300 speller experiments, we need to modify some of the parameters then save these configuration files, i.e. parameters files, to use them later in every experiment. 

Go to the batch folder and run the P3Speller_Emotiv.bat file. Click config in the P3Speller_Emotiv.bat window.

With the P300 speller configuration window, you will be able to change some of the default parameters related to visualization, system, source, storage, filtering, connector, and application settings. First of all, a parameter file that contains the source, i.e. hardware, settings’ is needed, so you do not have to set it every time. The source settings for Emotiv devices are specified in the following table.

Table 1. P300 speller configuration: Emotiv source settings

Variable Value
 SourceCh  14
 SampleBlockSize  4
 SamplingRate  128
 ChannelNames
 covered
 AF3 F7 F3 FC5 T7 P7 O1 O2
 P8 T8 FC6 F4 F8 AF4
 SourceChOffset  00000000000000
 SourceChGain  11111111111111
 HighPassFilter  at 0.1Hz

Figure 2. P300 speller configuration: Emotiv source settings

Figure 2 explains the source setting steps. After saving the parameter file as Emotiv.prm, you can use this file each time you run an experiment. Note that the source parameter file in our case is stored in the path: BCI2000/parms/fragments/amplifiers/Emotiv.prm; however, it can be stored anywhere. 

After configuring the source settings, you can start making the needed configurations for the storage, filtering, and application settings. The session details (subject name, session number, and run) in the storage settings needed to be edited each time you run an experiment according to the participant/subject. 

You can also alter the number of flashes a letter flashes in a single run, e.g., use ten flashes. Two parameters modifications should be done to change the number of flashes, the EpochsToAverage in the filtering tab and the NumberOfSequences in the application settings as in figure 3. 

Figure 3: P300 speller configuration: Change number of flashes

Finally, you can also change the application settings to design the P300 speller paradigm.

The following table and figure 4 illustrate the basic application settings for any language. Note that we explain the paradigm details of Arabic and English spellers in this tutorial. A detailed view of the paradigm design is explained in figures 5 and 6. 

Table 2. P300 speller configuration: Basic application settings

Variable Value
 NumberOfSequences  10
 InterpretMode  copy mode
 DisplayResults  unchecked
 NumMatrixColumns  6
 NumMatrixRows  6
 TextToSpell  The desired word or
 sentence

Figure 4. P300 speller configuration: Basic application settings
Figure 5. P300 speller configuration: To edit the matrix
Figure 6. P300 speller configuration: Paradigm design


After applying the above changes, save a parameter file that contains all the settings for each word in your experiment dataset (if any, otherwise use a specific word). Parameter files are helpful when the same settings are used more than once. 

In order to save the parameter file for the current configuration, click the Save Parameters button, then choose the file path and name to be stored within. Figure 7 shows an example of saving a parameter file.

Figure 7. Parameter files

Step 5: Wear your Emotiv device and ensure electrodes' connection

Epoc Flex from Emotiv company has up to 32 channels, and it contains all of the desired channels (Fz, Cz, Pz, P3, P4, P7, P8, and Oz).

First of all, to use Epoc Flex device for the first time, you need to charge it for about 3 hours, i.e. until its batteries become full. After that, start with hydrating the pads, placing them in the headset, then wearing it. The process will take about 2 to 5 minutes. 

During your first two attempts of using the device, the contact quality might be low, which is expected as the pads take time to get softer. However, you will get 100% contact quality in your second or third attempt.

In addition, here are some tips to achieve 100% contact quality:

  • Get the right size of the Epoc Flex cap after measuring the average head sizes of your participants.

  • The headset is fully charged.

  • Electrodes are hydrated.

  • Softly and gently press on the pads, i.e. electrodes, after placing the headset in every experiment.

  • Exclude any metal hair accessories.

  • Wait some time after doing the above tips.

Device Contact Quality:

Wearing and correctly connecting the Emotiv devices requires training and experience. Due to that, Emotiv helps with their software to provide the users with the device's contact quality and if the electrodes are placed correctly or not. Figure 8 shows a screenshot of the contact quality pages for Epoc Flex device.  Green lighted electrodes of the desired channels, i.e. channels with blue borders, are needed to use the Epoc Flex device. 

Note: Based on our experiments, the Epoc Flex can work effectively without reaching 100% contact quality. 

Figure 8. Epoc Flex contact quality page


Step 6: Run P300 speller (Calibration session)

Configure the speller by loading a pre-stored parameter file, as mentioned in Step 4, keeping in mind to change the storage information about the subject, i.e. participant name, with each participant. Then save the configuration by clicking on Set Config as illustrated in figure 9. 



Figure 9. P300 speller configuration

After setting the configuration, four windows will be generated:

• Log window: which displays and stores everything related to the experiment. An example of the log file is presented in figure 10.

Figure 10. P300 speller: Log window

• ERP for channel one window: which will display the Event Related Potentials (ERP), i.e. P300, detection when the experiment starts. An example of it is presented in figure 11.

Figure 11. P300 speller: ERP window

 Source signal window: which displays brain wave activity for each channel. An example of it is presented in figure 12. 

Figure 12. P300 speller: Source signal window

• Speller window: which displays the speller paradigm as shown in figure 13.

Figure 13. P300 speller: Paradigm. 

Then start the experiment by clicking on Start in the P3Speller_Emotiv window. Then a ”Waiting to start” text will appear as in figure 14.

Figure 14. Starting P300 speller


The flashes will appear, indicating the beginning of the spelling process, and the process will continue until the full word is spelt. After spelling the term, a ”TIME OUT !!!” string will appear, as shown in figure 15.

Figure 15. P300 speller: Ending the spelling process

After finishing the spelling experiment, a data file will be automatically saved in the data folder under the participant's name. That data file needs to be classified with the P300Classifier tool.

Step 7: Classify P300 speller outcomes using the P300Classifier

The experiments' data files need to be classified with the P300 classifier tool that BCI2000 provides. P300 classifier is placed in the tools folder in BCI2000. It is a stepwise regression that classifies the training file based on its flashes. A single file only can be added as a trained file. Then, specific parameter changes could be made before running the classifier. P300 classifier settings depend on some parameters related to the classifier, filter, spatial, and temporal settings. You only need to alter the settings of the filtering method and spatial settings, i.e. channel set. 

BCI2000 offers two filtering options: raw or Common Average Reference (CAR). CAR is a known spatial filtering method that proved its efficiency when working with standard electrode placement systems, such as in our case 10-10 system. Moreover, the channels specified in the spatial setting are specified in the P300 speller configurations in the source settings. Thus, the channel set should be the same as the number of channels specified earlier, which were 14 channels that the BCI2000 supports with Emotiv devices. 

Figure 16 illustrates the classification steps and parameters settings. After making these steps, a report will be generated in the details tab, where each flash’s accuracy will be presented, the spelt word in each flash, and the spelling duration as shown in figure 17. Note that high accuracy in fewer flashes represents a fast spelling process. 

Figure 16. P300 classifier: Classification steps

Figure 17. P300 classifier: Classification Report

Final words..

Congrats! You did your first P300 speller experiment. 
Keep in mind that this tutorial applies only the calibration mode, but you can further your knowledge and work to perform the real-time mode. Thanks for passing by, wish you all the best.

You may find helpful information in the following resources:
BCI2000: https://www.bci2000.org/mediawiki/index.php/Main_Page
Emotiv toolkit: https://www.emotiv.com/emotivpro/

Comments