0% found this document useful (0 votes)
4 views26 pages

Ecg Classifier

This research article presents a novel approach for classifying ECG signals into three categories: normal sinus rhythm, abnormal arrhythmia, and congestive heart failure using wavelet transforms and machine learning techniques. The methodology includes data augmentation and grid search optimization, resulting in a high classification accuracy of 99.58% and specificity of 99.7%. The findings suggest significant potential for improving early detection and patient outcomes in cardiovascular diseases.

Uploaded by

natnael tadele
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views26 pages

Ecg Classifier

This research article presents a novel approach for classifying ECG signals into three categories: normal sinus rhythm, abnormal arrhythmia, and congestive heart failure using wavelet transforms and machine learning techniques. The methodology includes data augmentation and grid search optimization, resulting in a high classification accuracy of 99.58% and specificity of 99.7%. The findings suggest significant potential for improving early detection and patient outcomes in cardiovascular diseases.

Uploaded by

natnael tadele
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

ECG-Based Cardiac Disease Detection in Time-

Frequency Domain using Grid Search Optimized


Wavelet Transforms
Diwakar

Babasaheb Bhimrao Ambedkar University (A Central University), Lucknow https://orcid.org/0000-


0002-4272-4467
Prof. Deepa Raj

Research Article

Keywords: Electrocardiogram, Classi cation, time domain, frequency domain, wavelets

Posted Date: August 13th, 2024

DOI: https://doi.org/10.21203/rs.3.rs-4468988/v2

License:   This work is licensed under a Creative Commons Attribution 4.0 International License.
Read Full License

Additional Declarations: The authors declare no competing interests.


ECG-Based Cardiac Disease Detection in
Time-Frequency Domain using Grid Search
Optimized Wavelet Transforms
Diwakar Diwakar1* and Deepa Raj1
1 Department of Computer Science, BBA University, Lucknow, India.

*Corresponding author(s). E-mail(s): diwakarmsccs0@gmail.com;


Contributing authors: deepa raj200@yahoo.co.in;

Abstract
Cardiovascular diseases(CVDs), including abnormal arrhythmias and congestive
heart failure, are a leading cause of mortality worldwide, with electrocardiogram
(ECG) signals serving as a critical diagnostic tool. This study introduces a novel
approach for classifying diseases in ECG signals into three categories: normal
sinus rhythm (NSR), abnormal arrhythmia (ARR), and congestive heart failure
(CHF). The classification is based on a combination of features extracted from
both the time domain (mean and standard deviation) and the frequency domain
(power spectral density and spectral centroid) of the ECG signals. Additionally,
energy values from selected frequency bands are utilized. To enhance the model’s
robustness, incorporate data augmentation techniques, including time-shifting
and flipping of the signals. These augmented datasets are then employed with
various classifiers, and an optimization process using grid search is applied to
enhance the classification performance. This methodology presents a promising
framework for automated ECG signal analysis, The results of the proposed work
have been exceptionally promising, showcasing a remarkable specificity rate of
99.7% and achieving an accuracy level of 99.58%. These findings hold significant
promise for advancing early detection methods and enhancing patient outcomes
in the realm of CVDs.

Keywords: Electrocardiogram, Classification, time domain, frequency domain,


wavelets

1
1 Introduction
Cardiac arrhythmias, characterized by abnormal heart rhythms, pose significant health
risks and require an accurate and timely diagnosis for effective treatment. The auto-
matic detection and classification of these conditions have become a focal point in
biomedical research, with the aim of creating dependable, non-invasive diagnostic
tools. Among the various diagnostic tools for cardiovascular diseases (CVDs), the
electrocardiogram (ECG) is a fundamental, non-invasive technique that records the
electrical activity of the heart over time. It provides crucial information about the
heart’s condition, including the presence of arrhythmias and signs of congestive heart
failure. However, the manual interpretation of ECG signals can be time-consuming and
requires a high level of expertise, leading to potential delays in diagnosis and treat-
ment. The application of machine learning (ML) techniques to ECG signal analysis
has been an area of active research in recent years. Several studies have demonstrated
the potential of ML to enhance the accuracy and efficiency of ECG interpretation.
Sharma et al. [1] conducted a study on feature extraction in the context of heart-
beat classification and arrhythmia detection. They utilized optimal orthogonal wavelet
filters and obtained an accuracy rate of 98%. Jing et al. [2] introduce an enhanced
ResNet-18 model tailored for ECG heartbeat classification. They employ a slicing
technique for data labelling, resulting in an impressive accuracy of 96.50%. An effec-
tive approach for detecting ventricular late potential based on an ECG signal and
SVM classifier is proposed by Giorgio et al. [3], resulting in a positive predictivity
of 88.52%. Jha et al. [4] introduced a highly efficient method for classifying ECG
beats, distinguishing between normal beats and seven types of arrhythmias. Their
approach utilizes tunable Q-wavelet-based features and achieved an impressive average
accuracy of 99.27%. Arumugam et al. [5] introduced a methodology centred around
wavelets to identify and classify Arrhythmia, resulting in a positive predictivity rate
of 95.92%. Zhao et al. [6], introduced a Deep CNN approach that utilized a 24-layer
CNN to extract features from ECG data through cross-size convolution kernels. The
proposed method achieved an accuracy of 87.1% in ECG classification. Wang et al. [7]
demonstrated a high accuracy of 98.74% in early arrhythmia detection by employing
continuous wavelet transform (CWT) and convolutional neural networks (CNNs). A
study conducted by Mohonta et al. [8] introduced a deep learning 2D-CNN model
combined with wavelet transform for arrhythmia classification, achieving an impres-
sive accuracy of 99.65% In their research, Eltrass et al. [9] presented a hybrid approach
that integrates deep neural networks, ECG features, and HRV measures to improve
the accuracy of ECG classification. The proposed system surpasses existing meth-
ods with remarkable results, achieving an accuracy of 98.75%. This hybrid approach
holds promise for real-time clinical implementation, potentially assisting cardiologists
in ECG diagnosis. Losada et al. [10] used the k-Nearest Neighbor algorithm on 9000
ECG signals from the PhysioNet database, demonstrating high accuracy in normal
signal classification but challenges with arrhythmias due to data imbalance. A study
proposes an ECG identification method leveraging wavelet transform and probabilistic
neural networks optimized by the whale optimization algorithm (WOA-PNN). This
method detects Q, R, and S waves through wavelet transform and P, T waves via local

2
windowed wavelet transform, significantly reducing ECG data dimensions. By integrat-
ing the probabilistic neural network and employing the mean impact value algorithm,
less influential characteristic values are eliminated, simplifying the model. The WOA-
PNN approach intelligently optimizes hyperparameters, achieving high identification
accuracy rates of 96.97% for a single ECG cycle and 99.43% for three cycles across the
ECG-ID, MIT-BIH Normal Sinus Rhythm, and MIT-BIH Arrhythmia databases [11].
In 2022, Hammad et al. [12] have shown that multimodal approaches can significantly
improve classification accuracy and efficiency in detecting arrhythmias compared to
single models. Deriche et al. [13] proposed a study employing 13 ECG geometric fea-
tures, based on the Pan-Tompkins QRS model, to classify five abnormal heartbeat
types using the MIT-BIH arrhythmia database. The method achieves over 92% accu-
racy. Different features optimally identify various heartbeat abnormalities. Haleem et
al. [14] proposed a method for the automatic detection of CVD via ECGs that rely on
rule-based diagnosis models, which are inefficient and require significant analysis. In
this paper, a two-stage multiclass algorithm is proposed, achieving 100% accuracy for
congestive heart failure, 97.9% for arrhythmia, and 100% for predicting sudden cardiac
deaths, surpassing state-of-the-art algorithms. The primary goal of this research is to
enhance the accuracy of cardiac arrhythmia classification, thereby contributing to the
development of more effective diagnostic tools. Provide a comprehensive overview of
the methodology and present the results of the experiments, which demonstrate the
efficacy of the approach. Moreover, the development of such automated systems could
have far-reaching implications beyond individual patient care. They could potentially
streamline workflows in healthcare settings, reduce the burden on healthcare pro-
fessionals, and contribute to more sustainable and efficient healthcare systems. The
remainder of this paper will detail the methodology, present the findings, and discuss
their implications for both clinical practice and future research.
The remainder of this paper is structured as follows: In Section 2, present
the materials and methodology, encompassing the ECG dataset, classifiers used, and
the evaluation metrics. Moving on to Section 3, delve into the proposed methods,
including a detailed explanation of feature extraction, classification and optimization.
The subsequent Section 4 outlines the experimental setup, while Section 5 showcases
the experimental results, encompassing accuracy scores, and confusion metrics and
these findings are compared with related work. Finally, in Section 6, we conclude
the paper by summarizing key points and suggesting potential directions for future
research.

2 Material and Methods


2.1 Dataset
This paper utilizes the ECG signal dataset, that consists of Cardiac arrhythmia
(ARR), Congestive heart failure (CHF), and Normal sinus rhythm (NSR) signals. The
dataset comprises 162 ECG recordings obtained from Physionet databases: MIT-BIH
arrhythmia database (containing 96 ARR recordings), BIDMC congestive heart fail-
ure database (containing 36 CHF recordings), and MIT-BIH normal sinus rhythm
database (containing 30 NSR recordings) [15]. The data matrix is structured as a

3
162∗65536 array, representing a total of 162 ECG signals, each with 65536 samples.
Each signal is labeled to indicate its type, enabling identification of the ECG signal
category. The database is organized such that rows 1 to 96 correspond to ARR signals,
rows 97 to 126 represent CHF signals, and rows 127 to 162 contain NSR signals. all
ECG signals are resampled to a fixed sampling frequency of 128 Hz and normalized
to remove any offset effect. Figure 1 illustrates a sample ECG signal.

Fig. 1: Sample of ECG signals

The database is first processed at the record level. Each record, which consists of
65536 samples, is divided into smaller signals of length 1000 samples. This partitioning
strategy aims to increase the size of the database. Additionally, to achieve a balanced
dataset, 30 recordings of each type (ARR, CHF, and NSR) are selected. Consequently,
the final dataset comprises 500 ECG signals from each category, with each signal
having a length of 1000 samples.

2.2 Classifiers
Several classifiers are trained and evaluated using the input dataset. The classifiers
employed in this research included the Random Forest (RF), XGBoost (XGB), Gra-
dient Boosting (GB), Support Vector Machine (SVM), K-Nearest Neighbors (KNN),
and Gaussian Naive Bayes (GNB). The training process involved fitting each classi-
fier to the input features and their corresponding target labels. The input dataset,
consisting of the features and target labels, is divided into training and testing sets.
The training set is used to train the classifiers, allowing them to learn the underlying
patterns and relationships in the data. After training, the classifiers are used to make
predictions on the testing set.

2.3 Evaluation Standards


The effectiveness of the neural-based model system is assessed using the following
metrics: accuracy, specificity, precision, sensitivity or recall, f1-score, and confusion
matrix. A brief discussion of these Metrics is given below. Accuracy is the percentage

4
of correctly categorized data instances overall data instances.

TP + TN
Accuracy = (1)
TP + FN + TN + FP

Specificity indicates the percentage of true negatives that the model accurately
detects. A model with high specificity will accurately identify most of the negative
outcomes, whereas one with low specificity may incorrectly classify many negative
results as positive.
TN
Specificity = (2)
TN + FP
Precision indicates what percentage of identifications are actually correct.
TP
Precision = (3)
TP + FP
Recall indicates the percentage of actual positives that are detected correctly.
TP
Sensitivity or Recall = (4)
TP + FN
F1 score is computed by calculating the harmonic mean of two Metrics (Precision
and recall). It is used to compare the performance of two classifiers.

2 × (Precision × Recall)
F1 score = (5)
Precision + Recall
Here, TP stands for ”True Positive,” FP for ”False Positive,” TN for ”True
Negative,” and FN for ”False Negative.”

3 Proposed Method
The objective of this study is to design an automated classification system using ECG
signals to accurately identify three different cardiac conditions: NSR, ARR, and CHF.
The basic block diagram illustrating the proposed method is depicted in Figure 2.

Fig. 2: Block Diagram of Proposed Method

In this experiment, taken a dataset X containing N ECG signals, each repre-


sented as a vector of M features: X = {x1 , x2 , ..., xN }, where xi = [xi1 , xi2 , ..., xiM ]

5
for i = 1, 2, ..., N . To enhance model robustness, data augmentation techniques are
applied, including time-shifting and flipping the signals. Augmented data includes the
original signal, a flipped version (xflipped ), and a time-shifted version (xtime-shifted ).
Feature extraction encompasses the analysis of both time-domain and frequency-
domain features from each ECG signal. Time domain features include the mean
(mean(xi )) and standard deviation (std(xi )). Frequency domain features are obtained
using the Wavelet Packet Transform (WPT) at level 3 and include the energy of
selected wavelet coefficients: Eaad , Eadd , Edad , and Eddd as shown in fig 5. This study
examined eight distinct features, which are subsequently subjected to various classifi-
cation models. further, employed Grid Search to fine-tune the hyperparameters of each
classifier for optimal performance. The algorithm of the proposed model is illustrated
in algo. 1.
Algorithm 1: Proposed Method for ECG Signal Classification
Data: Dataset X with N ECG signals, each represented as xi with M features
Result: Classification of ECG signals using various classifiers
Input : Extracted features from time and frequency domains
Output: Predicted disease for ECG signal
1 Step 1: Database Initialization and Signal Segmentation;
2 Load and initialize the ECG signal dataset: X = {x1 , x2 , . . . , xN }, where each
xi = [xi1 , xi2 , . . . , xiM ] for i = 1, 2, . . . , N ;
3 Step 2: Generate augmented datasets that include the original signal, a flipped
version (xflipped ), and a time-shifted version (xtime-shifted );
4 Step 3: Feature Extraction;
5 Step 3.1: Extract time domain features for each ECG record ;
6
Mean(xi ) and Std(xi )
7 Step 3.2: Apply Wavelet Packet Transform (WPT) with Sym4 wavelet to
decompose the ECG signals at level 3 ;
8 Step 3.3: Select Appropriate Bands (AAD, ADD, DAD, DDD);
9 Step 3.4: Calculate the energy of each selected frequency band ;
10 Step 3.5: Compute the Power Spectral Density (PSD) and Spectral Centroid
(SC) from the selected energy bands;
11 Step 4: Train classifiers (RF, XGB, SVM, GNB, KNN) using the extracted
features: Mean, Std, AAD, ADD, DAD, DDD, P SD, and SC;
12 Step 5: Apply Grid Search for Hyperparameter Optimization and Select the
best hyperparameters based on cross-validation performance;
13 Step 6: Generate predicted outputs;

6
3.1 Data Augmentation
Two augmentation techniques have been meticulously implemented in this study:
signalf lipping and time − shif ting. Despite the abundance of ECG data available for
the classification task, these augmentation strategies offer several compelling advan-
tages. They play a pivotal role in bolstering the model’s robustness by exposing it to an
expanded spectrum of data variations. This significance arises from the fact that, even
within a single category of ECG signals, inherent variations persist. Augmentation
augments this inherent variability, affording the model the capacity to generalize effec-
tively across novel instances and exhibit enhanced performance in real-world scenarios.
Furthermore, the application of augmentation techniques fosters superior generaliza-
tion capabilities that transcend the confines of specific instances within the dataset.
By simulating divergent recording conditions, electrode placements, and signal quality
variances, augmentation equips the model with the acumen to discern more resilient
and broadly applicable features. In addition to its generalization benefits, augmenta-
tion acts as a form of regularization, a vital safeguard against overfitting. It promotes
the model’s capacity to generalize proficiently, even when confronted with extensive
datasets. Therefore, even with sufficient data, augmentation techniques remain valu-
able for improving the performance and reliability of ECG signal classification models.
This augmentation technique can potentially improve the model’s ability to detect
and classify abnormal arrhythmias and congestive heart failure ECG signals.

Table 1: Model Performance with and without Data Augmentation


Classifier Accuracy (Without Augmentation) Accuracy (With Augmentation)
Random Forest 92.33% 95.00%
XGBoost 92.00% 99.58%
SVM 41.67% 37.5%
KNN 52.00% 67.00%

Data augmentation significantly enhances the performance of the ECG signal clas-
sification model. As shown in Table 1, the accuracy of Random Forest increased
from 92.33% to 95.00%, XGBoost from 92.00% to 99.58%, and KNN from 52.00% to
67.00%. This demonstrates that augmentation techniques improve model robustness
and accuracy, even when the original dataset is sufficient.

3.1.1 Flipping
Flipping is a data augmentation technique that involves inverting the polarity of the
signal. Flipping the signal can make the classification model more robust to changes
in signal orientation. ECG signals can vary in their orientation due to factors such as
electrodeplacement, patientpositioning, or recordingartif acts. By augmenting the
dataset with flipped signals, the model can learn to recognize patterns regardless of
the signal’s original orientation. Figure 3 illustrates a comparison between the original
signal and its corresponding flipped signal. Given an input signal S, the flipped signal
S flipped is obtained by multiplying each sample in S by -1:

7
Sflipped = −1 · S (6)

Fig. 3: Flipped Signal with Original Signal

3.1.2 Time Shifting


Figure 4 displays a comparison between the original signal and the time-shifted signal.
Time-shifting is a data augmentation technique that involves shifting the signal in
the time domain by a certain number of units. In this research work, a time shift of
5 units is used. The time-shifted signal S shifted can be obtained as displayed in the
equation 7. Given an input signal S, the time-shifted signal (S shifted) is obtained by
circularly shifting the samples in S by a shift amount k:

Sshifted[i] = S[(i + k) mod N ] (7)


where N is the length of the signal S.

3.2 Detailed Architecture of the Proposed Model for Feature


Extraction
Features are extracted from ECG signals in both the time domain and the frequency
domain using the WPT. Figure 5 illustrates the detailed architecture of the proposed
model offering insights into the methodology behind the process of feature extraction.

3.2.1 Time Domain Features


This process aimed to capture important statistical and spectral characteristics of the
signals. In the time domain, The mean (µ) and standard deviation (σ) of the signal are
computed. These statistical measures provide basic information about the signal’s cen-
tral tendency and variability. By calculating these features, obtain information about
the average amplitude and the variability of the ECG signal. These measures can help

8
Fig. 4: Time Shifted with Original Signal

differentiate between normal and abnormal patterns in the ECG. NSR, ARR, and
CHF exhibit distinct patterns in the ECG signals. Mean and standard deviation can
highlight differences in signal morphology among these rhythm types. The standard
deviation provides an indication of how much the signal values deviate from the mean.
In the context of ECG analysis, CHF can lead to increased variability in the signal due
to irregular heart contractions. Considering the standard deviation can capture this
increased variability, potentially aiding in the identification of congestive heart failure.
Mean and standard deviation can serve as informative features for classification algo-
rithms. By extracting these features and combining them with other relevant features,
can construct a feature vector that characterizes different ECG rhythm types.
• Mean (µ): Calculated as the average value of the signal.

N
1 X
µ= xi (8)
N i=1

Here, µ represents the mean value of the signal. N is the total number of samples
in the signal. xi represents the i-th sample of the signal.
• Standard Deviation (σ): Measured as the square root of the variance of the signal.
v
u
u 1 X N
σ=t (xi − µ)2 (9)
N − 1 i=1
Here, σ represents the standard deviation of the signal. N is the total number of
samples in the signal. xi represents the i-th sample of the signal. µ represents the
mean value of the signal.

9
Fig. 5: Detailed Architecture of the Proposed Method

3.2.2 Frequency Domain Features Extraction using Wavelet Packet


Transform
In the feature extraction process, the WPT is utilized to analyze the signal, employing
the ′ sym4′ wavelet, which represents the fourth-order symlet wavelet—a symmetric
extension of the Daubechies wavelet. WPT is an extension of the Discrete Wavelet
Transform (DWT) that offers a more detailed decomposition of the signal. In the
DWT, subsequent levels of the transform operate on the outputs of the Lowpass (Scal-
ing) filter, which may not provide a complete analysis of all frequency components. In
contrast, the WPT enables simultaneous processing of the results obtained from both
the Lowpass (Scaling) filter and the Highpass (Wavelet) filter at each level. The key
difference is that in the undecimated discrete wavelet transform, the outputs are not
downsampled. This means that the full frequency content of the signal is preserved

10
at each level of the transform, giving a more complete analysis of the signal. For a
one-dimensional signal x[n], the WPT can be expressed as:
X
W P Tj [n] = x[k] · ψj,k [n] (10)
k
Where, W P Tj [n] represents a WPT coefficient at a particular node. x[k] is the
input signal and ψj,k [n] is the wavelet function with scale j and translation k.

Table 2: Comparative Analysis of Different Wavelets


Wavelet Classifier Accuracy Best Parameters
Sym4 RF 95.00% Max Depth: 20, Min Samples Split: 2, Estimators: 50
XGBoost 99.58% Learning Rate: 0.1, Max Depth: 7, Estimators: 200
SVM 37.50% C: 1, Kernel: Linear
KNN 67.00% Neighbors: 3, Metric: Minkowski (P=1), Weights: Distance
GNB 55.20% Var Smoothing: 1e-9
db4 RF 97.11% Max Depth: None, Min Samples Split: 2, Estimators: 10
XGBoost 90.67% Learning Rate: 0.1, Max Depth: 3, Estimators: 50
SVM 79.22% C: 10, Gamma: Auto
KNN 70.22% Neighbors: 3
coif1 RF 95.22% Max Depth: None, Min Samples Split: 2, Estimators: 10
XGBoost 89.00% Learning Rate: 0.1, Max Depth: 3, Estimators: 50
SVM 78.00% C: 10, Gamma: Auto
KNN 69.56% Neighbors: 3
Haar RF 95.56% Max Depth: None, Min Samples Split: 2, Estimators: 10
XGBoost 88.22% Learning Rate: 0.1, Max Depth: 3, Estimators: 50
SVM 80.22% C: 10, Gamma: Auto
KNN 70.67% Neighbors: 3

In table 2, results demonstrated that the ’sym4’ wavelet provided the highest
accuracy with the XGBoost classifier, achieving an impressive accuracy of 99.58%,
surpassing other wavelets in performance metrics. The comparative results for each
classifier and their optimal parameters obtained through grid search optimization are
summarized in the above table 2. This comparative analysis validates the selection
of the ’sym4’ wavelet for the proposed ECG signal classification methodology. Fur-
thermore, WPT offers a notably versatile approach to signal analysis, especially when
the objective is to concentrate on distinct frequency bands or individual components
within the signal. This technique enables researchers and analysts to discern and exam-
ine specific aspects of a signal with a high degree of precision and selectivity, making
it a valuable tool in the realm of signal processing and analysis. In this work, one-
dimensional ECG signal x[n] decomposes using WPT with the Symlet-4 wavelet at
level 3. Here’s how the decomposition proceeds:

Level 1 Decomposition (j = 1)
At the first level, the ECG signal is decomposed into approximation and detail coef-
ficients using the Sym4 wavelet. Figure 6 displays the ECG signal graph at level 1 (A

11
& D coefficients) with the original signal. The approximation coefficients at this level
represent the low-frequency components of the ECG signal, and the detail coefficients
capture high-frequency details. The decomposition is given by:
X
W P T1 [n] = x[k] · ψ1,k [n] (11)
k
Here, ψ1,k [n] represents the Sym4 wavelet function at level 1.

Fig. 6: WPD level 1 bands with original ECG signal


.

Level 2 Decomposition (j = 2)
At the second level, both the approximation and detail coefficients from level 1 are
further decomposed into their own approximation and detail coefficients. Figure 7
displays the ECG signal decomposition at level 2 with the original signal. This results
in a more detailed representation of the ECG signal, capturing both low and high-
frequency components. The decomposition equations are as follows:
X
W P T2A [n] = W P T1A [k] · ψ2,k [n] (12)
k

X
W P T2D [n] = W P T1D [k] · ψ2,k [n] (13)
k
Here, ψ2,k [n] represents the Sym4 wavelet function at level 2. W P T1A [k] and
W P T1D [k] are the approximation and detail coefficients obtained at level 1. Equ. 12
and Equ. 13 are employed in the computation of approximation coefficients (AA and
AD) and detailed coefficients (DA and DD) respectively.

Level 3 Decomposition (j = 3)
At the third level, the process continues, with both the approximation and detail
coefficients from level 2 undergoing further decomposition. Figure 8 displays the ECG
signal decomposition at level 3 with the original signal. The equations for the third-
level decomposition are as follows:

12
Fig. 7: WPD level 2 bands with original ECG signal

X
W P T3A [n] = W P T2A [k] · ψ3,k [n] (14)
k
X
W P T3D [n] = W P T2D [k] · ψ3,k [n] (15)
k
Here, ψ3,k [n] represents the Sym4 wavelet function at level 3. W P T2A [k] and
W P T2D [k] are the approximation and detail coefficients obtained at level 2. Equ. 14 and
Equ. 15 are employed in the computation of approximation coefficients (AAA, AAD,
ADA, and ADD) and detailed coefficients (DAA, DAD, DDA, and DDD) respectively.

Fig. 8: WPD level 3 bands with original ECG signal

By performing this three-level decomposition using the Sym4 wavelet, obtain a


detailed representation of the original one-dimensional ECG signal x[n] that captures

13
different frequency components at various levels of detail. This multi-resolution anal-
ysis is valuable for tasks such as feature extraction in ECG data. Figure 9 depicts a
plot of all the bands at level 3 alongside the original signal.

Fig. 9: WPD level 3 bands with original ECG signal

Selection of Bands at Level 3 in WPT


In the context of WPT, at level 3, there are a total of eight available bands for
decomposition. These bands represent different combinations of approximation (A)
and detail (D) coefficients, each capturing specific information about the signal. The
eight bands at level 3 are AAA, AAD ADA, ADD, DAA, DAD, DDA, and DDD, where
each letter represents whether the coefficient is an approximation (A) or a detail (D)
coefficient.
For a particular signal analysis, it may be necessary to focus on specific frequency
components or details within the signal. In this scenario, we have selected four bands
out of the available eight for further analysis. The selected bands are as follows:
1. AAD (Approximation-Approximation- Detail): AAD combines two levels
of smoothed, lower-frequency information (AA) with the detailed high-frequency
information specific to the third level. This sub-band is capturing characteristics
related to the intermediate frequency range in a signal, potentially revealing details
about the morphology of ECG waveforms and different heart conditions.AAD band
plot displayed in Figure 10

Fig. 10: AAD plot

14
2. ADD (Approximation-Detai- Detail): It provides insights into both smoothed
and highly localized changes within the signal, offering a comprehensive view of
the signal’s frequency components. ADD is valuable for analyzing various features,
making it useful for applications like ECG analysis and the detection of cardiac
conditions. Figure 11 illustrates the ADD plot.

Fig. 11: ADD plot

3. DAD (Detail-Approximation- Detail): DAD band highlights high-frequency


details while still preserving essential approximation components.DAD band plot
displayed in Figure 12

Fig. 12: DAD plot

4. DDD (Detail-Detail-Detail): This band is selected to provide a comprehensive


analysis, capturing detailed high-frequency information without approximation.
This sub-band is sensitive to fast and localized changes within the signal, making it
invaluable for detecting specific cardiac events, arrhythmias, and other irregularities
in the ECG waveform. Figure 13 displayed a DDD plot.

Fig. 13: DDD plot

15
The choice of these specific bands allows for a more targeted analysis of the signal,
tailored to the requirements of the task at hand. The selection of bands in WPT
provides the flexibility to focus on the aspects of the signal that are most relevant to
analysis.

3.2.3 Energies, Power Spectral Density (PSD) and Spectral


Centroid (SC) Calculation
By the meticulous selection of specific nodes during wavelet packet decomposi-
tion(WPD), along with the subsequent computation of their energy values (represented
as the sum of squares of the coefficients), significant frequency components and their
corresponding contributions to the signal’s energy are discerned. These calculated
energy values are then leveraged to derive essential spectral features, including P SD
and Spectral Centroid. These spectral features provide valuable insights into the fre-
quency distribution within the signal, enriching the understanding and analysis. The
energy is calculated as follows.
N
X
Energy = c2i (16)
i=1
Here, ‘energy’ represents the energy of a selected node from the WPD. N is the total
number of coefficients in the selected node. ci represents the i-th coefficient of the
selected node.
PSD: The PSD is derived from the energies of the selected nodes. By examining
the PSD, which represents the power distribution across different frequency bands, it
can identify the dominant frequencies and their relative strengths. This information
helps in understanding the underlying mechanisms of cardiac disorders.
N
1 X
P SD = Energyi (17)
N i=1
where ’PSD’ represents the PSD, N is the total number of selected nodes, and
energyi represents the energy value of the i-th selected node.
SC: The SC is computed as the weighted average of the energies, indicating the
distribution of spectral energy.
PN
i=1 i · Energyi
SC = P N
(18)
i=1 Energyi
The SC represents the weighted average of the energy values of N selected nodes.
Let N be the total number of selected nodes, i be the index of the selected node, and
energyi be the energy value of the i-th selected node. Then, the SC can be calculated
as above Equ. 18 changes in the PSD and SC can provide quantitative measures of
alterations in the frequency characteristics of ECG signals. These changes may indi-
cate the progression or severity of cardiac conditions, including CHF. Tracking these
measures over time can assist in monitoring the effectiveness of treatments or inter-
ventions. The process commences with the extraction of informative features from the

16
input ECG signals. Both time and frequency domain analyses are deployed to encap-
sulate pertinent characteristics. In the time domain, statistical attributes, specifically
the mean and standard deviation, furnish insights into the overall signal morphology.
Meanwhile, in the frequency domain, the ’sym4’ wavelet is employed for WPT, and
energy values are derived from selectively chosen nodes at level 3. These energy values
provide valuable insights into the spectral attributes of the ECG signals. Each clas-
sifier acquires the distinctive attributes associated with ARR, CHF, and NSR ECG
signals.

3.2.4 Feature Importance


A total of eight features are derived from both the time and frequency domains. Within
the time domain, we calculate the mean (µ) and standard deviation (σ) of the signal.
In the frequency domain, assess the energies within four specific bands through the
WPT, as well as evaluate the PSD and the SC. The visual representations of these
extracted features, depicted in Figure 14, offer a visual means of understanding their
distribution and patterns.

Fig. 14: Features Visualization

The Displayed Figure 14 comprises a 3 x 3 grid of subplots, each displaying a fea-


ture’s distribution extracted from signals. The x-axis represents feature values, while
the y-axis depicts occurrence density via Kernel Density Estimation (KDE). Histogram
shapes reveal value distribution, with taller bars indicating higher density. KDE curves
offer insights into underlying probability density functions. The analysis yields insights
such as unimodal or bimodal distributions, spread, skewness, and overall shape, aiding

17
anomaly detection, feature selection, and data insights. The graph represents the dis-
tribution of different features extracted from the dataset. Each subplot in the graph
shows the histogram of a specific feature, and the histograms are differentiated by the
target labels (0, 1, 2). In the graph, each subplot corresponds to one of these features.
The x-axis represents the value range of the respective feature, and the y-axis repre-
sents the density of occurrences within that value range. The legend at the top right
corner of the graph represents the target labels. In this case, the labels 0, 1, and 2
represent different classes or categories of the data. These labels could correspond to
different types of signals or patterns that are being classified or analyzed. By observing
the histograms and the differentiation based on the target labels, we can gain insights
into the distribution and patterns of the features across different classes. It allows us
to understand how the feature values are distributed within each class and whether
there are noticeable differences or similarities between the classes.

3.3 Hyperparameters Optimization


The optimization of hyperparameters is achieved through the utilization of grid search,
and methodical exploration of predefined hyperparameter values to maximize their
performance. This iterative process serves to finely adjust the models and capture intri-
cate relationships within the ECG signal data. In the thorough evaluation of diverse
machine learning classifiers for the classification of ECG signal classes, an investigation
is conducted into the performance of RF, XGB, GB, SVM, KNN, and Gaussian Naive
Bayes algorithms. Among these classifiers, XGBoost emerges as the leading model fol-
lowing an exhaustive hyperparameter tuning process involving grid search. Through
the grid search, identified the optimal hyperparameters for the XGBoost model that
led to the best results in terms of classification accuracy and performance. Specifically,
achieved superior results with a learning rate of 0.1, a maximum depth of 7 for each
boosting tree, and the use of 200 estimators. This combination of hyperparameters
resulted in a well-generalized and robust model, capable of accurately distinguish-
ing between different ECG signal classes. Table 3 presents the optimal parameters
corresponding to each classifier.

4 Experimental Setup
The experimental setup involved implementing the proposed ECG signal classification
method using Python and libraries such as NumPy, pandas, scikit-learn, XGB, pywt,
and matplotlib. These tools are employed for data processing, manipulation, machine
learning, boosting, feature extraction through Wavelet Packet Transform, and visual
representation of results.

5 Experimental Results & Discussion


Based on the experimental results, indicating its ability to accurately classify ECG
signals. RF and GB demonstrated exceptional performance, achieving both high speci-
ficity and accuracy, with specificity values of 97.00% and 98.15%, and accuracy values

18
Table 3: Optimal Hyperparameters for Proposed Model’s
Classifiers using Grid Search
Classifier Parameter Value
XGBoost learning rate 0.1
max depth 7
estimators 200
RF max depth 20
min samples split 2
estimators 50
SVM cost parameter 1
kernel linear
KNN n neighbors 3
p 1
weights ’distance’
Gaussian Naive Bayes var smoothing default (1 × 10−9 )

of 95.00% and 96.25%, respectively, making them effective tools for cardiac condi-
tion identification.KNN and GNB also delivered notable results, with specificity and
accuracy values around 83.6% and 77.61%, indicating their competence in classifying
ECG signals. SVM, however, exhibited comparatively lower values for both specificity
and accuracy, with values of 73.3 and 37.5%, suggesting that SVM may not be the
optimal choice for this specific classification task. XGB displayed impressive speci-
ficity at 99.7% and accuracy at 99.58%, indicating its potential for detecting cardiac
conditions. Figure 15 illustrates the performance Metrics for all the classifiers.
A comprehensive overview of performance metrics for various classifiers, including
RF, GB, SVM, KNN, GNB and the proposed work, represented as ”XGB” These met-
rics encompass essential evaluation criteria such as Precision, F1-Score, Sensitivity,
Specificity, Accuracy, ARR, CHF, and NSR. Notably, the ”XGB” classifier, represent-
ing the proposed approach, demonstrates remarkable performance across the measured
metrics, with detailed insights provided in Table 4.
Using the same dataset, several additional methods are explored to optimize feature
selection in classification. The first experiment utilized Particle Swarm Optimization
(PSO) to enhance the accuracy of the RF, achieving an impressive 98%. In the second
experiment, the Genetic Algorithm (GA) is employed for feature subset evolution and
achieved 89.33% or accuracy with RF. The third experiment introduced a novel hybrid
approach, PSO-GA, which synergized PSO’s convergence speed and GA’s adaptability,
yielding a remarkable 97.78% accuracy in classifying ECG signals. Ultimately, the
proposed method, incorporating the XGB classifier, attained the highest accuracy of
99.58%.

5.1 Confusion Metrics Analysis


To ensure a balanced representation, a subset of the testing set containing a fixed
number of samples (80 samples per class) is selected for generating the confusion
Metrics. Figure 16 displayed the confusion Metrics for different classifiers.

19
Fig. 15: performance Metrics graph

Fig. 16: Confusion Metrics

Table 5 displayed the distribution of true positive, false positive, true negative,
and false negative predictions of the XGB classifier.
The confusion matrix table 5 reveals the number of true positives (TP), false
positives (FP), and false negatives (FN) for each class. Notably, the classifier achieved
perfect detection of Actual ARR, Actual CHF and Actual NSR cases, with TP counts
of 80 for both classes. However, for Actual CHF, there is 1 FN instance, indicating
cases where the model failed to correctly classify CHF. The absence of FP in the
Actual ARR and NSR categories suggests high precision in prediction. Overall, the
confusion matrix highlights the strengths of the classifier in differentiating between
the classes, and these models hold great promise for accurate cardiac disease diagnosis
and patient care.

20
Table 4: Performance metrics
Over all Over all
Classifiers Performance Metrics ARR CHF NSR
Specificity Accuracy
Precision 1 0.925 0.925
F1-Score 0.993 0.931 0.925
RF 0.97 0.95
Sensitivity 0.987 0.937 0.925
Specificity 0.993 0.968 0.962
Precision 0.987 0.961 0.938
F1-Score 0.993 0.949 0.944
GB 0.9813 0.9625
Sensitivity 1 0.937 0.95
Specificity 1 0.969 0.974
Precision 0.166 0.518 0.362
F1-Score 0.0232 0.261 0.522
SVM 0.733 0.375
Sensitivity 0.012 0.175 0.937
Specificity 0.662 0.69 0.848
Precision 0.73 0.659 0.621
F1-Score 0.721 0.69 0.597
KNN 0.836 0.67
Sensitivity 0.71 0.725 0.575
Specificity 0.858 0.855 0.795
Precision 0.87 0.594 0.433
F1-Score 0.701 0.376 0.554
GNB 0.7761 0.552
Sensitivity 0.587 0.275 0.766
Specificity [0.831 0.727 0.769
Precision 1 1 0.987
F1-Score 1 0.993 0.993
XGB 0.997 0.995
Sensitivity 1 0.987 1
Specificity 1 0.993 1

Table 5: Confusion Metrics


XGBoost
Classifier
Predicted Predicted Predicted
ARR CHF NSR
Actual ARR TP = 80 FP = 0 FN = 0
Actual CHF FP = 0 TP = 79 FN = 1
Actual NSR FP = 0 FP = 0 TP = 80

furthermore, the proposed model boasts high accuracy (99.58% with XGBoost),
robust data augmentation using flipping and time-shifting, and optimized feature
extraction via Wavelet Packet Transform (WPT) with ’sym4’ wavelet. Its comprehen-
sive evaluation with multiple classifiers demonstrates superiority over traditional and
deep learning methods, with significant implications for improving diagnostic accu-
racy, operational efficiency, and scalability in healthcare. However, the model requires
substantial computational resources, relies on a relatively small dataset, and shows
lower performance with SVM. Additionally, its dependence on data augmentation and
the need for further real-world validation are notable limitations.

21
5.2 Comparison with related work
In comparison to existing methods, proposed method stands out as it attains an
impressive accuracy of 99.58% on the MIT-BIH dataset, surpassing the performance
of several existing methods. Porumb et al. [16] employs a CNN and achieves an accu-
racy of 97.8%, while Avanzato and Beritelli [17] utilizes a 1-D CNN with five layers
and reports an accuracy of 98.33%. Kaspal et al. [18] combines ECG feature extrac-
tion and CNN, reaching accuracy levels of 90.60% and 93.24% for different datasets.
In contrast, Oh et al. [19] utilizes deep learning techniques such as CNN and LSTM,
yielding an accuracy of 98.10%. Huang et al. [20] applies STFT spectrogram and 2D-
CNN, achieving an accuracy of 99.00%, while Singh et al. [21] relies on RNN LSTM,
resulting in an accuracy of 88.1%. Orhan [22] uses a CNN and reports an accuracy
of 98.97%. Kaouter et al. [23] combines CNN with Continuous Wavelet Transform
(CWT), obtaining an accuracy of 93.75%, and Kumari et al. [24] utilizes CWT and
SVM, reaching an accuracy of 95.92%. Proposed approach, excels in accuracy, show-
casing its potential for advanced healthcare applications. Comparison of the proposed
method with several existing methods are displayed in Table 6.

Table 6: Comparison of proposed work with existing


Reference Method Dataset Results
MIT-BIH NSR
[16] CNN 97.8%
BIDMB CHF

MIT-BIH NSR
[17] 1-D CNN, 5-layer 98.33%
MIT-BIH Arrhythmia

SCD Holter
[18] ECG features extraction, CNN 90.60%
MIT-BIH Arrhythmia
93.24%

[19] Deep learning, CNN and MIT-BIT Arrhythmia 98.10%


LSTM

[20] STFT spectrogram 2D-CNN MIT-BIH 99.00%

[21] RNN LSTM MIT-BIH Arrhythmia 88.1%

[22] CNN CHF, NSR 98.97%

[23] CNN + CWT NSR, CHF, ARR 93.75%

[24] CWT + SVM CHF, NSR 95.92%

Time & freq. domain


Proposed features ,WPT MIT-BIH 99.58%
Work Energy, PSD, SC

22
6 Conclusion
This study presents a novel approach to ECG signal classification by leverag-
ing advanced data augmentation techniques and optimized feature extraction using
Wavelet Packet Transform with the ’sym4’ wavelet. The proposed model demonstrates
exceptional performance, achieving a high accuracy of 99.58% with XGBoost. These
results underscore the model’s robustness and effectiveness in accurately classifying
arrhythmias. The use of dual data augmentation techniques, including flipping and
time-shifting, significantly enhances the model’s ability to generalize to unseen data,
making it more reliable in practical applications. The comprehensive evaluation with
multiple classifiers further validates the superiority of the proposed method over tra-
ditional and deep learning models, highlighting its efficiency and lower computational
complexity.
The high accuracy and robust performance of the model have significant manage-
rial implications, including improved diagnostic accuracy, operational efficiency, cost
savings, scalability, and the potential for real-time patient monitoring. These benefits
make the proposed method a valuable tool in advancing automated cardiac disease
detection and enhancing patient care.
Future research could explore the integration of this model into wearable devices
and telemedicine platforms, as well as its application to larger and more diverse
datasets. The potential for continuous, real-time monitoring and early intervention
underscores the transformative impact this technology can have on cardiovascular
healthcare.

Funding
No funding for this study.

Declaration
On behalf of all authors, the corresponding author states that there is no conflict of
interest.

Ethical Approval
This article does not contain any studies which human participants or animals
performed by any of the authors.

References
[1] Manish Sharma, Ru-San Tan, and U Rajendra Acharya. Automated heartbeat
classification and detection of arrhythmia using optimal orthogonal wavelet filters.
Informatics in Medicine Unlocked, 16:100221, 2019.
[2] Enbiao Jing, Haiyang Zhang, ZhiGang Li, Yazhi Liu, Zhanlin Ji, Ivan Ganchev,
et al. Ecg heartbeat classification based on an improved resnet-18 model.
Computational and Mathematical Methods in Medicine, 2021, 2021.

23
[3] Agostino Giorgio, Maria Rizzi, and Cataldo Guaragnella. Efficient detection of
ventricular late potentials on ecg signals based on wavelet denoising and svm
classification. Information, 10(11):328, 2019.
[4] Chandan Kumar Jha and Maheshkumar H Kolekar. Cardiac arrhythmia clas-
sification using tunable q-wavelet transform based features and support vector
machine classifier. Biomedical Signal Processing and Control, 59:101875, 2020.
[5] Maheswari Arumugam and Arun Kumar Sangaiah. Arrhythmia identification
and classification using wavelet centered methodology in ecg signals. Concurrency
and computation: practice and experience, 32(17):e5553, 2020.
[6] Yunxiang Zhao, Jinyong Cheng, Ping Zhang, and Xueping Peng. Ecg classifica-
tion using deep cnn improved by wavelet transform. Computers, Materials and
Continua, 2020.
[7] Tao Wang, Changhua Lu, Yining Sun, Mei Yang, Chun Liu, and Chunsheng
Ou. Automatic ecg classification using continuous wavelet transform and
convolutional neural network. Entropy, 23(1):119, 2021.
[8] Shadhon Chandra Mohonta, Mohammod Abdul Motin, and Dinesh Kant Kumar.
Electrocardiogram based arrhythmia classification using wavelet transform with
deep learning model. Sensing and Bio-Sensing Research, 37:100502, 2022.
[9] Ahmed S Eltrass, Mazhar B Tayel, and Abeer I Ammar. Automated ecg multi-
class classification system based on combining deep learning features with hrv
and ecg measures. Neural Computing and Applications, 34(11):8755–8775, 2022.
[10] Diego Fernando Sendoya Losada, Julián José Soto Gómez, and Julián Andrés
Zúñiga Vela. Classification of ecg signals using machine learning techniques.
Academic Journal of Interdisciplinary Studies, 13(3):92, May 2024.
[11] Ning Li, Fuxing He, Wentao Ma, Ruotong Wang, Lin Jiang, and Xiaoping Zhang.
The identification of ecg signals using wavelet transform and woa-pnn. Sensors,
22(12):4343, 2022.
[12] Mohamed Hammad, Souham Meshoul, Piotr Dziwiński, Pawel Plawiak, and
Ibrahim A Elgendy. Efficient lightweight multimodel deep fusion based on ecg for
arrhythmia classification. Sensors, 22(23):9347, 2022.
[13] Mohamed Deriche, Saeed Aljabri, Mohammed Al-Akhras, Mohammed Siddiqui,
and Naziha Deriche. An optimal set of features for multi-class heart beat abnor-
mality classification. In 2019 16th International Multi-Conference on Systems,
Signals & Devices (SSD), pages 418–422. IEEE, 2019.
[14] Muhammad Salman Haleem, Rossana Castaldo, Silvio Marcello Pagliara, Mario
Petretta, Marco Salvatore, Monica Franzese, and Leandro Pecchia. Time adap-
tive ecg driven cardiovascular disease detector. Biomedical Signal Processing and
Control, 70:102968, 2021.
[15] Ary L Goldberger, Luis AN Amaral, Leon Glass, Jeffrey M Hausdorff, Plamen Ch
Ivanov, Roger G Mark, Joseph E Mietus, George B Moody, Chung-Kang Peng,
and H Eugene Stanley. Physiobank, physiotoolkit, and physionet: components of
a new research resource for complex physiologic signals. circulation, 101(23):e215–
e220, 2000.
[16] Mihaela Porumb, Ernesto Iadanza, Sebastiano Massaro, and Leandro Pecchia.
A convolutional neural network approach to detect congestive heart failure.

24
Biomedical Signal Processing and Control, 55:101597, 2020.
[17] Roberta Avanzato and Francesco Beritelli. Automatic ecg diagnosis using
convolutional neural network. Electronics, 9(6):951, 2020.
[18] Rabin Kaspal, Abeer Alsadoon, PWC Prasad, Nedhal A Al-Saiyd, Tran
Quoc Vinh Nguyen, and Duong Thu Hang Pham. A novel approach for early
prediction of sudden cardiac death (scd) using hybrid deep learning. Multimedia
Tools and Applications, 80:8063–8090, 2021.
[19] Shu Lih Oh, Eddie YK Ng, Ru San Tan, and U Rajendra Acharya. Auto-
mated diagnosis of arrhythmia using combination of cnn and lstm techniques with
variable length heart beats. Computers in biology and medicine, 102:278–287,
2018.
[20] Jingshan Huang, Binqiang Chen, Bin Yao, and Wangpeng He. Ecg arrhyth-
mia classification using stft-based spectrogram and convolutional neural network.
IEEE access, 7:92871–92880, 2019.
[21] Shraddha Singh, Saroj Kumar Pandey, Urja Pawar, and Rekh Ram Janghel. Clas-
sification of ecg arrhythmia using recurrent neural networks. Procedia computer
science, 132:1290–1297, 2018.
[22] Umut Orhan. Real-time chf detection from ecg signals using a novel discretization
method. Computers in biology and medicine, 43(10):1556–1562, 2013.
[23] Karboub Kaouter, Tabaa Mohamed, Dellagi Sofiene, Dandache Abbas, and
Moutaouakkil Fouad. Full training convolutional neural network for ecg signals
classification. In AIP conference proceedings, volume 2190. AIP Publishing, 2019.
[24] Ch Usha Kumari, R Ankita, T Pavani, N Arun Vignesh, N Tarun Varma,
Md Aqeel Manzar, and A Reethika. Heart rhythm abnormality detection and
classification using machine learning technique. In 2020 4th International Confer-
ence on Trends in Electronics and Informatics (ICOEI)(48184), pages 580–584.
IEEE, 2020.

25

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy