Technical Articles and Newsletters

Using Machine Learning to Predict Epileptic Seizures from EEG Data

By Gareth Jones, University College of London


Approximately 20-40% of epileptic seizures do not respond to anticonvulsant medication. As a result, individuals with epilepsy have no way of knowing if a seizure will occur when they are driving, swimming, or engaged in some other activity that would make a seizure particularly dangerous.

A recentKaggle解决这个问题通过挑战pa的竞争rticipants to develop algorithms that could predict epileptic seizures from human intracranial electroencephalograph (EEG) recordings (Figure 1).

图1. Kaggle提供的颅内脑电图数据。

图1. Kaggle提供的颅内脑电图数据。

Sponsored by MathWorks, the National Institutes of Health (NINDS), the American Epilepsy Society, and the University of Melbourne, the competition attracted 478 teams and 646 competitors from around the world.

The algorithms I developed in MATLAB®在个人参与者中得分最高,在比赛中排名第三。

Accessing and Preprocessing the EEG Data

The EEG data came from a long-term study conducted by the University of Melbourne.

In this study, intracranial EEG recordings were collected from 15 epileptic patients via 16 surgically implanted electrodes sampled at 400 Hz for several months. In the original study, researchers were unable to reliably predict seizures for about 50% of the test subjects.

Kaggle competition participants received almost 100 gigabytes of EEG data from three of the test subjects. Each ten-minute-long segment contained eitherperictaldata, recorded before a seizure, orinterictaldata, recorded during a long period in which no seizures occurred. Our job was to develop algorithms that could classify previously unseen segments as either preictal or interictal.

Kaggle competitors were given free access to MATLAB, but use of MATLAB was not required. I decided early on that I would use MATLAB. The competition data was provided in MAT files, making it easy to access in MATLAB. In addition, I use MATLAB for data collection and analysis in all my research work.

I began by concatenating any sequential 10-minute-long segments (Figure 2). I then partitioned all the data into epochs, or windows, with lengths varying from 50 seconds to 400 seconds. It was important to try a variety of epoch lengths because it was not obvious from the data at what time scale predictive features might be present in the data, or how quickly they might change over time.

图2. MAT文件中的EEG数据分为顺序时期。

Figure 2. EEG data in MAT files separated into sequential epochs.

Extracting Features and Identifying the Best Machine Learning Models

Unlike many data analysis competitions, the seizure prediction competition provided an opportunity to work with raw data rather than ready-made tables. Apart from re-referencing, the data provided had not undergone any additional preprocessing. The unstructured nature of the data allowed me to make the most of this data by performing my own preprocessing and feature extraction.

我在MATLAB中工作,从可以用来训练机器学习模型的数据中提取功能。具体而言,我开发了每个时期的算法,这些算法计算了频带功率,每个通道上的摘要统计数据(包括平均值,标准偏差,均方根,偏斜和峰度)以及时间域和频域中的通道对之间的相关性。我通过使用并行计算工具箱™同时处理不同核心的训练和测试数据,几乎将处理时间缩短了一半。

Because I was developing algorithms for the competition in my spare time, and not as a principal research activity, I wanted to develop a solution as quickly as possible. I have experience with supervised machine learning in other environments, but chose to use the Classification Learner app in Statistics and Machine Learning Toolbox™ to quickly search for the best classification model type for the features I had extracted. In a matter of minutes, the app had automatically trained and assessed models based on decision trees, discriminant analysis, support vector machines, logistic regression, nearest neighbors, and ensemble methods using boosted trees. It would have taken me days if not weeks of development time to construct and test all these machine learning models in Python or R.

Improving Prediction Accuracy

Next, I set about improving the performance of the two most promising machine learning models identified by the Classification Learner app: quadratic support vector machines and random undersampling (RUS) boosted trees. I tested various features and epoch lengths, ultimately identifying the 80-second, 160-second, and 240-second epoch lengths as the most important to the classification (Figure 3). Because I was working with multiple training and test sets, I had to manage and name numerous tables representing various combinations of features and epoch lengths. I used the new String class in MATLAB to programmatically generate labels for the tables. The String class eliminated a block of complex code that I had previously used for generating labels.

Figure 3. Plots showing relative importance of features and epoch lengths.

Figure 3. Plots showing relative importance of features and epoch lengths.

在测试了本地数据的机器学习算法后,我将其提交给Kaggle竞争网站,该网站将它们与一组未公开的测试数据相对。通过计算接收器操作特性曲线(AUC)下的面积来评估算法,这是评估二进制分类器和竞争对手的官方评分指标的常见措施。该评分的结果已在经常更新的公共排行榜上发布,因此参赛者可以看到他们的算法在比赛中相对于其他人的表现如何。

To further improve the accuracy of my algorithms, I tried several other techniques, including hyperparameter optimization. One of the most effective techniques I used was to implement an ensemble classifier by combining the SVM and RUS boosted tree models. Averaging the predictions of the two models resulted in a dramatic improvement in accuracy, enabling the ensemble classifier to score higher than either of its component models individually. The results were as follows:

SVM alone: ~0.65 AUC
RUS alone: ~0.72 AUC
SVM and RUS ensemble: ~0.80 AUC C

迈向更好癫痫管理的早期一步

Most of the contestants trained three separate machine learning models, one for each epilepsy patient. I created a single general model that worked for all three patients because I felt that in clinical practice, this solution would be more efficient than one that required EEG data to be collected from each patient. Clinically, a key aim (and difficulty) is to create models that can generalize across patients and make predictions for unseen individuals rather than training separate classifiers for each patient. It remains to be seen how effective the models produced in the competition are at predicting for new patients. As a first step toward incorporating the competition algorithms into clinical studies, University of Melbourne researchers are conducting further evaluation of the submitted algorithms using data that was not made available as part of the competition.

Aside from the competition’s potential benefits to epilepsy research, I benefitted personally from the opportunity to participate. For me, the competition was a deeply engaging way to learn new skills while potentially advancing research in an area that will benefit millions of epilepsy sufferers worldwide.

About the Author

Dr. Gareth Jonesis a research associate with the faculty of brain sciences at University College London. His research focuses on using psychophysics, electrophysiology, and computational modeling to explore the cortical mechanisms underlying the ability of mammals to integrate sensory information.

Published 2017 - 93132v00

为相关行业观点文章