Skip to content

Marco9249/ECG-Arrhythmia-Classification-CNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Clinical AI

1D-CNN Arrhythmia Classification System

🫀 High-Fidelity Electrocardiogram (ECG) Classification via Deep Learning 🫀


License: MIT TensorFlow Imbalanced-Learn Dataset


Author

"Enhancing clinical diagnostics with explainable, robust, and highly accurate one-dimensional convolutional neural networks."

Important

Implementation Note: This repository contains the core architecture and settings as described in the associated research paper. However, some code structures and experimental configurations have been slightly adjusted to facilitate educational study, modification, and independent testing. The codebase will be fully synchronized with the exact methodology presented in the manuscript upon the paper's final formal publication.


🎯 Project Overview

This repository contains the complete implementation for a highly optimized 1D Convolutional Neural Network (1D-CNN) designed for multi-class ECG arrhythmia classification using the globally recognized MIT-BIH Arrhythmia Dataset.

The system leverages Synthetic Minority Over-sampling Technique (SMOTE) to overcome severe clinical class imbalance and incorporates Grad-CAM visual interpretability to provide clinical trust in the model's decisions.

✨ Key Contributions

Contribution Description
⚖️ SMOTE Balancing Solves extreme MIT-BIH class imbalance (Group N dominates 82% of data)
🧬 1D Convolutional Layers Tailored to extract morphological wave structures from 187-timestep ECG signals
🔍 Explainable AI (XAI) 1D Grad-CAM implementation maps exactly which part of the QRS complex triggered the diagnosis
📊 Research-Grade Visuals Generates 10 fully automated, 4K true-white background clinical charts (Loss, Precision, Heatmaps)

🫀 Arrhythmia Classes Modeled

The network successfully categorizes 187-timestep waveforms into the AAMI recognized super-classes:

  1. N (Normal) - Normal beats & structural variations
  2. S (Supraventricular) - Premature or ectopic beats
  3. V (Ventricular) - Ventricular premature contraction
  4. F (Fusion) - Fusion of ventricular and normal beats
  5. Q (Unknown) - Paced beats, unclassified

🏗️ Architecture Pipeline

┌─────────────────────────────────────────────────────────────┐
│                                                             │
│   🫀  ECG Signal Vector (Length: 187)                        │
│                                                             │
│  ┌───────────────────────▼───────────────────────┐          │
│  │  Block 1: Conv1D (64 filters)                 │ High-    │
│  │  Batch Norm → ReLU → Max Pooling (Pool=2)     │ Freq     │
│  └───────────────────────┬───────────────────────┘          │
│                          │                                  │
│  ┌───────────────────────▼───────────────────────┐          │
│  │  Block 2: Conv1D (128 filters)                │ Wave     │
│  │  Batch Norm → ReLU → Max Pooling (Pool=2)     │ Capture  │
│  └───────────────────────┬───────────────────────┘          │
│                          │                                  │
│  ┌───────────────────────▼───────────────────────┐          │
│  │  Block 3: Conv1D (256 filters)                │ Deep     │
│  │  Batch Norm → ReLU                            │ Morph.   │
│  └───────────────────────┬───────────────────────┘          │
│                          │                                  │
│  ┌───────────────────────▼───────────────────────┐          │
│  │  Global Average Pooling 1D                    │          │
│  │  Flattening structural sequence               │          │
│  └───────────────────────┬───────────────────────┘          │
│                          │                                  │
│  ┌───────────────────────▼───────────────────────┐          │
│  │  Fully Connected Integrator                   │          │
│  │  Dense (128) + Dropout (0.3)                  │          │
│  └───────────────────────┬───────────────────────┘          │
│                          │                                  │
│        📋 Softmax Classifier (5 Probabilities)              │
│        [ N, S, V, F, Q ]                                    │
└─────────────────────────────────────────────────────────────┘

📂 Repository Structure

📦 ECG-Arrhythmia-Classification-CNN/
│
├── 📁 training_code/
│   └── 🧠 ecg_cnn_classifier.py         # Full Model, SMOTE, and Metrics Pipeline
│
├── 📁 training_data/
│   ├── 📊 mitbih_train.csv              # MIT-BIH Training Matrix
│   └── 📊 mitbih_test.csv               # MIT-BIH Testing Matrix
│
├── 📄 ECG_Arrhythmia_Classification_Paper.docx # Academic Manuscript
├── 📋 requirements.txt
└── 📖 README.md

🚀 Quick Start

  1. Install Dependencies:

    pip install -r requirements.txt
  2. Execute Full Clinical Pipeline:

    python training_code/ecg_cnn_classifier.py
  3. Outputs Generated Automatically:

    • Saved Final_Clinical_Model.keras engine
    • Sub-directory ecg_outputs/ populated with 10 Research-Grade Visuals (Data distribution, Confusion matrices, F1-Score mappings, and Grad-CAM interpretability heatmaps)

📚 Related Research Portfolio

# Paper Repository
1 Physics-Guided CNN-BiLSTM Solar Forecast Repo
2 Physics-Informed State Space Model (PI-SSM) Repo
3 PI-SSM Cross-Attention Networks Repo
... ... ...
6 DeepAR Probabilistic Forecasting Repo
7 ECG Arrhythmia Classification (this repo) 🌟 Repo

📖 Citation

@misc{abdullah2026ecgcnn,
  title   = {Automated Cardiac Arrhythmia Classification using Deep 1D Convolutional Neural Networks},
  author  = {Mohammed Ezzeldin Babiker Abdullah},
  year    = {2026}
}

👤 Author

Mohammed Ezzeldin Babiker Abdullah Researcher in Predictive Modeling & Deep Learning

GitHub

About

Official code: Automated Cardiac Arrhythmia Classification using Deep 1D Convolutional Neural Networks and SMOTE balancing

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages