Two week individual project on Predictive modeling of seizures using intra-cranial EEG records.
Processed 50Gb+ of long-term electrical brain activity recordings.
Extensive time series analysis, and feature selection heuristics to extract properties of brain waves’ signals, and generate personalized models for seizure prediction.
1. Anomaly Detection for
Seizure Prediction
(anomaly detection in waveforms)
Cynthia Alexander
22nd September, 2016
Anomaly Detection for Seizure Prediction Cynthia Alexander
2. iEEG = intracranial + electricity + brain + picture
(intracranial electro encephalogram)
Electrode assemblies
(implant)
Telemetry unit
(implant)
Personal advisory
device (hand-held)
Anomaly Detection for Seizure Prediction Cynthia Alexander
Implanted system
Seizure prediction – brief Hows and Whys
Motivation:
Easily enhance day-to-day life of individuals suffering from
epilepsy (~1% of adults over 18 years old*) by warning them
about events that might happen so they can take precautions.
Or, even better, aid seizure prevention when combined with new
treatments (i.e. deep-brain stimulation).
3. 10m 10m 10m 10m 10m 10m 5m Seizure
1 hour (Pre-seizure)
Telemetry unit output – data over time for 16 channels
Anomaly Detection for Seizure Prediction Cynthia Alexander
Standby
For the model, each patient’s recordings over the 16 channels
are split in 10 minutes windows
The goal is to accurately call pre-seizure windows as they
happen, to then warn an individual facing a seizure
4. Anomaly Detection for Seizure Prediction Cynthia Alexander
Pipeline
Random Forests
for Statistical Metrics and
Signal Transformations
2 layers Neural Network
for spectrograms classification
using Tensor Flow tools
Sample selection
Formatting and structure
EDA, Data cleaning
Input: Raw data from iEEGs
Output: Structured clean data
Input: Descriptive metrics, Signal
transformations, Channel Correlations,
Spectrograms
Engineering
Feature Selection
Summaries
Testing models
Parameter tuning
Validation
5. Features – Statistical metrics
Anomaly Detection for Seizure Prediction Cynthia Alexander
mean channel 11
Normalized distribution
std channel 00
Normalized distribution
absum channel 02
Normalized distribution
Standby
Pre-seizure
6. Features – Statistical metrics
Anomaly Detection for Seizure Prediction Cynthia Alexander
mean channel 11
Normalized distribution
std channel 00
Normalized distribution
absum channel 02
Normalized distribution
Standby
Pre-seizure
Remarkable differences across patients – i.e. Values for the median across channels
Each column one sample (10 min x 16 channels).
Medianperchannel
andwindow
Patient A Patient B Patient C
Pre-seizure
7. Image from mriquestions.com
Anomaly Detection for Seizure Prediction Cynthia Alexander
Features – Correlation and Signal
TransformationsAverage correlation of channels
over all samples
Standby samples
vs. all samples
Pre-seizure samples
vs. all samples
Wave decomposition
Fourier Transform
Each readout can be decomposed into the frequencies that make it up:
Gamma
(32+ Hz)
Beta
(16 – 31 Hz)
Alpha
(8 – 15 Hz)
Theta
(4 -7 Hz)
Delta
(< 4 Hz)
8. Image from mriquestions.com
Anomaly Detection for Seizure Prediction Cynthia Alexander
Features – Correlation and Signal
TransformationsAverage correlation of channels
over all samples
Standby samples
vs. all samples
Pre-seizure samples
vs. all samples
Wave decomposition
Fourier Transform
Each readout can be decomposed into the frequencies that make it up:
Gamma
(32+ Hz)
Beta
(16 – 31 Hz)
Alpha
(8 – 15 Hz)
Theta
(4 -7 Hz)
Delta
(< 4 Hz)
9. Anomaly Detection for Seizure Prediction Cynthia Alexander
Features – Spectrograms
Standby Pre-Seizure
Time window
Frequency
10. Results
Personalized model (train and predict on self over time):
Trained on other patient’s data predict on (no self-prior knowledge):
Anomaly Detection for Seizure Prediction Cynthia Alexander
11. Anomaly Detection for Seizure Prediction Cynthia Alexander
Interactive D3 App – Red shaded areas depict windows in which the model called a pre-seizure sample
12. In development and in order to help
users:
• Concentrate on personalized models
• Feed and predict on-App using real time data
• In the long run, aim for preemptive medicine
where care is specially provided in high-risk
windows (i.e. deep brain stimulation)
Anomaly Detection for Seizure Prediction Cynthia Alexander
13. Questions? Reach out!
Cynthia Alexander
cynth.alexander@gmail.com
4chromat
cynthiaalexanderrascon
4chromat.github.io
Thank you!
Anomaly Detection for Seizure Prediction Cynthia Alexander
14. Anomaly Detection for Seizure Prediction Cynthia Alexander
Data cleaning – Signal drop-outs and artifacts!
Editor's Notes
Hello, I am Cynthia and want to talk to you about a model for anomaly detection for seizure prediction
9s
Something really quick on how this works: brain waves are obtained by placing electordes directly on your brain.
The motivation to pursue this project is simple, about 1% of adults in the US suffer from epilepsy, and because of it they have seizures on which they might have no control on.
Current warning systems rely on self-awareness, so patients could definitely benefit from a prediction model
45’
In my dataset there are recordings over months for a couple of patients, each of this with 16 electrode groups.
For the model recordings were split in two categories, standby and pre-seizure (encompassing 1 hour preceding a seizure), and further broke down to 10 minute windows.
The goal here is call pre-seizure windows as they happen to warn people to take some precautions.
1:00
Here I show overview on how this model was built:
I started from raw brain recordings, and there was a fair amount of data cleaning, and exploratory data analysis.
Which eased feature selection and engineering.
Then the output of this features was tested on different models, and once the models where selected, there was a bit or parameter tuning.
All these allowed me to put together an app showing real data and model predictions.
1:40
About the features, the unit of prediction is a 10 min continuous signal varying in frequency and amplitude.
So to come up with features we need to aggregate the signal across electrodes or break it in smaller windows.
First I used plain statistical metrics, and it was amusing to see how basic metrics already showed different distribution among classes.
2:10
And a really important take away is that when comparing patients side to side, their recordings are largely different.
So it became a clear objective to work on a personalized model, or in the normalization across patients
Another step was to consider the correlation among electrode readouts since it is likely there is not one that points to a seizure but the combination of them
In this images each square represents the correlation among two electrodes coded by color, here the contrast of standby and pre-seizure samples to the bulk showed that pre-seizure samples have distinc correlations among electrodes.
A necessary feature to add where signal transformations, specially the fourier transform which I performed over window slices on the samples.
This would decompose the readout for each electrode into the frequencies that make it up, which are further classified into delta waves (those present in sleep), alpha (during relaxing times), beta (on a range of acivities) and so on. Higher frequencies would be more comon in pre-seizure samples.
Another feature are spectograms, which describe the frequency and and amplitud over time windows, helping to differentiate the two classes
The model produced decent results for a personalized model, where it was trained and tested on the same person over time. Here Random Forest got top performance, with a precision/recall curve that shows that with a bit over 60% precision it gets over 80% recall, which is great since we care more about true positives than false positives here
However for the generalized model, when the model is trained and tested in different persons and even with normalized data, the predictive power drops. So this reflects the contrast about brain waves and possibly also faults in my model.
To better visualize this, I made an app, where the red shaded areas depict windows called as high risk by the personalized model.
In this case this first call was a false positive. However down the line there is a true signal, for which a patient could have got about 20 minute warning before a seizure.
Applications of this can be made for any other data that could be encoded in wave form and personalized records, but more importantly to directly benefit users I need to concentrate on personalized models, and evaliate real time data.
Logos d3 tensor fllw
because in comparison to MEG/EEG studies, iEEG tends to be significantly less affected by artifacts,
Although EEG is designed to record cerebral activity it also records electrical activitiesarising from sites other than the brain, usually just considered artifacts that may or may not arise from the patients bodyf
Mechanical, external, artifacts, could be identified by a fixed form and a repetitive pattern. As well as signals that propagatte across electrodes that are not in proximity.
Artifacts caused by muscles, would be of high amplitud and fast activity, and has a distribution that reflects the locations of muscles generating it. Typica muslces artifacts begin and end abruptly. Chewing, for example would make appear as a high amplitud wave across many electode readouts.
The large space of artifacts that could exist in a readout add a layer of complexity in the identification of true positive signals, that as in other wave frequency problems is alsways benefitial to identify the source.
Remove 50Hz noise