GitHub - SaqlainXoas/ecg-cvd-project: ECG Cardiovascular Disease Classification · GitHub
Skip to content

SaqlainXoas/ecg-cvd-project

Repository files navigation

ECG Cardiovascular Disease Classification

Automated detection of cardiovascular diseases from 12-lead ECG images using Convolutional Neural Networks (CNNs).
This research investigates the role of lead-wise ECG segmentation in improving classification accuracy and explores the impact of individual leads in computer vision–based cardiovascular disease detection.


Overview

  • Lead-wise ECG Processing: Extracts individual leads from full 12-lead ECG images using calibrated coordinates.
  • CNN Classification: Deep learning model trained on individual lead images, with aggregated predictions for final classification.
  • Comprehensive Evaluation: Includes accuracy, precision, recall, F1-score, and confusion matrices for both lead-wise and aggregated predictions.

Dataset

  • Source: Mendeley Data Repository
  • Full ECG Images: 928 (12-lead ECG scans).
  • Processed Leads: 11,136 individual lead images (928 × 12).
  • Image Format: Original ECGs in JPG, processed as 128×128 grayscale lead images.
  • Classes (4 categories):
    • Normal: 284 ECGs → 3,408 leads
    • Abnormal Heartbeat: 233 ECGs → 2,796 leads
    • Myocardial Infarction (MI): 239 ECGs → 2,868 leads
    • History of MI: 172 ECGs → 2,064 leads

Train/Test Split:

  • Training: 9,600 images (80%)
  • Testing: 2,400 images (20%)

Preprocessing Pipeline

  1. Lead Extraction:

    • Extracts 12 leads (I, II, III, aVR, aVL, aVF, V1–V6) from 3×4 ECG grid layout.
    • Coordinate-based segmentation with logical pixel mapping.
  2. Enhancement & Cleaning:

    • Contrast (×1.2) and sharpness (×1.1) enhancement.
    • Gaussian blur + adaptive thresholding for noise removal.
    • Background removal via grayscale conversion and morphological operations.
  3. Normalization:

    • Pixel scaling to range [0,1].
    • Standard resizing to 128×128 pixels.

Model Architecture

  • Input: 128×128×1 (grayscale lead images).
  • CNN Layers:
    • Conv2D(32, ReLU) → MaxPooling → Dropout
    • Conv2D(64, ReLU) → MaxPooling → Dropout
    • Flatten → Dense(128, ReLU) → Dense(4, Softmax)
  • Optimizer: Adam
  • Loss Function: Sparse Categorical Crossentropy

Evaluation Metrics

  • Accuracy
  • Precision
  • Recall
  • F1-score
  • Confusion Matrices (per-class and aggregated)

Results

  • The model demonstrates strong classification accuracy across the four categories.
  • Lead-wise analysis highlights the impact of individual leads in detecting cardiovascular abnormalities.
  • Aggregated predictions improve robustness compared to single-lead classification.

Dependencies


License

© 2025 Saqlain Ahmed. For academic research and personal use only.
Redistribution or commercial use is prohibited without prior permission.

Contact

saqlainjuna@gmail.com

Acknowledgments

About

ECG Cardiovascular Disease Classification

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors