This repository contains the implementation of recurrent neural network (RNN) based deep learning architectures for detecting anomalies in ECG waveform and classifying normal and diseased condition.
The PhysioNet Challenge 2017 dataset which consists of 8528 short single lead signals of 30-60 seconds length, sampled at 300 Hz was used to train our models. The signals in the dataset is categorised into normal sinus rhythm (N), atrial fibrillation (A), other rhythms (O) and noisy signals (~).
The signals in a cell array, and their corresponding type in a categorical array, were saved in a .mat file.
It was observed that majority of the signals were 9000 samples long. So, all signals were processed to make them 9000 samples long to maintain uniformity and avoid excessive padding or truncating.
A naive bayes classifier was constructed to separate clean signals from noisy ones, to save the deep learning models from incorrect interpretations. This method was used rather than using a filters because a wide range of noises may be present in the signals and designing filters for elimination of every possible type is not quite practical.
The following steps were applied before training the models:
- Data Augmentation: To tackle class imbalance
- Feature Extraction: Extraction of spectral and morphological features to obtain a greater classification performance
- Standardization using Z-scoring: To avoid unequal weighting of features
- 80:20 train-test data split: For training and validation of the networks
Three RNN based architecures were used, which are:
- Long-Short Term Memory (LSTM)
- Bidirectional LSTM (BiLSTM)
- Gated Recurrent Units (GRU)
The model architectures are shown below.
The networks giving the maximum accuracies were saved and their prediction were merged into one. This method of creating an ensemble of neural networks helped to get a good overall accuracy in classification.
A GUI was created for visualization and analysis of the signals.
The GUI
- identifies the R peaks
- displays the amplitude values of R peaks
- displays the heart rate
- displays average RR interval
- displays heart rate variability
- displays NN50 value
- analyses the status of the rhythm and classifies it into normal, atrial fibrillation or other rhythms
- categorizes the condition of heart rate into normal, rapid (tachycardia) or slow (bradycardia)
- based on thecstatus of rhythm and the condition of heart rate, shows a suggestion about what should be done
Out of the three architectures, GRU gave the best classification accuracy. Merging of the models with high performance to make an ensemble neural network helped to improve the accuracy even more. The model was incorporated into the GUI, and it was able to analyse the signals in >1 s, which shows that it can be used for real-time analysis.
- Mohebbanaaz, Y. P. Sai and L. V. R. kumari, "A Review on Arrhythmia Classification Using ECG Signals," 2020 IEEE International Students' Conference on Electrical, Electronics and Computer Science (SCEECS), 2020, pp. 1-6, doi: 10.1109/SCEECS48394.2020.9
- Saadatnejad, Saeed & Oveisi, Mohammadhosein & Hashemi, Matin. (2019). LSTM-Based ECG Classification for Continuous Monitoring on Personal Wearable Devices. IEEE Journal of Biomedical and Health Informatics. PP. 1-1. 10.1109/JBHI.2019.2911367.
- Zhou, Zhi-Hua & Wu, Jianxin & Tang, Wei. (2002). Ensembling Neural Networks: Many Could Be Better Than All. Artificial Intelligence. 137. 239-263. 10.1016/S0004-3702(02)00190-X.