Taking brain-computer-interfacing one step further: a portable, wireless system coupled with online linear discriminant analysis for the detection of error-related potentials

. Recent years have witnessed extensive developments of computer science applications in medicine - assistive technologies. Among them, the concept of Brain-Computer-Interfaces, facilitating direct communication between brain and computer, has inspired numerous practical ideas on controlling an external device via neural signals. The perception of an error made by oneself, another human or a machine, triggers an error-related potential, which has already been exploited as a binary correction readout for decisions made by Brain-Computer-Interfaces. Our approach takes advantage of this technique, while taking it one step further regarding portability by using an affordable, robust and wireless headset, the Emotiv EPOC + , to recognize error-related potentials in electroencephalograms of subjects performing various on-site, dynamic tasks. We also introduce a straightforward linear-discriminant analysis classifier that extends the range of detection from offline, post-hoc analysis, to online, within-trial recordings, an essential condition towards blending machine-performed tasks with human-generated thought processes in everyday life.


Introduction
Development of Brain-Computer-Interfaces (BCIs) has been driven primarily by their clinical potential. For patients with neuromuscular disabilities, BCIs represent an alternative communication and motor pathway, in the sense of an artifical bypass or prothesis.
Throughout the last decades, milestones were reached when non-invasive, EEG-based BCIs allowed patients with severe disability to move a cursor on a computer screen [1] or even to regain partial mobility [2] using signals recorded from their primary sensor and motor cortices.
Later, considerations regarding the practicability of sensory and motor cortex-based non-invasive BCIs (high demand of cognitive attention and effort, lower spatial resolution and speed of analysis, errors in recognizing human intentions) led to the appraisal of errorrelated potentials (ErrPs) as drivers of robotic tasks.
ErrPs constitute a particular type of evoked or event-related potentials (ERPs), i.e. distinctly recordable neural responses to external stimuli, occuring specifically when, from the perspective of a subject, an action should either no longer continue or ought to return to an earlier stage. They can be detected directly via electroencephalography (EEG) from the anterior medial frontal cortex [3] (corresponding roughly to area underneath the Cz electrode).
At first, ErrPs were employed to correct a subject's own actions [4], but were then quickly extrapolated to adjust the observed movement performed by a robot during the course of a binary task [5]. As is the case with other ERPs, the latency and amplitude of ErrPs depend on the subject's perception of the importance of the error, the degree of involvement of the subject in the task (the amplitude of the signal is lower if the subject follows an external device passively than if it controls this device) and on the frequency of the stimuli [4,6,7,8].
Taking advantage of scientific 64-electrode EEG arrays, prompt and valid recognition of correct/erratic robotic behaviour has been demonstrated with an accuracy of approximately 70% even during live recordings [5].
The present study aims to extend the current research with respect to practicability in the quotidian setting, by means of an affordable, robust and wireless headset, the Emotiv EPOC + , employed in the analysis of ErrPs of subjects performing various onsite, dynamic tasks. Furthermore, by validating a method of detection of the correctness of an action that does not depend on the person's ability to move, the current study makes a step towards a method of online study of these ErrP signals using inexpensive and portable equipment.

Methods
Designing an algorithm for an ErrP-based BCI involves two stages: an initial one dedicated to calibration and training, during which the acquired EEG signal helps to set the optimal recording parameters, and another one for generating a classifier to discriminate the ErrP in the live recording setting.

Signal acquisition
The reception of the evoked signal was made using the Emotiv EPOC + headset with 14 (+2) channels corresponding to the 14 electrodes that are placed directly on the scalp: AF 3 , F 7 , F 3 , FC 5 , T 7 , P 7 , O 1 , O 2 , P 8 , T 8 , FC 6 , F 4 , F 8 , AF 4 (locations P 3 and P 4 represent CMS and DRL electrodes, mass and reference potential, respectively).
The Emotiv headset is a portable, high-resolution EEG system with a single analog-todigital converter with a maximum sampling frequency of 256Hz. After conversion, brain waves are preprocessed and the results are transmitted wirelessly to a USB receiver. This step involves, among other things, a passage through a Notch filter of 0.2 -43Hz.
The TestBench software attached to Emotiv EPOC + provides a working interface that displays real-time EEG data stream and monitors the quality of the contact areas between electrodes and scalp through an impedance correlation index. Unlike most EEG systems designed for research purposes, Emotiv EPOC + is not provided with hardware to integrate event markers into the EEG data stream.
However, the TestBench software offers an event marking option via a serial port, which enabled, in the case of the present study, its synchronization with the stimuli. Using a Com0Com Null virtual port Emulator Modem, time markers were inserted into the EEG simultaneously with signal acquisition (Fig.1). The Null-Modem Emulator is an opensource virtual kernel-mode serial port driver suitable for Windows and available under the GPL license.

Fig. 1. Conceptual illustration of the experiment
Although, physiologically, the response mechanism of the brain to the perception of an error is complex and involves more brain areas, basically it has been demonstrated that the response to an error can be detected [3] from the anterior medial frontal cortex (more precisely, the anterior cingulate cortex, ACC zone corresponding to the Cz electrode). One downside to the compactness of the EPOC + headset was the lack of a Cz electrode, so that our study focused on electrodes F 3 , F 4 , FC 5 and FC 6 , nearest to the region of interest.
Three subjects (two males, one female, aged 27-60 years with no current relevant ailments or symptoms) participated in the experiment. The recordings took place in a quiet room, where the subjects were seated approximately 1 meter in front of a laptop monitor (3200 x 1800 pixels, 13.3 inch screen diagonal).
For the visual stimulation task, subjects were presented with three quadratic visual cues (located North, East and West) as well as a movable, blue quadratic pointer in the centre of a black screen background (Fig. 1), programmed using Psychtoolbox. The task consisted of moving the blue pointer in the direction of the green cue (the other two being shown in red) with the arrow keys.
At a preprogrammed rate (25% of all trials) and in randomly chosen trials, the blue pointer would erroneously move towards one red cue instead of the green one which the subject would choose, thus providing a potential trigger for a feedback -related ErrP.
Visual stimuli were set up in 3 blocks of 100 trials for two of the subjects and in 7 blocks of 100 trials for the other subject. The number of subject-committed errors (i.e. pressing the wrong arrow key) were automatically displayed in the upper left corner of the screen (Table 1) and their corresponding trials were removed from the subsequent analysis.
Signal processing was performed in Matlab. To eliminate noise and reduce artifacts, a 2-20Hz IIR bandwidth Butterworth filter order 5 with a passband ripple of 0.01dB and 80dB of stopband attenuation was applied. The DC component was eliminated and the epochs were established from 100ms before stimulus onset (the moment of key press) until 800ms post-stimulus. Previous literature reported the ErrP to be mainly represented within the theta band (4-8Hz) [9]. However, in some subjects the ErrP may leak into higher frequency spectra [5] and we consequently included the alfa band (8-13Hz) as well.
The canonical ErrP, recordable at Cz, generated by the presentation of infrequent non-standard (erroneous) stimuli among a succession of frequent standard (correct) stimuli, is characterized by the N 2 /P 3 complex, Fig. 2A, i.e., a positive deviation of approximately 200ms, a highly negative deviation at 250ms and another, bigger, positive deviation at 320ms from the onset of the stimulus.
In our case, the presence of the specific ErrP components was verified after substracting the grand averages of the standard epochs (non-error epochs) from those of non-standard epochs (error epochs), Fig. 2B.   Fig.2. A. Canonical ErrP components N 2 /P 3 ; B. Grand average difference ERP -F 3 subject S 01 (error epochs minus nonerror epochs)

Classification
As a proof-of-principle, we used self-designed classifiers based on linear discriminant analysis (LDA) to discern between standard and non-standard (error) epochs. Just to make things clear, in contrast to a statistical test, the LDA does not directly answer the question whether the ErrP during standard and non-standard epochs are statistically significantly different from one another, but rather demonstrates pragmatically whether the epochs can or cannot be differentiated from one another after training a discriminating classifier algorithm.
The aim of our analysis in case of a positive outcome was to demonstrate the feasibility of the coupling between a portable device (Emotiv EPOC + ) and an algorithm in the online separation of potential control signals of a BCI.
In case of LDA, discrimination between distinct event classes entails three steps: calculating the separability between different classes by determining the distance between class averages (the variance between classes), calculating the variance within the class as the distance between the average and the class elements (or the within-class diffusion matrix) and then generating a lower dimensionality space [10].
The between-class variance matrix of each of the two classes (standard and nonstandard), , was calculated as: (1) where is the projection of the mean of the th class on a straight and is calculated according to the formula: (2) represents the projection of the total mean of all classes corresponds to: (3) and constitutes the transformation matrix of LDA [10]. The mean for each class in the feature space is given by: For the within-class variance matrix SWJ the following equation was used: (5) where stands for example i from class , and indicates the the centering data of the th class [10]. It follows that: The linear discriminant is defined as the linear function which maximizes Fisher's criterion: represents the eigenvalue of the transformation matrix .
The algorithm was applied to recorded data in two ways: with class dependency and without class dependency.

Results
For each of the electrodes around the region of interest (F 3 , F 4 , FC 5 and FC 6 ), we calculated the difference between grand averages of ErrPs from error and, respectively, non-error epochs (examples in Fig. 3).
A quantification of the negative deviations characteristic of the ErrPs is best performed after calculating the amplitude difference between grand averages of error and non-error trails. This has the advantage of eliminating unspecific brain activity during the two types of trials, thus enhancing specific ErrP components [11].
The mean and standard deviation of the grand average ErrPs were calculated per electrode and subject according to the three above-mentioned timeframe selection methods.
Due to the nature of the trials, the number of non-error vs error events/ epochs was unbalanced towards the former, with machine-generated error events representing approximately 25% of the total number of events/ epochs. Across sessions ErrPs exhibited consistent morphology, suggesting that changes in the levels of awareness and concentration do not exert a major influence on the signal shape.
Regarding EEG artefacts, the majority consisted of eye movement or blinking artefacts as well as electrode movement artefacts. Muscle contraction artefacts were prevented by instructing the subjects to produce only the minimum amount of movement necessary to performing the task, which evidently renders the method less applicable to everyday life. Elimination of artefact-laden epochs has been performed by visual selection, but in order to scale the method to a larger number of subjects, hybrid methods such as ICA (independent component analysis) coupled with visual selection could increase efficiency.
One disadvantage inherent to the recording device is the lack of periocular electrodes, essential in filtering out eye movement-related artefacts. This can be partially overcome by reverting the position of the headset on the head, such that the occipital electrodes act as supraorbital references.
The analysis was performed and yielded similar results on all four relevant electrodes, but out of considerations of clarity it is shown in the subsequent figures and tables only for electrode FC 6 . Tables 2, 3 and 4 provide the three sets of values thus obtained for electrode FC 6 .
The implemented methods for discrimination analysis, linear (LDA) and quadratic (QDA), originate from different assumptions regarding the covariance matrix of each class, but share the prerequisites of normally distributed data sets and the existence of a class-specific mean vector. In our case, when the number of features and thus the dimensionality of the class matrix is relatively small, QDA yields more accurate results (Tables 2-4). However, the larger the data sets, the more cumbersome the QDA inherent calculations become, so that the more inflexible LDA can be regarded as a more reasonable compromise.   Graphical outputs of both methods of discrimination are shown in Fig. 4A-D. The best discrimination was achieved by quadratic discrimination, using all values within 100 -500ms post-stimulus onset (Fig. 4D). The other methods and timeframes did not yield satisfactory discriminations (Fig. 4B-C).

Conclusions and discussion
The LDA substantiated a difference between the average potentials of standard and nonstandard (error) epochs, allowing for correct discrimination with lower accuracy, of 19%, in the case of linear discriminant classifiers, and, respectively, with a higher accuracy of 63% for quadratic discriminant classifiers, thus approaching values obtained with professional EEG recording systems (70% in [5]).