Skip to content

BassJonathan/Seizure-Detection

Repository files navigation

GitHub GitHub Repo stars GitHub forks

Seizure-Detection

ML project for the "Advanced Applied Machine Learning" course @DHBW Stuttgart

Table of Contents

  1. About the Project
  2. Relevance
  3. Dataset
  4. Run the Project
  5. License

About the Project

Epilepsy is a neurological disorder that manifests itself in repetitive and unpredictable seizures. It is one of the most common neurological disorders and affects people of all ages. Epileptic seizures occur because abnormal electrical connections occur in the brain, temporarily interrupting normal brain activity. A wide variety of symptoms can occur, depending on the area of the brain affected. Seizures, loss of consciousness, unnatural stimuli or altered behavior are common effects of a seizure. Due to the severity of these sympthoms, the life of the affected persons are heavily affected and extensive treatement is requiered.

EEG (Electroencephalography) is a non-invasive technique used to measure and record the electrical activity of the brain. It involves placing electrodes on the scalp to detect and amplify the tiny electrical signals generated by the neurons (nerve cells) in the brain.

Machine learning models can be trained to classify EEG data into seizure and non-seizure time windows. By analyzing the patterns and features of EEG signals, these models can accurately detect the occurrence of seizures in real-time. This can be valuable in developing automated seizure detection systems, which can provide timely alerts or trigger interventions, such as activating safety devices or alerting caregivers.

Relevance of the Data and Resulting Question

Epilepsy is a comparatively common neurological disorder that can severely impact the lives of those affected. Certain activities can no longer be performed and there is always the latent risk of a seizure. There is also a very high risk of injury from falls or consequential damage. The detection of epilleptic seizures based on EEG data using machine learning can help to diagnose the neurological disorder and also allow narrowing down to specific brain regions through a precise analysis of the functioning of the model. In addition, this technique is suitable for determining the type of epilleptic seizure and the resulting targeted treatment. Finally, real-time monitoring can take place, which warns the affected person early about the onset of a seizure and enables preventive measures to be taken. For these reasons, the question of how to classify EEG data with the aim of detecting epilleptic seizures is highly relevant for medicine and society and is therefore examined in more detail within this project.

The Dataset

This project uses the well established CHB-MIT Scalp EEG Database which has been used in research and practice. The dataset contains EEG-data from 23 cases which were collected from 22 subjects (5 males, ages 3–22; and 17 females, ages 1.5–19). Each case (chb01, chb02, etc.) contains between 9 and 42 continuous .edf files from a single subject. All signals were sampled at 256 samples per second with 16-bit resolution. A more datailed desription of the dataset is included in the 00_Preprocessing notebook.
Source: Physio.net

Run the Project

The project is divided into several Jupyter notebooks. Since the original data set consists of various files, some of which are in proprietary formats, extensive preprocessing must be performed. Based on this data, different machine learning methodologies can be applied, each of which is contained in a separate notebook. The general structure is as follows:

01_Data Preprocessing/00_Preprocesing.ipynb
This notebook contains all the preprocessing of the raw dataset. The individual files are loaded, converted, combined, labeled and a balanced data set is created. In addition, a selection of the required channels and/or patients is made to create the best possible dataset.

02_Seizure Presence Classification/00_Random_Forest.ipynb
This notebook uses a Random Forest Classifier to classify the EEG data. A hyperparameter optimization is performed to achieve the best possible result.

02_Seizure Presence Classification/01_Bi-LSTM.ipynb
This notebook uses a neural network for classification, which uses LSTM to process the temporal dependencies in the data and map them to the dense layers through an attention layer.

02_Seizure Presence Classification/02_Autoencoder Latent Space Classification.ipynb
This notebook uses a convolutional autoencoder, which is trained on the entire train split. The neural network is then clipped at the latent space and a second neural network is trained for classification based on the ouptut.

02_Seizure Presence Classification/02_Autoencoder Threshold Classification.ipynb
This notebook uses a convolutional autoencoder, which is trained only on EEG data without epilleptic seizures. When data with a seizure are processed by the neural network, a higher reconstruction error is generated, which enables a classification.

03_Seizure Type Classification/02_Autoencoder Latent Space Clustering.ipynb
This notebook uses a convolutional autoencoder trained only on EEG data with epilleptic seizures. The goal is to detect different seizure types based on the latent space by unsupervised clustering.

04_Model Comparison.ipynb
This notebook includes the comparison of the created models based on valid metrics and draws a conclusion as well as a critical reflection of the obtained results.

License

Distributed under the CC-BY-SA-4.0 License. See the LICENSE-file for more information.

About

Machine Learning project for the "Advanced Applied Machine Learning" course @DHBW Stuttgart.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors