# Automatic Arrhythmia Detection Based on the Probabilistic Neural Network with FPGA Implementation

Authors: Rohini Srivastava; Basant Kumar; Fayadh Alenezi; Adi Alhudhaif; Sara A. Althubiti; Kemal Polat
Journal: Mathematical Problems in Engineering
 (2022)

---

## Abstract

This paper presents a prototype implementation of arrhythmia classification using Probabilistic neural network (PNN). Arrhythmia is an irregular heartbeat, resulting in severe heart problems if not diagnosed early. Therefore, accurate and robust arrhythmia classification is a vital task for cardiac patients. The classification of ECG has been performed using PNN into eight ECG classes using a unique combination of six ECG features: heart rate, spectral entropy, and 4th order of autoregressive coefficients. In addition, FPGA implementation has been proposed to prototype the complete system of arrhythmia classification. Artix-7 board has been used for the FPGA implementation for easy and fast execution of the proposed arrhythmia classification. As a result, the average accuracy for ECG classification is found to be 98.27%, and the time consumed in the classification is found to be 17 seconds.


---

## Body

## 1. Introduction

According to British Heart Foundation, more than 5 million people a year suffer from arrhythmias or heart rhythm problems worldwide. According to the latest survey, it has been estimated that 6–12 million people worldwide will suffer this condition in the US by 2050 and 17.9 million people in Europe by 2060 [1, 2]. Atrial fibrillation (AFib) is a kind of arrhythmia, and the estimated number of individuals with AFib in 2010 was 33.5 million, according to a 2013 study. That’s about 0.5 percent of the world’s population. Bradycardia, ventricular tachycardia, and ventricular fibrillation may also result in several other heart problems, which may require the implantation of cardiac devices such as pacemakers and defibrillators. Several life-threatening diseases such as heart attack, sudden cardiac arrest, and stroke can be avoided if arrhythmias are diagnosed early. Several classification algorithms are available to classify arrhythmias, such as support vector machine (SVM), artificial neural network (ANN), convolutional neural network, and neuro-fuzzy classifier. Some hardware has also been proposed [3–50]. For arrhythmia classification, feature selection is an unavoidable task to perform. Some literatures have selected morphological features, whereas some have frequency domain chosen features to classify the ECG. To achieve accurate classification, the best feature selection is the combination of time and frequency domain features of ECG. There are several classes of arrhythmia such as bradycardia, tachycardia, fibrillation, paced beat (PB), left bundle branch block (LBBB), and right bundle branch block (RBBB). In these arrhythmia classes, some may result in life-threatening situations for cardiac patients. FPGA implementation of neural network-based ECG classification has been proposed earlier using a system generator to classify the ECG into only two classes [15, 18]. Apart from FPGA, hardware implementation using some different processors has also been proposed for ECG analysis: features extraction and classification [5, 17, 30, 31, 44–55]. Jiahao et al. [31] have presented CNN-based ECG classification hardware implementation with 99.1% average accuracy. The average accuracy is perfect. However, they have classified the ECG only into five classes.Despite a considerable number of software-based ECG classifiers available, prototype chips are still required at the user level to classify ECG, as all of them will not be familiar with the software classifiers. Furthermore, a trade-off has been seen between accuracy and the number of arrhythmia classes in all these existing works. To overcome the limitation of the current results, a fast and straightforward classification and the corresponding hardware implementation have been proposed to classify the ECG into eight classes with 98.27% average accuracy using a unique combination of ECG features. The block diagram of the proposed classification is shown in Figure1.Figure 1
Block diagram of ECG classification and FPGA implementation.Figure1 shows various steps for FPGA implementation of ANN-based arrhythmia classification. In the first block, ECG has been extracted from the MIT-BIH database in raw form. Then, the ECG is preprocessed using a low pass filter, notch filter, and high pass filter to remove muscle noise, powerline interference, and baseline wander, respectively. After the preprocessing, ECG features heart rate, spectral entropy, and 4th order autoregressive coefficient are extracted. These features are used to train artificial neural network (ANN) to classify the ECG into eight classes: normal sinus rhythm (NSR), atrial paced beat (APB), paced beat (PB), ventricular tachycardia (VT), ventricular fibrillation (VF), right bundle branch block (RBBB), Left bundle branch block (LBBB) and preventricular contraction (PVC), as shown in Figure 2. After training of ANN, FPGA implementation of pretrained ANN has been executed using Xilinx System Generator (XSG); an average classification accuracy of 98.27% has been achieved. The main contributions of the proposed arrhythmia classification are as follows:(i)
The ECG has been classified into eight classes: NSR, APB, PB, VT, VF, RBBB, LBBB, and PVC.(ii)
A unique combination of ECG features: spectral entropy, 4th order autoregressive coefficients, and heart rate have been used for feature selection.(iii)
PNN-based classifier has been used to achieve an average classification accuracy of 98.27%.(iv)
An FPGA-based hardware implementation has also been presented and implemented on the Artix-7 board. The proposed hardware comprises fewer components, and thus, the power and time consumption in arrhythmia classification is significantly less.Figure 2
Eight classes of ECG.The rest of the paper has been organized as follows: Section2 presents a hardware implementation of ECG preprocessing and features extraction. Training and hardware implementation of ANN has been discussed in Section 3. Section 4 presents classification results and analysis. Conclusion and future scope have been presented in Section 5.


## 2. ECG Preprocessing and Features Extraction

For the classification of arrhythmia, an ECG database is required. For ECG classification, several databases are available: MIT-BIH database, Massachusetts General Hospital/Marquette Foundation (MGH/MF) database, European ST-T database, Apnea-ECG database, etc. Among all these databases, the MIT-BIH database provides ECG data compatible with MATLAB. Therefore, in this work, arrhythmia databases are accessed in MATLAB from the MIT-BIH database, and preprocessing has been performed as it is known that ECG is a low-frequency signal and in the range of 0.05 Hz to 100 Hz. However, it is initially in raw form and includes various noises. Therefore, high pass filter, low pass filter, and notch filter are used to remove the noise. In addition, the analog ECG signals were sampled at a frequency of 360 Hz to use a notch filter with a notch frequency of 60 Hz for removing powerline interference and bandpass filtering at 0.1–100 Hz to avoid antialiasing saturation in analog to digital conversion. After the preprocessing, heart rate can easily be obtained. The original ECG, filtered ECG, and extracted heart rate have been processed using XSG, and the corresponding waveforms are shown in Figure3.Figure 3
The output waveform of the original ECG, filtered ECG, and extracted heart rate.In the above figures, a bradycardia database has been accessed, as shown in Figure3. In the first waveform, raw ECG is shown, which is preprocessed for the further classification process. The second waveform is the filtered or preprocessed ECG. After R-peak detection, heart rate is extracted, which is shown in the third waveform. It can be seen the extracted heart rate is below 60 beats per minute (bpm). After preprocessing of the ECG, features extraction is performed. In general, ECG waveform in the time domain is presented by six segments P-QRS-T-U, for ease in the processing as shown in Figure 4.Figure 4
ECG in P-QRS-T-U form.The features extracted in the time domain are known as morphological features, whereas sometimes features are extracted in the frequency domain known as frequency domain features. Most of the information for arrhythmia is obtained from the QRS segment of ECG. To obtain accurate classification, features from both domains, time and frequency, should be considered. The proposed work’s unique combination of six features: heart rate, spectral entropy, and 4th order autoregressive coefficient are considered. Heart rate is a morphological feature obtained by detecting R-peaks followed by an R-R interval of two consecutive P-QRS-T-U waves of ECG. After extraction of heart rate, autoregressive (AR) modeling of ECG is performed. As ECG is a time series signal, it is required to measure the correlation between its samples. AR modeling is basically used to predict the correlation between the present sample and the samples that precede/succeed the current value. In other words, it can be said that AR modeling provides the past and future behavior of ECG signals. An autoregressive (AR) model of order N can be expressed as(1)yt=−a1∗yt−1−a2∗yt−2−⋯aN∗yt−N+et.The autoregression name is derived from the fact that the variabley is regressed on its previous value. In the proposed work, 4th order autoregressive coefficients are obtained using Burg’s method to classify PVC, VT, VF, etc., accurately. In MATLAB, commands are available to obtain AR coefficients. After extraction of these five time-domain features, a frequency domain feature, spectral entropy, is obtained. To measure spectral power distribution, spectral entropy (SE) is estimated by Shannon’s channel entropy using the following equation:(2)Hx=−∑i=1nPxilogbPxi,where H(x) presents spectral entropy, P(xi) presents probability distribution function, and i = 1 to n is n-point discrete Fourier transform (DFT) of the sampled discrete-time ECG. It is used to measure the power distribution of ECG at different frequencies. The block diagram of feature extraction is presented in Figure 5.Figure 5
XSG block diagram of six features extraction of ECG.XSG is used to transfer the extracted ECG features to the Xilinx. The extracted features and Simulink output for the corresponding values are shown in Figures6 and 7, respectively.Figure 6
Extracted features of ECG: spectral entropy, AR coefficients, and heart rate.Figure 7
Simulink output for the values of ECG features.After extraction of ECG features, training of ANN, classification, and FPGA implementation of the complete system are performed.


## 3. FPGA Implementation of ECG Classification Using ANN

Heart rate, spectral entropy, and AR coefficients are used for the training of ANN. Implementing a neural network on Simulink is a difficult task to perform; however, for processing in XSG, it is a mandatory process to implement NN on Simulink. An ECG with 10 seconds duration is considered for the proposed method; therefore, a total of 3600 samples was used to train ANN as ECG was initially sampled at 360 Hz. A probabilistic neural network (PNN) with two hidden layers is used for fast training and better performance advantages. In the proposed work, the first layer of PNN consists of six features. Then, two hidden layers are used to classify the ECG. Finally, the output layer consists of an eight-bit target vector to discriminate the particular arrhythmia class. The Simulink block diagram of PNN is shown in Figure8.Figure 8
Simulink diagram of neural network architecture.As six ECG features are selected in this proposed work for arrhythmia classification, and 1050 samples are taken for each feature, therefore in NN, Layer 1 will consist of 6 × 1050 neurons. In contrast, Layer 2 consists of 6 × 1050 × 8 neurons, where 8 is the number of outputs. Finally, the output layer has eight classes. The internal structures of hidden Layer 1 and hidden Layer 2 are shown in Figure9.Figure 9
The internal structure of Layer 1 and Layer 2 of PNN.In various software, direct commands are available to execute NN, which do not provide any information about the hidden layers. In contrast, Simulink provides the facility to have detailed information about the hidden layer architecture and neurons. From Figure10, it can be easily seen that where weights and bias are added. The detail of internal circuitry can also be seen when we implement neural network on Simulink. For classification, two activation functions: Tansig and Softmax are used. Tansig is used for calculating output from the net input, whereas Softmax is used to convert a vector of numbers into a vector of probabilities. In the proposed method, PNN has an output of eight bits, known as a target vector, to discriminate a particular class of arrhythmia. The arrhythmia classes and their corresponding target vectors are shown in Table 1.Figure 10
Classification accuracy for eight classes of arrhythmia.Table 1
Arrhythmia classes and their corresponding target vector.
S. No.ArrhythmiaTarget vector1.Normal sinus rhythm100000002.Left bundle branch block010000003.Right bundle branch block001000004.Premature ventricular contraction000100005.Paced beat000010006.Atrial paced beat000001007.Ventricular fibrillation000000108.Ventricular tachycardia00000001After training, validation, and testing, accuracy for various arrhythmia classes is obtained, and it is found that the average accuracy of overall arrhythmia classification is found to be 98.27%. Accuracy for various classes of arrhythmia is shown in Figure10.From the above figure, it can be seen that among eight classes of ECG, most of the classes have a classification accuracy of more than 96%, except ventricular fibrillation (VF). This amount of accuracy is the lesser number of training data for VF. It can be improved by increasing the training data for VF. After validation and testing, FPGA implementation of the complete classification system is obtained using XSG. The block diagram of neural network-based ECG classification is shown in Figure11.Figure 11
Xilinx System Generator block diagram for NN-based ECG classification.Register transfer logic (RTL) for the ANN having eight arrhythmia classes at the output is presented in Figure12. The RTL of NN hardware comprises mainly two blocks: NN hardware and clock_driver. The ‘NN hardware’ block has a neural network algorithm, whereas ‘clock_driver’ provides a clock of 100 Hz for parallel processing. Block NN hardware provides the eight classes of arrhythmia: APB, LBBB, NSR, PB, PVC, RBBB, VF, and VT. Device utilization and timing analysis for the proposed NN-based ECG classification are discussed in the next section.Figure 12
RTL of ANN-based arrhythmia classification into eight classes.


## 4. Results and Analysis

The ECG has been classified into eight classes with an adequate average accuracy of 98.27%, and the proposed ANN-based classifier has been implemented on Artix-7 using XSG. Furthermore, for validation of the proposed classifier, the complete system generator block for PNN-based ECG classifier has been successfully implemented on the Artix-7 FPGA board, as shown in Figure13.Figure 13
Successful implementation of PNN-based arrhythmia classifier.The device utilization analysis of the corresponding hardware is presented in Table2.Table 2
Device utilization analysis of FPGA implementation of NN-based ECG classification.
Logic utilizationUsedAvailableUtilization (%)Number of slice register19251268001.5Number of fully used LUT-FF pairs010Number of bonded IOBs18721089Number of BUFG/BUFGCTRLs1323Time consumption17 secConsumed on-chip power25 mWTable2 indicates that the components used in the design of NN-based arrhythmia classification are very less and the implementation consumes less time and power. Therefore, the proposed design will have less computational complexity, a notable achievement for a neural network hardware implementation. As mentioned above, the overall accuracy achieved for arrhythmia classification into eight classes is 98.27%. The comparative analysis of the proposed work with some existing work is shown in Table 3.Table 3
Comparative analysis of the proposed arrhythmia classification’s FPGA implementation with some of the existing work.
Parameters[7][15][22][11]Proposed workNo. of classes of arrhythmia2NA258Set of features13176Training data120NANot mentioned50006300Hardware usedArtix-7Virtex-6ZynqVirtex-5Artix-7Number of slice registers2474 out of 1268001540 out of 93120Not mentioned3130 out of 288001925 out of 126800Number of fully used LUT-FF pairs0 out of 1260 out of 56045454 out of 109446149 out of 288000 out of 1Number of bonded IOBs27 out of 21030 out of 240Not mentionedNot mentioned187 out of 210Number of BUFG/BUFGCTRLs1 out of 321 out of 322 out of 32Not mentioned1 out of 32Time consumptionNot mentionedNot mentionedNot mentioned21.79 sec17 secConsumed on-chip powerNot mentionedNot mentionedNot mentionedNot mentioned25 mWAccuracy98.3%NA99.82%96.05%98.27%It has been seen from Table3 that among all the mentioned existing works, the proposed hardware has better performance as compared to the other reported works. All of them have fewer arrhythmia classes at the output and a large number of components used for the hardware implementation. The unique set of features are used in the proposed work. Most of the parameters are better as compared to the other existing works. Bonded IOBs are higher than the other existing works which is the only limitation of the proposed hardware implementation which is due to use of ECG features of different domain. The works reported in [7, 22] have more considerable accuracy of classification. However, they classified the arrhythmia only into two classes. The total time consumption for classification of ECG is reported 17 sec, which is the minimum time consumption reported till now.


## 5. Conclusions and Future Works

Probabilistic neural network-based arrhythmia classification and its hardware implementation had been discussed in this paper. ECG was preprocessed, and a unique combination of ECG features, spectral entropy, 4th order autoregressive coefficient, and heart rate, had been extracted to classify the arrhythmia accurately. PNN classification of arrhythmia was performed first on MATLAB and then on FPGA using Xilinx System Generator with an impressive average accuracy of 98.27% for eight classes of ECG. The implementation was performed on the Artix-7 FPGA board using Verilog inbuilt simulator. Device utility analysis of the proposed classification described that the components used in this algorithm are very low and consume less time and power, i.e., 17 sec and 25 mW. Vivado inbuilt simulator can also be used in the extended work for arrhythmia detector which may replace the use of two software. Several FPGA boards are now available that can directly access multiple of sensors. Thus, in future, real-time ECG classification can be performed using ECG sensors integrated with the Artix-7 FPGA board. 10-lead ECG sensors are more accurate than the 3-lead sensor; however, the placement of leads is a challenging task. Therefore, it would be better to use 3-lead ECG sensor for real-time arrhythmia classification.



---

*Source: 7564036-2022-03-22.xml*