1 Introduction

A healthy heart is vital for keeping an individual healthy. The heart’s electrical system is responsible for maintaining normal heart rhythm. Any disruptions in this system causes irregular rhythms, referred as arrhythmia, i.e., the heart may beat much faster (tachycardia) or slower (bradycardia) as compared to the normal heart rhythm. In addition to tachycardia and bradycardia, another type of arrhythmia could be fibrillation, which is characterized by chaotic and irregular heartbeat. It is normal for the heart to beat slow or fast in certain scenarios, however, larger irregularities might be a concern. Ventricular tachycardia (VT) and ventricular fibrillation (VF) are the leading causes of severe conditions such as sudden cardiac arrest, which require immediate medical attention [1,2,3]. A comprehensive review on sudden cardiac death (SCD) is provided in [4].

Sudden cardiac arrest refers to an abrupt loss in heart functioning. It may also lead to breathlessness and unconsciousness. It is usually caused by arrhythmia, resulting in improper pumping of blood to different parts of the body. If immediate assistance is not provided, it may result in SCD. It is listed amongst the topmost causes of natural deaths around the world [5]. Cardiopulmonary resuscitation (CPR) might be administered to the patient while medical assistance is being arranged. Further, defibrillation can help in restoring the heart functioning by providing an electrical stimulation [6,7,8]. Implantable defibrillators [9] are also being developed to reduce SCD risk. While patients with a history of cardiac disorder, such as coronary artery disease (CAD) exhibit a higher likelihood for SCD, it may also occur in patients having no pre-existing heart abnormality. Therefore, it is important to develop automated tools for an early assessment of SCD risk, to improve the survival chances of probable SCD cases. Although multiple techniques have been explored to predict the SCD risk, the most commonly used modality is electrocardiogram (ECG), since it has the advantages of being readily available, non-invasive and cost-effective [10, 11].

1.1 Literature review

Various studies in the literature proposed automated arrhythmia detection [12,13,14,15] considering ECG signals. A careful examination of different waves within the ECG signal offers insights into the functional abnormalities of the heart. Different measures relating to conduction and repolarization intervals in ECG are analyzed to predict ventricular arrhythmias [16,17,18,19,20,21]. QT interval [18], QT dispersion [19], T-wave alternans [20, 21] and the interval \(T_pT_e\) between peak and end of T-wave [17] are the repolarization-based predictors. On the other hand, \(T_pT_e/QRS\) and \(T_pT_e/(QT \times QRS)\) denote conduction-repolarization markers [16]. These parameters are computed from the wave corresponding to QRS complex and T-wave in the ECG signal. In addition to these, authors in [22, 23] examined ratios of repolarization intervals to predict SCD risk. The ECG morphological feature, R peak to T-end is investigated in [24] to foresee sudden cardiac arrest few minutes before VF onset. Further, magnitude and phase features computed using Taylor-Fourier transform are considered in [25]. Wavelet transform is used in [26, 27] to extract features from ECG signals. However, wavelet-based methods require prior selection of suitable wavelet as well as the levels of decomposition. These factors are critical to the performance of such methods. In cardiac sarcoidosis patients [28], SCD is predicted using multimodality imaging. Deep learning techniques are also explored in [29, 30] to detect SCD cases, but they require high computation resources.

Some researchers have analyzed heart rate variability (HRV) to detect SCD cases. HRV refers to the variation in the time gap between consecutive heart beats. Higher HRV is usually favorable as it indicates a stronger ability to handle stress. A recent study [31] found that populations with lower HRV values are at a higher risk of cardiovascular disorders. Various other studies [32,33,34] have also linked history of lower HRV values with deaths caused by abnormal heart function. However, a consensus is yet to be established regarding the normative HRV values [35, 36]. Moreover, assessment of SCD risk is highly complex and there is no clear evidence regarding relationship between SCD and an underlying pathology, such as HRV. A recent research [37] shows that less than 50% of SCD patients had low HRV values. Therefore, some recent works [38,39,40,41,42] extracted different features from HRV to predict SCD occurrence. Authors in [38] considered Wigner-Ville distribution to extract suitable information from HRV, while wavelet transform based approaches are considered in [37, 39]. Further, time-frequency domain information is captured in [40] using generalized S-transform. Feature selection techniques are explored in [43] for selecting appropriate features extracted from HRV signals.

Table 1 Summary of the existing techniques and research gaps

A summary of state-of-the-art techniques in literature for SCD detection, along with the identified research gaps, is provided in Table 1. Most of these works have compared SCD patients with normal sinus rhythm (NSR) subjects. Such a comparison may lead to inaccurate analysis as the differentiating factors might also be present in patients suffering from other heart disorders. Therefore, it is essential to discriminate between SCD and other critical cases such as congestive heart failure (CHF). If patients suffering from CAD are not treated, it may lead to infarction in coronary arteries, resulting in CHF, i.e., inability of heart to supply adequate blood to different parts of the body. Also, the prediction period should not be very small, since it is important to predict the occurrence as early as possible. The method should be accurate as well as sensitive towards detecting the critical cases.

1.2 Major contributions

In this work, we develop an easy-to-implement efficient method to differentiate between SCD and non-SCD cases. Discrete Fourier transform (DFT) is utilized to obtain frequency-based signal decomposition using zero-phase filtering. The key contributions of this work are as follows:

  1. 1.

    A novel feature is proposed to capture local patterns from the sub-band components extracted from 1 minute segments of the ECG signal.

  2. 2.

    Diverse machine learning-based classification algorithms are explored to produce the desired performance.

  3. 3.

    Robustness of the proposed method is demonstrated by evaluating performance in noisy conditions.

  4. 4.

    The proposed method achieves 100% accuracy for various scenarios, and provides sufficient time for the medical experts to take suitable curative actions.

  5. 5.

    The strength of our algorithm lies in its simplicity, accuracy and low computational complexity. Since DFT and inverse DFT can be easily implemented using fast-Fourier transform (FFT) algorithms, the proposed method can be easily deployed in real-time systems.

Table 2 List of abbreviations

Abbreviations used in this paper are listed in Table 2. The rest of the paper is organized as follows: The dataset, pre-processing, feature extraction and classification methods are described in Section 2. The results and discussions are provided in Section 3 while Section 4 presents the conclusions and directions for future work.

2 Materials and methods

The framework of the proposed sytem in shown in Fig. 1. In consists of five major steps: data acquisition, pre-processing, feature extraction, dimensionality reduction and classification. These steps are discussed in detail in the following sections.

2.1 Dataset

In this work, our aim is to detect SCD patients from NSR and CHF patients. For SCD cases, we consider 23 complete Holter recordings obtained from Physionet database [44]. It includes 18 patients with underlying sinus rhythm, 4 with atrial fibrillation and 1 continuously paced. All the subjects had sustained ventricular tachyarrhythmia, and mostly had an actual cardiac arrest. The NSR dataset includes 18 long-term ECG recordings with no significant arrhythmia [45]. It has both male and female subjects of different age. For CHF category, we consider long-term ECG recordings of 15 male/female subjects [46]. Each recording is of 20 hours duration and contains ECG signals, sampled at 250 Hz.

We extract 30 minute recordings each from the SCD, CHF and NSR subjects. These signals are re-sampled at the uniform sample rate of 200 Hz. 20 minute ECG signals, which are taken 10 minutes prior to VF onset for SCD, are considered in the experiment. There is no VF onset in non-SCD classes, i.e., NSR and CHF. All the ECG signals are segmented into 1 minute non-overlapping intervals for processing. Hence, we have 460 segments from SCD, 360 segments from NSR, and 300 segments from CHF, resulting in a total 1120 segments.

Fig. 1
figure 1

Proposed automatic SCD detection algorithm

2.2 Pre-processing

The pre-processing of the ECG signals involves two steps: (1) Decomposition of signal into different sub-band components, (2) Removal of baseline wander (BW) and power-line interference (PLI). BW is low-frequency noise present in the signal because of slight movements of electrodes or any muscular movements of the patient [47]. On the other hand, PLI refers to the noise contributed by the electrical power supply attached to the recording device. BW and PLI tend to be present in the recorded ECG signals [48] and need to be suppressed before processing the signals for detecting any disease.

Fourier-based signal decomposition is applied as follows. Let X(k) denote the DFT [49] of the segment x[n], i.e.,

$$\begin{aligned} X(k) = \sum _{n=0}^{N-1} x[n] \exp (-j2\pi kn/N) \quad \text {for} \quad k=0,1,2,\dots ,N-1, \end{aligned}$$
(1)

where the length of each segment \(N=1200\). Fourier intrinsic band functions (FIBFs) refer to the sub-band components \(c_i[n]\), \(i = 1,2,\dots ,M\), and are obtained as

$$\begin{aligned} c_i[n] = \frac{1}{N} \sum _{k=0}^{N-1} X(k)H_i(k) \exp (j2\pi kn/N) \quad \text {for} \quad n=0,1,2,\dots ,N-1, \end{aligned}$$
(2)

where

$$ \begin{aligned} H_i(k)= {\left\{ \begin{array}{ll} 1, \quad \text {for} \quad (K_{i-1}+1) \le k \le K_i \quad \& \quad (N-K_i) \le k \le (N - K_{i-1}-1), \\ 0, \quad \text {otherwise,} \end{array}\right. } \end{aligned}$$
(3)

with \(K_0=0\) and \(K_M=N/2\). The values for \(K_1,K_2,\cdots ,K_{M-1}\) correspond to the desired cutoff frequencies for the FIBFs [49]. In this work, we consider uniform frequency bands, i.e., \(K_i = iN/2M\). It is interesting to note that \(H_i(k)\) represent zero-phase filters [50], since they take only real and positive values, resulting in the phase part becoming zero. This is necessary as it ensures that the components \(c_i[n]\) do not suffer from any undesired time delays. The signal components capturing BW and PLI can be obtained by setting the cutoff frequencies as (0, 0.5) Hz and (59.5, 60.5) Hz [47]. Thereafter, they are subtracted from the ECG signal. The rest of the sub-band components are utilized to extract relevant features as discussed in the next section. The ECG signals for NSR, CHF and SCD classes are shown in Figs. 2, 3 and 4, respectively, along with their 5 sub-band components.

Fig. 2
figure 2

NSR ECG signal and the extracted FIBFs

2.3 Feature extraction

In this work, we propose a pattern-based feature to extract distinct information from the signal. It helps in capturing the variations in the local neighborhood for each sample. Considering one segment x[n] of the signal, the look ahead pattern (LAP) are extracted from its sub-band components \(c_i[n]\) as follows:

$$\begin{aligned} b_{ni}[j]= {\left\{ \begin{array}{ll} 1, \quad \text {if} \quad c_i[n+j] \ge \quad c_i[n] \quad j = 1,2,\dots ,m \\ 0, \quad \text {otherwise.} \end{array}\right. } \end{aligned}$$
(4)

The length of the pattern is denoted by m, and it refers to the number of forward samples to be considered for computation of the pattern. Using the LAP \(b_{ni}[j]\), the corresponding values are computed as:

$$\begin{aligned} p_i[n] = \sum _{j=1}^{m}b_{ni}[j]2^{m-j} \quad n = 0,1,2,\dots ,(N-1)-m \, . \end{aligned}$$
(5)
Fig. 3
figure 3

CHF ECG signal and the extracted FIBFs

Fig. 4
figure 4

SCD ECG signal and the extracted FIBFs

Fig. 5
figure 5

Computation of look ahead pattern (LAP) from signal samples considering \(m=8\)

Figure 5 illustrates the calculation of LAP values \(p_i[n]\). Maximum weight of \(2^{m-1}\) is assigned to the position nearest to the current sample, i.e., \(j=1\). After computing \(p_i[n]\) for each \(x_i[n]\), \(2^m\)-bin histograms are obtained as follows:

$$\begin{aligned} h_i[l] = h_i[l] + 1 \quad \text {if} \quad p_i[n] = l, \quad l = 0,1,\dots ,2^m - 1, \end{aligned}$$
(6)

while scanning \(p_i[n]\), as n varies from 0 to \((N-m-1)\). Proceeding in this manner, M \(2^m\)-bin histograms are computed for each 1 minute segment of the signal resulting in a feature vector of length \(2^m \times M\).

Principal component analysis (PCA) is applied on the extracted feature set to reduce the feature dimension. In this work, we consider only the first five components obtained after applying PCA on the feature vectors.

2.4 Classification

Six different machine-learning classifiers, namely, Support vector machine (SVM), k-nearest neighbour (kNN), Naive bayes (NB), decision tree (DT), XGBoost (XGB) and random forest (RF) are considered here for binary classification of ECG signals. These classifiers are widely used in biomedical signal processing applications. A short description of the classifiers is provided below.

  1. 1.

    SVM: It is the most popular non-probabilistic machine-learning classifier used for ECG signal analysis [51, 52]. Linear SVM draws hyperplanes in N-dimensional space to classify N-dimensional feature data points. Hyperplanes are selected in such a way that maximizes the margin between hyperplanes and also to the nearest data points. In case data points are not linearly separable, then kernel functions are used to transform low-dimensional input space into high-dimensional space and make the data points separable. Quadratic, cubic and Gaussian are the commonly used kernels. SVM needs less memory because it uses only the subspace of training data points called support vectors for making decisions.

  2. 2.

    kNN: It does not have any predefined mapping function, hence it is a type of non-parametric machine-learning algorithm [53]. It finds k nearest neighbours of the feature data point and uses their class labels for prediction. The class of the test data is predicted as the label assigned to majority of the k nearest neighbors. kNN uses complete training data in prediction, hence needs larger memory. Distance metric and the value of k are two important factors in kNN algorithm. Euclidean, city block, Hamming and Minkowski are some of the popular distance metrics used to obtain the neighbours. In [54], kNN classifier is applied to classify ECG signals corresponding to various cardiac diseases.

  3. 3.

    NB: It is a supervised probabilistic classifier based on Bayes’ principle. It is also known as simple Bayes’ classifier [55]. In this algorithm, the frequency table of features is created and then likelihood is computed using their probabilities. Posterior probability is calculated by applying Bayes’ theorem.

  4. 4.

    DT: It is a rule-based supervised machine-learning classifier [56]. It gives a graphical outlook of all the possible solutions to a situation based on the given constraints. It has a tree-like structure with decision nodes and leaf nodes. All the decision nodes are internal nodes and represent features whereas leaf nodes are the output nodes. Starting from the root node, it keeps on selecting the best features with a simple yes/no answer on the decision nodes and proceeds further towards the leaf nodes through branches. It imitates human decision rule thinking process and hence is easy to understand. It is used in [57] for ECG signal classification.

  5. 5.

    XGB: XGB is an extreme gradient boosting decision tree algorithm [58]. In this, weak model predictions are combined to get the strong prediction. Weak models are connected in sequence. First DT is built using the training data further, second DT attempts to correct the errors of the first model. This process is continued till correct prediction is made for the total data set or the maximum number of models are trained. Weight is increased to wrongly predicted variables before feeding it to next DT. These individual classifiers are ensemble to get the strong classification model. Ensemble learning approach is used for carcinoma disease prediction in [59].

  6. 6.

    RF: RF is a bagging classifier algorithm [60]. It has multiple DT for base learning. Every DT is trained over the random subsets of the total data set. Prediction of individual DTs are aggregated to conclude the final prediction by majority voting. Hence the prediction is not dependent on any single DT. This process of randomization and ensemble, reduces the variance occurred due to individual DT.

3 Results and discussions

In this work, three classes of patients, namely, SCD (23 subjects), NSR (18 subjects) and CHF (15 subjects) are classified based on the ECG signals obtained from Physionet datasets [44,45,46]. These signals are divided into non-overlapping 1 minute segments and sampled at 200 Hz. Top 5 features obtained using PCA are used to train the six different classifiers. Cross-validation (CV) is performed using the hold-out CV scheme. The simulations are carried out using MATLAB 2020 on i3 processor with 512 GB RAM.

The performance of each classifier is evaluated using accuracy, sensitivity, specificity, precision and F1-score. These values are computed from the confusion matrix as follows:

$$\begin{aligned} \text {Accuracy}\, (ACC)= & {} \dfrac{T_{P}+T_{N}}{T_{P}+T_{N}+F_{P}+F_{N}}\times 100 \% \nonumber \\ \text {Sensitivity}\, (SNS)= & {} \dfrac{T_{P}}{T_{P}+F_{N}}\times 100 \% \nonumber \\ \text {Specificity/Selectivity}\, (SLC)= & {} \dfrac{T_{N}}{T_{N}+F_{P}}\times 100 \% \nonumber \\ \text {Precision}\, (PRC)= & {} \dfrac{T_P}{T_P+F_P}\times 100 \% \nonumber \\ \text {Recall}\, (RCL)= & {} \dfrac{T_P}{T_P+F_N}\times 100 \% \nonumber \\ \text {F1-score}\, (F1)= & {} 2 \left( \dfrac{PRC \times RCL}{PRC+RCL} \right) \times 100 \%, \end{aligned}$$
(7)

where \(T_{P}\) refers to the SCD cases predicted correctly and \(T_{N}\) denotes the non-SCD (NSR and/or CHF) cases predicted correctly. On the other hand, \(F_{P}\) refers to non-SCD cases predicted as SCD cases, while \(F_{N}\) includes SCD cases predicted as non-SCD cases.

Box plots graphically represent the spread of the data through quartiles based on five criteria, i.e. minimum, first quartile, median, third quartile and maximum. Hence, the dispersion of the data can be easily visualized. Box plots are drawn for top five PCA features in Fig. 6 to depict their statistical distribution for each of the three classes. The range of features for different classes can be compared, thereby assisting in discriminating between the classes. It is apparent that the selected features offer good separation between the NSR, CHF and SCD classes. Further, the first feature obtained after PCA is the most significant feature as compared to the other features.

Fig. 6
figure 6

Box plots depicting statistical distribution of the five features obtained after applying PCA on features extracted from the SCD, NSR and CHF ECG signals

Table 3 Comparison of different classifiers for differentiation between NSR and SCD cases

The ECG signal of a subject exhibits certain changes not only in the case of SCD, but also due to other cardiac disorders like CHF. Hence, experiments are conducted to perform three different binary classifications: SCD versus NSR, SCD versus CHF, and SCD versus non-SCD (CHF, NSR). This analysis identifies the vulnerable subjects of SCD accurately from CHF and NSR classes. Table 3 compares the performance of the six classifiers in terms of ACC, SNS, SLS, PRC and F1, for distinguishing between NSR and SCD classes. It is observed that SVM, DT, XGB and RF classifiers achieve 100% values for all the performance metrics. The next experiment is conducted to discriminate another cardiovascular disorder CHF from SCD subjects. Results are summarised in Table 4. SVM, kNN, DT, XGB and DT classifiers obtain 100% classification results in terms of various performance metrics. Lastly, the performance of various classifiers for non-SCD (CHF, NSR) versus SCD classification is compared in Table 5. Once again, 100% values are reported for SVM, DT, XGB and RF classifiers. Thus, the proposed algorithm is not only identifying SCD from NSR cases, but it is also able to differentiate between CHF and SCD cases with 100% accuracy.

Table 4 Comparison of different classifiers for differentiation between CHF and SCD cases
Table 5 Comparison of different classifiers for differentiation between non-SCD (CHF+NSR) and SCD cases
Fig. 7
figure 7

Classification accuracy at varying SNR levels considering different values of LAP feature length m

The results shown above are obtained using LAP feature with length \(m=6\). However, it is important to analyze the effect of change in feature length on the performance of the algorithm. Further, we also study the impact of additive white Gaussian noise (AWGN) to test the robustness of the proposed feature. Five different levels of signal-to-noise power ratio (SNR) are considered in this work, i.e., -10dB, -5dB, 0dB, 5dB and 10dB. Figure 7 (a), (b) and (c) show the accuracy obtained by SVM classifier at different SNR with \(m=5,6,7\), for classification between NSR & SCD, CHF & SCD, and non-SCD (NSR, CHF) & SCD cases, respectively. Similar trends are observed in all the three cases. It is evident that accuracy improves with increase in the length m, since better signal variations can be captured by taking more forward samples for computing LAP. However, as the SNR increases beyond 0dB, the accuracy achieved for different values of m becomes comparable. Considering a specific value for m and varying SNR, there is no significant change in the performance, except when the noise power becomes more than the signal power (SNR\(<0\)dB). Therefore, the proposed algorithm is quite robust to the presence of slight noise in the system.

In the literature, various other methods have been studied for classification of SCD signals. The results obtained by our method are compared with the state-of-the-art methods in Table 6. Devi et al. [37] used signal processing techniques to extract 32 features and optimal features are selected by unsupervised and boosting ensemble learning. SCD detection is performed 10 minutes prior to VF onset and 83.33% accuracy is obtained. The non-SCD class comprises both CHF and NSR cases. Further, reinforcement learning is applied in [29] to select features for 1 minute ECG segments for SCD and NSR subjects, but it suffers from the drawback of larger processing time. Prediction is done 13 minutes prior to VF onset and 90.18% accuracy is obtained. Fifty SCD signal features are combined in [9] to achieve 85.7% accuracy, while Parsi et al. [43] applied feature selection method and reported an accuracy of 91.5%. Morphological features are used in [24] for prediction of limited numbers of SCD and NSR subjects and 100% accuracy is achieved. In [23], arrhythmic parameters are used to classify only SCD and NSR classes and 99.49% accuracy is obtained. Most of these works consider the differentiation between the SCD and NSR classes only, and may thus fail in more realistic scenarios where the patient may be suffering from non-SCD disorder.

It is observed from Table 6 that the proposed method is performing better than the existing schemes with 100% accuracy for differentiating between SCD and non-SCD (NSR and CHF) cases. Moreover, the SCD prediction is done at least 10 minutes prior to VF onset, offering sufficient time for taking preventive action.

Table 6 Comparison of the proposed method with the existing methods

4 Conclusions and future directions

The challenging problem of prior identification of a severe heart abnormality, SCD, has been addressed in this work. The proposed method can assist in reducing the fatalities associated with the disease, by raising an alarm at the appropriate time. In this approach, the ECG signal is divided into 1 minute segments and these segments are decomposed into sub-band components using a Fourier-based technique. The baseline wander and power-line interference are also removed from the recorded ECG signal. Thereafter, look ahead pattern are extracted, followed by application of PCA. First five features, thus obtained, are utilized by machine-learning classifiers to differentiate between the SCD and non-SCD cases. The proposed method is robust, easy-to-implement as well as efficient. In terms of performance, the proposed algorithm is superior than the existing state-of-the-art schemes. It produces high classification accuracy even in noisy environments. In future, we would explore the proposed technique for automated assessment of other heart-related disorders using ECG signals. Look ahead pattern, as proposed in this work, may be utilized in other signal processing applications as well.