Skip to content

Latest commit

Β 

History

History
93 lines (75 loc) Β· 3.92 KB

File metadata and controls

93 lines (75 loc) Β· 3.92 KB

πŸ«€ Arrhythmia Classification on CPSC 2018 Dataset

This project focuses on multi-class arrhythmia classification using the CPSC 2018 12-lead ECG dataset. It supports training and evaluation on both 12-lead signals and single-lead signals, with configurable model architectures and MLflow-based experiment tracking.

πŸ“Œ Table of Contents

  1. Project Structure
  2. CPSC Dataset
  3. Installation
  4. Modules Breakdown
  5. Installation
  6. How to use

🧠 Project Structure

β”œβ”€β”€ config.py                                   # Configuration file for paths and settings
β”œβ”€β”€ cpsc_data_prep_csv.py                       # Script to prepare CSVs from raw data
β”œβ”€β”€ data_processing
β”‚   β”œβ”€β”€ cpsc_signal_loader.py                   # Signal loading and preprocessing
β”‚   β”œβ”€β”€ data_generator.py                       # Data generator for model input
β”‚   β”œβ”€β”€ data_loading.py                         # Load and preprocess dataset
β”‚   β”œβ”€β”€ data_reduction.py                       # Dataset size reduction scripts
β”‚   β”œβ”€β”€ data_splitter.py                        # Train/Val/test splitting utilities
β”œβ”€β”€ models
β”‚   β”œβ”€β”€ checkpoints                             # Model checkpoints (saved weights)        
β”‚   β”œβ”€β”€ final                                   # Final trained models
β”‚   β”œβ”€β”€ misclassified_samples                   # Incorrect predictions for analysis
β”‚   β”œβ”€β”€ model
β”‚   β”‚   β”œβ”€β”€ cnn1d_resent_18.py                  # resnet model  
β”‚   β”‚   └── cnn_attentaion_bilstm_improve.py    # cnn_attentaion_bilstm_model
β”‚   β”œβ”€β”€ model_paths                             # Model path utilities
β”‚   β”œβ”€β”€ model_plots                             # Training and evaluation plots
β”‚   β”œβ”€β”€ model_results                           # Evaluation results (metrics)
β”‚   └── Spectrograms                            # Spectrogram representations of signals
β”œβ”€β”€ README.md                                   # Project documentation
β”œβ”€β”€ requirements.txt                            # Python package dependencies
β”œβ”€β”€ test_cpsc.py                                # Testing script
β”œβ”€β”€ train_custom_log_cpsc.py                    # Training script with MLflow logging
β”œβ”€β”€ utils
β”‚   β”œβ”€β”€ model_selector.py                       # Model selection utilities
β”‚   β”œβ”€β”€ utils.py                                # Utility functions and global configs and input sizes paths
β”‚   └── visualization.py                        # Visulization utility
└── visualize_signal.py                         # ECG signal visulization script




πŸ›’οΈ CPSC Dataset

CPSC dataset is opensource dataset avaliable here

βš™οΈ Installation

  1. Colne the repository:
   clone repo
  1. Install dependencies:
pip install -r requirements.txt

3.Download the datasets:

  • place the datasets as per your convinent give the correspoding path in the config file and utils file

πŸš€ How to use

  1. To train a model
python3 train_custom_log_cpsc.py
  • config.py: Contains model selection, MLflow enable/disable settings, number of epochs, and all other required configuration parameters.

  • utils.py: Contains file paths, input sizes, and other utility constants needed across the project.

    • Models will be saved in models/checkpoints/.
    • Training history will be saved in mlflow server
  1. To test a model
python3 test_cpsc.py
  • training logs ,tesing logs, model performace metrics and model are saving in mflow server
  1. To Visualization
python visualize_signal.py --file_path data/test_data.pkl --plot_signal --sampling_rate 250
  • provide reqiured args for visulization of the signal