Degree

Bachelor of Science (Computer Science)

Department

Department of Computer Science

School

School of Mathematics and Computer Science (SMCS)

Advisor

Dr. Imran Khan, Assistant Professor, Department of Computer Science, IBA Karachi

Keywords

Electrocardiography, Arrhythmia Classification, Deep Learning, Explainable Artificial Intelligence, Clinical Decision Support, Retrieval Augmented Generation

Abstract

Cardiac Digital Shadow is an AI powered ECG analysis platform that makes clinical grade arrhythmia detection accessible through a web interface. Traditional ECG interpretation depends on trained cardiologists and specialist software, which creates a bottleneck in research and educational settings where fast, automated analysis is needed. The platform lets users upload a twelve lead ECG recording and receive an instant AI driven analysis across 71 diagnostic and rhythm conditions. A deep learning model trained on the PTB-XL dataset identifies conditions with severity classifications and highlights the exact regions of the waveform that influenced each prediction. The system also computes clinical measurements such as heart rate, PR interval, QRS duration and QTc, adjusts interpretations based on patient demographics, and generates structured clinical notes. Users can simulate cardiac pathologies and treatments, ask an AI assistant questions about the analysis in plain language, and export a formatted clinical report. The main contribution of this project is bringing deep learning inference, signal level explainability, demographic aware clinical reasoning and an accessible web interface together in a single platform that supports medical education, ECG research and pre clinical decision support.

Tools and Technologies Used

Python, FastAPI, Uvicorn, PyTorch, Keras, scikit learn, NumPy, SciPy, pandas, NeuroKit2, WFDB, HeartPy, PyWavelets, joblib, ReportLab, Groq API, LangGraph, ChromaDB, sentence transformers, Pydantic, React 19, TypeScript, Vite, Tailwind CSS, uPlot, Docker, Docker Compose

Methodology

The project followed a modular, pipeline driven approach in which each component was built and validated independently before integration.

  1. ECG data pipeline: supports WFDB and CSV formats with automatic format detection, lead standardisation, amplitude normalisation and resampling.
  2. Classification model: an xresnet1d101 model was trained on PTB-XL for 71 class multi label cardiac classification. It was benchmarked against SVM, Logistic Regression and a Transformer encoder baseline to measure performance gains.
  3. Clinical measurements: a NeuroKit2 based delineation layer extracts PR interval, QRS duration, QTc and HRV metrics, and a signal quality gate rejects corrupt recordings before inference.
  4. Explainability: Grad-CAM produces temporal saliency maps over the raw ECG so that predictions are interpretable and clinically grounded.
  5. Demographic reasoning: a threshold engine personalises interpretations based on patient age, sex and BMI.
  6. AI assistant: built as a Retrieval Augmented Generation pipeline using ChromaDB and sentence transformers, with a knowledge base covering all 71 conditions to give grounded answers to clinical questions.
  7. Frontend and deployment: the interface was developed in React 19 with TypeScript, using uPlot for waveform rendering, and the full system was containerised with Docker and Docker Compose.

Document Type

Restricted Access

Submission Type

BSCS Final Year Project

Share

COinS