This repository contains the implementation and results of my Master's thesis:
"Sleep Apnea Classification using Deep Learning Algorithm"
submitted to the Faculty of Electrical Engineering, K. N. Toosi University of Technology, Winter 2023.
Sleep apnea is a prevalent disorder with serious health implications. This work proposes a deep learning approach to classify:
- Obstructive Sleep Apnea (OSA)
- Central Sleep Apnea (CSA)
- Mixed Sleep Apnea (MSA)
- Normal Breathing
The model is trained solely on ECG signals using HRV and EDR features with an LSTM-based neural network.
📄 Full thesis available in thesis/MinaMoazami_Thesis.pdf
The following public datasets are used:
- MIT-BIH Polysomnographic Database
- Nationwide Children’s Hospital Sleep DataBank (NCHSDB)
- Cleveland Family Study (CFS)
Due to licensing, raw data is not included. Please refer to the links above.
This study uses publicly available polysomnography datasets to extract single-lead ECG signals. The methodology includes:
- Signal Processing: Extracting HRV (Heart Rate Variability) and EDR (ECG-Derived Respiration) features from filtered ECG signals using NeuroKit2.
- Segmentation: Dividing signals into 60-second non-overlapping epochs with corresponding apnea labels.
- Feature Engineering: Time-domain, frequency-domain, and non-linear HRV features were combined with EDR patterns.
- Modeling: A stacked LSTM (Long Short-Term Memory) model was designed to learn temporal dynamics and classify each epoch into:
- Normal Breathing
- Obstructive Sleep Apnea (OSA)
- Central Sleep Apnea (CSA)
- Mixed Sleep Apnea (MSA)
The proposed model achieved high performance on multi-class classification tasks using ECG data alone:
| Metric | Value |
|---|---|
| Precision | 0.721 |
| Recall | 0.709 |
| F1 Score | 0.699 |
| AUC (avg.) | 0.894 |
Class-wise performance showed that the model performs best for distinguishing Normal and OSA events, with slightly lower precision on MSA due to class imbalance.
notebooks/: Jupyter Notebooks for data preprocessing, feature extraction, and model trainingthesis/: Final PDF of the thesismodels/: Optionally include saved models or logs here
Install required libraries via:
pip install -r requirements.txt