Keywords

1 Introduction

From many literatures published recently, it can find that most of the research work tend to research the field of ECG (Electrocardiograph) automatic classification in the time domain and frequency domain analysis, while the heart is a complex nonlinear chaotic system, which is affected by many factors. So the form of ECG is very different, the time domain analysis and frequency domain analysis can only give some simple characteristics of the test data from time domain and frequency domain, hence, under the internal factors and external factors together the difference between the original expected results and the actual situation are very big. A large number of researchers have proved that the ECG signal has multiple fractal characteristics, while the use of multi-fractal to analyze the chaotic system is also a trend.

ECG data pre-analysis process is the main research content of the ECG signal noise interference. ECG data preprocessing techniques include a variety of classical filter filtering methods and a variety of modern use of waveform transformation signal processing methods. These pretreatment techniques can be divided into three categories: the classical filter method, the optimized filter method and the high-tech filter method based on wavelet analysis, mathematical morphology and neural network analysis.

Currently, the main research direction of ECG automatic classification and identification is to extract the characteristic waveforms of the ECG signal and its waveform characteristic parameters so as to analyze and diagnose the ECG signal type.

With the development and research of wavelet analysis, neural network, fractal theory and other nonlinear signal processing techniques, the knowledge in these fields is used to analyze the data, which is composed of continuous Q wave, R wave and S wave. Wave group identification has become a new focus of attention. Sahambi et al. [10] proposed a method based on the principle of wavelet transform modulus maxima. The algorithm successfully identifies the waveforms and their associated features in the ECG data, and the algorithm has strong resistance to simulated baseline drift and high frequency noise. Wavelet transform and adaptive matching filter technology are combined to achieve a new QRS complex detection technology, the application of this method after the QRS wave group detection accuracy and detection rate has been greatly improved.

2 Basic Theory

2.1 Fractal Concept

Definition:

If a set ensures that the formula (1) holds, then we call the set as a fractal set. For \( D_{H} (A) \) is the Hausdorff dimension of set \( A \), \( D_{\text{T}} (A) \) is the geometry dimension of \( A \).

$$ D_{H} (A) > D_{\text{T}} (A) $$
(1)

Although the fractal judgment using the definition of formula (1) is correct, there are still some fractal geometries that can be omitted, and it cannot contain some useful fractal geometry.

After scholars continue to theoretical research and practical application, resulting in a variety of views to explain the concept of fractal, to enhance their understanding [16]:

  1. (1)

    The structure is very detailed, in a small detail, the local implication of all the characteristics of the overall change;

  2. (2)

    Fractal is actually a feature, which is not only applicable to the geometry, it also is a concept, function, or some kind of signal in a statistical model.

  3. (3)

    Uncertainty and irregularity, the traditional European geometric language can only analyze its whole or part of the characteristics of the part.

  4. (4)

    In theory, fractal geometry can be done infinite mosaic, but in reality the nature of fractal geometry is impossible to have an infinite mosaic of the hierarchical structure.

  5. (5)

    One of the characteristics of self-similarity is the level difference. In general, localities and the whole show good similarity only in the case of hierarchical adjacency; on the contrary, the greater the gap between the levels, the local and the whole show a poor self-similarity, and even come to that they are dissimilar conclusion.

  6. (6)

    A part of the fractal geometry can be simply defined and analyzed by recursive and iterative methods.

2.2 Fractal Characteristics

Fractal characteristics as mentioned above, the two main properties of fractal are self-similarity and scale-free.

  1. (1)

    Self-similarity

One of the most representative features of fractal theory is self-similarity. As the fractal definition mentioned in the concept of fractal, the basis for judging whether a thing has fractal properties is whether the thing has self-similarity. Self-similarity refers to the structural characteristics or process characteristics of things in different observation scales, local and overall performance consistent or similar.

  1. (2)

    No scaling

In the part of the fractal geometry, since the thing has self-similarity, the selected local area is enlarged and transformed, and the local area is compared with the original one by enlarging and transforming. It is found that the original area and the local area in the morphological characteristics of performance similar or consistent, this feature is called scale-free.

2.3 Multi-fractal Data Analysis

In the process of analyzing the data using fractal theory, many researchers are aware of a similar phenomenon [13]: When using the single-fold fractal theory to describe most of the things that exist objectively, the single-fractal theory can only be able to describe the global features, and it lack of the more delicate characterization of local characteristics.

The single-fractal analysis can only describe the global features of time-series data, and lack of a more detailed characterization of the local features. Multifractal analysis, as a single-fractal analysis extension, can effectively deal with such phenomena, and is widely used in Characterization of Time Series.

Mainly using MFDFA method for processing, MFDFA method process:

  1. (1)

    time series \( x_{t} ,t = 1,2,3, \ldots ,T \);

  2. (2)

    Calculate the cumulative deviation sequence \( Y_{i} \):

    $$ Y_{i} = \sum\limits_{k = 1}^{i} {(x_{k} - \overline{x} )} ,i = 1,2,3, \ldots ,T $$
    (2)
  3. (3)

    Calculate the local root mean square \( F(s,v) \): divide the cumulative deviation sequence into \( N_{s} \) segments, each segment length \( _{s} \), the last segment length is \( T\bmod s \); then the cumulative deviation sequence \( Y_{i} \) is divided into segments 2 \( N_{s} \), each segment length \( s \) and the last segment length \( T\bmod s \). This is divided into 2 \( N_{s} \) segments. Calculate the local root mean square of each segment, and get the root mean square sequence \( f(s,v) \)

    $$ \begin{aligned} & f(s,v) = \frac{1}{s}\sum\limits_{i = 1}^{s} {(Y_{(v - 1)s + i} - y_{v} (i))^{2} } , \\ & v = 1,2,3, \ldots ,N_{s} \\ \end{aligned} $$
    (3)
    $$ \begin{aligned} & f(s,v) = \frac{1}{s}\sum\limits_{i = 1}^{s} {(Y_{{N - (v - N_{s} )s + i}} - y_{v} (i))^{2} } , \\ & v = N_{s} + 1,N_{s} + 2,N_{s} + 3, \ldots ,2N_{s} \\ \end{aligned} $$
    (4)
    $$ \bar{x} = \frac{1}{T}\sum\limits_{k = 1}^{T} {x_{k} }. $$
  4. (4)

    Calculate the global root mean square \( F_{q} (s) \):

    (5)
  5. (5)

    According to formula (5), grouping with different q values, the q value of each group is the same, in the group take different s value to get many, with formula (6) obtaining the H value corresponding to the q value, finally obtains many pairs (q, H).

    $$ \ln F^{2} (q;s) = C + H \cdot \ln s $$
    (6)

    If the data is a multifractal time series, H and q are constant, that is, the generalized Hurst exponential graph is a curve; if the data is a single time series, a horizontal straight line.

  6. (6)

    Calculate the mass index \( \tau (q) \):

    $$ \tau (q) = qH(q) - 1 $$
    (7)
  7. (7)

    Calculate the singularity index \( \alpha \):

    $$ \alpha { = }\frac{d\tau (q)}{dq} = H(q) + q \cdot H^{\prime}(q) $$
    (8)
    $$ H^{\prime}(q_{i} ) = \frac{{H(q_{i} ) - H(q_{i + 1} )}}{{q_{i} - q_{i + 1} }} $$
    (9)
  8. (8)

    Calculate the singular spectrum \( f(\alpha ) \):

    $$ f(\alpha ) = q\alpha - \tau (q) = q(\alpha - h(q)) + 1 $$
    (10)

3 ECG Characteristics Analysis

3.1 Multifractal Analysis

In the MIT heart rate abnormalities database, selecting the five with a complete ECG cycle ECG data. The five ECGs were taken from different categories, such as normal beat (NB), left bundle branch block beat (LB), right bundle branch block heartbeat (RB), premature ventricular contraction (PB), and atrial premature beat (AB) were randomly selected, as shown in Fig. 1. NB signal, sub-picture b is the LB signal, sub-picture c is the RB signal, sub-picture d is the PB signal, and the sub-picture e is the AB signal. In the case of random sampling, for each category, the data is collected for all categories. For example, when we extract the NB signal, the whole is made up of the MIT-BIT database as a whole, that is, the NB signal is composed of the NB signal extracted from the number 100 file to the number 234 file. To the NB signal extracted from the number 234 file. Respectively, on the extraction of five ECG time series are shown as below.

Fig. 1.
figure 1

Five ECG signals

The generalized Hurst exponent of the NB signal is shown in Fig. 2. The subgraph a is the general Hurst exponent of the NB signal, the subgraph b is the LB signal, and the subgraph c is RB signal, the sub picture d is the PB signal, the sub picture e is the AB signal. From the multifractal method we can see the generalized.

Fig. 2.
figure 2

Five generalized hurst exponential graphs

Hurst exponent H q and q can be used as the main basis for judging whether a thing has multifractality. It can be seen from the figure that the generalized Hurst exponents H q and q of the five electrocardiographic time series have obvious decreasing relations. So we can conclude that the ECG signal is multifractal. In the process of change of q and H q , we find that when the absolute value of q is greater than 5, the change of generalized Hurst exponent is obviously slowed down. Judging from the multi-fractal method can be seen when the HQ and q independent, that is, no matter how the occurrence of q changes, HQ is a constant, the thing is single-fractal. Therefore, we can draw the conclusion: ECG time series in the case of −5 \( \leqslant \) q \( \leqslant \) 5, the multi-fractal nature is the most obvious.

On the basis of the experimental evidence that the ECG signal has multi-fractal properties, we have carried on the further experiment. In the MIT-BIT database, 50 samples were extracted from the five ECG data, and the MFDFA method was applied to 250 ECG signals. The Hurst changes were extracted in Table 1. From Table 1, the difference between the NB signal and the RB signal is small, and the difference between the NB signal, the LB signal, the RB signal, the AB signal and the PB signal is large. It can be concluded that the generalized Hurst exponent cannot be used as the main classification feature of the five kinds of ECG signals, but it can only play a role of auxiliary ECG signal classification.

Table 1. Five generalized Hurst exponential changes

3.2 Scale-Free Interval Analysis

From the fractal characteristics of the previous, we can see that things with fractal properties are scale-free characteristics. So in the ECG signal processing, the determination of the scale-free interval is not negligible.

We also use the data in the scale-free interval analysis of the five signals as the research sample of the scale-free interval, where sub-graph a is the NB signal analysis graph, sub-graph b is the LB signal, sub-graph c is the RB signal, Sub-picture d is the PB signal, sub-picture e is the AB signal, in each sub-graph from bottom to top order q value, that is −10, −5, −3, −1, 0, 1, 3, 5, 10. The MFDFA method is applied to each sample data, the scale s is preset between 30 and 110, and the preset value range of the order q is “−10, −5, −3, −1, 0, 1, 3, 5, 10”. After the MFDFA method, the results shown in Fig. 3. It can be seen that for q > 0 and s between 60 and 100, \( {\text{ln}}(F_{q} ({\text{s}})) \) and s exhibits an obvious linear relationship with s To 100 for its scale-free interval.

Fig. 3.
figure 3

Analysis of five kinds of signals without scale interval

3.3 ECG Feature Identification

The scale-free interval obtained in the previous section has obvious problems: when q > 0, the resulting multifractal spectrum is a half-spectrum (as shown in Fig. 4). The general multifractal spectrum is a curve with a single peak. Therefore, we assume that the multi-fractal half-spectrum ECG signal can be used as the characteristics of ECG signal.

Fig. 4.
figure 4

Multifractal semigroup of five signals

The MFDFA method was applied to the BMC signal to obtain its multifractal spectrum (Fig. 5). From the multifractal spectrum, we can see that the BMC signal multifractal spectrum is symmetrical, and it can be used half spectrum, but the multi-fractal spectrum derived from the MFDFA method is less symmetry. Nonetheless, we can conclude that the multifractal can be approximated by the multifractal.

Fig. 5.
figure 5

BMC signal multiple fractal spectrum

4 Neural Network Classification

In this paper, the classification of the ECG signal using the back-propagation algorithm for weight adjustment and threshold adjustment of the feed-forward neural network as a classification model, the BP neural network. As the BP network model in the training process involves more parameters, so we must continue to adjust the parameters of model training, and through the classification of ECG signal classification accuracy rate to determine a set of parameters in the model performance.

4.1 The Number of Features and Classification Results

The MFDFA method was applied to the five ECG signals to obtain its multifractal half-spectrum and its generalized Hurst exponent. The features of multi-fractal half-spectrum and generalized Hurst exponent are divided into four categories:

  1. (1)

    Basic spectral characteristics

In general use of multifractal spectroscopy for classification of features, the researchers generally use the formula (11) as the eigenvector.

$$ \begin{aligned} & feature = \{ \alpha_{\hbox{min} } ,\alpha_{\hbox{max} } ,\Delta \alpha ,f_{\hbox{min} } (\alpha ), \\ & f_{\hbox{max} } (\alpha ),\Delta f(\alpha )\} \,{ = }\,F_{0} \\ \end{aligned} $$
(11)
  1. (2)

    the basic spectral characteristics and its expansion characteristics

This case contains four extended features in addition to the six eigenvalues in Eq. (11). These four expansion characteristics are \( \bar{\alpha } \), \( std(\alpha ) \), \( \bar{f}(\alpha ) \) and \( std(f(\alpha )) \), as in (12). Inside, \( \bar{\alpha } \) is the mean value of the sequence \( \alpha \) obtained after the MFDFA method, and \( std(\alpha ) \) is the standard deviation of the sequence, \( \bar{f}(\alpha ) \) is the mean value of the sequence \( f(\alpha ) \) obtained after the MFDFA method, and \( std(f(\alpha )) \) is the standard deviation of the sequence. So the eigenvalues in this case are shown in Eq. (13).

$$ F_{1} = \left\{ {\bar{\alpha },\,std(\alpha ),\,\bar{f}(\alpha ),\,std(f(\alpha ))} \right\} $$
(12)
$$ feature = F_{0} \cup F_{1} $$
(13)
  1. (3)

    Basic spectrum and generalized Hurst exponent

This case contains three generalized Hurst exponential features in addition to the six basic eigenvalues in Eq. (11). The three generalized Hurst exponential characteristics are \( h_{\hbox{min} },\, \) \( h_{\hbox{max} } \) and \( \Delta h \), as in (14). The minimum value of the generalized Hurst exponent sequence obtained by MFDFA method is the maximum value of the generalized Hurst exponent sequence, and \( \Delta h \) is the difference between \( h_{\hbox{max} } \) and \( h_{\hbox{min} } \). So this list contains the eigenvalues as shown in formula (15), which is the union of formulas (11) and (14).

$$ F_{2} = \{ h_{\hbox{min} } ,\,h_{\hbox{max} } ,\,\Delta h\} $$
(14)
$$ feature = F_{0} \cup F_{2} $$
(15)
  1. (4)

    Basic spectrum, spectral expansion and Hurst exponent characteristics

In this case, the first three lists are all included, including not only the basic spectral characteristics, but also the extended features of the basic features and the generalized Hurst exponential characteristics, as below formula

$$ feature = F_{0} \cup F_{1} \cup F_{2} $$
(16)

The above four kinds of lists are applied to the network model which has already been built. For each list, it is trained 30 times. Taking the average value of the iteration times, the mean value of the accuracy and the standard deviation of the accuracy as the standard metrics. The experimental results are shown in Table 2.

Table 2. Number of features and classification results

It can be seen from Table 2 that the increase of the number of features will promote the increase of accuracy, but also increase the time consumption of training. Training time and the number of features is a typical positive correlation, but the number of features and the number of iterations is not a clear linear relationship. From the first list to the second list of accuracy growth than from the first list to the third list of more accurate growth. Comparing the generalized Hurst index of the five ECG signals, the generalized Hurst index of the normal ECG and the generalized Hurst index of the abnormal ECG are obviously different, but the difference of the generalized Hurst index between abnormal electrocardiograms is not very obvious. It can be seen that the generalized Hurst exponent has obvious difference among the groups, but the difference among group is small, so the generalized Hurst index cannot be used as the feature of classification. However, by comparing the multi-fractal half-spectrum of five ECG signals, any one of the five signals has obvious distinguishing characteristics from the other four signals. So the generalized Hurst index can only be used as an auxiliary classification, but it can enhance the classification effect is limited. From the second list to the fourth list and from the third list to the fourth list, it is found that the extended features of the multifractal halftone are better than the generalized Hurst exponent for the network model. Moreover, comparing the first list with the third list, adding the generalized Hurst exponential feature will improve the classification effect of the network model, but at the same time will greatly increase the instability of the network model. A comparison of the second list and the fourth list will also reveal a similar situation. Therefore, although the generalized Hurst exponential feature can enhance the classification effect, it will increase the instability of the model at the same time.

4.2 Hidden Layer and Classification Results

The number of neurons in the hidden layer was set to 10, 20, 30 and 40, respectively, and the neural network model was used to study and validate the data. Under the conditions of the number of neurons in the hidden layer, 30 training and tests were taken, and the mean value of the iteration number, the mean value of the accuracy and the standard deviation of the accuracy were taken as the standard metrics.

As can be seen from Table 3, the number of hidden neurons and the number of iterations will show a typical positive correlation, that is, with the number of hidden neurons increases, the number of iterations will be significantly increased, but the number of elements of hidden layer of neurons and the number of iterations are nonlinear. While the more the hidden neuron are, the longer the network model will learn. As the number of neurons in the input layer increases, the number of loop optimization model parameters will increase correspondingly, meanwhile the time of model learning will increase.

Table 3. Hidden layer and iterative relationship

It can be seen from Table 4 that the accuracy of the model increases with the number of hidden neurons. However, when the number of neurons in the hidden layer exceeds 30, the increase in accuracy will be significantly reduced. Comparing the first and second lists with the first and the third lists, it is found that the generalized Hurst exponent is not as good as the extended multifractal spectral feature, but the generalized Hurst exponent has the same effect on the iteration number and there is no strong multifractal characteristic. The generalized Hurst exponent and the extended multifractal semi-spectral feature have advantages and disadvantages for the model’s lifting. Although extending the multi-fractal half spectrum, the multifractal half-spectrum characteristic is extended. At the same time found that the combination of the two cases, which is in the fourth case, the accuracy will be significantly improved.

Table 4. Hidden layer and accuracy relationship

From Table 5, we can see that with the increase of the number of neurons in the hidden layer, the stability of the model’s prediction will be enhanced. At that time, when the number of hidden layer neurons reached 30, the stability decreased slowly.

Table 5. Hidden layer and accuracy standard deviation

5 ECG Diagnosis System Process

5.1 De-noising

The process mainly for low-frequency noise filtering out high-frequency noise filtering and ECG cycle automatically.

  1. (1)

    low-frequency noise filter out

The main component of low-frequency noise is the baseline drift interference, so we filter out low-frequency noise in the method used to force the wavelet transform filter noise. Firstly, db5 wavelet is used to decompose the ECG signal. In the process of decomposition, the noise signal (low frequency noise) in the data is filtered by the one-dimensional wavelet coefficient threshold method.

  1. (2)

    high-frequency noise filter out

High-frequency noise mainly includes two parts of the EMG noise and power-frequency interference noise, so we use high-frequency noise filtering threshold method, the same multi-resolution using db5 wavelet decomposition.

5.2 Automatic Segmentation

The R-wave position is quickly located by the difference threshold method, and then the forward and backward search are carried out at the position of the R-wave, respectively. If the R-wave cannot satisfy the fixed length when the signal is taken forward, that is, if the longest signal that can be obtained is less than, the R-wave is discarded. Likewise, if the R-wave cannot satisfy the fixed length when the signal is taken backward, that is, the longest signal that can be obtained is less than, the R-wave is discarded. Finally, the segments of the electrocardiogram were segmented and the position of the R wave was recorded, and each ECG signal was distinguished by the position of the R wave.

5.3 Feature Extraction

The MFDFA method was used to extract the multi-fractal half-spectrum and generalized Hurst exponent of ECG, which is the formula (16). And the eigenvector is used as the output vector of the neural network classification model.

5.4 Classification of Models

The classification model uses a three-layer feedforward neural network, and uses the back propagation algorithm to update the weights and thresholds of each neuron. The training data and test data were used to train the feed-forward neural network model, and a model with 97.5% accuracy was chosen as the classification model of ECG diagnosis system. And two recent ECG diagnosis papers [15, 16] were compared. In [15], the features of ECG waveforms are extracted by using wavelet analysis, and the improved BP neural network algorithm is used to train ECG signals. The average recognition accuracy of this model is 92.8%. The article [16] uses the ECG signal chaos characteristic analysis and the Lyapuov index and so on as the characteristic of the ECG signal, and uses the BP neural network to carry on the classification, this model average recognition accuracy rate reaches 94.53%. The wavelet model and chaos model are compared with the fractal model. The comparison results are shown in Table 6. The results show that the fractal model is better than the wavelet model in classification, especially in the PB signal classification situation to enhance the effect is very obvious. Fractal model is superior to chaotic model in identifying NB, RB, PB and AB signals, especially for PB signals, although the ability to identify LB signals is slightly inferior to chaotic model.

Table 6. Comparison of model accuracy

5.5 Data Labeling

After the classification of the model, generate the corresponding data label file. The data in the label file is a matrix, which is the number of complete ECG cycles of the ECG signal. The first column shows the position of the R wave and the second column indicates the ECG period of the R wave. The categories of ECG signals are N, L, R, P and A, representing NB, LB, RB, PB and AB signals, respectively. And then generate the corresponding graph or table from the corresponding data annotation file.

In this paper, the main research content is NB, LB, RB, PB and AB signals, and in reality only these five signals composed of ECG fragments is relatively small, so the ECG fragments mentioned in this article ECG simulator simulation generated. Arranging different types of ECG signals into a sequence, and inputting the sequence into the ECG simulator, and finally generating an ECG fragment. 100 ECG fragments consisting of random arrangement of NB, LB, RB, PB and AB signals, each containing about 5 to 10 cycles. In Table 7, TP denotes the number of cases in which positive cases are judged as positive cases, that is, the actual number of ECG cycles is the same as the system judgment; FP is the number of cases in which negative cases are judged as positive cases, i.e., other kinds of signals FN is the number of cases in which the positive type is judged to be negative, that is, the signal of the current type is judged as the number of signals of other classes by the system; TN is the number of negative cases judged as negative. F1 is calculated by the formula (17).

Table 7. Simulation results
$$ F1 = \frac{2PR}{P + R} $$
(17)

The precision rate P and the recall rate R are calculated by the formulas (18) and (19), respectively.

$$ P = \frac{TP}{TP + FP} $$
(18)
$$ R = \frac{TP}{TP + FN} $$
(19)

From Table 7 available, the system of the ECG signal recognition ability from strong too weak in turn for the PB signal, RB signal, NB signal, LB signal, AB signal. Although the recognition of the AB signal the weakest, but the recognition rate of the system is still up to 93%.