Our objective is to capture and preprocess EEG signals, build learning models that can detect epileptic seizures with an accuracy greater than 80%, and build a software architecture around it to showcase our results.
Emotiv Insight is a consumer graded product, designed for Brain Computer Interface (BCI) . The device can measure EEG signals from 5 different channels – AF3, AF4, T7, T8 and Pz. Besides having an adequate number of channels, this headset gives us a better signal quality compared to other alternatives.
Photo 1: EMOTIV Insight headset
Models & results
The K-means clustering algorithm is implemented using tslearn.TimeSeriesKMeans with metrics Dynamic Time Warping specifically used for time series comparison.
The model returned prediction results of 94% accuracy with the following centroids and confusion matrix. As proposed from the confusion matrix, 377 out of 400 time series were classified correctly with 0 type I error and 23 out of 400 time series were misclassified as type II error.
Photo 1. Centroids of the model.
Photo 2.Confusion matrix from testing the model.
Pyramidal 1-Dimensional Convolutional neural network (P1D-CNN)
P1D-CNN is implemented through tensorFlow by adding layers to model.Sequential and later was tested with fragments of EEG signal to determine whether patient has epilepsy or not. One side not from the architecture below is that the second fully connected layer has the activated sigmoid function.
Results from training and testing with data are gathered after splitting testing signal to a fixed window sized(with overlap) and plugging in optimized parameters.
Photo 5: 10-fold cross validation with the given parameters average accuracy and loss
Overall software architecture
Photo 6: Software architecture
The backend is built in Python and connects to a Heroku PostgreSQL database using FastAPI with SQLAlchemy. We chose Python because we were familiar with it, and PostgreSQL because it’s a decent solution to store time-series and relational data that provides stability and speed out of the box.
The database contains a table for storing Patient details, multiple dynamic time-series tables for storing individual session data for each patient, and one table for storing the results generated by our AI models for each session.
Photo 8: Front page view – List of all patients
Photo 9: Individual patient view
Photo 10: Result page for K-Mean model
Khoa Nguyen: K-Means Clustering Model
Studying Data Science – Linkedin
Machine learning is fun!
Huy Nguyen: P1D CNN Model
Studying Data Science – email@example.com
Working with a team makes you believe that you can achieve far greater things – and you do.
Sophie Truong: Software
Studying Digital Systems and Design – Linkedin
A blank screen is my worst nightmare. But it’s also where I get to turn nothing into something.
Aayush Kucheria: Project Manager | Software
Studying Data Science and Quantum Technologies – Linkedin
This was my first step in neuroscience, won’t be my last.
The project, as part of the summer course ELEC-D0301 Protopaja, was in cooperation with Futurice Oy and Orion Pharma.
Other material: Creative Commons (CC BY 4.0)