=Paper= {{Paper |id=Vol-3736/paper4 |storemode=property |title=ECG Arrhythmia Classification and Interpretation using Convolutional Networks for Intelligent IoT Healthcare System |pdfUrl=https://ceur-ws.org/Vol-3736/paper4.pdf |volume=Vol-3736 |authors=Oleksii Kovalchuk,Olexander Barmak,Pavlo Radiuk,Iurii Krak |dblpUrl=https://dblp.org/rec/conf/icyberphys/KovalchukBRK24 }} ==ECG Arrhythmia Classification and Interpretation using Convolutional Networks for Intelligent IoT Healthcare System== https://ceur-ws.org/Vol-3736/paper4.pdf
                                ECG Arrhythmia Classification and Interpretation
                                using Convolutional Networks for Intelligent IoT
                                Healthcare System
                                Oleksii Kovalchuk1,∗,†, Olexander Barmak1,† Pavlo Radiuk1,†, and Iurii Krak2,3,†
                                1 Khmelnytskyi National University, 11, Institutes str., Khmelnytskyi, 29016, Ukraine
                                2 Taras Shevchenko National University of Kyiv, 64/13, Volodymyrska str., Kyiv, 01601, Ukraine
                                3 Glushkov Cybernetics Institute, 40, Glushkov ave., Kyiv, 03187, Ukraine



                                                 Abstract
                                                 In modern healthcare, timely and precise diagnosis of arrhythmias can significantly impact patient
                                                 outcomes, as arrhythmias are indicative of various cardiac disorders that require immediate attention.
                                                 The classification of these irregular heartbeats based on electrocardiogram (ECG) signals is essential
                                                 for the development of intelligent healthcare systems that can provide real-time monitoring and
                                                 diagnosis, integrating seamlessly into smart city infrastructures and IoT-enabled smart homes. In this
                                                 paper, we propose novel methods to enhance the classification and interpretation of arrhythmia by
                                                 ECG signals based on convolutional neural network (CNN). Leveraging the MIT-BIH Arrhythmia
                                                 Database, which includes 48 recordings from 47 patients, the proposed approach involved
                                                 preprocessing the ECG signals into fragments and enhancing the CNN architecture with Batch
                                                 Normalization layers and an additional convolutional layer. The network was trained and validated
                                                 using statistical metrics namely accuracy, precision, recall, and F1-scores. The results demonstrated
                                                 an overall classification accuracy of 99.43%, with particularly high precision and recall for Normal
                                                 beats, Right bundle branch block beats, and Left bundle branch block beats, achieving F1-scores close
                                                 to 100%. The introduced CNN showed superior performance in distinguishing between nine types of
                                                 arrhythmias. However, the study highlighted the limitation of relying on clinical features for decision
                                                 justification, especially in cases of overlapping pathologies. Overall, the findings suggest that the
                                                 proposed approach can serve as a reliable supporting tool for arrhythmia diagnosis, offering high
                                                 accuracy and potential integration into real-time monitoring systems.

                                                 Keywords
                                                ECG classification, ECG interpretation, arrhythmia detection, convolutional neural networks, IoT
                                healthcare, intelligent systems1

                                1. Introduction
                                Over a vast period, healthcare professionals have relied on a multitude of measurements
                                presented as time series to diagnose the state of the human body. Among these, the
                                electrocardiogram (ECG) is crucial for diagnosing heart diseases. In the current era, the
                                proliferation of computing devices, including those belonging to the Internet of Things (IoT),


                                ICyberPhyS-2024: 1st International Workshop on Intelligent & CyberPhysical Systems, June 28, 2024, Khmelnytskyi,
                                Ukraine
                                ∗ Corresponding author.
                                † These authors contributed equally.

                                   losha.kovalchyk1998@gmail.com (O. Kovalchuk); barmako@khmnu.edu.ua (O. Barmak);
                                radiukp@khmnu.edu.ua (P. Radiuk); iurii.krak@knu.ua (Iu. Krak)
                                   0000-0001-9828-0941 (O. Kovalchuk); 0000-0003-0739-9678 (O. Barmak); 0000-0003-3609-112X (P. Radiuk); 0000-
                                0002-8043-0785 (Iu. Krak)
                                            © 2023 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0).




CEUR
                  ceur-ws.org
Workshop      ISSN 1613-0073
Proceedings
has essentially facilitated the collection of such signals [1]. Wearable devices and other IoT
technologies enable the recording and storage of large volumes of ECG data, facilitating its reuse
for various research purposes and expanding the range of consumers of this information [2, 3].
This shift highlights the critical need for efficient processing and accurate decision-making
based on these signals.
    Within the domain of IoT systems, the ability to process and analyze vast amounts of data
from connected devices is crucial. Deep learning (DL) models [4], particularly convolutional
neural networks (CNNs) [5], have emerged as powerful tools for addressing tasks related to
ECG signal analysis and arrhythmia classification [6]. The use of CNNs in this context allows
for the automated and highly accurate interpretation of ECG signals, making them invaluable
in IoT healthcare systems. These intelligent systems enhance the capability of IoT devices to
not only monitor but also provide actionable insights in real-time, significantly improving
health outcomes and preventive care.
    However, the sensitivity of medical diagnoses necessitates not only high accuracy but also
the ability to explain and interpret the decisions made by these AI models, a field known as
explainable artificial intelligence (XAI) [7]. The integration of CNNs with XAI techniques
ensures that healthcare professionals can trust and understand the AI-driven insights [8], thus,
enhancing the reliability and acceptance of these advanced diagnostic tools in real-world
applications [9]. In the context of IoT systems, this ensures that the data collected by smart
devices is not only used effectively but also transparently [10], fostering trust and broader
adoption of IoT-enabled healthcare solutions [11, 12].
    In the field of ECG classification using DL models, several studies have made significant
contributions, each with unique methodologies and insights. Xu and et al. [13] developed a
neural network classifier that identifies five classes, including an “all other” class. However, the
inclusion of the “all other” class can lower overall accuracy due to the broad range of signals it
encompasses, potentially leading to less specificity for certain pathologies. Degirmenci et al.
[14] achieved high accuracy using a 64x64 input data size for arrhythmic heartbeat
classification. Despite this, the significant computational resources required pose challenges for
real-time applications and use on devices with limited processing power. Abdelhafid et al. [15]
focused on ECG arrhythmia classification using five classes without an “all other” class. This
likely contributed to their high classification rates. However, the exclusion of a miscellaneous
class may not reflect real-world accuracy, as it ignores signals that do not fit predefined
categories.
    In addition to the above, Zhang et al. [16] presented an interpretable DL model for
diagnosing 12-lead ECGs. Their work stands out for its interpretability and comprehensive
analysis of multiple leads, offering detailed insights into the diagnostic process. However, the
complexity of their model may hinder its use in simpler or more resource-constrained settings,
as high interpretability often comes at the cost of computational efficiency. Singh and Sharma
[17] proposed a deep CNN for arrhythmia interpretation and classification, demonstrating high
accuracy and efficiency. However, like other studies, they face challenges in real-time
application due to computational demands. Additionally, their work does not address the
classification of signals that do not fit predefined classes, which is crucial for practical
deployment.
    Overall, as stated above, the field of ECG classification using DL models faces several
challenges [18]. For effective arrhythmia detection, it is crucial to develop DL models that might
balance accuracy, computational feasibility, and the ability to handle a wide range of signals,
ensuring practicality and robustness in real-world applications. Thus, to overcome these issues,
this study aims to enhance the classification and interpretation of arrhythmia based on ECG
signals using deep CNN. The main contributions of this work include:

   •   The proposed method for classifying heart activity disorders (arrhythmias) based on
       ECG signals, which differs from known methods due to a modified neural network
       architecture, which is designed to identify nine types of arrhythmias, the volume of
       input data, and the expansion of the list of classes, resulting in improved classification
       quality.
   •   The proposed method for interpreting the classification results of arrhythmias obtained
       using a DL model, which allows presenting the classification results in a form
       understandable to the doctor.

   The structure of this paper is organized as follows: The Methods section details the proposed
method for classifying pathologies in the ECG signal and the proposed method for interpreting
the classification results in a manner, understandable to medical professionals. The Results
section presents the classification and interpretation results demonstrating the effectiveness of
the proposed methods. Finally, the manuscript concludes with the Conclusions section
summarizing the findings and discussing future research directions.

2. Methods
2.1. Method for classification of pathologies on the ECG signal
The proposed method for classifying pathologies in the ECG signal is schematically shown in
Figure 1.


                            Input data: ECG signal and R peak indexes

                                Step 1: Split ECG signal on fragments


                           Step 2: Classify ECG fragments by CNN model


                         Output data: Predicted pathology for each ECG

Figure 1: Schema of the ECG signal classification method for detecting arrhythmia pathologies,
beginning with input data of the ECG signal and R peak indexes, followed by splitting the ECG
signal into fragments (Step 1), classifying each fragment using a CNN model (Step 2), and resulting
in output that reaffirms the initial input data for continuous analysis.

   Input Data for the Method:
   •   ECG Signal: A one-dimensional array S that represents the amplitude of the electrical
       signal measured at specific moments in time for a given lead. The recordings were
       digitized at 360 samples per second with 11-bit resolution within the range of 10 mV.
   •   Indices of R-Peaks: A one-dimensional array P, where each element 𝑝𝑝𝑖𝑖 matches the index
       i in the array S, where an R-peak occurs.

   Output Data: The predicted pathology.
   Below, we examine the main steps of the proposed method.

2.1.1. Splitting the ECG signal into fragments
The first step of the method is aimed at preprocessing the input data and forming a fragment
suitable for classification. Based on domain knowledge from the medical field, it is necessary to
consider not just the current cardiac cycle but also the preceding and succeeding cardiac cycles
to make an accurate decision regarding a specific pathology [19]. Examples of input ECG signal
fragments are shown in Figure 2.




                      (a)                                              (b)




                      (c)                                              (d)
Figure 2: Examples of the input fragments of the ECG signal: (a) ECG-signal with the normal
beat, (b) ECG-signal, representing the right bundle branch block beat, (c) ECG-signal with the
left bundle branch block beat, and (d) ECG-signal, which represent the paced beat.

   As illustrated in Figure 2, the fragment of the signal should contain information on both the
current cardiac cycle (the primary object of classification) and the preceding and subsequent
cardiac cycles. Therefore, the fragment should be constructed to include three cardiac cycles,
with the primary cardiac cycle located in the middle. Preliminary experimental studies [20] have
shown that 700 signal samples are required to represent the three cardiac cycles (for this input
signal format).
   The formed ECG signal fragments are transferred to the second step of the method for
further classification using the CNN model.
2.1.2. Classification of ECG fragments with the CNN model
In the current step of the proposed method, the classification of ECG signal fragments is carried
out using a CNN. This work proposes an enhancement of the CNN architecture for a similar
ECG signal classification task presented in [13], but with different input sample types. The
authors claimed a numerical result with an overall accuracy of 99.43%. Note that the stated
architecture was used for a limited number of classes. The proposed CNN architecture is shown
in Figure 3.




Figure 3: The CNN architecture for ECG classification, showing (a) the original model [12] and
(b) the improved model, each detailing the input size, convolutional layers with ReLU activation,
max pooling, batch normalization, encoded data, and linear layers for the classification output.

   To achieve better results and extend the classes of pathologies, we propose the following
improvements to the CNN architecture: (i) adding Batch Normalization layers after each
convolutional layer, (ii) adding an additional convolutional layer, and (iii) optimizing
hyperparameters for the main CNN layers.
    The final version of the improved network architecture contains 1,147,081 trainable
parameters. For comparison, the network proposed in [13] uses 1,045,213 parameters. The
difference is 101,868 parameters. Considering the input data size increased from 300 to 700 and
the number of classification classes increased (from 5 to 9), this increase in training parameters
is negligible.
    Additional work was conducted to find the optimal hyperparameters for the neural network
layers for ECG signal pathology classification. Libraries PyTorch Lightning [21] and Optuna
[22] were used for hyperparameter optimization.
    The classification result obtained by the considered method is forwarded for the
interpretation of the classification results by the method considered in the next section.

2.2. Method of interpretation of classification results
Given the sensitivity of decision-making in the medical field and the opacity of decisions made
by proposed DL tools (decisions are made through an opaque “black box” mechanism), there is
a need to explain the results in a form understandable to the doctor. The proposed interpretation
method will be described as follows:

   1.   General concept of the proposed approach.
   2.   Criteria by which the doctor determines a specific pathology on the ECG signal.
   3.   Establishing the method of providing these criteria to the doctor in the parameters of
        the input ECG signal supplied to the DL model.

    The proposed method is schematically depicted in Figure 4.
    Next, we will examine the stages of the interpretation method in detail. The main concept of
the developed method is aimed at explaining the classification results in an accessible form
using features that the doctor uses to diagnose pathologies on the ECG signal. These are specific
features that the doctor can see on the input signal (cardiac cycle) and which, in a certain way,
allow the doctor to agree or disagree with the decision made by the DL model.
    In the process of determining a specific pathology on the ECG signal, the doctor considers
various features that indicate possible pathologies. These features are predefined for each type
of pathology and may all be present together or only some of them, based on which the doctor
makes the final decision.
    The input information of the interpretation method is the cardiac cycle signal in the form in
which it was supplied to the input of the neural network classifier (Figure 4) and the class of
pathology determined by the same classifier.
    Step 1: Empirically determine the fragment of the input signal (attention zone) that may
contain information about the feature.
    Step 2: The goal is to choose a means by which the doctor will be informed about the
presence or absence of a feature on the signal fragment. The selection of the means is carried
out by sequentially analyzing the information according to the criteria presented below.
Figure 4: The proposed interpretation method for ECG fragments involves empirically
determining the receptive region for the feature (Step 1), followed by analyzing means to
confirm or deny the presence of a sign in the receptive field (Step 2), ultimately determining the
presence or absence of the feature in the ECG fragment.
   •   Is it possible to obtain a solution through the visual representation (in various ways) of
       the signal fragment against similar fragments of the training set (labeled by two classes:
       i) the considered pathology or ii) norm and all other pathologies)?
   •   Is it possible to obtain a solution through statistical indicators understandable to the
       doctor?
   •   Is it possible to obtain a solution through the formulas?
   •   Is it possible to obtain a solution through visual analytics tools like Principal Component
       Analysis (PCA) [23], Multidimensional Scaling (MDS) [24], t-Distributed Stochastic
       Neighbor Embedding (t-SNE) [25], etc.)?
   •   Is it possible to obtain a solution through classifiers built for such cases using machine
       learning (ML) models?
   •   Is it possible to obtain a solution through classifiers built for such cases using DL
       models?

   The result and output information of the proposed interpretation method is the presence (or
absence) of a feature in the current fragment of the ECG signal.

2.3. Dataset
In this work, we use an ECG signal sample based on the MIT-BIH Arrhythmia Database. The
MIT-BIH Arrhythmia Database was created for research in the field of automatic arrhythmia
recognition. It was developed at the Laboratory for Computer Science and Artificial Intelligence
at the Massachusetts Institute of Technology in conjunction with the Beth Israel Hospital
Medical Center (now Beth Israel Deaconess Medical Center). The database includes 48 records,
each 30 minutes long, taken from 47 different patients. At the same time, experts (cardiologists)
commented on each cardiac cycle, thus forming an annotation that allows assessing and
validating the results of arrhythmia detection approaches.
    In this work, all signals from the database were divided into smaller segments with a length
of 8000. The resulting sample of signals was divided into training and test samples in a ratio of
80% to 20%. Table 1 shows the quantitative distribution of each class of pathologies in the
training and test samples.
    In Table 1, the class names correspond to the annotation of the MIT-BIH Arrhythmia
database, and have the following interpretation:

   •   Class 1: N – Normal beat.
   •   Class 2: R – Right bundle branch block beat.
   •   Class 3: L – Left bundle branch block beat.
   •   Class 4: / – Paced beat.
   •   Class 5: V – Premature ventricular contraction.
   •   Class 6: F – Fusion of ventricular and normal beat.
   •   Class 7: f – Fusion of paced and normal beat.
   •   Class 8: A – Atrial premature beat.
   •   Class 9: NA – Others.
Table 1
Quantitative distribution of classes in the training and testing samples of the MIT-BIH
Arrhythmia Database
   Class name      N            R          L           /      V       F     f       A       NA

Dataset
  Training       36,971       3,458      3,469       3,148   2,937   389   444    1,175     189
   samples
   Testing       12,784       1,657       959        1,224   1,097   168   141     476       89
   samples


2.4. Evaluation criteria
In this section, we provide evaluation criteria that were used to assess the performance of the
proposed multi-class classification CNN model using several standard metrics: accuracy,
precision, recall, and F1-score that are computed based on the concepts of true positives (TP),
false positives (FP), false negatives (FN), and true negatives (TN) for each class.
    Accuracy measures the overall correctness of the model. It is the ratio of the correctly
predicted instances to the total instances.

                                                  ∑𝐾𝐾𝑖𝑖=1 TP𝑖𝑖                              (1)
                            Accuracy =                                 ,
                                         ∑𝐾𝐾𝑖𝑖=1(TP𝑖𝑖 + FP𝑖𝑖 + 𝐹𝐹𝐹𝐹𝑖𝑖 )
   where K is the number of classes, i stands for the index of each class.
   Precision, also known as Positive Predictive Value, is the ratio of correctly predicted positive
instances to the total predicted positives.

                                                     TP𝑖𝑖                                (2)
                                    Precision𝑖𝑖 =            ,
                                                 TP𝑖𝑖 + FP𝑖𝑖
   Recall, or Sensitivity, is the ratio of correctly predicted positive instances to all actual
positives. It measures the model's ability to identify positive instances.

                                              TP𝑖𝑖                                    (3)
                                      Recall𝑖𝑖 =      ,
                                          TP𝑖𝑖 + FN𝑖𝑖
  The F1-score is the harmonic mean of precision and recall, providing a balance between the
two metrics.

                                             Precision𝑖𝑖 × Recall𝑖𝑖                (4)
                          𝐹𝐹1 − 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑖𝑖 = 2 ×                  .
                                            Precision𝑖𝑖 + Recall𝑖𝑖
   Metrics (1)–(4) allow us to comprehensively evaluate the performance of our multi-class
classification model, providing insights into its strengths and weaknesses.
3. Results
3.1. Classification results
The classification results of the proposed deep convolutional network (CNN) for arrhythmia
interpretation are visually represented below. These results highlight the model's performance
across different classes of ECG signals, demonstrating its effectiveness and accuracy.
   Figure 5 illustrates the training and validation accuracy and loss curves during the training
process of the CNN model.




                       (a)                                               (b)
Figure 5: Accuracy and loss curves that represent (a) training and validation accuracy and (b)
training and validation loss while training the CNN model.

    In Figure 5(a), the training and validation accuracy show a steady increase, reaching a high
plateau as the epochs progress. This indicates that the model is learning effectively and
achieving high accuracy on both the training and validation datasets. Figure 5(b) complements
this by showing a consistent decrease in both training and validation loss, suggesting that the
model is not only learning but also generalizing well to unseen data. The minimal overfitting
observed here is crucial for the model's reliability in real-world applications.
    The confusion matrix and ROC-curved presented in Figure 6 provide a detailed view of the
model's performance across different classes of ECG signals.
    Figure 6(a) presents a confusion matrix that provides a detailed overview of the proposed
CNN performance in classifying nine classes of ECG signals. The high true positive rates along
the diagonal indicate the model's ability to accurately classify the majority of ECG signal types,
demonstrating its effectiveness in distinguishing between different arrhythmias. The minimal
off-diagonal elements reflect a low rate of misclassification, underscoring the robustness and
precision of the CNN model. Complementing this, Figure 6(b) showcases the ROC curves for
multi-class ECG classification, illustrating the model's discriminative capability across different
classes. The ROC curves, which plot the true positive rate against the false positive rate, exhibit
high area under the curve (AUC) values, indicating the model's strong performance in achieving
high sensitivity and specificity. Together, these figures validate the proposed CNN model's
efficiency in accurately classifying arrhythmias, highlighting its potential for reliable real-world
applications in medical diagnostics.
                       (a)                                                 (b)
Figure 6: Classification results: (a) confusion matrix obtained by the proposed CNN model
based on the testing dataset; (b) ROC-curves for multi-class ECG classification.

   Furthermore, Table 2 details the precision (2), recall (3), and F1-score (4) for each class in the
testing dataset, along with the number of elements per class.

Table 2
Classification metrics for the testing dataset
       Class             Precision               Recall           F1-score           Number of
                                                                                      elements
         1                   1.00                 1.00              1.00               1,2782
         2                   0.99                 0.99              0.99                1,097
         3                   0.99                 1.00              1.00                1,224
         4                   1.00                 1.00              1.00                1,657
         5                   1.00                 0.99              1.00                 958
         6                   0.96                 0.95              0.95                 476
         7                   0.88                 0.84              0.86                 168
         8                   0.97                 0.95              0.96                 141
         9                   0.90                 0.89              0.89                  89

    The model achieves nearly perfect precision, recall, and F1-scores for most arrhythmia
classes, particularly for Normal beat (N), Right bundle branch block beat (R), and Left bundle
branch block beat (L), all with F1-scores close to 1.00. The Premature ventricular contraction (V)
class also shows excellent precision and recall, with an F1-score of 1.00. While the Fusion of
paced and normal beat (f) and Atrial premature beat (A) classes perform slightly lower, they
still demonstrate strong classification metrics with F1-scores of 0.86 and 0.96, respectively. The
'Others' (NA) class, though showing the lowest performance with an F1-score of 0.89, still
indicates a relatively high level of accuracy, suggesting some room for improvement.
    Overall, the proposed deep CNN model demonstrates superior performance in classifying
various arrhythmias from ECG signals. The high accuracy, precision, recall, and F1-scores across
most classes underscore the model's potential for real-world applications in medical diagnostics.
The consistent performance across training and validation sets indicates that the model does
not overfit and maintains its effectiveness on unseen data. The improvements in the CNN
architecture, such as adding Batch Normalization layers and additional convolutional layers,
have significantly contributed to the model's robust performance.

3.2. Interpretation results
3.2.1. Sample of applying the proposed approach
Let us consider an example of applying the proposed interpretation method to explain
classification results for the pathology “Premature Ventricular Contraction” (PVC), also known
as “Ventricular Extrasystole.” The following features are characteristic of this pathology:

   •   Absence of P-peak.
   •   Widened QRS complex.
   •   Deformed QRS complex; deformation implies a change in the shape of the QRS complex
       – right ventricular extrasystole if it resembles left bundle branch block in lead V1 and
       left ventricular extrasystole if it resembles right bundle branch block.
   •   Presence of a full compensatory pause, which is the interval between two consecutive
       ventricular complexes of sinus rhythm, with an extrasystole in between, equal to twice
       the RR interval of sinus rhythm.

   The interpretation for each pathology will be discussed further.

3.2.2. No P-peak
Let us plot all ECG signals from the training set for the classes “Normal” and “Premature
Ventricular Contraction” (Figure 7).
   As seen in Figure 7, the attention zone for the feature was determined empirically (Figure
7(a). Simple visual representation does not work in this case. The red and blue areas completely
overlap.
   When reproducing fragments from a single point (Figure 7(b), the picture improves, but not
for all cases (only for signals with a clearly defined presence and absence of the peak).
   Since it was not possible to visually determine the presence or absence of the P-peak, it is
proposed to use a peak detection function integrated into the Neurokit2 package [26].
                      (a)                                             (b)
Figure 7: The interpretation results for an ECG-sample: (a) attention zone for the feature
“Absence of P-peak” and (b) all fragments from a single point.

3.2.3. The QRS complex is widened with deformation
On the graph with all ECG signals for the classes “Normal” and “Premature Ventricular
Contraction,” the attention zone for the current feature was empirically determined (Figure 8).
The identified attention zone should fully cover the QRS complex.
   As with the previous feature, simple visual comparison does not work due to significant
overlap between signals. Applying PCA to the data from the attention zone in the ECG signal
shows that the data does not have substantial dispersion, but instead exhibits some grouping.
However, the formed groups do not have clear separation.
   In such conditions, classification methods using ML models will perform worse than those
using DL models. Therefore, identifying the QRS complex that corresponds to “normal” and
“widened with deformation,” according to the pathology of ventricular extrasystole, will be
done using neural network methods.

3.2.4. Presence of a full compensatory pause
A compensatory pause is the time that elapses after an extrasystole until the occurrence of a
normal contraction. Therefore, when an extrasystole is situated between other extrasystoles,
this calculation does not occur, and the check for the presence of the feature is only performed
for the last instance of the extrasystole in the sequence.
   A complete compensatory pause means that the heart rhythm fully returns to its normal
cycle after an extrasystole. This happens when the sum of the intervals before and after the
extrasystole equals two normal R-R intervals.

                               𝑅𝑅𝑅𝑅𝑝𝑝 + 𝑅𝑅𝑅𝑅𝑓𝑓 ≈ 2 ∗ 𝑅𝑅𝑅𝑅𝑛𝑛 ,                            (5)
   where 𝑅𝑅𝑅𝑅𝑝𝑝 is the R-R interval before the extrasystole, 𝑅𝑅𝑅𝑅𝑓𝑓 – R-R interval after the
extrasystole, and 𝑅𝑅𝑅𝑅𝑛𝑛 – R-R interval between cardiac cycles in the norm.




                      (a)                                             (b)
Figure 8: The interpretation results for an ECG-sample: (a) attention zone for the feature
“Absence of P-peak” and (b) all fragments from a single point.

4. Conclusions
In this research paper, we proposed and implemented new methods for classifying and
interpreting arrhythmias based on deep CNN applied to ECG signals. The method involved
splitting ECG signals into fragments and classifying these fragments using an enhanced CNN
architecture, which included the addition of Batch Normalization layers and an extra
convolutional layer. The dataset used for training and testing was the MIT-BIH Arrhythmia
Database, ensuring a robust evaluation of our approach. The obtained results demonstrated high
accuracy, precision, recall, and F1-scores, with particularly strong performance for Normal
beats, Right bundle branch block beats, and Left bundle branch block beats, achieving F1-scores
close to 100%. The model's overall accuracy reached 99.43%, showcasing its effectiveness in
distinguishing between different arrhythmias. Nevertheless, the main limitation of our
proposed interpretation approach is the reliance on a limited number of clinical features to
justify the decisions made by a DL model. This limitation is evident when multiple pathologies
overlap within the same heart rhythm, necessitating the introduction of additional features to
ensure accurate diagnosis.
   Future work will focus on validating the proposed methods through clinical trials using real
cases and cardiograms, aiming to enhance the model's reliability and applicability in real-world
medical diagnostics.
References
[1] S. A. El-Moneim Kabel, G. M. El-Banby, L. A. Abou Elazm, W. El-Shafai, N. A. El-
     Bahnasawy, F. E. A. El-Samie, A. A. Elazm, A. I. Siam, M. A. Abdelhamed, Securing Internet-
     of-Medical-Things networks using cancellable ECG recognition, Sci. Rep. 14 (2024) 10871.
     doi:10.1038/s41598-024-54830-2.
[2] N. Cozzoli, F. P. Salvatore, N. Faccilongo, M. Milone, How can big data analytics be used
     for healthcare organization management? Literary framework and future research from a
     systematic review, BMC Health Serv. Res. 22 (2022) 809. doi:10.1186/s12913-022-08167-z.
[3] M. S. Nidhya, S. Bajidvali, R. A. V. Nageswara, M. S. Javeed, Internet of things (IoT) smart
     wearable sensors in healthcare, in: AI and IoT Technology and Applications for Smart
     Healthcare Systems, Auerbach Publications, Boca Raton, 2024, pp. 172–183.
     doi:10.1201/9781032686745-11.
[4] Q. Xiao, K. Lee, S. A. Mokhtar, I. Ismail, A. L. b. M. Pauzi, Q. Zhang, P. Y. Lim, Deep learning-
     based ECG arrhythmia classification: A systematic review, Appl. Sci. 13.8 (2023) 4964.
     doi:10.3390/app13084964.
[5] C. Guo, B. Yin, J. Hu, An electrocardiogram classification using a multiscale convolutional
     causal attention network, Electronics 13.2 (2024) 326. doi:10.3390/electronics13020326.
[6] U. Gupta, N. Paluru, D. Nankani, K. Kulkarni, N. Awasthi, A comprehensive review on
     efficient artificial intelligence models for classification of abnormal cardiac rhythms using
     electrocardiograms, Heliyon 10.5 (2024) e26787. doi:10.1016/j.heliyon.2024.e26787.
[7] P. Radiuk, O. Barmak, E. Manziuk, I. Krak, Explainable deep learning: A visual analytics
     approach        with      transition   matrices,      Mathematics       12.7     (2024)    1024.
     doi:10.3390/math12071024.
[8] G. Ott, Y. Schaubelt, J. M. Lopez Alcaraz, W. Haverkamp, N. Strodthoff, Using explainable
     AI to investigate electrocardiogram changes during healthy aging—From expert features
     to raw signals, PLOS ONE 19.4 (2024) e0302024. doi:10.1371/journal.pone.0302024.
[9] P. Wagner, T. Mehari, W. Haverkamp, N. Strodthoff, Explaining deep learning for ECG
     analysis: Building blocks for auditing and knowledge discovery, Comput. Biol. Med. 176
     (2024) 108525. doi:10.1016/j.compbiomed.2024.108525.
[10] G. Chuiko, O. Yaremchuk, Handling the breast cancer recurrence data for a more reliable
     forecast, Comp. Syst. and Inform. Technol. 4 (2023) 10–15. doi:10.31891/csit-2023-4-2
[11] G. Hadjichristofi, G. Varveris, K. Katzis, Assessing trustworthiness of IoT-health devices in
     hospital environments, in: 2020 IEEE Eighth International Conference on Communications
     and      Networking          (ComNet),    IEEE,       New      York,     NY,      USA,     2020.
     doi:10.1109/comnet47917.2020.9306089.
[12] W. Meng, W. Li, J. Han, C. Su, Security, trust, and privacy in machine learning-based
     internet of things, Secur. Commun. Netw. 2022 (2022) 1–3. doi:10.1155/2022/9851463.
[13] X. Xu, H. Liu, ECG heartbeat classification using convolutional neural networks, IEEE
     Access 8 (2020) 8614–8619. doi:10.1109/access.2020.2964749.
[14] M. Degirmenci, M. A. Ozdemir, E. Izci, A. Akan, Arrhythmic heartbeat classification using
     2D      convolutional          neural   networks,        IRBM      43.5      (2022)     422–433.
     doi:10.1016/j.irbm.2021.04.002.
[15] E. Abdelhafid, E. Aymane, N. Benayad, S. Abdelalim, E. Y. ALAOUI My Hachem, O. H. T.
     Rachid, B. Brahim, ECG arrhythmia classification using convolutional neural network, Int.
     J. Emerg. Technol. Adv. Eng. 12.7 (2022) 186–195. doi:10.46338/ijetae0722_19.
[16] D. Zhang, S. Yang, X. Yuan, P. Zhang, Interpretable deep learning for automatic diagnosis
     of 12-lead electrocardiogram, iScience 24.4 (2021) 102373. doi:10.1016/j.isci.2021.102373.
[17] P. Singh, A. Sharma, Interpretation and classification of arrhythmia using deep
     convolutional network, IEEE Trans. Instrum. Meas. 71 (2022) 2518512.
     doi:10.1109/tim.2022.3204316.
[18] F. K. AL-Shammri, H. Noman Obeid, M. S. Abbas, A. S. Mohammed, Z. alzamili, M. A.
     Aleigailly, K. Ali Hasan, F. V. Çelebi, Developing healthcare using internet of things (IoT):
     A survey of applications, challenges and future directions, BIO Web Conf. 97 (2024) 00004.
     doi:10.1051/bioconf/20249700004.
[19] O. Kovalchuk, P. Radiuk, O. Barmak, I. Krak, Robust R-peak detection using deep learning
     based on integrating domain knowledge, in: Proceedings of the 6th International
     Conference on Informatics & Data-Driven Medicine, CEUR-WS.org, Aachen, 2024, pp.
     1613–0073.
[20] O. Kovalchuk, P. Radiuk, O. Barmak, S. Petrovskyi, 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, CEUR-WS.org,
     Aachen, 2023, pp. 227–238.
[21] W. Falcon, The PyTorch lightning team, PyTorch Lightning, Software, v. 2.2.4, Zenodo,
     Open source, 2024. doi:10.5281/zenodo.11100106.
[22] T. Akiba, S. Sano, T. Yanase, T. Ohta, M. Koyama, Optuna: A next-generation
     hyperparameter optimization framework, in: Proceedings of the 25th ACM SIGKDD
     International Conference on Knowledge Discovery & Data Mining, Association for
     Computing Machinery, New York, NY, USA, 2019, pp. 2623–2631.
[23] F. Kherif, A. Latypova, Principal component analysis, in: Machine Learning, Elsevier, 2020,
     pp. 209–225. doi:10.1016/b978-0-12-815739-8.00012-2.
[24] E. Paradis, Reduced multidimensional scaling, Comput. Stat. 37 (2021) 91–105.
     doi:10.1007/s00180-021-01116-0.
[25] S. Shi, Y. Xu, X. Xu, X. Mo, J. Ding, A preprocessing manifold learning strategy based on t-
     distributed stochastic neighbor embedding, Entropy 25.7 (2023) 1065.
     doi:10.3390/e25071065.
[26] D. Makowski, T. Pham, Z. J. Lau, J. C. Brammer, F. Lespinasse, H. Pham, C. Schölzel, S. H.
     A. Chen, NeuroKit2: A Python toolbox for neurophysiological signal processing, Behav.
     Res. Methods 53.4 (2021) 1689–1696. doi:10.3758/s13428-020-01516-y.