Towards Efficient ECG-based Atrial Fibrillation Detection via Parameterised Hypercomplex Neural Networks
This is a Python and PyTorch code for the PH-CNN framework in our EUSIPCO 2023 paper:
L. Basso, Z. Ren and W. Nejdl, "Efficient ECG-Based Atrial Fibrillation Detection via Parameterised Hypercomplex Neural Networks," 2023 31st European Signal Processing Conference (EUSIPCO), Helsinki, Finland, 2023, pp. 1375-1379, doi: 10.23919/EUSIPCO58844.2023.10289763.
Atrial fibrillation (AF) is the most common cardiac arrhythmia and associated with a high risk for serious conditions like stroke. The use of wearable devices embedded with automatic and timely AF assessment from electrocardiograms (ECGs) has shown to be promising in preventing life-threatening situations. Although deep neural networks have demonstrated superiority in model performance, their use on wearable devices is limited by the trade-off between model performance and complexity. In this work, we propose to use lightweight convolutional neural networks (CNNs) with parameterised hypercomplex (PH) layers for AF detection based on ECGs. The proposed approach trains small-scale CNNs, thus overcoming the limited computing resources on wearable devices. We show comparable performance to corresponding real-valued CNNs on two publicly available ECG datasets using significantly fewer model parameters. PH models are more flexible than other hypercomplex neural networks and can operate on any number of input ECG leads.
CPSC 2018:
python train_cpsc2018.py
CPSC 2021:
python train_cpsc2021.py
Attributes for train_config
and model_config
can be adapted in these files or in cfg.py
files.
Parameter | Attribute Name | Options |
---|---|---|
Real-valued or PHC model | model_name | CPSC 2021: "seq_lab", "seq_lab_phc" CPSC 2018"cnn", "cnn_phc" |
CNN module | cnn_name | "multi_scopic", "resnetNS", "densenet_vanilla" Baselines: "resnet_stanford", "resnet_nature_comm_bottle_neck_se" |
RNN module | rnn_name | "none" Baseline: "lstm" |
Attention module | attn_name | "se", "none" |
Dimensionality | n_leads | CPSC 2021: 2, 4 CPSC 2018: 2, 4, 6, 12 |
Proposed PH-CNN architecture:
It includes three modules: (1) a CNN, (2) a squeeze-and excitation (SE) attention, and (3) a multilayer perceptron (MLP) classifier. Compared to real-valued DNNs, parameterised hypercomplex (PH) convolution and multiplication replace real-valued convolutional and fully-connected (FC) layers, respectively. We construct separate models for two tasks: (a) AF detection, where every sampling point of the input ECG signal gets classified as AF/non-AF, and (b) global abnormality classification, where the output is a vector of class probabilities.
Implemented and tested PH-CNN backbones:
- Multi-Scopic CNN
- ResNet with separable convolutions
- DenseNet
Code adapted from benchmark test from torch_ecg repository at https://github.com/DeepPSP/torch_ecg/tree/master/benchmarks
H. Wen and J. Kang, “torch ecg: An ECG deep learning framework implemented using PyTorch,” 2022. [Online]. Available: https://github.com/DeepPSP/torch_ecg
H. Wen and J. Kang, “A novel deep learning package for electrocardiography research,” Physiological Measurement, pp. 1–29, 2022.
Parameterised Hypercomplex Layers adapted from https://github.com/eleGAN23/HyperNets
E. Grassucci, A. Zhang, and D. Comminiello, “PHNNs: Lightweight neural networks via parameterized hypercomplex convolutions,” IEEE Transactions on Neural Networks and Learning Systems, 2022.
A. Zhang, Y. Tay, S. Zhang, A. Chan, A. T. Luu, S. C. Hui, and J. Fu, “Beyond fully-connected layers with quaternions: Parameterization of hypercomplex multiplications with 1/n parameters,” in ICLR, 2021.