P-Wave Detection Using a Fully Convolutional Neural Network in Electrocardiogram Images

: Electrocardiogram (ECG) signal analysis is a critical task in diagnosing the presence of any cardiac disorder. There are limited studies on detecting P-waves in various atrial arrhythmias, such as atrial ﬁbrillation (AFIB), atrial ﬂutter, junctional rhythm, and other arrhythmias due to P-wave variability and absence in various cases. Thus, there is a growing need to develop an e ﬃ cient automated algorithm that annotates a 2D printed version of P-waves in the well-known ECG signal databases for validation purposes. To our knowledge, no one has annotated P-waves in the MIT-BIH atrial ﬁbrillation database. Therefore, it is a challenge to manually annotate P-waves in the MIT-BIH AF database and to develop an automated algorithm to detect the absence and presence of di ﬀ erent shapes of P-waves. In this paper, we present the manual annotation of P-waves in the well-known MIT-BIH AF database with the aid of a cardiologist. In addition, we provide an automatic P-wave segmentation for the same database using a fully convolutional neural network model (U-Net). This algorithm works on 2D imagery of printed ECG signals, as this type of imagery is the most commonly used in developing countries. The proposed automatic P-wave detection method obtained an accuracy and sensitivity of 98.56% and 98.78%, respectively, over the ﬁrst 5 min of the second lead of the MIT-BIH AF database (a total of 8280 beats). Moreover, the proposed method is validated using the well-known automatically and manually annotated QT database (a total of 11,201 and 3194 automatically and manually annotated beats, respectively). This results in accuracies of 98.98 and 98.9%, and sensitivities of 98.97 and 97.24% for the automatically and manually annotated QT databases, respectively. Thus, these results indicate that the proposed automatic method can be used for analyzing long-printed ECG signals on mobile battery-driven devices using only images of the ECG signals, without the need for a cardiologist.


Introduction
According to the World Health Organization, deaths due to cardiac disorder will reach about 23.3 million worldwide by 2030 [1].Therefore, improvement in cardiovascular diagnosis technologies is especially important for humanity.
In developed countries, modern electrocardiograms (ECGs) that produce digital output are the most commonly used diagnosis technology.On the other hand, in developing countries, paper-based ECGs are still dominant [2,3].This study is concerned with the medical environment in developing countries where paper-based ECGs are used.These paper-based ECG images require digitization so that they can be transformed into 1D signals in order to apply the state-of-the-art algorithms that have been well studied in the literature.Working on a digitized version of paper-based ECGs (1D version) has important advantages in terms of storage space and the ease of exchanging patients' clinical information between healthcare facilities [2,4,5].Yet, certain limitations remain, such as dealing with alignment issues, the loss of relative timing between leads, and inaccuracy in high-frequency regions, to name of few.Moreover, digitizing the output of paper-based ECGs requires costly and complicated algorithms [6].Thus, there is a need to develop a highly accurate and sensitive automatic segmentation algorithm that works directly on paper-based ECGs (a 2D version) without the need for digitization.
An ECG signal consists of these main components: the P-waves, followed by the QRS complex, and then the T-waves [7].In many cases, cardiologists need to manually analyze ECG recordings acquired from patients over several days, making the task very troublesome and time-consuming [8].The automatic annotation of ECG waves is important for understanding the regulation of heartbeats during sleep and hypertension [9][10][11][12][13][14], for diagnosing several cardiac arrhythmias [15][16][17][18][19][20][21][22], and for detecting other atrial disorders.Many research methods have been devoted to annotating the QRS complex (R-peaks) [23].Although R-peaks have robust noise resistance due to their high signal-to noise ratio (SNR), there is a limitation in the information conveyed by them.Annotation of P-waves is even more challenging for many reasons, such as a low SNR, the possible overlapping of P-and T-waves, and their absence and variability due to some specific morphologies [24].
To our knowledge, there have been limited attempts to automatically annotate P-waves in available standard datasets [25].This is due to a lack of available standard datasets with annotated P-waves used as a benchmark for validation.Therefore, there is a growing need for P-wave annotation in different available datasets.
The QT Database [26] is considered one of the most commonly used databases for P-wave annotation purposes.This database contains a total of 105 15-min records of two-channel ECGs, each sampled at 250 Hz.The records have been selected mainly from the currently available ECG databases, including the MIT-BIH Arrhythmia Database [27], the European Society of Cardiology ST-T Database [28], and several other ECG databases obtained at the Beth Israel Deaconess Medical Center in Boston, and recordings of patients who experienced sudden cardiac death.This makes this dataset an excellent source of varied and well-characterized data.
The MIT-BIH AF database [29,30] is considered a challenging database for P-wave annotation.This dataset contains a total of 25 10-h records of two-channel ECGs, each sampled at 250 Hz.The records are of people suffering from atrial problems, such as atrial fibrillation (AFIB), atrial flutter (AFL), junctional rhythms (AV), and other rhythms.Unfortunately, the MIT-BIH AF database [29,30] includes only annotations of R-peaks and lacks P-wave annotation.Hence, in this paper, the manual annotation of P-waves in the MIT-BIH AF database [29,30] is performed with the help of a cardiologist who was used as a benchmark for the evaluation of different algorithms.However, there is no guarantee that all present P-waves have been labeled, nor that all labels are correct.
In the literature, P-waves have been automatically detected using different techniques.In [31][32][33][34][35][36][37], the authors presented an automatic P-waves detection technique based on wavelet transform.However, the authors in [31][32][33] did not validate the algorithms with any standard databases.In [33], no P-wave delineation criterion is explained.In [38][39][40], the authors proposed an automated P-wave detection method based on second order derivatives and low-pass differentiation.In [41,42], other algorithms for automatic P-wave detection based on adaptive threshold are presented.Although the algorithm in [42] achieved high sensitivity, it was not validated with any standard database.In [43][44][45], the authors introduced deep neural networks for P-wave detection.The authors of [43], used a neural network with asymmetric basis functions for the purpose of extracting the features of P-waves in the MIT-BIH Arrhythmia Database [27], but the detection rate is not mentioned.
Over the past few years, deep convolutional neural networks have gained attention in the field of visual recognition [46,47].However, in biomedical image processing, the desired output should include localization and pixel labels.In [48], the authors trained a deep convolutional network using a sliding-window to label each pixel in the image by providing a patch around that pixel as an input.This network is good at localizing, but suffers from redundancy, due to overlapping patches.In [49], the authors introduced the U-Net fully convolutional neural network architecture.This network provides good classification, as well as localization, using very few training images.
To our knowledge, this paper is the first to introduce the manual annotation of P-waves in the MIT-BIH AF database [29,30] to be used as a benchmark for validation and evaluation purposes.In addition, it introduces an automated prediction algorithm for P-waves, with their variable morphologies, in the aforementioned database.This should help clinicians in diagnosing several cardiac arrhythmias.Furthermore, the proposed algorithm works on printed ECG signals, which are the most commonly used in developing countries, without the need for digitalization, as in [2].The proposed automated algorithm uses U-Net deep fully convolutional networks.The proposed algorithm is validated over the well-known QT database [26] and the performance is compared to other algorithms in the literature.
This paper is organized as follows; in Section 2, we provide information on datasets used in this article.In addition, we introduce the proposed algorithm.In Section 3, we present the experimental results obtained, and our conclusions are given in Section 4.

Used Databases
The presence of standard ECG databases is essential for the evaluation of ECG signal detection algorithms.Most of these databases contain annotation files for QRS, but lack P-wave annotation.In this study, two databases were used to evaluate the performance of the proposed algorithm.A self-annotated database (MIT-BIH AF database) and a standard annotated database (QT database).In Table 1, we provide a summary of the aforementioned databases.The MIT-BIH AF database [29,30] recordings were made at Boston's Beth Israel Hospital (now the Beth Israel Deaconess Medical Center) using ambulatory ECG recorders with a typical recording bandwidth of approximately 0.1 to 40 Hz.This database contains 605 episodes for different rhythms of atrial fibrillation (AFIB), atrial flutter (AFL), junctional rhythms (AV), and other rhythms.This database provides an opportunity to test the robustness of P-wave detection in many different cases: the absence of P-waves in AFIB (f-waves), sawtooth P-waves in AFL, inverted P-waves in AV, and normal P-waves in other rhythms.
Annotation files for R-peaks in this standard database are available for the evaluation of the QRS detection algorithms, but, this is not the case for P-waves.Thus, in this paper, a cardiologist manually annotated the P-waves in the MIT-BIH AF database [29,30].Manual annotation is performed for the first 5 min of each record from Lead II, as sinus P-waves are usually most prominently seen in Lead II [3].Figures 1 and 2 provide samples of the manual annotations obtained, where P-waves have sometimes been detected for normal and abnormal beats, and other times are absent for atrial fibrillation.The annotation file of P-waves can be found as Supplementary Material.Since the MIT-BIH AF database [29,30] is self-annotated, a standard annotated database must be used to validate the proposed automatic algorithm.The standard annotated QT database [26] is used for this purpose.
This database has two types of annotations: manual annotation and automatic annotation.The manual annotation was carried by two cardiologists who annotated only the selected beats (in a file called "q1c") in all recordings except "sel35" and "sel37".The automatic annotation of the whole database was carried out using ECGPUWAVE" software, which reads "pu" files.In this study, the P-wave duration of Lead II of the entire automatically annotated QT database [26], along with the manually annotated beats for the same database, is used for validation purposes for the proposed automatic detection algorithm.

Proposed P-Wave Image-Based Detection Algorithm
In this study, a knowledge-based P-wave detection algorithm based on fully convolutional networks is proposed and evaluated.This algorithm is inspired by the framework proposed in [49], which is mainly used for the segmentation of biomedical images, such as brain lesion segmentation [50], tumor segmentation [51], and many other segmentation applications.We build upon this approach to automatically detect P-waves from ECG images, taking into consideration that an ECG is always printed on a grid paper.The grid background can be removed by the algorithm proposed in [2], as a pre-processing stage.Our proposed algorithm is then used to detect P-waves in the imagebased ECG.

Segmentation via U-Net Architecture
The U-Net is a fully convolutional network that was developed in [49] for biomedical image segmentation.The goal of the U-Net is to produce a semantic segmentation, with an output that is the same size as the original input image, but in which each pixel in the image is colored one of X colors, where X represents the number of classes to be segmented.
The U-Net architecture, as shown in Figure 3, consists of two paths.The first path is the encoder path, which is used to capture the image's contents.The encoder is just traditional blocks of convolutional and maximum pooling layers.The convolutional operation has two inputs: the input image of size n*n* number of channels, where n*n is the image pixel size and there is a set of 'k' filters (also called kernels or feature extractors), each one of size f × f × number of channels, where f is typically 3 [52].The output of a convolutional operation is also a 3D output image of size (nout × nout × k).The relationship between nin and nout is given by [49] (c) (d) Amplitude (mv.) Amplitude (mv.)Time (sec.)Time (sec.) Since the MIT-BIH AF database [29,30] is self-annotated, a standard annotated database must be used to validate the proposed automatic algorithm.The standard annotated QT database [26] is used for this purpose.
This database has two types of annotations: manual annotation and automatic annotation.The manual annotation was carried by two cardiologists who annotated only the selected beats (in a file called "q1c") in all recordings except "sel35" and "sel37".The automatic annotation of the whole database was carried out using ECGPUWAVE" software, which reads "pu" files.In this study, the P-wave duration of Lead II of the entire automatically annotated QT database [26], along with the manually annotated beats for the same database, is used for validation purposes for the proposed automatic detection algorithm.

Proposed P-Wave Image-Based Detection Algorithm
In this study, a knowledge-based P-wave detection algorithm based on fully convolutional networks is proposed and evaluated.This algorithm is inspired by the framework proposed in [49], which is mainly used for the segmentation of biomedical images, such as brain lesion segmentation [50], tumor segmentation [51], and many other segmentation applications.We build upon this approach to automatically detect P-waves from ECG images, taking into consideration that an ECG is always printed on a grid paper.The grid background can be removed by the algorithm proposed in [2], as a pre-processing stage.Our proposed algorithm is then used to detect P-waves in the image-based ECG.

Segmentation via U-Net Architecture
The U-Net is a fully convolutional network that was developed in [49] for biomedical image segmentation.The goal of the U-Net is to produce a semantic segmentation, with an output that is the same size as the original input image, but in which each pixel in the image is colored one of X colors, where X represents the number of classes to be segmented.
The U-Net architecture, as shown in Figure 3, consists of two paths.The first path is the encoder path, which is used to capture the image's contents.The encoder is just traditional blocks of convolutional and maximum pooling layers.The convolutional operation has two inputs: the input image of size n*n* number of channels, where n*n is the image pixel size and there is a set of 'k' filters (also called kernels or feature extractors), each one of size f × f × number of channels, where f is typically 3 [52].The output of a convolutional operation is also a 3D output image of size (n out × n out × k).The relationship between n in and n out is given by [49] where n in is the number of input features, n out is the number of output features, k is the convolution kernel size, p is the convolution padding size, and s is the convolution stride size.
Appl.Sci.2020, 10, x FOR PEER REVIEW 6 of 21 where nin is the number of input features, nout is the number of output features, k is the convolution kernel size, p is the convolution padding size, and s is the convolution stride size.The maximum pooling layer is then used to retain the maximum value of a pre-defined area and stores its position in a switch variable.This creates a pooling map that reduces the feature map size, which results in fewer network parameters.
The filter and stride sizes are two important parameters in the maximum pooling operation.The idea is to retain only the important features of the maximum valued pixels from each region and neglect the rest.Both the convolution operation and the pooling operation result in down-sampled images.When applying the convolution operation again, the filters in the next layer will be able to show the larger context.As the number of filters used gradually increases, more complex features from the image can be extracted.By down-sampling, the model better understands what is present in the image, but it loses the information of where it is present.
The second path is the decoder, which is used to obtain precise localization using transposed convolutions.Transposed convolution (deconvolution) is a technique to perform the up-sampling of an image with learnable parameters.Transposed convolution is exactly the opposite process of a normal convolution, where the input volume is a low-resolution image and the output volume is a high-resolution image with location information.It is followed by the merged layer, where the output of the transposed convolution layers is merged with the feature maps from the encoder at the same level to obtain more precise locations.

Experimental Setup
The U-Net model was run on a K80 GPU with a total of 12 GB of ram with the Python 3.5 anaconda package, tensor flow 1.2.1, and Keras 1.0.As the MIT-BIH AF database [29,30] consists of ECG signals in the time domain while the U-Net inputs must be images, the data were first converted to 2D ECG images.This makes this approach applicable to any printed ECG signal after background

Encoder stage
Decoder stage The maximum pooling layer is then used to retain the maximum value of a pre-defined area and stores its position in a switch variable.This creates a pooling map that reduces the feature map size, which results in fewer network parameters.
The filter and stride sizes are two important parameters in the maximum pooling operation.The idea is to retain only the important features of the maximum valued pixels from each region and neglect the rest.Both the convolution operation and the pooling operation result in down-sampled images.When applying the convolution operation again, the filters in the next layer will be able to show the larger context.As the number of filters used gradually increases, more complex features from the image can be extracted.By down-sampling, the model better understands what is present in the image, but it loses the information of where it is present.
The second path is the decoder, which is used to obtain precise localization using transposed convolutions.Transposed convolution (deconvolution) is a technique to perform the up-sampling of an image with learnable parameters.Transposed convolution is exactly the opposite process of a normal convolution, where the input volume is a low-resolution image and the output volume is a high-resolution image with location information.It is followed by the merged layer, where the output of the transposed convolution layers is merged with the feature maps from the encoder at the same level to obtain more precise locations.

Experimental Setup
The U-Net model was run on a K80 GPU with a total of 12 GB of ram with the Python 3.5 anaconda package, tensor flow 1.2.1, and Keras 1.0.As the MIT-BIH AF database [29,30] consists of ECG signals in the time domain while the U-Net inputs must be images, the data were first converted to 2D ECG images.This makes this approach applicable to any printed ECG signal after background removal.A total of 690 one-channel input images of time-domain ECG signals were used, each of 10 s from the MIT-BIH AF database [29,30].They were divided into a training set and a testing set (2:1).Every image had corresponding manually annotated ground truth labeling.Four hundred and sixty images were used for training.This number of images is not nearly enough to feed a deep learning neural network.Therefore, we used a module called "ImageDataGenerator" in a Keras preprocessing image to perform data augmentation [48].The remaining images (230 images) were used to test the trained U-Net model.The model takes less than 15 min to train over 20 epochs.This number of epochs was used as the test accuracy did not increase much for the last five epochs, as shown in Figure 4.
In the encoder process of the U-Net model, each input image of size 512 × 512 × 1 was first fed to two convolutional layers of size 2 × 2 and strides of 2, and this process was repeated until an output image size of 32 × 32 × 1024 was obtained, while in the decoder process successive layers of deconvolution and merge layers were applied till the output image of size 512 × 512 × 1 was obtained.The output represents the segmented P-waves and their corresponding locations.
Appl.Sci.2020, 10, x FOR PEER REVIEW 7 of 21 removal.A total of 690 one-channel input images of time-domain ECG signals were used, each of 10 s from the MIT-BIH AF database [29,30].They were divided into a training set and a testing set (2:1).Every image had corresponding manually annotated ground truth labeling.Four hundred and sixty images were used for training.This number of images is not nearly enough to feed a deep learning neural network.Therefore, we used a module called "ImageDataGenerator" in a Keras preprocessing image to perform data augmentation [48].The remaining images (230 images) were used to test the trained U-Net model.The model takes less than 15 min to train over 20 epochs.This number of epochs was used as the test accuracy did not increase much for the last five epochs, as shown in Figure 4.
In the encoder process of the U-Net model, each input image of size 512 × 512 × 1 was first fed to two convolutional layers of size 2 × 2 and strides of 2, and this process was repeated until an output image size of 32 × 32 × 1024 was obtained, while in the decoder process successive layers of deconvolution and merge layers were applied till the output image of size 512 × 512 × 1 was obtained.The output represents the segmented P-waves and their corresponding locations.Since there are only two classes (P and no P), each pixel within the image has a value between 0 and 1. Zero represents no P-waves, and 1 represents P-wave presence.We take 0.5 as the threshold to decide whether to classify a pixel as 0 or 1.

Evaluation Metrics
The performance of the P-wave detection algorithms were evaluated using three statistical measures: sensitivity (SE), positive predictivity (+P), and accuracy given by Equations ( 2)-( 4), where TP represents the number of true positives (P-waves as detected similarly to the manually annotated P-waves), FN represents the number of false negatives (the annotated P-wave has not been detected by the proposed method), and FP represents the number of false positives (P-waves detected by the system but not similar to the manually annotated data).

𝑆𝐸 = 𝑇𝑃 𝑇𝑃 + 𝐹𝑁
(2)  Since there are only two classes (P and no P), each pixel within the image has a value between 0 and 1. Zero represents no P-waves, and 1 represents P-wave presence.We take 0.5 as the threshold to decide whether to classify a pixel as 0 or 1.

Evaluation Metrics
The performance of the P-wave detection algorithms were evaluated using three statistical measures: sensitivity (SE), positive predictivity (+P), and accuracy given by Equations ( 2)-( 4), where TP represents the number of true positives (P-waves as detected similarly to the manually annotated P-waves), FN represents the number of false negatives (the annotated P-wave has not been detected by the proposed method), and FP represents the number of false positives (P-waves detected by the system but not similar to the manually annotated data).

Evaluation Results
The proposed algorithm was evaluated using the MIT-BIH AF database.The MIT-BIH AF database [29,30] contains ECG signals with no P-waves in the case of AFIB, sawtooth P-waves in the case of AFL, and normal P-waves in other cases.Figure 5 indicates that the proposed algorithm is able to successfully detect the P-waves, even when the P-and T-waves are merged in the ECG signals.
It correctly located P-waves in normal and abnormal cases.The abnormal cases have overlapping P and T waves, the presence of U-waves between P-and T-waves, and negative polarization.It can also be deduced that the proposed algorithm is not affected by noise and that it is thus a robust algorithm.

Evaluation Results
The proposed algorithm was evaluated using the MIT-BIH AF database.The MIT-BIH AF database [29,30] contains ECG signals with no P-waves in the case of AFIB, sawtooth P-waves in the case of AFL, and normal P-waves in other cases.Figure 5 indicates that the proposed algorithm is able to successfully detect the P-waves, even when the P-and T-waves are merged in the ECG signals.
It correctly located P-waves in normal and abnormal cases.The abnormal cases have overlapping P and T waves, the presence of U-waves between P-and T-waves, and negative polarization.It can also be deduced that the proposed algorithm is not affected by noise and that it is thus a robust algorithm.Table 2 illustrates the evaluation results obtained over the test data in 23 records of the MIT-BIH AF database.These results were obtained by training the model using 460 images of ECG recordings, each consisting of 10 s for 23 patients (00735 and 03665 are unavailable signals), and tested by using 230 images of the same specifications for the same patients.The proposed algorithm achieved a training accuracy of 99.8%, a testing accuracy of 98.56% after 20 epochs, a sensitivity of 98.78%, and a positive predictivity of 97.41%.

Performance Validation and Discussion
As the MIT-BIH AF database is self-annotated, it is essential to validate the performance of the proposed algorithm over a standard annotated database.Thus, the well-known QT database [26] was used for this purpose.The algorithm was applied on the automatically annotated records of the QT database, and the performance was compared to [45].The authors in [45] combined four different deep recurrent neural networks (RNNs), for example, long-short term memory (LSTM), and each was trained to extract useful features from ECG signals and determine the absence or presence of P-waves.The outputs of these networks were then combined for the final detection of P-waves using a five-fold cross-validation method.This output was then evaluated using the automatically annotated QT database.In addition, the proposed algorithm was applied to the manually annotated beats in the QT database and the results were compared to [35,37,39,40,44].The authors in [35,37] detected P-waves depending on wavelet transform.In [39,40], the authors proposed automated P-wave detection algorithms based on second-order derivatives and low-pass differentiation.These techniques are mathematically simple.However, they only detect monophasic P-waves and are not suitable for biphasic waves.In [44], three different deep neural network architectures were implemented and their results were compared to each other's, showing that the best P-wave detection architecture is the ConvNet.

Automatically Annotated QT Database Results
The detection performance of the automatically annotated QT database obtained by the proposed P-wave detector is shown in Table 3. 9450 images were divided into 6300 images for training and 3150 images for testing.When comparing the output to the automatic annotation, the detection performance over the automatically annotated QT database obtained an average SE of 98.97%, a +P of 99.45%, a training accuracy of 99.7% and a test accuracy of 98.74%.Table 4 summarizes the performance comparison of the proposed P-wave detection algorithm over the automatically annotated QT database along with [45].The performance comparison is in terms of the number of beats, methodology, SE, and accuracy.Using five-fold validation, the proposed algorithm achieved an average sensitivity of 98.4% and an accuracy of 98.74%.The proposed algorithm scored slightly higher performances on SE and accuracy overall when compared to [45].It is clear that the proposed algorithm can handle ECG recordings with high performance over the 111,201 automatically annotated heartbeats.The detection performance on the manually annotated QT database obtained by the proposed P-wave detector is shown in Table 5.As the manually annotated beats are random, the whole database was introduced to the automatic detector.9,450 images were divided into 6300 images for training and 3150 images for testing.When comparing the output to the manual annotation, the detection performance over the manually annotated QT database obtained an average SE of 97.24%, a +P of 97.22%, a training accuracy of 99.92%, and a test accuracy of 98.9%.Table 6 summarizes the performance comparison of the proposed P-wave detection algorithm over the manually annotated QT database along with [35,37,39,40,44].The comparison is in terms of the number of beats, the methodology, SE, and accuracy.The proposed algorithm scored a lower sensitivity and a higher +P than that achieved using wavelet transform in [35,37,39].Fortunately, our proposed algorithm achieved a higher accuracy than that achieved by the ConvNet proposed in [44].Moreover, the proposed algorithm's performance is comparable to other algorithm performances found in the literature [53].Thus, the results are promising, as the algorithm can detect P-waves over different databases, sampling frequencies, different types of arrhythmias, and noise

Conclusions
Automatic analysis of an ECG signal delivers important information for diagnosis to medical experts.The MIT-BIH AF database is considered a challenging ECG database, as it contains various types of ECG signals.To our knowledge, this paper is the first to manually annotate P-waves in the MIT-BIH AF database.In addition, it is the first to develop an efficient automated algorithm to detect the absence or presence of the different shapes of P-waves using a fully convolutional neural network model (U-Net).This automated algorithm works on 2D images of printed ECGs without the need for its digitization.
The proposed automatic P-wave detection method achieved an accuracy and sensitivity of 98.56 and 98.78%, respectively, over the first 5 min of Lead II of the MIT-BIH AF database (a total of 8280 beats).Moreover, the proposed method was validated using the well-known automatically and manually annotated QT database.This resulted in accuracies of 98.98 and 98.9% and sensitivities of 98.97 and 97.24% for the automatically and manually annotated QT database, respectively.Thus, this indicates that the results are promising, as this image-based approach can be applied in analyzing old ECG records when only printed versions are available.It also stands as a benchmark for testing and validation purposes.This study also provides a positive proof of concept for detecting P-waves in abnormal ECG beats with atrial disorders using a small amount of training data.However, further generalization is required to detect QRS complexes and T-waves.

Figure 1 .Figure 1 .
Figure 1.Samples of manually annotated P-waves in the MIT-BIH AF database for normal beats.(a) 05091 record; (b) 08405 record; (c) 08455 record; and (d) 08215 record, where the light blue areas represent P-wave duration.

Figure 1 .
Figure 1.Samples of manually annotated P-waves in the MIT-BIH AF database for normal beats.(a) 05091 record; (b) 08405 record; (c) 08455 record; and (d) 08215 record, where the light blue areas represent P-wave duration.

Figure 2 .
Figure 2. Samples of manually annotated P-waves in the MIT-BIH AF database, where the P-wave is absent in case of atrial fibrillation, (a) 07162 record; (b) 04126 record; (c) 06426 record; and (d) 06995 record.

Figure 3 .
Figure 3. U-Net architecture and the parameters used in the proposed algorithm.Each box contains an n* n* k input and 2@Conv layers (which means that two consecutive convolution Layers are applied).The left-hand side is the contraction path (Encoder), where we apply regular convolutions and max-pooling layers, and the right-hand side is the expansion path (Decoder) where we apply transposed convolutions along with regular convolutions.

Figure 3 .
Figure 3. U-Net architecture and the parameters used in the proposed algorithm.Each box contains an n* n* k input and 2@Conv layers (which means that two consecutive convolution Layers are applied).The left-hand side is the contraction path (Encoder), where we apply regular convolutions and max-pooling layers, and the right-hand side is the expansion path (Decoder) where we apply transposed convolutions along with regular convolutions.

Figure 4 .
Figure 4. Model accuracy chart, where the blue line represents the training accuracy, while the orange one represents the validation (testing) accuracy.

Figure 4 .
Figure 4. Model accuracy chart, where the blue line represents the training accuracy, while the orange one represents the validation (testing) accuracy.

Figure 5 .
Figure 5. Demonstrating the performance of the proposed P-wave detection algorithm on the MIT-BIH atrial fibrillation database.The P-wave is detected in electrocardiogram (ECG) signals that contain: (a) high-frequency noise; (b) normal sinus rhythm without U-waves; (c) normal sinus rhythm with U-waves; (d) normal sinus rhythm with negative polarization; (e) merged P-and T-waves.Here, the red circle asterisk represents detection of merged P-and T-waves.(f) No P-wave detected in case of premature atrial fibrillation.

Table 1 .
Databases used for evaluation and validation.

Table 2 .
P-wave detection performance over the annotated MIT-BIH Atrial Fibrillation database.

Table 3 .
P-wave detection performance over the automatically annotated QT database.

Table 4 .
P-wave detection performance comparison on the automatic annotated QT database [N/R: not reported].

Table 5 .
P-wave detection performance over the manual annotated QT database.

Table 6 .
P-wave detection performance comparison on the manual annotated QT database.[N/R: not reported].