ECG Classification Using Re-Uploading Variational Quantum Circuits
From Clinical ECG Data to Embedded Quantum-Classical Inference
This project presents an end-to-end Quantum Machine Learning (QML) framework for Electrocardiogram (ECG) classification, combining classical biomedical signal processing, variational quantum circuits, and embedded artificial intelligence.
The system uses ECG recordings from the PTB-XL dataset as its primary input. The Pan-Tompkins algorithm is applied to detect QRS complexes and extract heartbeat-related information. The resulting feature vectors are then used to train a Re-Uploading Variational Quantum Circuit (VQC).
After training, the optimized quantum circuit parameters are transferred into an embedded-compatible implementation and deployed on the Arduino UNO Q for on-device inference.
The main objective is to investigate the feasibility of executing trained quantum machine learning models on resource-constrained embedded platforms without requiring a physical quantum processor during inference.
The complete framework consists of three major stages:
- Biomedical signal processing and feature extraction.
- Quantum machine learning model development and training.
- Embedded model implementation and inference on Arduino UNO Q.
flowchart TD
A["PTB-XL ECG Dataset"]
B["Lead I and Lead II Selection"]
C["Pan-Tompkins Algorithm"]
D["QRS Detection and Heartbeat Analysis"]
E["ECG Feature Extraction"]
F["Feature Selection and Normalization"]
G["Quantum Data Encoding"]
H["Re-Uploading Variational Quantum Circuit"]
I["Hybrid Quantum-Classical Training"]
J["Optimized Model Parameters"]
K["Embedded Model Implementation"]
L["Arduino UNO Q"]
M["On-Device Inference"]
N["ECG Classification"]
A --> B --> C --> D --> E --> F
F --> G --> H --> I --> J
J --> K --> L --> M --> N
The project uses the PTB-XL dataset, a publicly available clinical ECG dataset containing 12-lead electrocardiogram recordings and associated diagnostic annotations.
The dataset provides a foundation for developing and evaluating automated ECG classification models.
Input configuration:
| Parameter | Description |
|---|---|
| Dataset | PTB-XL v1.0.3 |
| Input signals | Lead I and Lead II |
| Sampling frequency | 100 Hz |
| Signal type | 12-lead ECG recordings |
| Labels | Derived from diagnostic annotations |
| Data partitioning | Patient-wise training, validation, and testing folds |
The Pan-Tompkins algorithm is employed for QRS complex detection and heartbeat localization.
The signal processing pipeline consists of:
- Bandpass Filtering: Reduces baseline drift and unwanted frequency components.
- Differentiation: Emphasizes rapid changes in the ECG waveform.
- Squaring: Enhances prominent signal variations associated with QRS complexes.
- Moving Window Integration: Extracts the temporal characteristics of QRS complexes.
- Adaptive Peak Detection: Identifies candidate R-peaks and heartbeat locations.
This process provides the temporal information required for subsequent heartbeat analysis and feature extraction.
Following QRS detection, informative ECG characteristics are extracted to construct compact feature vectors for the quantum classifier.
The feature engineering pipeline incorporates:
- R-peak amplitude and heartbeat morphology.
- RR interval and temporal characteristics.
- QRS-related waveform measurements.
- ECG amplitude and interval measurements.
- Statistical and PCA-based heartbeat representations.
The extracted features are subsequently selected, normalized, and transformed into the input representation required by the quantum model.
The core classification architecture is based on a Re-Uploading Variational Quantum Circuit (VQC).
Data re-uploading enables classical ECG features to be repeatedly encoded into a parameterized quantum circuit. Multiple encoding and variational layers allow the circuit to construct expressive nonlinear representations of the input data.
The architecture combines trainable single-qubit rotations, entanglement operations, and quantum measurements.
| Component | Operations | Function |
|---|---|---|
| Data Encoding | RX, RY, RZ | Encodes classical ECG features |
| Variational Layers | Trainable RX, RY, RZ | Learns optimized circuit parameters |
| Entanglement | CZ | Establishes correlations between qubits |
| Measurement | Pauli-Z expectation values | Produces model outputs |
flowchart TD
A["Classical ECG Feature Vector"]
B["Quantum Data Encoding"]
C["Parameterized Rotation Gates"]
D["CZ Entanglement"]
E["Data Re-Uploading"]
F["Repeated Variational Layers"]
G["Pauli-Z Measurement"]
H["Classification Output"]
A --> B --> C --> D --> E
E --> F --> G --> H
The VQC is trained using a hybrid quantum-classical optimization strategy.
The training procedure consists of:
- Loading the preprocessed ECG feature vectors.
- Encoding classical features into quantum states.
- Executing the parameterized quantum circuit.
- Measuring quantum expectation values.
- Calculating the classification loss.
- Updating trainable circuit parameters using a classical optimizer.
- Evaluating model performance on validation and test datasets.
The optimized variational parameters are then exported for embedded implementation.
A major focus of this project is translating a trained quantum machine learning model into an embedded-compatible implementation.
The Re-Uploading VQC is initially trained in a quantum simulation environment. After training, the optimized parameters and corresponding circuit operations are converted into numerical operations suitable for execution on the Arduino UNO Q.
Instead of executing quantum gates on physical quantum hardware, the embedded implementation reproduces their mathematical behavior using classical numerical computation.
Consequently, the trained model can perform inference directly on the embedded platform without requiring an external quantum computing backend.
flowchart TD
A["Trained Re-Uploading VQC"]
B["Export Optimized Parameters"]
C["Translate Quantum Circuit Operations"]
D["Embedded C/C++ Implementation"]
E["Arduino UNO Q"]
F["Input Feature Vector"]
G["Numerical Circuit Evaluation"]
H["Expectation Value Calculation"]
I["ECG Classification"]
A --> B --> C --> D --> E
E --> F --> G --> H --> I
- Reproduce the trained VQC inference behavior.
- Implement quantum circuit calculations using embedded numerical operations.
- Execute model inference without a physical quantum processor.
- Evaluate inference latency and computational resource consumption.
- Investigate the feasibility of quantum machine learning on edge devices.
| Category | Technologies |
|---|---|
| Dataset | PTB-XL, PhysioNet |
| Signal Processing | Pan-Tompkins Algorithm |
| Programming Languages | Python, C/C++ |
| Feature Engineering | NumPy, SciPy, Scikit-learn |
| Quantum Computing | PennyLane |
| Quantum Architecture | Re-Uploading VQC |
| Embedded Development | Arduino Framework |
| Hardware Platform | Arduino UNO Q |
The framework evaluates both classification performance and embedded execution efficiency.
| Metric | Purpose |
|---|---|
| Accuracy | Measures overall classification correctness |
| Precision | Measures the reliability of positive predictions |
| Recall | Measures the ability to identify positive samples |
| F1-score | Balances precision and recall |
| ROC-AUC | Evaluates classification discrimination capability |
| Metric | Purpose |
|---|---|
| Inference Latency | Measures the time required for one prediction |
| Memory Consumption | Evaluates embedded memory requirements |
| Computational Cost | Estimates the numerical computation requirements |
| Prediction Consistency | Compares embedded outputs with the reference model |
This project explores a practical direction for bringing Quantum Machine Learning closer to embedded artificial intelligence.
By combining clinical ECG data, established biomedical signal processing techniques, variational quantum circuits, and embedded computing, the framework investigates how a trained quantum model can be translated into an executable implementation on a real-world edge device.
The project focuses on the intersection of three research areas:
- Biomedical AI: Automated analysis and classification of ECG signals.
- Quantum Machine Learning: Variational quantum circuits and data re-uploading architectures.
- Embedded AI: Efficient model execution on resource-constrained hardware.
The long-term goal is to investigate the potential of quantum machine learning architectures for real-time biomedical applications at the edge.
Quantum Machine Learning | Biomedical Signal Processing | Embedded AI
An experimental research project on quantum-classical ECG classification.
Project title: 'Quantum machine learning models for biomedical time-series: applications to ECG signal processing'
Funding agency: Ministry of Education (Taiwan), TEEP internship program, project No. EORPD2R0281
IRB No.: 202501594B0
Principal investigator: Renata Wong, Department of Artificial Intelligence, Chang Gung University
Co-investigator: Tianqi Chen, Agency for Science, Technology and Research (A*STAR), Singapore
Research assistant: Tran Minh Trung (MOE TEEP intern), AISeQ Laboratory, University of Information Technology, Vietnam National University, Ho Chi Minh City