# A Low-Power ECG Processor ASIC Based on an Artificial Neural Network for Arrhythmia Detection
## 3 System Modules
### Classification Engine  
The proposed ECG classification engine is based on a feed-forward neural network--specifically, a multi-layer perceptron (MLP). MLP is an ANN composed of multiple layers of neurons, where each neuron is connected to neurons in the next layer. This architecture is based on the following considerations: (1) Data processing: ANN is suitable for processing structured data. The ECG signal is time series data, where the features of each time point are used as the input; (2) Feature extraction: ANN can automatically learn features from the original ECG signal data without the need for additional feature extraction; (3) Nonlinear relationship: There are complex nonlinear relationships in the ECG signal, such as the amplitude and slope of QRS waves. ANN can capture these relationships by using nonlinear activation functions; (4) Multi-types classification: Arrhythmias contain multiple categories; classification can be achieved by adjusting the output layer neurons. Figure 6 shows the proposed ANN model, which includes one input layer, one hidden layer, and one output layer, with sizes of 100, 8, and 5, respectively. The calculation of hidden layer neurons is as follows:  
\[\rm{H_{Nk}}=\sum_{i=1}^{S_{i}}x_{i}w_{ik}+b_{k}, \tag{6}\]  
\[\rm{f(H_{Nk})}=max\ (0,\ H_{Nk}), \tag{7}\]  
Figure 5: (**a**) Connection between the data handler and other modules. (**b**) Workflow of the data handler. where \(S_{i}\) is the size of the input layer, and \(x_{i}\), \(w_{ik}\), and \(b_{k}\) are the input, weight, and bias of one neuron, respectively. The results are activated by the rectified linear unit (ReLU) function, which is defined by (7). The output layer contains five neurons, representing a normal beat (NOR), left bundle branch block beat (LBBB), right bundle branch block beat (RBBB), premature ventricular contraction beat (PVC), and atrial premature beat (APB). The calculation of each neuron is the same as (6). To obtain the probability of each type, Softmax is used as the transfer function, which is defined as:  
\[P_{j}=\frac{e^{O_{Nj}}}{\sum_{i=1}^{S_{o}}e^{O_{Ni}}}, \tag{8}\]  
where \(S_{o}\) is the size of the output layer, and \(O_{Nj}\) is the result of the j-th output layer neuron. More than ten thousand segmented heart beats centered around the R-peak are obtained from the MIT-BIH database, which is achieved through a simple ECG segmentation algorithm containing R-peak detection. Each arrhythmia type contains 2500 heartbeat records with a length of 100 sampling points. These data are randomly disrupted and divided into a training set and testing set, each containing 6250 records. The dataset has been normalized by subtracting the mean to reduce the risk of numerical overflow and ensure the stability of the training. The error Backpropagation (BP) algorithm is used for training this model. For a training case \(\left(\vec{x}_{k},\vec{y}_{k}^{\prime}\right)\), the output of the neural network is \(\vec{y}_{k}^{\prime}=\left(y_{1}^{k},\ y_{2}^{k^{\prime}},\ \dots,y_{S_{o}}^{k \prime}\right)\), and the mean square error of the network is:  
\[E_{k}=\frac{1}{2}{\sum_{j=1}^{S_{o}}}\left(y_{j}^{k^{\prime}}-y_{j}^{k}\right) ^{2}, \tag{9}\]  
Figure 6: The proposed neural network model for arrhythmia classification. The BP algorithm updates weights in the negative gradient direction. Taking the example of the weights connecting the hidden layer to the output layer, denoted as \(\mathrm{w_{kj}}\), the update can be computed as follows:  
\[\Delta\mathrm{w_{kj}} =-\alpha\frac{\partial\mathrm{E_{k}}}{\partial\mathrm{w_{kj}}} \tag{10}\]  
where \(\alpha\) represents the learning rate, which is set to 0.001 in this paper. The training epochs are set to 30 because our experiments show that more epochs do not significantly improve the accuracy and loss performance. In addition to the already determined input and output layers, the construction of an ANN model is based on considerations of classification accuracy and energy efficiency.