A deep learning method for ECG signal prediction based on VMD, Cao method, and LSTM neural network

Background: In body area network (BAN), accurate prediction of ECG signal can not only let doctors know the patient's condition in advance, but also help to reduce the energy consumption of sensors. In order to improve the accuracy of ECG signal prediction, this paper proposes a deep learning method for ECG signal prediction. Methods: The proposed prediction method combines variational mode decomposition (VMD), Cao method and a long short-term memory (LSTM) neural network. In the method, VMD decomposes ECG data into a series of intrinsic mode functions (IMFs), which reduces the non-stationary character of ECG signals and helps to improve the prediction accuracy. Cao method is used to determine the input dimension of LSTM input layer, namely, the minimum embedding dimension of each IMF is the input dimension of LSTM input layer. Each IMF is predicted by a LSTM neural network which adopts Adam optimizer. All IMFs predictions are aggregated to get the final prediction result. Results: To evaluate the prediction accuracy of the proposed method, simulation experiments are carried out on ECG data from the MIT-BIH Arrhythmia Database. Experimental results show that the RMSE (root mean square error) and MAE (mean absolute error) of the proposed model are 0.001326 and 0.001044 respectively, which are more than 10 percent lower than the traditional prediction methods. Conclusions: Compared with some traditional prediction methods, the proposed prediction method improves the prediction accuracy obviously.


Introduction
ECG is one of the most commonly used methods in clinic. It is significant for doctors and BAN to predict ECG signal accurately. On the one hand, doctors can know the patient's condition in advance; on the other hand, it helps sensors in BAN to reduce energy consumption. In BAN, there are some sensors placed under the skin or inside the body, and their batteries are inconvenient to replace. Therefore, it is necessary to reduce energy consumption and prolonging the lifetime of a sensor. If a prediction model is established in both sensor node and sink node, when the prediction error exceeds the specified threshold value, the sensor node will send the measured data, 2 otherwise, it will not send the measured data [1]. According to this view, the prediction technology can reduce data transmission and reduce the energy consumption of a sensor. In BAN, the data volume of the ECG signal is the largest, which is several times higher than that of other signals. The accurate prediction of an ECG signal can eliminate the need to collect data in real time and reduce the amount of data transmission, so as to achieve the purpose of reducing the energy consumption of a sensor.
In BAN, the data collected by sensors are time series data. For time series prediction, prediction model is the key factor of prediction accuracy. With the application of deep learning more and more widely, many scholars began to use deep learning technology to study time series prediction. As a typical deep learning model, Recurrent neural network(RNN) has been applied in time series prediction [2][3][4].Compared with the traditional time series prediction methods, RNN improves the prediction accuracy, but it still has the shortcomings of gradient disappearance and gradient explosion. LSTM is an improved RNN, which overcomes the shortcomings of RNN. At present, LSTM has achieved wide application in natural language processing [5][6], machine translation [7][8], and handwriting recognition [9]. Many researchers are focused on the time series prediction with LSTM. Essien et al. [10] proposed a deep ConvLSTM autoencoder (2-DConvLSTMAE) predictive model for machine speed prediction. The predictive model was applied to the multistep time-series prediction problem and achieved improved predictive performance. Du et al. [11] proposed a deep irregular convolutional residual LSTM model for predicting the flows of crowds in transportation lines. The proposed model outperforms both traditional and deep learning based urban traffic passenger flow prediction methods. Wang et al. [12] proposed an earthquake prediction system. The proposed system can make accurate predictions with different temporal and spatial prediction granularities. Some literatures proposed to use VMD combined with LSTM to predict time series [13][14], but they seldom discussed how to solve the input length problem of LSTM input layer. Relevant literature shows that LSTM is indeed more effective than the traditional RNN model in the analysis and prediction of time series data [15][16].
This paper focuses on the prediction of an ECG signal. Because an ECG signal is a nonlinear and non-stationary time series signal with an inherent random feature, it is difficult to predict accurately. At present, there are some literatures on the prediction of ECG signals. Wei et al. [17] developed a universal model for highly accurate prediction of ECGs and EEGs. The model combined a convolutional neural network (CNN) and bi-directional recurrent neural network (BRNN). Sun et al. [18] proposed a prediction method of an ECG signal using an error backpropagation neural network (BPNN) and VMD. An ECG signal prediction method based on phase space reconstruction (PSR) and BPNN was proposed in [19], with accuracy close to that of the previously mentioned method. An ECG signal prediction method based on autoregressive integrated moving average (ARIMA) model and discrete wavelet transform (DWT) was proposed in [20]. Although the prediction accuracy of the method is relatively high, it needs to smooth the ECG signal in advance, and there is a certain signal distortion. In [21], an ECG signal prediction method was proposed. In the method, the PSR and the TS fuzzy model were used to predict an ECG signal. The prediction error of the method was the same order of magnitude as that in [18] and [19].
The prediction accuracy of the existing ECG prediction methods is relatively low. To improve the prediction accuracy of ECG signal, we propose a deep learning method for ECG signal prediction using VMD, Cao method, and LSTM neural network. Firstly, we use VMD to preprocess ECG data. VMD decomposes a non-stationary ECG into some stationary IMFs, which is helpful to improve the prediction accuracy. Secondly, the optimal input dimension of LSTM input layer is determined by Cao method. Finally, we use the Adam optimizer to optimize the parameters of LSTM and predict ECG signal by the LSTM. The rest of this paper is organized as follows. Results section describes a simulation experiment and the analysis of its results. Discussion section compares the proposed prediction method with some competitive prediction methods. Conclusions section provides concluding remarks. Methods section describes in detail an ECG signal prediction method based on VMD, Cao method, and LSTM neural network.

Results
All ECG data in the simulation experiment are from the MIT-BIH Arrhythmia Database [22]. We selected No.100 ECG data, which consists of 2,768 data points, for the experiment. We used two-thirds of No.100 ECG data as the training set (i.e., 1845 data points) and the remaining one-third as the test set (i.e., 923 data points). All experiments were carried out in MATLAB and Python compiling environment. The LSTM model was implemented in a Theano framework based on Keras deep learning tools. The parameters of LSTM are epochs=250, batch_size=4, optimizer=Adam, loss=mean_squared_error, and activation=Relu.
The common performance measures of prediction methods are RMSE, MAE, mean absolute percentage error (MAPE), and R-square (R 2 ), defined as where () Xn ( is the predicted value of () Xn, N is the number of () Xn, and Xmean is the mean of () Xn. 4 The proposed method is used to predict the test set of No. 100 ECG, as shown in Figure 1. In Figure 1, raw signal represents the original signal and test prediction represents the predicted signal. Figure 1 shows that the original ECG waveform is consistent with its predicted waveform. The prediction indexes of the test set are shown in Table 1.  Table 1 shows that the prediction error is very small and the correlation between the predicted signal and the original signal is good.

Compared with some prediction methods
We compared the proposed method with the prediction methods of references [18], [19], and [21]. We experimented on the same data source, No. 100 ECG, and the experimental results are shown in Table 2 and Figure 2.  As shown in Table 2 and Figure 2, the RMSE and MAE of the proposed method are much smaller than those of references [18], [19] and [21]. This illustrates that the prediction accuracy of this paper is much higher than that of references [18], [19] and [21], respectively.

Compared with some hybrid prediction methods
In addition, the proposed method (VMD-Cao-LSTM) was compared with other traditional hybrid methods, such as the method based on wavelet transform(WT), PSR, and radial basis function(RBF) neural network (WT-PSR-RBF); the method based on empirical mode decomposition (EMD), PSR, and RBF neural network (EMD-PSR-RBF); the method based on VMD, PSR, and BP neural network (VMD-PSR-BP); and the method based on VMD, generalized regression neural network (GRNN) , and PSR (VMD-PSR-GRNN). The experimental data were No.  Table 3. It is obvious from Table 3 that the prediction performance of this paper (VMD-Cao-LSTM) is better than that of WT-PSR-RBF, EMD-PSR-RBF, VMD-PSR-BP and VMD-PSR-GRNN.

Compared with some deep learning prediction methods
We also compared the proposed method with some deep learning prediction methods. The comparison results were shown in Table 4 and Figure 3.  Table 4 shows that the RMSE and MAE of VMD-Cao-LSTM are obvious less than those of LSTM, MLP and CNN. In Figure 3, the prediction error of VMD-Cao-LSTM is less than that of LSTM, CNN and multi-layer perceptron (MLP). Table 4 and Figure 3 show that the prediction performance of VMD-Cao-LSTM outperforms that of LSTM, CNN and MLP.

Conclusions
In this paper, we review the latest development of ECG prediction methods. Based on the analysis of VMD, Cao method and LSTM, we propose a deep learning method for ECG signal prediction. Using the ECG data of the MIT-BIH Arrhythmia Database as the data source, we evaluate the prediction performance of the proposed method. Simulation results show that the RMSE and MAE of the proposed prediction method are only 10 -3 orders of magnitude, while those of the general prediction methods are 10 -2 orders of magnitude. We draw a conclusion that the prediction method proposed in this paper significantly improves the accuracy of ECG signal prediction. In the next work, we will study how to use the prediction method proposed in this paper to reduce the energy consumption of the sensor.

VMD
Variational mode decomposition (VMD) decomposes an input signal into a series of discrete band-limited IMFs around the center frequency. In time series prediction, the function of VMD is to reduce the non-stationary character of time series, which is helpful to improve the accuracy of prediction. Each IMF component is obtained through the following three steps: Step 1: Calculate the analytic signal of each modal function Step 2: Multiply the analytical signal by the estimated center frequency k jw t e  , and move it to the base frequency spectrum, which is Step 3: Estimate the bandwidth of each mode by Gaussian smoothing of the demodulated signal, i.e., the L 2 norm of the gradient. The constrained variational model is where x is the input signal and 2 g is the Euclidian distance. In order to find the 8 optimal solution of the above problem, turn the constrained variational model into an unconstrained variational model by introducing the quadratic penalty factor  and Lagrange multiplication operator () t  . The extended Lagrange expression is Find the saddle point of the extended Lagrange expression using the alternating direction multiplier method (ADMM) [23] to solve the extended Lagrange problem.
The saddle point is obtained by alternating renewal The specific implementation process of VMD is as follows: Step 1: Initialize  Step 3: Repeat step 2 until the convergence condition is reached where ε is a judgment threshold. Before VMD, the number K of IMFs needs to be predetermined. K can be selected according to the ratio of residual energy Rres to the original signal energy. The Rres is defined as follows: where X(n) is the original signal, uk (n) is the IMF, and N is the sample number. When Rres is less than 1% and there is no significant downward trend, the number K can be determined [24]. For the No. 100 ECG data, the Rres of VMD with different K are 9 shown in Table 5.  Table 5 shows that the Rres has no obvious downward trend when K =14. Therefore, we set K =14 in the experiment.

Em Em
Em where m is the embedding dimension, τ is the time delay, ()  Table 6. The minimum embedding dimension m is the input dimension of LSTM neural network.

LSTM neural network
As one of the classic models of deep learning, LSTM is widely used in time series prediction. LSTM is an improved RNN model, which solves the problems of gradient disappearance and gradient explosion that RNN cannot overcome. Each LSTM unit is composed of a memory cell and three gates: an input gate, a forget gate, and an output gate. The functions of these three gates are: the input gate decides the information that should be input; the forget gate determines the information that should be discarded; the output gate decides the information that should be output. The architecture of LSTM unit is shown in Figure 4.
x t h t Figure 4 The architecture of LSTM unit The output values of three gates (input gate ) where W and b denotes weight matrices and bias vectors of gates, respectively. In addition,  and tanh are the activation functions between different layers, t c is the current state of the cell, t c %is the unit state of the current input, and t h is the current output of the cell. The expressions of  and tanh are as follows: By introducing cell state t c and three gate structures of forgetting gate, input gate and output gate, LSTM has the ability of long-term and short-term memory, thus solving the problems of gradient disappearance and gradient explosion of RNN. Compared with other neural networks, LSTM is more suitable for time series data prediction.

The proposed prediction method for ECG signal
Based on the study of ECG signal prediction, this paper proposes a hybrid method of ECG signal prediction. Its flowchart is shown in Figure 5. The prediction steps of the proposed method are as follows: Step 1: Decompose ECG data into K IMFs by VMD. In the experiment, we use K = 14 to get a better prediction result.
Step 2: Determine the input variables of the LSTM neural network by Cao method.
Step 3: Establish a LSTM neural network and use it to predict the test set of each IMF.
Step 4: Add the prediction results of the LSTM neural network to obtain the final ECG signal prediction result.
Step 5: Analyze the prediction error and compare it to other prediction methods.