Atrial Fibrillation Detection Using Feedforward Neural Network

Atrial fibrillation is one of the most common arrhythmias in clinics, which has a great impact on people's physical and mental health. Electrocardiogram (ECG) based arrhythmia detection is widely used in early atrial fibrillation detection. However, ECG needs to be manually checked in clinical practice, which is time-consuming and labor-consuming. It is necessary to develop an automatic atrial fibrillation detection system. Recent research has demonstrated that deep learning technology can help to improve the performance of the automatic classification model of ECG signals. To this end, this work proposes effective deep learning based technology to automatically detect atrial fibrillation. First, novel preprocessing algorithms of wavelet transform and sliding window filtering (SWF) are introduced to reduce the noise of the ECG signal and to filter high-frequency components in the ECG signal, respectively. Then, a robust R-wave detection algorithm is developed, which achieves 99.22% detection sensitivity, 98.55% positive recognition rate, and 2.25% deviance on the MIT-BIH arrhythmia database. In addition, we propose a feedforward neural network (FNN) to detect atrial fibrillation based on ECG records. Experiments verified by a 10-fold cross-validation strategy show that the proposed model achieves competitive detection performance and can be applied to wearable detection devices. The proposed atrial fibrillation detection model achieves an accuracy of 84.00%, the detection sensitivity of 84.26%, the specificity


Introduction
According to Cardiovascular Health and Disease Report 2019 Summary [1], the number of cardiovascular patients from 1990 to 2017 continues to increase, and the mortality rate is on the rise.
Arrhythmia is one of the most important cardiovascular diseases and atrial fibrillation is the most common arrhythmias in clinics.With the rapid development of Internet of Things, big data, cloud computing, artificial intelligence and other technologies, wearable ECG monitoring devices have attracted the attention of academia and industry [28].It is crucial to develop accurate atrial fibrillation prevention technologies, which can be applied for wearable ECG devices.Although many studies in areas of cardiovascular disease prevention have been reported during the past decade [2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19], there are still some difficulties in the research of atrial fibrillation detection: (1) It is difficult to detect atrial fibrillation in the early stage due to it has the characteristics of intermittent onset, short onset time, and rapid disappearance of symptoms; (2) In the clinic, doctors usually diagnose atrial fibrillation by observing the ECG manually, which is inefficient and subjective.To overcome the abovementioned difficulties, it is necessary to develop an automatic atrial fibrillation detection method to improve the accuracy and efficiency of atrial fibrillation detection.
Traditional atrial fibrillation detection methods are reliant on feature extraction of F wave, P wave, and R peak in electrocardiogram (ECG).Those methods only perform well when tested on small datasets, such as the MIT-BIH database [23].Its performance on a large amount of clinical data may decrease due to the traditional feature based methods depend on the artificially defined features, which

Related Works
In this section, we first give a review of traditional feature extraction based atrial fibrillation detection methods and then discuss deep learning based atrial fibrillation detection methods.
In the ECG, the main characteristics of atrial fibrillation episodes are the disappearance of the P wave, the disorder and irregularity of the f wave, and the absolute irregularity of the RR interval.
Automatic atrial fibrillation detection algorithms based on these characteristics have been widely studied.Millán et al. [2] utilized the characteristics of the disappearance of P waves in the ECG to detect atrial fibrillation.They used the empirical mode decomposition to analyze the denoised signal and converted the processed signal into the corresponding mode function to obtain the P wave features for atrial fibrillation detection.Du et al. [3] proposed an atrial fibrillation detection algorithm based on the characteristics of f wave clutter and irregular TQ interval in ECG.However, the P wave and f wave have weak amplitude and are likely to be influenced by noise.Furthermore, the irregular f wave changes are relatively weak.On the contrary, the irregular RR interval can be easily observed in the ECG and time-based changes of RR interval are not affected by noise.To this end, Huang et al. [4] used the absolute irregularity of the RR interval to detect atrial fibrillation.This algorithm used the density histogram of the RR interval to obtain the distribution curve of the RR interval and calculates its increase.Liu et al. [5] proposed a combination method of multiple signal quality indices and machine learning to classify 10-s single-channel ECG segments as acceptable and unacceptable.Wan et al. [6] introduced a mathematical model built by a support vector machine to detect different diseases based on the ECG data analyzed by the empirical mode decomposition and multiscale entropy method.
In [7], a method based on the mean instantaneous frequency of the ST intervals was proposed to quantitatively evaluate the risk of sudden cardiac deaths.
Recently, many studies based on deep learning have pushed atrial fibrillation detection results to extracted the QRS wave related features of the ECG and used it as the input of the neural network.The data of the CinC2017 ECG Challenge was classified through the feedforward neural network (FFNN).
Andreotti et al. [14] proposed a residual neural network (ResNet) to detect atrial fibrillation on ECG signals.This ResNet can support training deeper networks while avoiding gradient disappearance.Wan et al. [15] proposed four layers of one-dimensional CNN to take ECG beat sampling points as input for feature extraction and classification.Finally, the generated characteristic matrix is fed into the proposed FNN model that outputs the atrial fibrillation detection results.resolution analysis so that noise can be removed when it is distributed at multiple resolutions, which can well describe the non-stationary, sudden changes, and power failures of the signal [20].

Proposed Approach
The wavelet transform of the signal ( ) f x is defined as： where  is the scale factor, which reflects the scalability of the basic wavelet function； represents the displacement, which represents the displacement of the basic wavelet function.
The wavelet decomposition mainly aiming at the correction of baseline drift because the baseline drift is the most difficult one to be removed among the three common interferences in the ECG signal.
The ECG signal is decomposed into 6 levels as shown in   To resolve these two problems, we design a novel R-wave extraction algorithm on QRS wave refer to the classic Pan-Tompkins algorithm [21].We assume that the maximum heart rate of the human body is 210 bpm so that the maximum heart rate of the human body per minute can be obtained [25].
Combined with the sampling frequency of the input signal, the window data can be determined, and then the judgment condition can be set.The flowchart of the proposed feature extraction algorithm on the QRS wave is shown in Figure 4.The RR sequence (in ) is extracted from the processed R-wave through the following function.

Feature extraction based on RR interval
In the previous section, the R-wave is preprocessed to extract a more accurate RR interval.In this section, the RR sequence is preprocessed for extracting the feature matrix.First, filter out the outliers from the RR sequence.Then, set the upper and lower thresholds of the outliers according to the relationship between the median value and the variance of the RR sequence, where Filter out abnormal values greater than ℎ_ and less than ℎ_, obtain RRd1 and RRd2 by calculating first-order derivative and second-order derivative on the output sequence.Use RR, RRd1, and RRd2 sequences to extract 72 signal features from ventricular activity.A dataset containing 8528 samples and 72 features per sample can be built, which is the input of the FNN after processing.

Preprocessing of the feature dataset
In section 3.2.2,we obtain the dataset composed of the feature vectors.It is necessary to remove outliers in the dataset before it is fed into the neural network.We set two thresholds TH h

Feature selection
The objectives of feature selection are to select important features to alleviate the dimensionality disaster and to remove irrelevant features to reduce the difficulty of learning tasks.We aim to select the best feature vector from 72 feature vectors that are sent into FNN for training.We use the backward elimination method to perform feature selection, as shown in Figure 5.

Model composition
The architecture of the proposed FNN model is shown in Figure 6, which is a multi-layer feedforward neural network with a hidden layer composed of 128 neurons.The 1×22 feature matrix composed of the 22 feature vectors after filtered out is used as the input layer, and the sub-layer is performed through the pooling layer.Sampling compresses and filters feature vectors to reduce information redundancy.The random weight matrix generated by the input matrix is mapped to the hidden layer as the next-level input and then mapped to the output layer through the weight matrix.
where i x is the original ECG signal, and y i is the noise-reduced ECG signal.

Analysis of preprocessing results
We use the 109th record in the MIT-BIH arrhythmia database for testing and select the first 10s of sample points to show the noise reduction results.Figure 8 shows the comparison between the preprocessed signal and the original ECG signal.It can be seen that the original ECG signal is full of glitches, which indicate that the signal contains power frequency interference and EMG interference.
Moreover, the original signal baseline drift in the first 5s is relatively serious.The preprocessed signal is smoother, and the baseline drift is effectively corrected.We can conclude that the proposed preprocessing method has good suppression effects on the three kinds of interferences.We further evaluate the proposed preprocessing method by comparing it with other preprocessing methods.The comparison results are shown in Table 1, one can see that the proposed preprocessing method has the best trade-off between SNR and MSE.This result indicates that the proposed preprocessing method is effective to remove various noise interference while retaining the original information.Our method is simpler and more flexible that can perform multi-resolution analysis and can characterize the non-stationarity, sudden changes, and breakpoints of the signal.In addition, the window length of our method can be adjusted according to requirements to realize the ideal accuracy.
where true positive (TP) represents the number of correctly detected R-waves.False positive (FP) represents the number of non R-waves that are wrongly detected as R-wave.False negative (FN) represents the number of R-waves that are wrongly detected as non R-waves.N represents the total number of R-waves in the database.The definition standard of TP and FP is 280ms which is consistent with the length of each segment.
We use the MIT-BIH arrhythmia database to analyze the R-wave detection results.We take the first 8000 sampling points of the 109th record in the database as an example.Figure 9 shows the detection and calibration results, the R-wave detection result is represented by a red circle, the noise threshold is marked by a black dashed line, and the signal threshold is marked by a red dashed line.

Comparison of the proposed method with other methods
In this section, the proposed FNN model is compared with the shallow CNN method [22], the Convolutional Recurrent Neural Network (CRNN) method [26], and the ResNet method [27].The dataset is also divided into 4 categories, and each type of signal corresponds to a label for output.The comparison results are shown in Table 4.The evaluation results of our method for four metrics are calculated by averaging the mean value of training and testing results presented in Table 3.Although the other methods show better results than ours, those methods adopt complicated CNN architecture which costs high computation time.On the contrary, the proposed method is simpler and applicable, which can be applied to the wearable device.In addition, the training results of the shallow CNN decreasing when reducing the number of convolutional layer filters.Our method performs better than the shallow CNN [22] using 1 filter of length 30.In summary, the proposed FNN based atrial fibrillation detection model is competitive and has a lot of room for optimization.

Conclusions
In this work, an atrial fibrillation detection model based on a multilayer feedforward neural network is proposed.First, a novel preprocessing method of wavelet transforms combined with sliding window filtering is introduced, which shows better performance when compared with common preprocessing algorithms.In addition, a robust feature extraction algorithm is developed to extract the R-wave features.Our R-wave detection algorithm achieves 99.22% detection sensitivity, 98.55% positive recognition rate, and 2.25% deviance on the MIT-BIH arrhythmia database.Furthermore, the proposed an effective FNN model is proposed that achieves an overall detection sensitivity of 84.26%, the detection accuracy of 84%, a specificity of 93.23%, and the area under the receiver operating curve of 89.40% on the mixed dataset composed of MIT-BIH arrhythmia and Challenge2017.We believe that our work will make a valuable contribution to the area of atrial fibrillation.
have low generalization ability.In recent years, deep learning technology is developing rapidly and has achieved promising results in atrial fibrillation detection.Contrary to traditional feature extraction based atrial fibrillation detection methods, deep learning based methods have superior discriminative ability to detect informative features for atrial fibrillation detection.Therefore, it is very natural to apply deep learning technology for the automatic detection of atrial fibrillation.In this research, an effective feedforward neural network (FNN) is proposed for automatic atrial fibrillation detection, which can automatically detect atrial fibrillation with high performance.The contributions of this work are summarized as follows. Novel preprocessing algorithms of ECG signals are presented.Firstly, wavelet transform is used to reduce the noise of the ECG signal by removing the three common interferences.After that, the sliding window filtering (SWF) algorithm is introduced to filter high-frequency components in the ECG signal to increase the accuracy of R-wave detection. Inspired by the classical R-wave extraction algorithm of Pan-Tompkins [21], we propose a robust R-wave detection algorithm by combining the characteristics of R-wave, T-wave, and P-wave.The evaluation results of the proposed algorithm on the MIT-BIH arrhythmia database [23] show that the detection sensitivity and positive recognition rate are 97.78% and 95.29%, respectively. An effective FNN model is developed to detect atrial fibrillation based on ECG records.This model takes the characteristic matrix extracted from the RR interval as input and the model parameters of the model are optimized through the grid search method.We evaluate the proposed FNN model on the mixed dataset composed of the Challenge 2017 database [24] and MIT-BIH arrhythmia database [23] by using a 10-fold cross-validation strategy.Empirical experimental results show that the proposed method achieves an accuracy of 84.00%, the detection sensitivity of 84.26%, the specificity of 93.23%, the area under the receiver working curve of 89.40%.The rest of this work is organized as follows.Section 2 reviews the existing atrial fibrillation detection studies.In Section 3, the details of the proposed FNN based atrial fibrillation detection model are described.Section 4 presents experimental results and analysis.Finally, conclusions are summarized in Section 5.

a
higher level.Contrary to the traditional feature extraction methods, the deep learning-based methods have a good self-learning ability to automatically extract discriminative features, which gets rid of the dependence on prior knowledge and artificial feature extraction[8].Wei et al.[9] developed a method by combining a convolutional neural network (CNN) and multiple features of the ECG signal to detect atrial fibrillation.Salloum et al.[10] proposed a recurrent neural network (RNN) based method and evaluated it on the ECG-ID Database and MIT-BIH Arrhythmia Database.Teijeiro et al.[11] also presented an RNN based method to detect atrial fibrillation and verified it on short-term ECG signals in the 2017 PhysioNet Cardiology Computing Challenge.In this challenge, the algorithm integrated F1 score was 0.83, ranking first in the challenge.Yao et al.[12] researched atrial fibrillation detection algorithms based on Multi-scale CNN (MCNN).This algorithm uses the real-time heart rate sequence extracted from the ECG as the input of MCNN to detect atrial fibrillation.Jiménez-Serrano et al.[13]

Figure 1
Figure 1 displays a flowchart of the proposed feedforward neural network (FNN) based atrial fibrillation detection method.The input ECG signal is first preprocessed by wavelet transform and sliding window filtering.Then, useful features are extracted to generate the characteristic matrix.

Figure 1
Figure 1 Flowchart of the proposed FNN based atrial fibrillation detection method

Figure 2 .
The low-frequency component of the sixth layer contains most of the energy of the baseline drift interference (around 0.05~2Hz), the low-frequency band of this layer is removed to correct the baseline drift.Other noises with the ECG can be quantified and removed by the threshold method.The retained scale coefficients and wavelet coefficients can be regarded as the decomposition of the signal after noise reduction, and then the scale coefficients and wavelet coefficients are reconstructed according to the wavelet reconstruction principle.The db6 wavelet is used for reconstruction, thereby recovering the wavelet transformed filtered signal.

Figure 2
Figure 2 Schematic diagram of 6-level wavelet decomposition

Figure 3
Figure 3 Flowchart of sliding window filtering

Figure 4
Figure 4 Flowchart of QRS wave extraction algorithm method as in section 3.1.2.The eigenvalues above TH h  and below TH l  are regarded as outliers, and these outliers will be replaced by these same limits.In addition, if a sample contains NaN values due to feature extraction errors, we will delete the sample from the dataset.The final dataset containing 8503 samples.
The first step is to select the significance level x  and x  which are obtained based on the original feature vector.Then, scale the outlier to x x    within the level.NaN values judged as noise.After that, regularize the feature vectors to the standard normal distribution to scale the input.Finally, extract the largest characteristic variable and set it to P. If P > x x    , delete the characteristic variable, otherwise rebuild the model using remaining variables for fitting.

Figure 5
Figure 5 Flowchart of feature selection using backward elimination methodTo avoid the early stopping of the backward elimination algorithm, we add a slack condition in the feature selection process.If the final accuracy of the current j-round iteration is relatively lower than the previous round iteration (j-1), we delete the feature variables of the current iteration to maximize the accuracy of atrial fibrillation detection.The judgment function is as follows.

Figure 6
Figure 6 The architecture of the proposed feedforward neural network model

Figure 7 Flowchart of FNN training process 4 Experimental Results 4 . 1 Evaluation of the preprocessing method 4 . 1 . 1
Figure 7 Flowchart of FNN training process

Figure 8
Figure 8 Comparison of the signal after preprocessing and noise reduction with the original ECG signal

Figure 9
Figure 9 The detection and calibration of the first 8000 sampling points of the 109th record

Table 1
Comparison of different preprocessing methodsSensitivity (SEN), positive prediction rate (PPR), and deviance (DEV) are used to measure the R-wave detection results.The calculation formulas of SEN, PPR, and DEV are as follows.

Table 2
displays the detection results tested on a total of 109494 heart beats records in the MIT-BIH arrhythmia database.Our method achieves 98.55% SEN, 99.22% PPR, and 2.25% DEV.

Table 2 R
-wave detection results in the MIT-BIH arrhythmia database 80% of the data used for training while 20% of the data used for testing.The learning rate is 0.7 and the momentum is 0 which are the optimized values selected by grid searching.The 10-fold cross-validation is performed to evaluate the proposed FNN model.The 20% of the training data are selected as the validation set to verify the performance of the model in each training period.We randomly divide the mixed dataset into 5 equal parts.During the training process, four groups of five data groups are randomly selected for training.As shown in Table3, the average values of Acc, Sen, Spec, and AUC of the four test results are 83.14%,82.39%, 92.61%, and 87.79%, respectively.

Table 3
Ten-fold cross-validation results of 4 groups of neural network models

Table 4
Comparison results of our method and the other methods