https://github.com/minamoazami/sleepapnea-classification-ecg
Sleep Apnea Classification using Deep Learning on ECG Signals
https://github.com/minamoazami/sleepapnea-classification-ecg
apnea classification deep-learning ecg ecg-classification ecg-signal keras lstm python sleep-apnea tensorflow
Last synced: about 1 month ago
JSON representation
Sleep Apnea Classification using Deep Learning on ECG Signals
- Host: GitHub
- URL: https://github.com/minamoazami/sleepapnea-classification-ecg
- Owner: MinaMoazami
- License: mit
- Created: 2025-06-12T11:08:21.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-06-12T11:45:42.000Z (12 months ago)
- Last Synced: 2025-06-26T03:04:46.875Z (11 months ago)
- Topics: apnea, classification, deep-learning, ecg, ecg-classification, ecg-signal, keras, lstm, python, sleep-apnea, tensorflow
- Language: Jupyter Notebook
- Homepage:
- Size: 20.8 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sleep Apnea Classification using Deep Learning on ECG Signals
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.
## π Thesis Overview
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`](thesis/MinaMoazami_Thesis.pdf)
---
## π§ͺ Datasets
The following public datasets are used:
- [MIT-BIH Polysomnographic Database](https://physionet.org/content/slpdb/1.0.0/)
- [Nationwide Childrenβs Hospital Sleep DataBank (NCHSDB)](https://physionet.org/content/nch-sleep/3.1.0/)
- [Cleveland Family Study (CFS)](https://sleepdata.org/datasets/cfs)
> Due to licensing, raw data is not included. Please refer to the links above.
---
## π¬ Method
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)
---
## π Results
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.
---
## π Repository Contents
- `notebooks/`: Jupyter Notebooks for data preprocessing, feature extraction, and model training
- `thesis/`: Final PDF of the thesis
- `models/`: Optionally include saved models or logs here
---
## π¦ Requirements
Install required libraries via:
```bash
pip install -r requirements.txt