CardioNet-XL πŸ«€

Model TensorFlow Dataset

CardioNet-XL is a specialized 1D Convolutional Neural Network (CNN) designed for multi-label classification of cardiac abnormalities from ECG signal data. Trained on the PTB-XL dataset, the model is optimized to detect five specific classes, providing a high-precision screening tool for clinical decision support.


πŸ“‹ Table of Contents


✨ Features

  • Multi-label Classification: Simultaneously detects 5 cardiac abnormalities
  • Optimized Thresholds: Class-specific decision boundaries for clinical use
  • High Specificity: Excellent performance on ST/T Change (AUC: 0.918) and Normal rhythm (AUC: 0.915)
  • Lightweight Architecture: 4.1M parameters, suitable for edge deployment
  • Clinical Ready: Designed with medical decision support in mind
  • Trained on Large-Scale Data: Leverages the comprehensive PTB-XL dataset

πŸ“Š Dataset

PTB-XL: Large Publicly Available Electrocardiography Dataset

CardioNet-XL is trained on the PTB-XL database, one of the largest publicly available ECG datasets for machine learning applications.

Dataset Characteristics

  • Size: 21,837 clinical 12-lead ECG records
  • Duration: 10 seconds per record
  • Sampling Rates: 100 Hz and 500 Hz available
  • Patients: 18,885 unique patients
  • Annotations: Expert-validated diagnostic labels
  • Source: Physikalisch-Technische Bundesanstalt (PTB), Germany
  • Time Period: October 1989 to June 1996

Clinical Labels

The dataset includes comprehensive annotations for:

  • Diagnostic Classes: Normal ECG, Myocardial Infarction, ST/T Changes, Conduction Disturbances, Hypertrophy, and more
  • Form Annotations: Detailed morphological descriptions
  • Rhythm Annotations: Heart rhythm classifications
  • Demographics: Age, sex, and clinical metadata

Access the Dataset

# Download from PhysioNet
wget -r -N -c -np https://physionet.org/files/ptb-xl/1.0.3/

Citation for PTB-XL Dataset:

@article{wagner2020ptbxl,
  title={PTB-XL, a large publicly available electrocardiography dataset},
  author={Wagner, Patrick and Strodthoff, Nils and Bousseljot, Ralf-Dieter and Kreiseler, Dieter and Lunze, Fatima I and Samek, Wojciech and Schaeffter, Tobias},
  journal={Scientific Data},
  volume={7},
  number={1},
  pages={154},
  year={2020},
  publisher={Nature Publishing Group}
}

Dataset Link: PTB-XL on PhysioNet


πŸ—οΈ Model Architecture

CardioNet-XL utilizes a deep 1D-CNN architecture with 4.1M trainable parameters. The model processes raw ECG signals through three convolutional blocks followed by a dense classification head.

Architecture Overview

Layer Type Output Shape Parameters
Conv1D Block 1 (32 filters) (None, 1000, 32) 2,720
BatchNormalization (None, 1000, 32) 128
MaxPooling1D (None, 500, 32) 0
Conv1D Block 2 (64 filters) (None, 500, 64) 10,304
BatchNormalization (None, 500, 64) 256
MaxPooling1D (None, 250, 64) 0
Conv1D Block 3 (128 filters) (None, 250, 128) 24,704
BatchNormalization (None, 250, 128) 512
MaxPooling1D (None, 125, 128) 0
Flatten (None, 16000) 0
Dense (256 units) (None, 256) 4,096,256
Dropout (0.5) (None, 256) 0
Output Dense (5 units) (None, 5) 1,285

Total Trainable Parameters: 4,135,717 (15.78 MB)


πŸ“ˆ Performance Metrics

Classification Report

The model demonstrates strong discriminative performance across major cardiac conditions:

Class Precision Recall F1-Score Support
NORM (Normal) 0.86 0.70 0.77 963
MI (Myocardial Infarction) 0.86 0.26 0.39 550
STTC (ST/T Change) 0.87 0.38 0.53 506
CD (Conduction Disturbance) 0.93 0.35 0.51 496
HYP (Hypertrophy) 1.00 0.01 0.02 262
Micro Average 0.87 0.43 0.57 2777
Macro Average 0.90 0.34 0.44 2777

Optimal Decision Thresholds

Class-specific thresholds optimized for clinical sensitivity-specificity balance:

  • NORM: 0.17
  • MI: 0.34
  • STTC: 0.43
  • CD: 0.41
  • HYP: 0.33

ROC-AUC Scores

  • STTC: 0.918
  • NORM: 0.915
  • MI: Strong performance
  • CD: Strong performance

πŸ”§ Installation

Prerequisites

pip install tensorflow>=2.0.0 numpy pandas scikit-learn matplotlib wfdb

Clone Repository

git clone https://github.com/yourusername/CardioNet-XL.git
cd CardioNet-XL

πŸš€ Quick Start

Load Model and Predict

import tensorflow as tf
import numpy as np

# Load the pre-trained model
model = tf.keras.models.load_model('cardionet_xl.h5')

# Define optimal thresholds for each class
thresholds = np.array([0.17, 0.34, 0.43, 0.41, 0.33])
class_labels = ['NORM', 'MI', 'STTC', 'CD', 'HYP']

# Load your ECG data (shape: [batch_size, 1000, channels])
ecg_data = np.load('your_ecg_data.npy')

# Get model predictions
predictions = model.predict(ecg_data)

# Apply optimal thresholds
binary_predictions = (predictions > thresholds).astype(int)

# Display results
for i, sample in enumerate(binary_predictions):
    detected_conditions = [class_labels[j] for j, pred in enumerate(sample) if pred == 1]
    print(f"Sample {i}: {', '.join(detected_conditions) if detected_conditions else 'No abnormalities detected'}")

Input Data Format

  • Shape: (batch_size, 1000, channels)
  • Type: Normalized ECG signal (recommend z-score normalization)
  • Sampling Rate: 500 Hz (downsampled from PTB-XL)
  • Duration: 2 seconds per sample

Loading PTB-XL Data

import wfdb
import pandas as pd

# Load PTB-XL metadata
metadata = pd.read_csv('ptb-xl/ptbxl_database.csv')

# Load a single record
record = wfdb.rdsamp('ptb-xl/records500/00000/00001_hr')
ecg_signal = record[0]  # ECG data

πŸ“š Training Details

Training Configuration

  • Dataset: PTB-XL (500 Hz sampling rate)
  • Train/Test Split: Standard PTB-XL split (stratified by patient)
  • Optimizer: Adam
  • Loss Function: Binary Crossentropy
  • Epochs: Early stopping at Epoch 4 (optimal generalization)
  • Batch Size: 32
  • Validation Split: 20%
  • Data Augmentation: Optional noise injection and time shifting

Training Observations

  • Consistent decrease in training loss
  • Validation loss begins to rise after Epoch 4, indicating optimal stopping point
  • Model achieves peak performance early in training
  • Class imbalance addressed through weighted loss function

πŸ₯ Clinical Applications

CardioNet-XL is designed for:

  • Automated ECG Screening: First-line triage in clinical settings
  • Remote Monitoring: Wearable device integration
  • Emergency Departments: Rapid preliminary assessment
  • Telemedicine: Remote cardiac evaluation support
  • Research: Large-scale ECG analysis
  • Education: Teaching tool for ECG interpretation

⚠️ Important: This model is intended for research and clinical decision support only. It should not replace professional medical diagnosis.


πŸ“– Citation

If you use CardioNet-XL in your research, please cite:

@software{cardionet_xl_2024,
  title={CardioNet-XL: Multi-label ECG Classification using 1D CNNs},
  author={Your Name},
  year={2024},
  url={https://huggingface.co/sid512206/CardioNet-XL}
}

@article{wagner2020ptbxl,
  title={PTB-XL, a large publicly available electrocardiography dataset},
  author={Wagner, Patrick and Strodthoff, Nils and Bousseljot, Ralf-Dieter and Kreiseler, Dieter and Lunze, Fatima I and Samek, Wojciech and Schaeffter, Tobias},
  journal={Scientific Data},
  volume={7},
  number={1},
  pages={154},
  year={2020},
  publisher={Nature Publishing Group}
}

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

Note: The PTB-XL dataset is licensed under the Creative Commons Attribution 4.0 International License.


🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Areas for Contribution

  • Model architecture improvements
  • Additional cardiac condition classifications
  • Explainability and visualization tools
  • Deployment scripts for clinical environments
  • Documentation improvements

πŸ“§ Contact

For questions or collaborations, please reach out via:


πŸ™ Acknowledgments

  • Dataset: PTB-XL ECG Database - Wagner et al., 2020
  • PhysioNet: For hosting and maintaining open medical datasets
  • Framework: TensorFlow/Keras
  • Inspiration: Clinical need for automated ECG interpretation
  • Community: All contributors and researchers advancing cardiac AI

πŸ“š Related Resources


Dataset: PTB-XL on PhysioNet

Downloads last month
6
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support