=Paper= {{Paper |id=Vol-3609/paper1 |storemode=property |title=Robust R-peak Detection using Deep Learning based on Integrating Domain Knowledge |pdfUrl=https://ceur-ws.org/Vol-3609/paper1.pdf |volume=Vol-3609 |authors=Oleksii Kovalchuk,Pavlo Radiuk,Olexander Barmak,Iurii Krak |dblpUrl=https://dblp.org/rec/conf/iddm/KovalchukRBK23 }} ==Robust R-peak Detection using Deep Learning based on Integrating Domain Knowledge== https://ceur-ws.org/Vol-3609/paper1.pdf
                         Robust R-peak Detection using Deep Learning based on
                         Integrating Domain Knowledge
                         Oleksii Kovalchuka, Pavlo Radiuka, Olexander Barmaka, Iurii Krakb,c
                         a
                           Khmelnytskyi National University, 11, Institutes str., Khmelnytskyi, 29016, Ukraine
                         b
                           Taras Shevchenko National University of Kyiv, 64/13, Volodymyrska str., Kyiv, 01601, Ukraine
                         c
                           Glushkov Cybernetics Institute, 40, Glushkov ave., Kyiv, 03187, Ukraine


                                          Abstract
                                          Electrocardiography (ECG) is a pivotal clinical technique for assessing heart function by
                                          recording its electrical activity. However, accurate processing and analysis of ECG signals,
                                          particularly the detection of R-peaks, remains challenging. Any inaccuracies in R-peak
                                          detection can significantly impact subsequent stages of analysis, potentially leading to
                                          incorrect diagnoses and treatment decisions. Therefore, in this study, we aim to refine the
                                          approach to identifying R-peaks in ECG signals by integrating knowledge of a reference
                                          ECG signal into the input signal, addressing the critical need for accurate R-peak detection
                                          in diagnosing various cardiac pathologies. The authors propose a novel method involving
                                          the integration of knowledge into the ECG signal, processing this information using a
                                          convolutional neural network, and post-processing the CNN model's results to identify R-
                                          peaks. The method was evaluated using various four well-known ECG databases.
                                          Comparative results, with an error margin of +-25 ms, revealed that the proposed approach
                                          was the top performer across almost all metrics and databases, frequently achieving
                                          accuracy scores of 0.9999 and demonstrating high precision, recall, and F 1-score. Based
                                          on the investigation findings, the proposed approach is robust and reliable, with the best
                                          performance achieved on the QT database test set, offering a balanced and dependable
                                          solution for R-peak detection in ECG signals.

                                          Keywords 1
                                          Healthcare diagnosis, electrocardiogram, ECG monitoring, R-peak detection, domain
                                          knowledge, deep learning

                         1. Introduction
                            The exploration of Electrocardiogram (ECG) processing through artificial intelligence (AI) and deep
                         learning (DL) paradigms has opened up avenues for more precise and timely cardiac anomaly detection,
                         significantly impacting patient care and outcomes. A pivotal component of ECG analysis is the
                         detection of R-peaks, which are crucial for determining heart rate and other cardiac parameters [1], [2].
                         The accurate detection of these peaks is integral for diagnosing a myriad of cardiovascular diseases [3].
                            A standard ECG comprises 12 leads, obtained using 10 electrodes [4]. This allows for the
                         measurement of the heart’s overall electrical potential from 12 different angles. A typical ECG signal
                         diagram is presented in Fig. 1.




                         IDDM’2023: 6th International Conference on Informatics & Data-Driven Medicine, November 17–19, 2023, Bratislava, Slovakia
                         EMAIL: losha.kovalchyk1998@gmail.com (O. Kovalchuk); radiukpavlo@gmail.com (P. Radiuk); аlexander.barmak@gmail.com
                         (O. Barmak); yuri.krak@gmail.com (I. Krak)
                         ORCID: 0000-0001-9828-0941 (O. Kovalchuk); 0000-0003-3609-112X (P. Radiuk); 0000-0003-0739-9678 (O. Barmak); 0000-0002-8043-
                         0785 (I. Krak)
                                    ©️ 2023 Copyright for this paper by its authors.
                                    Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0).
                                    CEUR Workshop Proceedings (CEUR-WS.org)


CEUR
                  ceur-ws.org
Workshop      ISSN 1613-0073
Proceedings
Figure 1: Schematic illustration of leads12 of an ECG signal [4].

    The application of DL in ECG processing presents some challenges that are reflective of the broader
issues in the fusion of healthcare and emerging technologies. Any issues in R-peak detection can
adversely affect all subsequent stages of processing, analysis, and classification of the ECG-signal.
Accordingly, high accuracy in recognizing R-peaks is crucial for advancing the field and unlocking the
full potential of AI and DL in cardiac care. Thus, the primary contribution of this research is the
refinement of the approach to identifying R-peaks in the ECG signal by integrating knowledge of a
reference ECG signal into the input signal.
    The structure of the paper is as follows. In Section 2, we review existing methods for R-peak
detection in ECG signals. Section 3 is comprehensive, detailing the novel approach for R-peak
detection, the CNN architecture used, post-processing methods, datasets employed, neural network
training, and evaluation criteria. In Section 4, the paper examines the results obtained, where we
compare our approach with existing analogs and discuss the implications of the results. Finally, Section
5 concludes the study findings and discusses the potential for future research.

2. Related works
    The primary method of preparing ECG signals for use in DL models involves segmenting cardiac
cycles based on the R-peaks present in the signal. R-peak detection influences the quality of applying DL
methods to address core tasks such as classification and identification [5]. Thus, providing high accuracy
in recognizing R-peaks is mandatory for prompt and robust cardiac care.
    One of the primary hurdles is the diversity and complexity of ECG data. The morphology of ECG
signals can vary extensively among individuals due to factors such as age, gender, and underlying
cardiac or systemic conditions. This heterogeneity necessitates the development of robust algorithms
capable of accurately identifying R-peaks amidst a plethora of signal forms [6]. DL models, especially
convolutional neural networks (CNNs), have shown promise in handling such complex data, yet their
performance can be significantly influenced by the quality and amount of data they are trained on.
    Moreover, the issue of data quality and accessibility is another significant challenge. High-quality,
labeled ECG data is essential for training reliable DL models [7]. However, obtaining such data is often
encumbered by privacy concerns, as well as logistical and financial hurdles [8]. Additionally, the
labeling of ECG data requires expertise in cardiology, further constraining the availability of high-
quality training data.
    Furthermore, the interpretability of DL models remains a major concern. The “black-box” nature of
these models can lead to resistance from healthcare professionals who might find it difficult to trust or
understand the decisions made by the AI [9]. This lack of transparency also poses challenges in
identifying and correcting errors in R-peaks detection, which is critical for ensuring patient safety and
effective diagnosis.
    Currently, there are numerous methods and approaches to detecting the R-peak in ECG signals, with
their effectiveness often reported as approximately 99%. However, in such studies, a large margin of error
is typically used, or it is not mentioned at all. For instance, in study [10], a high reported result for peak
detection in the ECG signal was achieved, but the margin of error was as high as ± 75 milliseconds. This
value results in an overall error window of 150 milliseconds, which exceeds the length of the entire QRS
complex under normal conditions.
    Porr et al. [11]conducted a meta-analysis in their article regarding the results of approaches such as:
Pan and Tompkins by Fariha et al. [12], Hamilton and Tompkins by Ahmad et al. [13], Christov by Xiong
et al [14], and Kalidas by Ivora et al. [15]. As a result of this study, the authors found that each article
reported very high accuracy rates of 98% or more. This can likely be attributed to large time tolerances,
possibly 100 milliseconds or even more.
    Another prominent toolbox for ECG processing is NeuroKit2 [16]. It is an open-source Python tool
tailored for efficient neurophysiological signal processing, catering to both beginners and experts. Its
comprehensive suite for varied signals, from ECG to EMG, ensures broad applicability in research
scenarios. NeuroKit2 ‘s advantages are broad signal compatibility, user-centered design, and emphasis on
research transparency, as for disadvantages, – potential learning curve for novices and reliance on
community contributions for updates and improvements.
    Therefore, in this study, we aim to develop a novel approach based on CNN to R-peak detection in
ECG signals, focusing on reducing the permissible error during peak determination.

3. Methods and materials
   To enhance existing approaches for detecting R-peaks in ECG signals, a method illustrated in Fig. 2
has been proposed.


                 EKG signal                                                              R-peaks



                 Knowledge
                                                        CNN                          Post-processing
                 integration

Figure 2: Schematic of the traditional approach to R-peak detection.

   In this approach, it is suggested to integrate knowledge about the reference cardiac cycle into the
input ECG signal. Specifically, the following stages of information transformation are proposed:
       1. Integration of knowledge about the ECG signal.
       2. Processing of information using a CNN model.
       3. Processing the results of the CNN model to identify R-peaks.

3.1.    Integration of knowledge into the ECG signal
    It is known that in the I-II and V1-V6 leads of the ECG signal, a distinctive feature of the R-peak is
the most positive deviation of the signal at a certain part of the signal. To integrate this knowledge into
each segment of the ECG signal from the formed samples, the steps outlined in Fig. 3 are applied.
    The input receives an ECG signal, S, in the form of a one-dimensional array of values. Based on the
length of the signal, the K array is initialized with zero values, into which integrated knowledge is
recorded.
    In step 1 of the algorithm, a segment of 260 elements is taken from the ECG signal. This number of
elements was determined experimentally and is sufficient to cover a cardiac cycle.
    In step 2, a theoretical identification of the R-peak is conducted, specifically the maximum positive
deviation, p, in the obtained signal segment. The identified maximum deviation undergoes verification
to determine if it is the peak of a wave. If the deviation doesn’t increase from the left and decrease from
the right, then the found deviation is not at the wave’s peak, and the process returns to the first step to
process the next part of the signal. If the verification is successful, the process moves to the next step.
                               Input data: ECG signal S


            1               Take 260 items of ECG signal.


            2                Find maximum deviation p.




                            Is the maximum deviation
                                the top of the wave?                No

                                               Yes

           3             Form the knowledge integration.


           4 Skip the next 100 items of ECG from maximum deviation.



                                 Is the End of the
                                  signal reached?              No
                                              Yes

                Output data: generated knowledge integration K for ECG
                                      signal S

Figure 3: Scheme of the proposed approach to the extraction of R-peaks.

   Step 3 involves populating the K array with knowledge. Based on the identified peak, its global
index, i, in the ECG signal S is determined. Subsequently, the K array is filled with a value of 1 in the
range [i-20, i+20]. This range typically covers the QRS complex, which includes the R-peak.
   Step 4 is optimization oriented. It aims to avoid searching for a new maximum deviation (theoretical
R-peak) immediately after the deviation p found in step 2, as R-peaks appear at specific intervals.
   The outcome of the algorithm is the populated K array. The visualization of overlaying knowledge
on the ECG signal is shown in Fig. 4.




Figure 4: The result of the integration of knowledge into the ECG signal according to the proposed
approach.
3.2.    CNN architecture for detecting R-peak
   At this stage, based on the results of existing approaches to the determination of R-peaks by neural
network means, it is proposed to use the following neural network architecture (Table 1).

Table 1
Architecture of the utilized CNN.
       Layer name          Input        Output        kernel_size   stride       padding       Scale
                                                                                              factor
                                                 Encoder
        Conv1d               2            32               3           1            1
         ReLU
       MaxPool1d                                           2           2
        Conv1d              32            64               3           1            1
         ReLU
       MaxPool1d                                           2           2
        Conv1d              64           128               3           1            1
         ReLU
       MaxPool1d                                           2           2
        Conv1d              128          256               3           1            1
         ReLU
       MaxPool1d                                           2           2
                                                 Decoder
       Upsample                                                                                  2
        Conv1d              256          128               3           1            1
         ReLU
       Upsample                                                                                  2
        Conv1d              128           64               3           1            1
         ReLU
       Upsample                                                                                  2
        Conv1d              64            32               3           1            1
         ReLU
       Upsample                                                                                  2
        Conv1d              32            1                3           1            1
         ReLU
        Sigmoid


3.3.    Post processing to determine R-peaks
    The final stage is designed to process the output of the CNN model, P, to convert it into indices
where the R-peaks are located in the input signal. The output from the CNN network is an array of the
same dimension as the input array with the ECG signal. An example of the CNN network’s output is
illustrated by the red line in Fig. 5.
                        (a)                                                (b)
Figure 5: Output of the CNN: (a) the initial output from the CNN, (b) the overlaid initial output of the
CNN on the input ECG signal.

    The indices of the R-peaks correspond to the indices of the P array elements where the values exceed
a specified threshold. In our study, this threshold is set at 0.1. Additionally, indices are merged if there
is a short interval between the identified segments of indices.

3.4.    Datasets
   In this work, the following four datasets with ECG signals were used:
   •    MIT-BIH Arrhythmia Database (MIT-BIH) [17].
   •    QT Database (QT) [18].
   •    China Physiological Signal Challenge-2020 Database (CPSC-2020) [19].
   •    University of Glasgow Database (UoG) [20].
   MIT-BIH Arrhythmia Database. From the MIT-BIH dataset, signals numbered 108 and 207 were
excluded because parts of the annotation in these signals do not correspond to the peak apex, thereby
preventing accurate training and testing of the neural network. An example of such a signal is shown in
Fig. 6.




Figure 6: An example of a labeled ECG signal from MIT-BIH [17].

   QT Database. Signals belonging to QT have been filtered. From this dataset, signals containing an
incomplete (non-standard) ECG signal were removed. An example of such a signal is presented in
Fig. 7.
Figure 7: An example of an incorrect ECG signal from MIT-BIH that was extracted from [17].

    Given that the signals in the mentioned databases have varying frequencies, additional
transformations were carried out to ensure that all signals from all databases had a frequency of 400
Hz. Signals from these datasets were segmented into fragments of length 4000 for their subsequent use
as input signals for the neural network. Fragments obtained from datasets 1-3 were divided into training
and testing sets in a 70/30 ratio, respectively.
    High Precision ECG Database – University of Glasgow. From this dataset, a separate independent
test set of signals was created. The test set included signal fragments recorded from lead II during the
following experiments (activities): sitting, maths, and walking. Table 2 presents the number of
fragments included in the training and testing sets.

Table 2
Distribution of signals in the used data set.
                Sample title                        Database title                The number of signal fragments
               Training data                           MIT-BIH                                68811
                                                       MIT-BIH                                2484
                   Test data                               QT                                 2148
                                                      CPSC 2020                               24861
              Unique test data                 ECG Database – UoG                              876


3.5.     Training of a neural network
   For training the network, 70% of the dataset formed from the MIT-BIH, QT, and CPSC-2020
databases was used. The training was conducted in two stages. The loss curves for the training and
validation datasets are shown in Fig. 8.
                                               Loss learning curves
          0,02
                                                Training             Validation

        0,015
       Loss




          0,01


        0,005


               0
                    1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59
                                                        Epochs

Figure 8: Training and validation loss learning curves.
   During the first stage of training, the Adam optimizer was used for 45 epochs with a learning rate of
0.001. In this stage, a loss value of 0.000821 was achieved. In the second stage, training was conducted
over 15 epochs with a learning rate of 0.0001, resulting in a loss value of 0.000580. The total training
time was 82 minutes.

3.6.    Evaluation criteria and experiment setup
    Let us represent the count of positive and negative instances in the initial dataset by P and N,
respectively. Applying a classifier categorizes objects into true positives (TP), true negatives (TN), false
positives (FP), and false negatives (FN). This research evaluated the suggested method using various
statistical measures as outlined below.

                                                  TP + TN
                               Accuracy =                      ,                                      (1)
                                             TP + TN + FP + FN
                                                     TP
                                      Precision =         ,                                           (2)
                                                  TP + FP
                                                   TP
                                       Recall =         ,                                             (3)
                                                TP + FN
                                                 2TP
                                      𝐹1 =                .                                           (4)
                                           2TP + FP + FN

    In training our network, we employed the Adam optimizer across 10 epochs, meticulously setting
the training parameters based on insights and empirical evidence from our previous research [21], [22].
Specifically, we manually selected a learning rate within the range of 0.0001 to 0.001, set the weight
decay at 0.0005, fixed the momentum at 0.85, and chose a batch size of 64. This process took place on
a single NVIDIA GeForce GTX 1650 GPU, spanning approximately 155 minutes.
    It is noteworthy that we opted for manual hyperparameter tuning over automatic optimization. This
decision was grounded in our extensive experience in deep learning for R-peak detection, as detailed in
our prior works. We recognized that the unique characteristics and challenges of R-peak detection
render the task highly sensitive to hyperparameter choices. Given this sensitivity, and the fact that
automatic hyperparameter optimization can sometimes lead to suboptimal and overfit models in such
contexts, we concluded that a manual, knowledge-driven approach was more appropriate. This
approach ensured that our model was not only tailored to the specificities of R-peak detection but also
benefited from the proven effectiveness of parameter values validated in our previous successful
applications of deep learning in related domains.
    Experiments were conducted using the following software: Python 3.9 [23], Scikit-learn [24], and
PyTorch [25]. The system utilized for these experiments had the following specifications: Intel Core i7
9th Gen, 16GB RAM, and an NVIDIA GeForce GTX 1650 GPU with 4 GB of video memory.

4. Results and discussion
   When calculating the presented metrics, an error margin of +-25 ms (equivalent to +- 10 points) is
used. Testing of the proposed approach was conducted using test datasets, which were formed from
data not included in the training sets. As a result of the calculations, confusion matrices were generated
for each dataset, as shown in Fig. 9.
                                                                           (b)
                       (a)




                        (c)                                                (d)
Figure 9: Confusion matrices obtained using the proposed approach from experimental testing with
various ECG signal datasets: (a) MIT-BIH, (b) QT, (c) CPSC-2020, and (d) UoG.

   Fig. 10 illustrates the R-peak detection obtained by the proposed approach.
Figure 10: Visualizing different samples with detecting R-peaks obtained by the proposed approach.
The red asterisk (*) symbol denotes the R-peak according to the database annotation, and the green
circle indicates the calculated position of the R-peak.

   A thorough analysis was also conducted on cases where the statistical indicators were found to be
lower. Fig. 11(a) illustrates a case where the proposed approach identified an R-peak that was not
annotated in the database. The result shown in Fig. 11(b) depicts a case where the R-peaks annotated in
the database are marked as a negative deviation, which in this instance is incorrect.




                         (a)                                                (b)
Figure 11: Analysis of cases for which the statistical indicators were lower: (a) an R-peak that was not
annotated in the database, (b) a case where the R-peaks annotated in the database are marked as a
negative deviation.

    The results of R-peak detection using the proposed approach were compared with analogues:
Rodrigues et al. [1], Koka et al. [6], Zahid et al. [10], and NeuroKit2 [16]. When calculating the
statistical indicators, a proposed error margin of +-25 ms was used. The comparative data presented in
Table 3 for the five approaches across four test datasets – MIT, QT, CPSC-2020, and UoG – on metrics
of Accuracy, Precision, Recall, and F1-score, gives insight into their performance and efficacy in
different contexts.
    Analyzing accuracy from Table 3, it is apparent that the approaches by Zahid et al. and Ours are the
standout performers across all databases, frequently achieving a score of 0.9999. They marginally
outperform the others, demonstrating a higher level of detecting R-peaks. NeuroKit2 also demonstrates
high accuracy but slightly trails behind Zahid et al. and Ours.
    Precision is a metric that further emphasizes the robustness of Zahid et al. and Ours, especially in
the MIT and CPSC-2020 databases, where their scores hover around 0.99 (Table 3). Such an outcome
suggests that these approaches have a high rate of true positive predictions. NeuroKit2 follows suit with
commendable precision, notably in the UoG database, where it scores 0.9932, surpassing even Zahid et
al. and Ours.

Table 3
Results of the R-peaks detection. Reminder: ECG signals from the UoG database were not included in
the training set.
          Database             Approach         Accuracy      Precision        Recall       F1-score
            MIT                NeuroKit2         0.9997         0.9644        0.9340         0.9490
            MIT              Rodrigues et al.    0.9992         0.8322        0.9491         0.8868
            MIT                Koka et al.       0.9992         0.8938        0.8699         0.8817
            MIT                Zahid et al.      0.9999         0.9905        0.9858         0.9881
            MIT                    Our           0.9999         0.9909        0.9849         0.9879
             QT                NeuroKit2         0.9997         0.9655        0.9410         0.9531
             QT              Rodrigues et al.    0.9991         0.7824        0.9427         0.8551
             QT                Koka et al.       0.9993         0.8866        0.8767         0.8816
             QT                Zahid et al.      0.9999         0.9789        0.9778         0.9783
             QT                    Our           0.9999         0.9830        0.9808         0.9819
         CPSC-2020             NeuroKit2         0.9997         0.9514        0.9514         0.9514
         CPSC-2020           Rodrigues et al.    0.9989         0.7763        0.9212         0.8426
         CPSC-2020             Koka et al.       0.9995         0.9232        0.8972         0.9100
         CPSC-2020             Zahid et al.      0.9999         0.9855        0.9927         0.9891
         CPSC-2020                 Our           0.9999         0.9851        0.9943         0.9897
            UoG                NeuroKit2         0.9998         0.9932        0.9596         0.9761
            UoG              Rodrigues et al.    0.9996         0.9083        0.9990         0.9515
            UoG                Koka et al.       0.9994         0.9194        0.8968         0.9080
            UoG                Zahid et al.      0.9995         0.9838        0.8666         0.9215
            UoG                    Our           0.9996         0.9856        0.9000         0.9409


    For recall, different databases reflect varying levels of recall for the five approaches (Table 3).
Rodrigues et al. exceeds others in the UoG database with a near-perfect recall of 0.9990, although its
precision is lower. Zahid et al. maintains strong recall performance in the CPSC-2020 database with a
score of 0.9927, indicating a high sensitivity to detecting true positives.
    The F1-score, which is the harmonic mean of precision and recall, reveals a balanced performance
for Zahid et al. and Ours across all databases. They consistently achieve high F 1-scores, indicating a
balanced ratio of precision to recall. NeuroKit2 also shows a balanced performance, particularly in the
UoG database with a value of 0.9761, hinting at its reliability.
    In summation, the approaches by Zahid et al. and Ours are markedly the top performers across
almost all metrics and databases, demonstrating a balanced and reliable performance. Their high scores
in accuracy, precision, and F1-score depict them as robust and dependable approaches. Rodrigues et al.
and NeuroKit2 exhibit specific strengths in recall and precision respectively in certain databases, but
they do not match the all-rounded performance of Zahid et al. and Ours.
    Visual analysis of the detection results showed that in certain segments of the ECG signal, our
approach identifies more R-peaks. For instance, Fig. 12 illustrates a comparison of each method’s
performance on a similar ECG signal, where our proposed approach yielded more accurate results.
                (a)                                 (b)                                 (c)




                         (d)                                                   (e)
Figure 12: Visual comparison of the results of R-peak detection by the considered approaches: (a)
NeuroKit2, (b) Rodrigues et al., (c) Koka et al., (d) Zahid et al, (e) Our approach. Red labels indicate the
location of R-peaks annotated by medical experts, and green labels indicate the R-peaks identified by
the respective approach.

   As per Fig. 12, the observations are as follows:
   •    NeuroKit2 detected two R-peaks with incorrect positioning.
   •    Rodrigues et al. located almost all R-peaks with some positional errors.
   •    Koka et al. missed three R-peaks.
   •    Zahid et al. failed to detect 1 peak.
   •    The proposed approach accurately identified all R-peaks.
   It should be also noted that the best performance of the proposed approach compared to analogues
was achieved on the test set derived from the QT database. For an independent dataset based on the
UoG database, our approach ranked second. This suggests that this dataset contains ECG signals with
characteristics that are either absent or minimally present in the training set. As a result, the CNN model
may not be fully equipped to recognize the R-peak for such ECG signals. For NeuroKit2, such
characteristics are less critical, as it identifies R-peaks as local maxima in QRS complexes found by the
steepness of the ECG signal’s absolute gradient.

5. Conclusions and Future work
    In this study, we focused on refining the approach to identifying R-peaks in the ECG signal by
integrating knowledge of a reference ECG signal into the input signal. The significance of accurate R-
peak detection is emphasized, as it forms the foundation for subsequent analyses of the ECG signal and
the diagnosis of various cardiac pathologies.
    To enhance existing R-peak detection techniques, a novel approach was proposed, which integrates
knowledge about the reference cardiac cycle into the input ECG signal. The process involves three main
stages: (i) the integration of knowledge about the ECG signal, (ii) the processing of this information
using a CNN model, (iii) and post-processing of the results of the CNN model to identify R-peaks. The
CNN architecture utilized was detailed, encompassing both encoding and decoding layers, and was
trained using datasets like MIT-BIH, QT, and CPSC-2020.
    The evaluation of the proposed method was comprehensive using test samples of MIT-BIH, QT,
CPSC-2020, and UoG. An error margin of +-25 ms was used for calculating metrics. The results were
compared with other approaches that represent the state of the art in ECG processing. The proposed
method consistently demonstrated high performance across various metrics and databases. Specifically,
in the MIH-BIH and QT databases, the proposed approach outperformed its analogs achieving 99.99%.
A visual analysis further substantiated the efficacy of the proposed approach, showing that it often
identified more R-peaks accurately compared to other methods.
    However, the research acknowledged certain limitations. In some segments of the ECG signal, the
proposed approach identified more R-peaks, which could be a point of contention. Additionally, while
our approach performed exceptionally well in most cases, there were instances where it missed or
inaccurately positioned R-peaks.
    Future research could delve deeper into refining this integration, exploring other neural network
architectures, applying a wider set of clinical knowledge for further integration, and expanding the
application to other aspects of ECG analysis. The potential to further reduce the error margin and
achieve even more precise results remains an exciting prospect.

6. References
[1] R. Rodrigues and P. Couto, “Semi-supervised learning for ECG classification,” in 2021 Computing
    in Cardiology (CinC), Brno, Czech Republic, 13-15 September 2021: IEEE, Sep. 2021, pp. 1–4.
    doi: 10.23919/CinC53138.2021.9662693.
[2] P. M. Tripathi, A. Kumar, R. Komaragiri, and M. Kumar, “A review on computational methods
    for denoising and detecting ECG signals to detect cardiovascular diseases,” Arch Computat
    Methods Eng, vol. 29, no. 3, pp. 1875–1914, May 2022, doi: 10.1007/s11831-021-09642-2.
[3] T. Anbalagan, M. K. Nath, D. Vijayalakshmi, and A. Anbalagan, “Analysis of various techniques
    for ECG signal in healthcare, past, present, and future,” Biomedical Engineering Advances, vol.
    6, p. 100089, 2023, doi: 10.1016/j.bea.2023.100089.
[4] “The ECG leads: Electrodes, limb leads, chest (precordial) leads and the 12-Lead ECG,” ECG &
    ECHO. Accessed: Sep. 26, 2023. [Online]. Available: https://ecgwaves.com/topic/ekg-ecg-leads-
    electrodes-systems-limb-chest-precordial/
[5] X. Peng, H. Zhu, X. Zhou, C. Pan, and Z. Ke, “ECG signals segmentation using deep
    spatiotemporal feature fusion U-Net for QRS complexes and R-peak detection,” IEEE
    Transactions on Instrumentation and Measurement, vol. 72, pp. 1–12, 2023, doi:
    10.1109/TIM.2023.3241997.
[6] T. Koka and M. Muma, “Fast and sample accurate R-peak detection for noisy ECG using visibility
    graphs,” in 2022 44th Annual International Conference of the IEEE Engineering in Medicine &
    Biology Society (EMBC-2022), Glasgow, Scotland, United Kingdom, 11-15 July 2022: IEEE Inc.,
    2022, pp. 121–126. doi: 10.1109/EMBC48229.2022.9871266.
[7] O. Kovalchuk, P. Radiuk, O. Barmak, and I. Krak, “A novel feature vector for ECG classification
    using deep learning,” in Proceedings of the 4th International Workshop on Intelligent Information
    Technologies & Systems of Information Security (IntelITSIS-2023), Khmelnytskyi, Ukraine,
    March 22–24, 2023: CEUR-WS, 2023, pp. 227–238. [Online]. Available: https://ceur-ws.org/Vol-
    3373/paper12.pdf
[8] A. Raza, K. P. Tran, L. Koehl, and S. Li, “Designing ECG monitoring healthcare system with
    federated transfer learning and explainable AI,” Knowledge-Based Systems, vol. 236, p. 107763,
    2022, doi: 10.1016/j.knosys.2021.107763.
[9] P. Radiuk, O. Kovalchuk, V. Slobodzian, E. Manziuk, and I. Krak, “Human-in-the-loop approach
    based on MRI and ECG for healthcare diagnosis,” in Proceedings of the 5th International
    Conference on Informatics & Data-Driven Medicine, Lyon, France, 18-20 November: CEUR-
    WS.org, 2022, pp. 9–20. [Online]. Available: https://ceur-ws.org/Vol-3302/paper1.pdf
[10] M. U. Zahid et al., “Robust R-peak detection in low-quality holter ECGs using 1D convolutional
     neural network,” IEEE Trans. Biomed. Eng., vol. 69, no. 1, pp. 119–128, 2022, doi:
     10.1109/TBME.2021.3088218.
[11] B. Porr and P. W. Macfarlane, “A new QRS detector stress test combining temporal jitter and
     accuracy (JA) reveals significant performance differences amongst popular detectors.” bioRxiv, p.
     722397, Jul. 27, 2023. doi: 10.1101/722397.
[12] M. A. Z. Fariha, R. Ikeura, S. Hayakawa, and S. Tsutsumi, “Analysis of pan-tompkins algorithm
     performance with noisy ECG signals,” J. Phys.: Conf. Ser., vol. 1532, no. 1, p. 012022, 2020, doi:
     10.1088/1742-6596/1532/1/012022.
[13] I. Ahmad, “QRS detection for heart rate monitoring,” International Journal of Electrical
     Engineering and Technology, vol. 11, no. 4, pp. 360–367, 2020.
[14] H. Xiong, M. Liang, and J. Liu, “A real-time QRS detection algorithm based on energy
     segmentation for exercise electrocardiogram,” Circuits Syst Signal Process, vol. 40, no. 10, pp.
     4969–4985, 2021, doi: 10.1007/s00034-021-01702-z.
[15] A. Ivora et al., “QRS detection and classification in Holter ECG data in one inference step,” Sci
     Rep, vol. 12, no. 1, Art. no. 1, 2022, doi: 10.1038/s41598-022-16517-4.
[16] D. Makowski et al., “NeuroKit2: A Python toolbox for neurophysiological signal processing,”
     Behav Res, vol. 53, no. 4, pp. 1689–1696, 2021, doi: 10.3758/s13428-020-01516-y.
[17] G. B. Moody and R. G. Mark, “MIT-BIH Arrhythmia Database.” physionet.org, PhysioNet, 2005.
     doi: 10.13026/C2F305.
[18] P. Laguna, R. G. Mark, A. L. Goldberger, and G. B. Moody, “The QT Database.” physionet.org,
     PhysioNet, 1999. doi: 10.13026/C24K53.
[19] Z. Cai et al., “An open-access long-term wearable ECG database for premature ventricular
     contractions and supraventricular premature beat detection,” Journal of Medical Imaging and
     Health Informatics, vol. 10, no. 11, pp. 2663–2667, 2020, doi: 10.1166/jmihi.2020.3289.
[20] L. Howell and B. Porr, “High precision ECG Database with annotated R peaks, recorded and
     filmed under realistic conditions.” University of Glasgow, University of Glasgow, Luis Howell,
     2018. doi: 10.5525/gla.researchdata.716.
[21] I. Krak, O. Barmak, and P. Radiuk, “Detection of early pneumonia on individual CT scans with
     dilated convolutions,” in Proceedings of the 2nd International Workshop on Intelligent Information
     Technologies & Systems of Information Security (IntelITSIS-2021), T. Hovorushchenko, O.
     Savenko, P. Popov, and S. Lysenko, Eds., Khmelnytskyi, Ukraine, March 24–26, 2021: CEUR-
     WS.org, 2021, pp. 214–227. Accessed: May 09, 2021. [Online]. Available: http://ceur-ws.org/Vol-
     2853/
[22] P. Radiuk, O. Barmak, and I. Krak, “An approach to early diagnosis of pneumonia on individual
     radiographs based on the CNN information technology,” The Open Bioinformatics Journal, vol.
     14, no. 1, pp. 92–105, Jun. 2021, doi: 10.2174/1875036202114010093.
[23] “Python 3.9.0,” Python.org. Accessed: Sep. 26, 2023. [Online]. Available:
     https://www.python.org/downloads/release/python-390/
[24] F. Pedregosa et al., “Scikit-learn: Machine learning in Python.” arXiv, Jun. 05, 2018. doi:
     10.48550/arXiv.1201.0490.
[25] A. Paszke et al., “PyTorch: An imperative style, high-performance deep learning library,” in
     Advances in Neural Information Processing Systems, H. Wallach, H. Larochelle, A. Beygelzimer,
     F. d\textquotesingle Alché-Buc, E. Fox, and R. Garnett, Eds., Vancouver, BC, Canada, December
     8–14, 2019: Curran Associates, Inc., 2019, pp. 8024–8035. [Online]. Available:
     https://dl.acm.org/doi/abs/10.5555/3454287.3455008