1 Introduction

In recent years, heart disease has consistently ranked as one of the leading causes of death worldwide. The mortality rate attributed to heart disease causes remains the highest globally, with related deaths accounting for one-third of all global fatalities each year. Consequently, urgent attention is required to address the prevention and timely diagnosis of heart disease.

Electrocardiogram (ECG) is one of the earliest biological signals studied and applied in clinical medicine. Meanwhile, ECG data is typically large-scale time-series data that requires reliable data storage and management. Cloud computing [1] provides an efficient solution for this, including features such as data backup, recovery, security, and access control, which has been successfully applied in [2]. As well, ECG is a crucial tool in the clinical diagnosis of cardiovascular disease. Consequently, improving the accuracy of ECG classification has become an attractive research focus [3,4,5,6]. Einthoven [7] invented the ECG machine in 1903 and it has been applied in clinical practice since then, making a significant contribution to the diagnosis, treatment and prevention of cardiovascular disease and arrhythmia. The automatic classification of ECG signals [8,9,10,11] has gained interest among academics due to the advancement of machine learning. Venkatesan et al. [12] utilized KNN to classify ECG signals by preprocessing the signals based on LMS algorithm, and the classifier exhibited excellent performance.

Sliding window algorithm is considered in this paper. Sliding windows are widely used in arrays or strings and perform well in the classification of time series. In time series of social indicators, Filho [13] combined the Detrended Fluctuation Analysis (DFA) with a sliding window to analyze the crime indicator fluctuations, which dynamically analyzed the related indicators like managing, monitoring, and controlling the information capacity of crime-ralated data. In biological series, for the precise detection of foot-to-ground contact phases, Jeon et al. [14] explored a model based on a sliding window and considered overlapping labels whose validation accuracy reached approximately 85%. Due to the excellent performance of sliding windows in time series, sliding windows have been taken into analyzing ECG signals [15,16,17]. Therefore, research of sliding windows is of great social significance.

Multifractal Detrended Fluctuation Analysis (MF-DFA) model is selected to extract features in this paper. MF-DFA is developed on the basis of DFA [18, 19], a scalar index calculation method proposed by Peng et al. in 1994 for analyzing long-range correlations in time series using the DNA mechanism. DFA determines the statistical autocorrelation of a signal based on Hurst exponents. However, traditional DFA only scales second-order statistical moments and assumes process being normally distributed. As well, DFA can be used to evaluate human ECG signals using the developed ECG device [20]. Subsequently, MF-DFA was proposed by Kantelhardt [21], enabling the extraction of scaled exponential and multifractal spectra of non-stationary time series. This allows for the efficient analysis of multifractal features in time series. Subsequently, MF-DFA has been widely used in various time series in different fields, such as meteorology, and financial mathematics [22, 23]. Morever, MF-DFA is also extensively used in practical applications, especially in classification. MF-DFA was adopted to extract features and performed excellently in classification [24]. Jiao et al. [25] used MF-DFA to identify chaotic features in three signal sets originating from states of Myocardial Infarction (MI), Arrhythmia, and a healthy state. In [26, 27], MF-DFA has satisfactory performance in classifying atrial premature beat people and normal sinus rhythm subjects. In addition to the overall study classification of ECG signals, a nearest neighbor classifier based on the local fractal dimension has been processed, demonstrating excellent adaptability [28].

In order to obtain more detailed information of ECG signals, the sliding window algorithm is adopted in this paper. Meanwhile, considering the multifractal nature of ECG signals, a classifier consisting of sliding windows and the MF-DFA method has been taken in to account.

The remainder of the paper is structured as follows. We introduce the methodology in Section 2. Section 3 intrduces some information of ECG signals. Section 4 exhibits the experimental results. Section 5 presents the comparisonand discussion with some existing methods. Section 6 reports the conclusion.

2 Methodology

2.1 Sliding window algorithm

The sliding window algorithm is used to solve the sub-element problem of an array or alphabetic string. It can transform the nested loop problem into a single loop problem so that the time complexity can be decreased. The specific operation is that using fixed-size sublist and iterating over the whole list with the sublist. It is commonly used in processing sequences [29].

The specific steps are given as follows:

Step1: Fix the size of the sliding window;

Step2: Fix q;

Step3: Move the sliding window with an increment of 15 until the right of the series, and then calculate the local Hurst exponent H in each sliding window respectively.

Step4: Compose a new sequence by using the calculated H and then apply the new time series to the MF-DFA model to extract 6 generalized Hurst exponents.

Step5: Calculate the accuracy, sensitivity and specificity of the classification using support vector machine (SVM) based on 6 extracted generalized feature values.

Step6: Alter q, repeat the previous operations and compare the performances of the classification.

2.2 MF-DFA

Consider a time series \(\left\{ T\right\} _a, a=1,2,\dots ,W\). Construct a cumulative sequence as follows:

$$\begin{aligned} t(i)=\sum _{i=1}^{j}(T_i-\overline{T}), j=1,...,N, \end{aligned}$$
(1)

where \(\overline{T}\) is the mean of \(\left\{ T\right\} _a^W\).

Divide the new time series t(i) into \(W_s\) segments and \(W_s = \lfloor \frac{W}{s} \rfloor \) where s is the size of non-overlapping window and W is the length of the series.

Here, in order to save more information, the segmentation operation is then performed again from the end to the begining. Therefore, \(2W_s\) segments can be obtained. Then, for the s points in each segment \(\mathcal {I},\quad \mathcal {I}=1,2,\dots ,2W_s\), applying least square method to polynomial fitting, we can obtain:

$$\begin{aligned} y_\mathcal {I}(\alpha ) = b_1\alpha ^k + b_2\alpha ^{k-1} + ... + b_k\alpha + b_{k+1},\quad \alpha = 1,2,...,s. \end{aligned}$$
(2)

Calculate the mean squared error and then calculate the \(q-\)order wave function on this basis. When \(\mathcal {I}=1,2,\dots ,W_s\):

$$\begin{aligned} f^2 = \frac{1}{s} \sum _{\alpha =1}^{s} \left\{ t[(\mathcal {I}-1)s+\alpha ]-y_\mathcal {I}\right\} . \end{aligned}$$
(3)

When \(\mathcal {I}=W_s,W_{s+2},\dots ,2W_s\):

$$\begin{aligned} f^2 = \frac{1}{s} \sum _{\alpha =1}^{s} \left\{ t[(W-(\mathcal {I}-W_s)s+\alpha ]-y_\mathcal {I}\right\} . \end{aligned}$$
(4)
$$\begin{aligned} {\begin{matrix} F_q(s) = {\left\{ \begin{array}{ll} \left\{ \frac{1}{W_s} \sum _{w=1}^{W_s} [f^2]^q \right\} ^{\frac{1}{q}}, ~ \text{ if } q \ne 0,\\ \exp \left( \frac{1}{W_s} \sum _{w=1}^{W_s} \ln [f^2] \right) , ~ \text{ if } q = 0. \end{array}\right. } \end{matrix}} \end{aligned}$$
(5)

With the increase of s, \(F_q(s)\) will increase in a power-law relationship, which can be interpreted as \(F_q(s) \varpropto s^{h(q)}\). h(q) is called generalized Hurst exponent. Also, when \(q = 2\), we call it standard DFA model. When h(q) varies with q, the time series will exhibit multifractal properties. Otherwise, when the original sequence is a single fractal, h(q) is a constant independent of q.

2.3 Support vector machine

Support vector machine (SVM) is a commonly used classifier [30], which is widely used in binary classification problems. SVM plays a major role not only in linear classification but also nonlinear classification. When it comes to nonlinear classification, a suitable Kernel function is selected to transform nonlinear classification problem into linear classification problem, allowing us to avoid computing dot product in high-dimensional feature space. Therefore, the problem needs to be solved is given as follows.

$$\begin{aligned} \underset{\lambda }{\min }[\frac{1}{2} \sum _{i=1}^{n}\sum _{j=1}^{n}\lambda _i\lambda _jy_iy_j(\phi (x_i)\cdot \phi (x_j))-\sum _{i=1}^{n}\lambda _i], \end{aligned}$$
(6)
$$\begin{aligned} s.t. \sum _{i=1}^{n}\lambda _iy_i=0, \quad 0\le \lambda _i\le C, \quad i=,1,2,\dots ,N, \end{aligned}$$
(7)

where x represents the original sample and \(\phi (x)\) represents the new feature vector. \(y_i\) and \(y_j\) are the classification labels, where \(y_i, y_j \in \left\{ +1,-1\right\} \) and C is a constant greater than 0, representing the penalty function. Meanwhile, from (7), the best solution can be obtained \(\lambda ^*=(\lambda _1^*,\lambda _2^*,\dots ,\lambda _N^*)^T\).

Next, calculate the following formulas:

$$\begin{aligned} {\begin{matrix} w^*=\sum _{i=1}^{N}\lambda _i^*y_i(x_i\cdot x_j),\\ b^*=y_j-\sum _{i=1}^{N}\lambda _i^*y_i(x_i \cdot x_j). \end{matrix}} \end{aligned}$$
(8)

Here, choose a component \(\lambda _j^*\) of \(\lambda ^*\), which should satisfy \(0<\lambda _j^*<C\).

Finally, separate hyperplane.

$$\begin{aligned} w^*\cdot x+b^*=0. \end{aligned}$$
(9)

The split hyperplane can be expressed as \(f(x)=sign(w^*x+b^*)\) or \(f(x)=sign(\sum _{i=1}^{N}\lambda _i^*y_i(x_i\cdot x_j)+b^*)\). The inner product can be replaced by kernel function, which can obtain the nonlinear SVM. The commonly used kernel functions are shown in Table 1.

Table 1 Kernel functions
Fig. 1
figure 1

The original time series of NSR ECG signals and APB ECG signals

3 Data collection

All ECG signals were obtained from the MIT-BIH Arrhythmia Database. All ECG signals were recorded with a sampling frequency of 360 HZ and a sampling frequency of 200 [adu/mV]. We collect ECG signals from 50 subjects with atrial premature beat (APB) and 50 people with normal sinus rhythm (NSR). Each piece of ECG signals consists of 3600 points.

Fig. 2
figure 2

Schematic diagram of the process of constructing a new time series. 100 points represent the size of the sliding window and we calculate the Hurst exponent of the 100 points. The sliding window moves to the right with an interval of 15 points

Fig. 3
figure 3

A new times series composed by local Hurst exponents when q equals 0

We use the sliding window with a fixed size of 100 to acquire a local Hurst exponent. Then, move the sliding window to the end in a step size of 15 each time. Therefore, we can obtain 234 local Hurst exponents from each time series. Subsequently, we treated these 234 local Hurst exponents as a new time series and utilize the MF-DFA method to require a set of generalized Hurst exponents which is then used in the classification by SVM.

4 Computational results

First of all, we fix the size of the sliding window to 100 and move it at an interval of 15 each time. Next, we fix q and calculate the local Hurst exponent H of ECG signals in each sliding window. All calculations were conducted using MATLAB R2020a on a 2.50GHz Intel(R) Core(TM) i5-7200U CPU.

Table 2 SWD-MF-DFA model based on different q

An original ECG sequence is made up of 3600 points. Figure 1 exhibits the initial time series. First, we consider the case when q equals 0. Therefore, we can obtain a new series (for convenience, we call it DFA series). The process of extracting local Hurst exponents from the original ECG signal sequence by using the sliding window can be referred to Fig. 2. Figure 3 shows the new time series consisting of local Hurst exponents.

DFA method is used in the first step. It is a common method to handle non-stationary signals like meteorological signals [31]. DFA can quantitatively analyze the correlation nature of signal sequences and determine the different properties of the signals by calculating the correlation index. As well, it is capable of effectively filtering out trend components of various orders in the sequence and detecting long-range correlations containing noise, which is suitable for the analysis of non-stationary time series with long-range power-law correlation.

Fig. 4
figure 4

Six generalized Hurst exponents of (a) NSR ECG signals and (b) APB ECG signals

The following step involves using the MF-DFA method to extract 6 feature values, referred to as Sliding-Window-DFA-MF-DFA model (SWD-MF-DFA). SVM is utilized to examine the accuracy based on the extracted generalized Hurst exponents and Gaussian kernel function is adopted. When constructing the DFA sequence, we adopt different values of q and calculate the corresponding accuracies. Since the common range of q used in MF-DFA is (-10, 10), so the q adopted to obtain local Hurst exponents are integers within this range, totaling 21 samples. Subsequently, extract 6 generalized Hurst exponents and use them as a feature vector. Then, apply the feature vector to SVM to calculate the accuracy, as well as the sensitivity and the specificity. Since SVM is supervised learning, we label the feature vectors of NSR ECG signal with the value 1 as the class 1 and label the feature vectors of NSR ECG signals with the value -1 as the class 2. Due to the small number of samples, we use leave-one-out cross-validation method. In this paper, we randomly disrupt the samples 100 times. Each time, the samples are divided into 10 disjoint subsets, with one serving as the test set and the rest as the training set. Therefore, the samples can be fully utilized so that the results are the closest to the expectations of training on the entire test set. Table 2 displays the classification accuracy, sensitivity, and specificity. We observe that when q deviates from 0, the accuracy shows a downward trend generally. However, all the accuracies are higher than 60%.

Here, q represents the order of the fluctuation function in DFA series and Q represents the range of q used in the MF-DFA model. Acc, Sen, and Spe represent accuracy, sensitivity and specificity, respectively. The specific calculations are given as follows:

$$\begin{aligned} {\begin{matrix} Acc &{}= \frac{TP+TN}{TP+FN+FP+TN},\\ Sen &{}= \frac{TP}{TP+FP},\\ Spe &{}= \frac{TP}{TP+FN}, \end{matrix}} \end{aligned}$$
(10)

where the meanings of TP, TN, FP and FN are True positive, True negative, False positive, and False negative, respectively.

Figure 4 shows the distribution of the features. The blue line represents the generalized Hurst exponent when q equals 0. We observe that the points above the blue line represent generalized Hurst exponent when Q belongs to (-10, 0), are quite scattered. Conversely, below the blue line, when Q is (0, 10), the distribution of the points is clustered. When the fluctuation of the features is larger, the self-similarity is sacrificed more. In other words, the similarity of NSR ECG signals and APB ECG signals increases, indicating that it is challenging to distinguish NSR and APB ECG signals, leading to a decrease in classification accuracy.

Fig. 5
figure 5

(a): x represents the first generalized Hurst exponent; y represents the second generalized Hurst exponent; z represents the third generalized Hurst exponent; the three generalized Hurst exponents are extracted when Q is (-10, 0), and (b): x represents the forth generalized Hurst exponent; y represents the fifth generalized Hurst exponent; z represents the sixth generalized Hurst exponent; the three generalized Hurst exponents are extracted when Q is (0, 10)

It is difficult to determine the distinctiveness of the features from Fig. 4. As well, we observe the fluctuation in APB ECG signals is evident. When Q is in the range of (-10,0), the dissimilarity before the APB and NSR ECG signals appears to be smaller compared to when Q is in the range (0, 10). Therefore, we divide the extracted feature values in Fig. 4 into 2 parts equally, delimited by the blue line, where the blue line is the Hurst value when Q equals 0. Thus, three feature values are extracted when Q is (-10, 0) and the other feature values are extracted when Q belongs to (0, 10). We use 3D coordinates to present their distribution. Figure 5 exhibits a better fluctuation phenomenon. The red circles represent the features extracted from APB ECG signals and the black circles are the features extracted from NSR ECG signals. The one the left means the generalized Hurst exponents when \(Q<0\), and the one on the right means \(Q>0\). Comparing with Fig. 5(a) and (b), the intersecting points in Fig. 5(a) are more than those in Fig. 5(b). When the degree of mixing is higher, the similarity of two signals is higher, indicating that it is hard to distinguish the signals, resulting in low classification accuracy. It is evident that the degree of mixing is higher when Q is (-10, 0). Few points are cross-distributed. Therefore, we select the range (0, 10) as the experimental interval.

In order to better discriminate this pattern, for the previous 21 samples, we fix Q to (-10, 0) and extract 6 generalized Hurst exponents. Afterwards, the extracted 6 feature values form a feature vector, which is then applied it to SVM to calculate the classification accuracy of SWD-MF-DFA model. Subsequently, change Q to (0, 10) and repeat the previous operations. All the calculated results are shown in Table 3. Under the same q, the bolded data represents the higher accuracy obtained by reextracting the features from the newly obtained sequence and classifying it. It is obvious to see from Table 3 that the accuracy when Q is (0, 10) is higher than that when Q is (-10, 0) in most samples. It is clear from Fig. 6 that the extracted feature values of NSR ECG signals in the interval (0, 10) have fewer intersections with those of APB ECG signals. That means (0, 10) is the better interval that should be selected.

Table 3 SWD-MF-DFA model based on different q

Figure 6 clearly illustrates the similarity of the extracted feature values. When Q belongs to (-10, 10) and (-10, 0), various feature values of APB ECG signals are intertwined with those of NSR ECG signals. However, in Fig. 6(c), the eigenvalues are basically separate, suggesting that the accuracy of the classification will increase. In the two exceptions noted in Table 3, we find they still satisfy the pattern. Observing Fig. 7, the Hurst exponents in Fig. 7(a) and (b) have more intersections than those in Fig. 7(c). In some parts, a higher accuracy is achieved when Q is in (-10, 0) because the intersectionality of feature values in (-10, 0) is lower than that of (0, 10). Therefore, features in (-10, 0) are more differentiated.

Fig. 6
figure 6

Based on MF-DFA, the distribution of feature values of the DFA series constructed when q equal 0. (a): Six features are extracted when Q is (-10, 10), (b): Six features are extracted when Q is (-10, 0), and (c): Six features are extracted when Q is (0, 10)

Fig. 7
figure 7

Based on MF-DFA, the distribution of feature values of the DFA series constructed when q equals 6. (a): Six features are extracted when Q is (-10, 10), (b): Six features are extracted when Q is (0, 10), and (c): Six features are extracted when Q is (-10, 0)

Then, we use MF-DFA to obtain six feature values without processing the original series. The results are listed in Table 4:

Table 4 The classification accuracy, sensitivity and specificity of the MF-DFA method without prior treatment

Comparing with the traditional MF-DFA method, we find that the accuracy of SWD-MF-DFA is higher. Table 5 shows when q equals 0 during constructing DFA series and the range of Q in MF-DFA is (0, 10), the accuracy of classification is the best. At last, we pick it as the parameter in our method. 90% of the samples are used as the training set, and the remaining 10% are used as the test set. We use SVM to perform 100 cross-validations and pick up the mean value. At the same time, we calculate the sensitivity and specificity in Fig. 8.

Table 5 The accuracy, sensitivity and specificity based on SWD-MF-DFA model and DFA sequence constructed when q is 0
Fig. 8
figure 8

The accuracy, the sensitivity, and the specificity of SWD-MF-DFA model. The accuracy is the mean value after 100 calculations, so as the sensitivity and the specificity

Table 6 Comparison with other methods about ECG signals in heart disease

5 Discussion

From Tables 4 and 5, it is evident that our proposed method has a higher accuracy, indicating that our approach is more effective at capturing the key information in the input data compared to the sole use of the MF-DFA method. Meanwhile, we compare the performance of the proposed method with existing approaches. Here, the experimental ECG data comes from MIT-BIH Arrhythmia Database. Observing Table 6, although the classification accuracy is not the highest, the accuracy of our proposed method is acceptable. As well, the sensitivity needs to be further improved. However, it is gratifying that the specificity is satisfactory.

In fact, sliding window has been widely in various models [36,37,38]. Meanwhile, the proposed method can effectively extract local features, so that the the local structures and patterns in the data can be focused on. This aids in capturing the local information, thereby increasing sensitivity to local variations. As well, the extraction of local features can decrease the dimension of the data, indicating that the original data can be mapped to a more compact representation, helping to reduce computational burden and prevent overfitting.

6 Conclusions

In this paper, considering MF-DFA performs well in ECG classification, and in order to obtain more detailed local information of ECG signals, we introduced a sliding window algorithm to the MF-DFA model. We took 100 points as a group, then used the MF-DFA model to extract the Hurst exponent of this set of points. Subsequently, we took another 100 points to the right at an interval of 15, and calculated the Hurst exponent until the last point was reached. Therefore, a total of 234 Hurst exponents can be obtained, which were used to form a new series. Next, we extracted 6 generalized Hurst exponents using MF-DFA of the new series, which were regarded as the input vector of SVM. Finally, we used SVM to examine the performance of the proposed method.

Here, we employed the influence of q when forming the new sequence. Generally, when forming the new sequence, we conducted 21 experiments, iterating over q with an interval of 1, ranging from -10 to 10. The results showed that when \(q=0\), the classification accuracy of the new formed series was the highest. As well, we observed the difference of the fluctuation when extracting 6 generalized Hurst exponents. In most conditions, when Q was in (0, 10), the accuracy was higher than that when Q was (-10, 0). As well, from the spatial distribution of feature values, when Q was in the range of (0, 10), the intersection between NSR ECG signals and APB ECG signals was smaller, indicating that the similarity was low so that the accuracy was higher. Finally, the SWD-MF-DFA model obtained a classification accuracy, sensitivity, and specificity of 90.00%, 81.93%, and 98.10%, respectively. Meanwhile, we compared our method to only using MF-DFA, our method performed better. As well, we compared the proposed method with other methods, although there was still room for improvement, the results were satisfactory. In the future, we will modify this model and render it suitable for 2D image classification.