This project aims to create a brain computer interface based on electroencephalographic data (EEG data) with the help of machine learning algorithms. Using a subject’s EEG reading, we will have to infer what he or she is thinking about or doing - (motion) A or B in a t0 to tn timeframe.
- Process(parsing and filtering) EEG data
- Implement a dimensionality reduction algorithm
- Train and predict EEG data
Subjects performed different motor/imagery tasks while 64-channel EEG were recorded using the BCI2000 system. Each subject performed 14 experimental runs: two one-minute baseline runs (one with eyes open, one with eyes closed), and three two-minute runs of each of the four following tasks:
1. A target appears on either the left or the right side of the screen. The subject opens and closes the corresponding fist until the target disappears. Then the subject relaxes.
2. A target appears on either the left or the right side of the screen. The subject imagines opening and closing the corresponding fist until the target disappears. Then the subject relaxes.
3. A target appears on either the top or the bottom of the screen. The subject opens and closes either both fists (if the target is on top) or both feet (if the target is on the bottom) until the target disappears. Then the subject relaxes.
4. A target appears on either the top or the bottom of the screen. The subject imagines opening and closing either both fists (if the target is on top) or both feet (if the target is on the bottom) until the target disappears. Then the subject relaxes.
You can know details and get the EEG dataset from here.
Common Spatial Pattern is a technique to analyze multi-channel data based on recordings from two classes (conditions). CSP yields a data-driven supervised decomposition of the signal parameterized by a matrix
CSP, like PCA, allows for dimensionality reduction and is especially often used to analyze EEG data. The need for spatial filtering in EEG data analysis can be found here.
Here is the calculation method based on this paper.
The problem of recovering sources from their linear mixtures without knowledge of the mixing channel has been widely studied. In its simplest form it can be expressed as the problem of identifying the factorization of the
We consider each column of
We begin by noting that the matrix
An obvious example is the time averaged covariance matrix,
The same process is performed for the other class of data, and using
Note that these two conditions alone are already sufficient for source separation. To recover the sources from the observation
Let us further assume nonzero diagonal values for
where by assumption,
Eq(8) is obtained by the following calculation procedure.
This constitutes a generalized eigenvalue equation, where the eigenvalues represent the ratio of the individual source statistics measured by the diagonals of
Implementaion of CSP algorithm with python is here.
You can train and predict EEG data(Task 4) by running below command. --subject_num
is the number of subjects used training and prediction. --show
is the flag whether program shows the result.
python3 srcs/train_and_predict.py --subjects_num 1 --show
I used CSP algorithm for dimensional reduction. The lower image shows 4 spatial filters with large eigenvalues.