Abstract
Keywords
Introduction
Cardiovascular diseases are among the leading causes of death per the World Health Organization and the Centers for Disease Control and Prevention [8,64]. Arrhythmias are heart rhythms other than normal sinus rhythm with a heart rate between 60 beats/minute and 100 beats/minute; that is, arrhythmias are heart rhythms that are either too fast, too slow, abnormal, and/or irregular. Most arrhythmias must be treated since they can either lead to 1) more chaotic electrical activity of cardiac muscle resulting in loss of cardiac output and/or 2) the formation of thromboemboli (e.g. as in atrial fibrillation) possibly resulting in stroke [40]. The overall prevalence of arrhythmias among adults is estimated to be around 2% with atrial fibrillation being among the most common arrhythmias [13,30]. The global prevalence of atrial fibrillation has been estimated to be about 0.51% [35].
The contraction and relaxation of cardiac muscle cells is driven by ion movement across cell membranes and must be coordinated in order for the heart to pump blood effectively. This ion movement is governed by an electrochemical potential comprised of 1) ion concentration gradients and 2) electric potentials. The depolarization and subsequent repolarization of cardiac muscle cells causes changes in electric potential on the body surface which can be measured non-invasively using an electrocardiogram (ECG). ECG analysis is important for accurate diagnosis, treatment, and prevention of cardiovascular diseases.
Topological data analysis (TDA) refers to a collection of methods concerned with
quantifying ‘shapes’ of data which are invariant under continuous deformations such as
stretching and twisting. The main tool of TDA is persistent homology which quantifies the
homology of structures within the data which
Several approaches to computer-aided ECG rhythm classification have been performed, including neural networks [5,15,17,21,25,39,46,48,51,56,61,62,66–68], wavelet transformation and independent component analysis [31,65], using higher-order statistics of wavelet-packet decomposition coefficients as features [32], and support vector machines using projected and dynamic ECG features [9]. An overview of TDA applied to cardiovascular signals has recently been performed [23]. In the field of computer-aided ECG analysis, TDA has been used to construct metrics of heart rate variability [11,20]. Additionally, the Mapper algorithm has been applied to predict the presence and severity of heart disease [2]. Computer-aided ECG rhythm classification methods which utilize TDA include neural networks with topological-based features [16,53], fractal dimension in tandem with neural networks [55], mapping ECG signals to a higher dimensional space prior to computing topological features [26,27,34,36,41], and utilizing a sliding window and Fast Fourier Transform to process the ECG signal prior to computing topological features [43]. These approaches construct topological predictor variables utilizing information directly derived from the birth and death radii statistics along with extra information such as heart rate, fractal dimension statistics, and persistent entropy.
To the author’s knowledge, constructing predictor variables for use in machine learning
models to classify ECG rhythms based off information derived from cycle representatives has
not yet been performed. Additionally, to our knowledge, there has been no computer-aided ECG
analysis which utilizes only the
In Section 1.1, we give a brief overview of the aspects of persistent homology utilized in this study. Appendix A formalizes the intuition underlying persistent homology described in Section 1.1. The Methods portion is split into three parts: Section 2.1 describes the novel ECG processing pipeline, Section 2.2 describes the construction of predictor variables primarily based off the topological features of the processed ECG signal, and Section 2.3 describes the specific classification tasks along with the statistical models and evaluation metrics used. The Results/Discussion section presents the evaluation metrics and ROC curves for each statistical model used. The Conclusion section contains a brief comparison between the method proposed here and other methods which use TDA and machine learning for rhythm classification in addition to describing some future directions.
Intuition behind persistent homology
The background on persistent homology presented both here and in Appendix A is restricted to two-dimensional data and one-dimensional
homology features. The methods discussed generalize to higher dimensions, but we restrict
our focus to the relevant dimensions used in the ECG analysis presented here. A toy
example dataset

Consider the set of points in the plane
For a given two-dimensional dataset

The cycle representatives of a given equivalence class of non-contractible loops
The free and publicly available Shaoxing Hospital Zhejiang University School of Medicine electrocardiogram (ECG) database was used in this study [69]. This database consists of 10646 12-lead ECG signals, each spanning 10 seconds with a sampling frequency (i.e. the number of electric potential differences recorded per second) of 500 Hz, of which 10605 have non-empty Lead 2 signals. This study strictly utilizes Lead 2, i.e. the ‘rhythm lead’, so the term ‘ECG signal’ is henceforth used to refer to Lead 2 ECG signals. Each ECG signal is labeled with one of 11 rhythms by professional experts. The distribution of these 11 rhythms across the 10605 ECG signals is shown in Table 1.
Rhythm distribution
Rhythm distribution
ECG signals are typically characterized as 1-dimensional lists of real numbers of length
In the remainder of this section, we describe 1) ECG signal processing prior to extraction of topological features, 2) the construction of predictor variables derived from persistent homology, and 3) the statistical modeling approaches and evaluation metrics used. A flowchart providing an overview of our approach to arrhythmia detection is shown in Fig. 3.

Flowchart of ECG signal processing and arrhythmia classification.
Given a raw ECG signal
Next, an isoelectric baseline is included in

Illustration depicting the effect of the isoelectric baseline on the persistence diagrams of ECG signals. PD: persistence diagram. A–B) normal sinus rhythm ECG signal without baseline and corresponding PD. C–D) same as A–B but with the isoelectric baseline included. Note the cluster of topological features that appeared and the P, S, and T-waves their area-minimal cycle representatives correspond to. E–F) atrial fibrillation without baseline included and corresponding PD. G–H) same as E–F but with the isoelectric baseline included. H1 features: equivalence classes of non-contractible loops.
The onset of each QRS-complex in the processed ECG signal

Depiction of preprocessing transformations applied to a normal sinus rhythm ECG signal. A) raw ECG signal with normal sinus rhythm. B) normalized ECG signal with maximum amplitude 1 and minimum amplitude 0. C) normalized ECG signal with isoelectric baseline included and R-waves identified.
Each equivalence class of non-contractible loops with birth radius
The computation of the
effective centroid coordinates of an area-minimal cycle representative is depicted in
Fig. 6. The equivalence classes of non-contractible loops
with centroid time coordinate

Computation of the effective centroid coordinates of an area-minimal cycle representatives. A) processed ECG signal with normal sinus rhythm and R-waves, an area-minimal cycle representative corresponding to a P-wave, and an area-minimal cycle representative corresponding to a T-wave identified. B) zoomed-in region depicting the computations of the effective time-coordinates of the two area-minimal cycle representatives. C) zoomed-in region depicting the computation of the effective amplitude-coordinate of the area-minimal cycle representative corresponding to the T-wave.
The persistent homology of the processed signal
Three different binary classifications are carried out: Atrial Fibrillation vs. Non-Atrial
Fibrillation Arrhythmia vs. Normal Sinus
Rhythm Arrhythmias with Morphological Changes vs. Sinus
Rhythm with Bradycardia and Tachycardia Treated as
Non-Arrhythmia
For each of the three binary classifications,
Logistic Regression, Linear Discriminant Analysis, Quadratic Discriminant Analysis, Naive
Bayes, Random Forest, Gradient Boosted Decision Tree, K-Nearest Neighbors, and Support
Vector Machine with Linear, Radial, and Polynomial Kernel Models are constructed. For
background on the theory and/or implementation of these statistical models, see [28]. Stratified 5-fold cross-validation is
performed, and in each of the 5 folds, the true positives (TP), false positives (FP),
false negatives (FN), and true negatives (TN) are recorded in a confusion matrix like that
shown in Fig. 7 for each statistical model used. The mean and
standard deviation of the F1-Scores, Accuracies, Sensitivities, Specificities, Positive
Predictive Values (PPVs), and Negative Predictive Values (NPVs) across the five folds are
recorded. Definitions of these evaluation metrics can be found in [52].

Confusion matrix.
The optimal hyperparameters for the Random Forest, Gradient Boosted Decision Tree,
K-Nearest Neighbors, and Support Vector Machines with Radial and Polynomial Kernel Models
were chosen as the hyperparameters which yielded the largest mean F1-Score across all
folds in 5-fold stratified cross validation. The grid search spaces of hyperparameters for
the relevant models are: Random Forest:
Gradient Boosted Decision
Tree:
K-Nearest
Neighbors: Support
Vector Machine with Radial Kernel: Support
Vector Machine with Polynomial Kernel:
For each of the three binary classifications, the relative influence of the predictor
variables in the statistical model yielding the largest mean F1-score across the five
folds is quantified using the methods described in Section 8.1 of “Greedy Function
Approximation: A Gradient Boosting Machine” by Friedman [18].
Binary classification outcomes: atrial fibrillation vs. Non-atrial fibrillation
Binary classification outcomes: atrial fibrillation vs. Non-atrial fibrillation
Binary classification outcomes: arrhythmia vs. Normal sinus rhythm
The mean and standard deviation across the five folds for the binary classifications of (i) Atrial Fibrillation vs. Non-Atrial Fibrillation, (ii) Arrhythmia vs. Normal Sinus Rhythm, and (iii) Arrhythmia with Morphological Changes vs. Sinus Rhythm with Bradycardia and Tachycardia Treated as Non-Arrhythmia with the hyperparameters yielding the largest F1-Score are shown in Tables 2, 3, and 4, respectively. The results corresponding to the top-performing model with respect to each evaluation metric are displayed in bold. Observe that the Gradient Boosted Decision Tree Model outperforms all other models with respect to F1-Score and Accuracy across each of the three binary classification tasks, closely followed by the Random Forest Model. The maximum mean F1-Score attained by the Gradient Boosted Decision Tree Model across the five folds was 0.967, 0.839, and 0.943 for binary classification of Atrial Fibrillation vs. Non-Atrial Fibrillation, Arrhythmia vs. Normal Sinus Rhythm, and Arrhythmia with Morphological Changes vs. Sinus Rhythm with Bradycardia and Tachycardia Treated as Non-Arrhythmia, respectively. The corresponding mean Accuracy attained by the Gradient Boosted Decision Tree Model across the five folds was 0.946, 0.946, and 0.921 for binary classification of Atrial Fibrillation vs. Non-Atrial Fibrillation, Arrhythmia vs. Normal Sinus Rhythm, and Arrhythmia with Morphological Changes vs. Sinus Rhythm with Bradycardia and Tachycardia Treated as Non-Arrhythmia, respectively. The Gradient Boosted Decision Tree and Random Forest models outperformed all other models with respect to the area under the Receiver-Operator Characteristic Curves (AUC) for all three classification tasks as seen in Fig. 8, Fig. 9, and Fig. 10. This may be due to heterogeneity of the data; regardless, in computer-aided ECG analysis, interpretability of statistical models may be less important than the performance of said models, rendering more support in favor of ensemble and tree-based modeling approaches given their favorable performance.
Recall that TDA quantifies the ‘shape’ of data. Thus, the motivation behind presenting the classifications of both (i) Arrhythmia vs. Normal Sinus Rhythm and (ii) Arrhythmias with Morphological Changes vs. Sinus Rhythm with Bradycardia and Tachycardia Treated as Non-Arrhythmia is to illustrate how the results are improved when TDA is used to classify two groups that primarily have different shapes, not frequencies. With this in mind, it may not be surprising that the presented TDA approach performs much better when classifying arrhythmias when the only two arrhythmias characterized solely by abnormal periodicity (assuming the individual has at most one rhythm as is the case in the data used in this study) – i.e. tachycardia and bradycardia – are not considered to be part of the arrhythmia group.
Binary classification outcomes: arrhythmia with morphological changes vs. Sinus rhythm with bradycardia and tachycardia treated as non-arrhythmia

Receiver operator characteristic curve for classification of atrial fibrillation vs. Non-atrial fibrillation.

Receiver operator characteristic curve for classification of arrhythmia vs. Sinus rhythm.

Receiver operator characteristic curve for classification of arrhythmia with morphological changes vs. Sinus rhythm with bradycardia and tachycardia treated as non-arrhythmia.
The relative influence [18] of each predictor
variable in the top-performing model with respect to mean F1-score (i.e. Gradient Boosted
Decision Tree model) across the five folds in the classifications of Atrial Fibrillation vs.
Non-Atrial Fibrillation, Arrhythmia vs. Normal Sinus Rhythm, and Arrhythmia with
Morphological Changes vs. Sinus Rhythm with Bradycardia and Tachycardia Treated as
Non-Arrhythmia are shown in Fig. 11, Fig. 12, Fig. 13 in Appendix B. Atrial fibrillation is characterized by (1) absent/attenuated
P-waves and (2) irregularly irregular frequency, so it is not surprising that the standard
deviation of the RR-interval holds most influence for the classification of Atrial
Fibrillation vs. Non-Atrial Fibrillation. Note that 9 of the 15 most influential predictor
variables in the classification of Atrial Fibrillation vs. Non-Atrial Fibrillation stem from
area-minimal cycle representatives and that
Comparison of studies applying TDA and machine learning to arrhythmia classification
The methods used in other studies that approach computer-aided ECG rhythm classification through a combination of TDA and machine learning are summarized in Table 5. Due to the wide range of classification tasks performed and evaluation metrics used in these studies, the classification tasks and evaluation metrics are not shown in Table 5 to avoid (i) presenting misleading comparisons and (ii) subjectivity in choosing the results from other studies to present. These other studies use a variety of databases [19,42] and sometimes a sample size on the scale of tens or hundreds, in addition to having longer – and consequently more informative – signals compared to the database used in this study [69]. Another factor to consider when comparing analyses of TDA and machine learning in ECG rhythm classification is the fact that different ECG databases often have signals labeled with different rhythms that may not be found in other ECG databases. The approach presented here attains similar results as these previous studies with respect to classification outcomes while utilizing a novel ECG signal processing pipeline and topological predictor variable construction, particularly with respect to using information derived from area-minimal cycle representatives.
The method presented here differs from other methods utilizing TDA and machine learning in
three main ways: by using information about optimal
cycle representatives of equivalence classes of non-contractible loops when
constructing topological predictor variables. by focusing
only on the by introducing an isoelectric baseline to
create non-trivial equivalence classes of non-contractible loops corresponding to the
P, Q, S, and T-waves (if they are present to begin with).
This
novel approach to ECG signal processing and construction of topological predictors yields
classification results on par with other methods proposed in the literature and demonstrates
the utility of optimal cycle representatives in TDA. Future directions include multiclass
rhythm classification, other methods of defining the isoelectric baseline to account for
baseline wander in longer ECG signals, including statistics derived from optimal cycle
representatives in other approaches such as sliding window and Fast Fourier Transform
embeddings, and including an isoelectric baseline prior to embedding ECG signals in higher
dimensions. Several studies have used TDA-derived statistics as input to neural networks
[16,53,55]; however, to the author’s
knowledge, there has been no study performed which utilizes persistence images [1] as the TDA-derived input for neural networks in
arrhythmia detection, yielding another direction for future work.
There have been people working on computer-aided ECG analysis since the invention of the ECG machine. Over the past 20 years, there have been many machine learning approaches taken, yielding encouraging results. Some of these methods have involved TDA. Regardless of the type of method taken in computer-aided ECG analysis and the goodness of the evaluation metrics, we must take care to not rush to replace ECG interpretation by skilled health care professionals, however tempting the potential time and cost savings may be. In addition to the obvious danger of automated arrhythmia classification algorithms missing a harmful arrhythmia that a skilled healthcare professional would not have missed, bells and whistles from automated arrhythmia detection algorithms can lead to unnecessary medical staff fatigue and an increase in stress and adverse outcomes in hospitalized patients [12,29,33,54,58,59].
The data used in this study are free and publicly available at
