Introduction

The electrocardiogram (ECG) is an indirect measure of the electrical activity of the heart. The activity can be measured by placing leads on the surface of the skin. Cardiologists can use features of measures to obtain important data about their patients’ clinical condition. The features are reflected by the morphology and duration of the individual waves of the ECG (P, QRS complex, and T waves). The detection of every component of the ECG can be an extra clinical sign and very informative with respect to the manifestation of the ECG waveform. In fact, waveform detection is necessary to determine the heart rate, and several related arrhythmias such as Tachycardia, Bradycardia and Heart Rate Variation. It is also necessary for further processing of the ECG signal in order to detect abnormal beats [1]. Particularly, the detection and classification of QRS complexes between normal and abnormal waveforms are very important clinical criteria for diagnosing of patients.

Producing an algorithm for the detection of ECG waveforms is a difficult problem due to the time-varying morphology of the signal subject to physiological conditions and with a presence of noise. Over the last decades there have been a number of techniques proposed to detect these waveforms. For instance early attempts of Senhadji et al who compared the ability of wavelet transform based on three different wavelets (Daubechies, Spline, and Morlet) to recognize and describe isolated cardiac beats [2]. Sahambi et al used a first-order derivative of the Gaussian function as a wavelet for the characterization of the ECG waveforms, where they used modulus maxima-based wavelet analysis to detect and measure various parts of signal, especially the location of the onset and offset of the QRS complex and P and T waves [3]. The other algorithms have been developed based on spectral [4, 5] or wavelet features [6, 7], amplitude relative to background activity [8, 9] and spatial context [10, 11] to characterize the ECG signal. These features was used to classify the ECG signal using statistical methods [12], ANNs [13], or support vector machines (SVMs) [14] in order to identify the occurrence of QRS complexes. It is crucial for ECG QRS detection systems to result in high sensitivity, even if this results in a large number of false detections. Such systems can be used to reduce considerably the amount of data that need to be reviewed then cardiologists can easily discard false detections. Since the application of wavelet transforms in electro-cardiology is a relatively new field of research, many methodological aspects of the wavelet technique is being applied and will require further investigations in order to improve the clinical usefulness of this novel signal processing technique.

In our previous work we examined ECG signals with complex valued CWT which produced desirable results, however it lacked with high computational cost [15]. In this study we develop a simple and computationally fast algorithm that provides reliable accuracy in detection and classification of heart abnormalities. Here, we analyzed the ECG data with proposed four wavelet functions which are Daubechies family of wavelets db5, symlets sym4 and from biorthogonal family of wavelets bior1.3, bior6.8. Following, we employ adaptive wavelet threshold method for detection and extraction of QRS complexes. In the final stage, we train and test the neural network with backpropagation learning algorithm. The detail procedures of our methodology are explained in the next section.

Material and methods

We used data from the MIT-BIH arrhythmia database to test the performance of our methodology [16]. All ECG data used here are sampled at 360 Hz, and the resolution of each sample is 11 bits/sample, therefore the bit rate of these data is 3,960 bps. We did the simulation on 100 different ECG obtained from various ECG systems of 30 patients. We also evaluated our algorithm using arrhythmic ECG data from the American Heart Association (AHA) database [17]. The data includes 80 two channel excerpts of analog ambulatory ECG recordings, digitized at 250 Hz per channel with 12 bit resolution over a 20 mV range. These recordings represent a wide variety of QRS morphologies according to level of arrhythmia. All of the tests were conducted both on normal and abnormal ECG for the robustness of the proposed method.

Wavelet analysis

The wavelet analysis procedure consists of adopting a wavelet function, also called an analyzing wavelet or mother wavelet. Temporal analysis is performed by contracting and dilating of the same analyzing wavelet function. In wavelet transform, the original signal is represented in terms of a wavelet expansion with respect to the analyzing mother wavelet. Therefore, we can perform the data operations using the corresponding wavelet coefficients. Because wavelet transforms measures the similarity between the wavelet basis function and the analyzed signal, it is important to find the appropriate wavelet basis functions that are suitable for the signal of interest that provides the strong resemblance index. Then the strong resemblance index will be the compact wavelet coefficients of the signal.

In fact, the wavelet function should have a certain shape that we would like to localize in the original signal. Then, one criterion for choosing the wavelet function is it looks similar to the patterns of the original QRS waveform. Therefore our choice is based on the shape of the QRS waveforms to be detected in the signal. As a result we can obtain only intrinsic signal structures across the wavelet subbands with properly selected wavelet functions. In the presence of noise, the successful separation of QRS complexes from noise can then be achieved.

The following process is done in wavelet analysis:

  1. 1.

    Perform multiscale decomposition of the signal using wavelet functions

  2. 2.

    Perform wavelet thresholding to extract QRS from noise at each subbands

  3. 3.

    Locate the arrival times of QRS complexes at across the subbands

  4. 4.

    Combine the QRS feature vectors at different subbands

In multiscale wavelet decompositions, the higher scales correspond to the more "stretched" wavelets that capture the low frequency contents of the signal. The more stretched the wavelet, the longer the portion of the signal is covered, and thus the sparser the signal features are measured by the wavelet coefficients. It was observed that QRS complexes are best represented at higher scales of the wavelet transforms, which our decision was made accordingly.

We propose four wavelet functions that are suitable in our study for detecting of QRS complexes. These functions are bior1.3, bior6.8, sym4 and db5 as illustrated in Fig. 1. It was found two biorthogonal wavelets match the intrinsic structure of QRS waveforms better than Daubechies wavelets, as their biphasic shape is reminiscent of QRS. It is therefore, expected that the biorthogonal wavelets provide a sparser representation of ECG signal than db2 and db5.

Fig. 1
figure 1

Four different mother wavelet functions, a bior1.3, b bior6.8, c sym4 and d db.5

Let us consider in brief, the representation of continuous-time functions in terms of two variables—scale and shift. The representation is called continuous wavelet transform [18]. Although the CWT is redundant, it is worth of use because of its interesting features. Consider a family of functions obtained by shifting and scaling a wavelet function ψ(t) such as

$$\psi _{{a,b}} {\left( t \right)} = \frac{1}{{{\sqrt a }}}\psi * {\left( {\frac{{t - b}}{a}} \right)}$$
(1)

where a, bR, a > 0, and a star denotes complex conjugate. The normalization ensures that \({\left| {\psi _{{a,b}} {\left( t \right)}} \right|} = \,{\left| {\psi {\left( t \right)}} \right|}\). The wavelet function has to oscillate. This, together with the decay property, has given ψ(t) the name wavelet or “small wave”.

The continuous wavelet transform of a signal s(t) is defined as

$$CWT{\left( {a,b} \right)} = {\int\limits_{ - \infty }^\infty {\psi _{{a,b}} {\left( t \right)}s{\left( t \right)}dt} }$$
(2)

The CWT possesses properties similar to properties of other linear transformations: linearity, shift property, localization property, energy conservation, and scaling property.

Because of high redundancy in CWT, it is inefficient for algorithmic implementation; however it is possible to discretize the transform parameters. Thus one can choose dyadic scales and translations from a discrete set \({\left\{ {a = 2^{j} ;\,b\, = \,k2^{j} ;j,k\, \in \,Z\,} \right\}}\), so that the corresponding wavelets ψ a,b an orthonormal basis of L 2(R). As the result the set of translations of CWT operates in discrete time vector. In this way we set dyadic scales of CWT to reduce the redundancy. It practically filters out a significant amount of noise and also appreciably reduces the real-time computation requirements. Conventional methods in QRS detection are based on discrete time wavelet transforms which are efficient but have some limitations. Our main idea was to mathematically improve the CWT performance over conventional methods and make it suitable for our purposes.

QRS detection by thresholding

Here we explain the threshold process for detecting of QRS waveforms. First, the CWT decomposition is applied to the ECG signal by using the proposed mother wavelets. As a result we obtain wavelet coefficients of the signal to further perform our analysis and operation on it. Following, we used an adaptive wavelet threshold method which was proposed by Donoho and Jonstone [19]. Their proposed wavelet threshold method performs reasonably accurate in the analysis of non-stationary signal such as ECG. For example, with an ECG free of artifact, a reasonable accurate detection of QRS waveforms is possible. Even so, the difficulty arises with artifacts, particularly the combination of various noise and signal types in the analyzed ECG signal. This problem increases the number of false detections, which commonly challenges all automatic systems.

The proposed wavelet threshold method is formulated as follows; Let s(t) be the noise free signal and x(t) the corrupted signal with white noise b(t) as in Eq. 1,

$$\begin{array}{*{20}l}{{x{\left( t \right)}_{{\,i}} = s{\left( t \right)}_{{\,i}} + b{\left( t \right)}_{{\,i}} } \hfill} & {{i = 1, \ldots ,n} \hfill} \\\end{array} $$
(3)

The thresholding function is defined in Eq. 2 which was proposed by Donoho and Johnstone.

$$T_{s} \,{\left( {\lambda ,w_{k} } \right)} = \left\{ {\begin{array}{*{20}l}{{x{\left( {w_{k} } \right)}} \hfill} & {{if{\left| {w_{k} } \right|} >\lambda } \hfill} \\{0 \hfill} & {{if{\left| {w_{k} } \right|} <\lambda } \hfill} \\\end{array} } \right.$$
(4)

where w k represents the wavelet coefficients of corrupted signal x(t).The thresholding acts on the wavelet coefficients w k at different scales \({\left\{ {k = 2^{j} ;j\, \in \,Z} \right\}}\). The authors proposed a universal threshold \(\lambda = \sigma {\sqrt {\,2\,\log {\left( N \right)}} }\) where N is the number of samples of the analyzed time series. Here σis the noise level of the wavelet coefficients defined by σ = MAD/0.6745. The MAD represents the absolute median estimated on each scale. We can obtain thresholded wavelet coefficients from the interested wavelet scale. Thus, for example if we want to get thresholded wavelet coefficients from the scale {a 2} we define the σ—noise level of that scale and set λ—threshold value and make our decision based Eq. 4 T s (λ,w 2). The overall detailed algorithm is illustrated in Fig. 2.

Fig. 2
figure 2

The proposed methodology flowchart for detecting of QRS complexes

Neural network classification

In classification stage three layer feedforward networks employing the backpropagation (BP) learning algorithm [20] were trained and tested using CWT coefficients obtained as described previously. Each network had a three nput nodes, variable numbers of hidden layer neurons (from 3 to 12), and one output neuron. Normal and abnormal QRS events were represented as 1 and 0 respectively. The sigmoid function was used as the activation function. We trained and tested each network at least twice, and took the best result as the accurate classification rate of that particular network. Classification performance of ANNs was measured using conventional criteria where a true positive (TP) outcome was registered when both ANN and ECG readers classified a QRS complex as abnormal. False positive (FP), true negative (TP) and false negative (FN) outcomes were similarly defined. Using these definitions, sensitivity specifity and selectivity values were calculated using formulas (Eqs. 57) below respectively.

$$Sensitivity = \frac{{TP}}{{TP + FN}}\, \times \,100\,{\left( \% \right)}$$
(5)
$$Specificity = \frac{{TP}}{{TN + FP}}\, \times \,100\,{\left( \% \right)}$$
(6)
$$ADR = \frac{{Sensitivity\, + \,Specificity}}{2}\, \times \,100\,{\left( \% \right)}$$
(7)

The average detection rate was used to calculate the overall classification accuracy of the proposed system.

Experimental results

The wavelet decompositions were applied at five levels from {a 2, a 4, a 6, a 8, a 10}.We have selected wavelet coefficients from each scales and compared the number of QRS detections. We found that the best representation of the QRS presence at scales {a 6, a 8}.Although, the presence of QRS complexes are also detected in other scales, however it makes difficult to discriminate the QRS from T wave. The Fig. 3 illustrates the wavelet decomposition of the noisy ECG signal. Without needing any preprocessing filtering technique, our method can extract pure QRS waves from the analyzed signal. The decompositions are obtained from {a 2, a 4, a 8, a 10} scales. One can notice the clear detection of QRS complexes throughout the five corresponding scales; however the {a 6, a 8} scales represent the clear ECG QRS components.

Fig. 3
figure 3

Wavelet decomposition of noisy ECG signal at five scales {a 2,…,a 10} using bior.6.8 function

Another example is shown in Fig. 4, from full length ECG signal corresponding to abnormal heart activity. The detection of QRS complexes is obtained from scale {a 8}. The results show us estimation of the signal QRS waveform much clearly that none of the signal is missed.

Fig. 4
figure 4

Full length signal a noisy ECG and b wavelet detection of the QRS complex at scale a8 using sym4

The main problems in detection of ECG points are the separation from the contaminated noise in the signal. Therefore most of the current algorithms face difficulties in extraction of QRS points in preprocessing stage. As a result it may increase misclassification performance of the classifier. Next, the detail of ECG signal segment and the denoised wavelet coefficients are shown in Fig. 5. This is the result when we calculate the σ noise level and extract it from the analyzed scale. It demonstrates the ability of our method to eliminate noises in ECG by capturing the most relevant and correlated coefficients between the signal segment and mother wavelets. Again, the clear detection of QRS and T waveforms are obtained.

Fig. 5
figure 5

Details of the ECG signal a in three cycles and b wavelet coefficients obtained at scale a8 using sym4

Following we tested our method for cardiac arrhythmia ECG with abnormal QRS wave. The results are depicted in Fig. 6 and detail segment is shown in Fig. 7. We found the algorithm is not sensitive to the change of QRS waveforms during abnormal heart activity.

Fig. 6
figure 6

ECG arrhythmia signal (a) and b detection using db5 wavelet function at scales {a2,…,a10}

Fig. 7
figure 7

Details of ECG, a QRS complex and b arrhythmia detection using db5 wavelet function

Let’s consider the case ECG with premature ventricular contraction (PVC), also known as a premature ventricular complex. The detection of PVC plays an important role in the diagnosis of the patients. It can be understood as a "skipped beat" or perceived as palpitations in the chest. In PVC, the ventricles contract first, which means that circulation is inefficient. Multiple beat PVC arrhythmias may pose a danger and single PVC beats can be asymptomatic in healthy individuals as well. The detection of abnormal QRS is obtained at through decomposed scales of wavelet functions as shown in Fig. 8. One can notice the abrupt changes in its amplitude of PVC QRS complexes. Thus the features extracted for normal and abnormal cardiac activity are distinct, which may further be used in automatic classification between two classes. The detail representation is shown in Fig. 9 where the R peak is identified using db5 wavelet function. The T waves are also detected in small wavelet coefficients however T wave features will be different from that of QRS complexes in classification stage.

Fig. 8
figure 8

PVC ECG signal, a QRS complex and b detection of QRS waveform using db5 wavelet function

Fig. 9
figure 9

Details of PVC ECG signal, a QRS complex and b detection using db5 at scale a6

We have evaluated our method in detecting of various arrhythmias relevant QRS waveforms that has normal and time varying irregular rhythms. Each beat detection were compared and confirmed with the recommendation of American National Standard for ambulatory ECG analyzers [21]. Although the ECG QRS complexes appear in variable shapes duration (width, morphology) depending on the arrhythmia type we confirmed that the proposed wavelet functions localize the important cardiac events accurately. Even those negative going waveforms can be detected, which is usually found in supraventricular arrhythmias. For instance, Fig. 10 illustrates the ECG segment from patient diagnosed with supraventricular arrhythmias. Rectangular in the Fig. 10 (a) shows the locations of one cycle QRS complex onset R wave and offset points. Wavelet localization of these waveforms regardless of the QRS morphology is obtained as shown in Fig. 10 (b) where the important diagnostic events such as onset offset and negative R wave are estimated. The locations of other QRS waveforms can be visually confirmed in the time series.

Fig. 10
figure 10

Supraventricular arrhythmia detection, a segment with negative going QRS complex, b wavelet detection of R peak with Q onset and S offset points

The overall classification of our method is discussed next. Input features to the neural network consisted of positive wavelet amplitude (PWA) and negative wavelet amplitude (NWA) crossings and the wavelet wave duration (WWD) of the QRS complex. Thus we defined three compact input feature vectors as shown in Fig. 11.

Fig. 11
figure 11

Wavelet input features for neural network classifier as positive, negative wavelet amplitude and duration of wavelet wave coefficients

Here the PWA and NWA feature values are set from the universal threshold \(\lambda = \sigma {\sqrt {\,2\,\log {\left( N \right)}} }\) which is automatically set for normal and arrhythmic QRS complex in wavelet stage. Since we are using a binary classification and because we have a good wavelet denoising method it is possible to consider the only arrhythmic QRS complex features vectors. Then the any other input feature vector will be considered as a normal QRS waveform.

Once the defining feature vectors are completed, a set of N input/output pairs as \(c_{n} = {\left\{ {\left. {x_{n} ,d_{n} } \right|n\, = 1,2, \ldots ,N} \right\}}\) is obtained, where c n represents the classes of ECG signal and x n , d n represents input feature vector and the desired output. We divided data into two subsets, training set and test set.

  1. 1.

    \(ECG_{{train}} = {\left\{ {\left. {x_{n} ,d_{n} } \right|n\, = 1,2, \ldots N} \right\}}\) is used to train ANN for adjusting and determining the networks’ running parameters weights and biases.

  2. 2.

    \(ECG_{{test}} = {\left\{ {\left. {x_{n} ,d_{n} } \right|n\, = 1,2, \ldots ,N} \right\}}\) is used to validate off-line classification performance of the neural networks once the network has converged.

Total number of 125 datasets corresponding to normal and arrhythmia ECG signal wavelet coefficients was collected. For training set ECG train 95 data samples have been used and the remaining ECG test was used for offline validation.

The validation was performed over the ECG signal class which was indicated by the index of highest output of the classifier. We repeated this procedure for several times, each time using a different test set chosen from the two class of the data, until all possible choices for the test set have been used. In addition, this type of training and testing process was done 10 times for each neural network model with varying hidden neurons with each subset of ECG train and received the average value.

For instance, the Table 1 provides the classification results obtained by each wavelet function as an input feature. The results are given in terms of sensitivity and specificity and average detection rate. One can compare the detection accuracy for each wavelet function, where biorthogonal wavelets surpass the other two wavelet functions in performance. Therefore the biorthogonal wavelet functions are selected for feature extraction.

Table 1 Detection results with four wavelets in terms of sensitivity, specificity and accuracy

We compared the results for classification accuracy from each wavelet scale ECG data set. For example, the detection accuracy is illustrated in Fig. 12 for four wavelet function at scales {a 2, a 4, a 6, a 8, a 10} accordingly. Results confirm that the choice of wavelet coefficient from scales { a 6, a 8 } provides better accuracy than the other scales. The details for overall highest classification accuracy was obtained by using biorthogonal wavelet functions with 96–93% at scale {a 6} and 97–98% at {a 8}.

Fig. 12
figure 12

Accuracy of ANNs from dyadic scale combinations using wavelet functions, bior1.3, bior6.8 and sym4, db5

ECG test data set contains various types of ECG signals corresponding to normal and arrhythmia. Here we manually divided the selected segment of ECG test data set into five classes (A, B, C, E, and F) to validate the offline classification performance. Table 2 shows the classification performance of the algorithm for selected ECG data set. Here we used bior1.3 wavelet coefficients as an input to neural network. First column of the table represents five data set each contains 10 recordings sets.

Table 2 The off-line validation results for the proposed algorithm applied to five data sets

Second column defines the belonging classes of each dataset as normal, PVC, VT and SVT classes. Following column shows the total number of test patterns corresponding to normal and abnormal patterns in each class of dataset.

For two classes of dataset (A, B) there were few abnormal QRS patterns detected. For PVC period several abnormal QRSs were detected. Since occurrence of PVC contains the periods with less abnormality so there’s actually abnormal activity in the recordings. As to VT and SVT data we can see that almost all events contain abnormal QRS but there were only a few normal QRS segments detected.

We can conclude that the maximum detection rate achieved 97.2% for off-line classification which is indeed good accuracy rate for unseen data recognition. We tested the neural networks several times and the accuracy was within the range of 94% to 97%. The neural classifier performance slightly changes at each trial however it still achieves reliable accuracy rate which is comparable with the currently available methods.

Discussion

In this work, we investigated the methodological aspects of continuous wavelet transforms to provide new robust method for detection of ECG QRS complexes. The efforts have been done for improvements in the algorithm towards more effective wavelet filtering and pre-processing stage as well as a better threshold technique. The developed methodology achieves higher detection rates using the proposed wavelet scheme. In addition, we found that designing a mother wavelet functions that matches the shape or frequency characteristics of QRS events offer higher accuracy of detection and classification. Besides we have applied wavelet thresholding which also was used as the denoising tool to reject various kinds of artefacts. Obtained results are promising for fast real time detection system and implementation of the algorithm. It also produces relatively good results with comparing to the present available works.

The neural network classifier when provided with reduced set of relevant features of QRS complexes (wavelet coefficients) achieves desired classification rates. As a result the classifier performance can be obtained without decreasing the information content of the signal. The classifier proved the robustness and speed of detection of abnormalities of QRS complexes, which is not too sensitive to the parameters of the wavelet coefficients. Another main criteria of our methodology based on low complexity of the algorithm hence low computational load, which can be characterized as very satisfactory. We believe that, the clinical use of the algorithm would be beneficial in the analysis of various types of cardiac disorders.

Let’s consider some of the well known methods for comparative case. First, Senhadji et al compared the ability of wavelet transform based on three different wavelets (Daubechies, Spline, and Morlet) to recognize and describe isolated cardiac beats [2]. Their proposed method carries a unique approach by using discrete wavelet transforms to obtain ECG coefficients from detail representations. The DWT is computationally fast but when applied to such physiological signal it may reject some important information of the signal content through filtering low, and high frequency contents of the signal. For analysis of ECG signals it is important to maintain the physiologically relevant information by rejecting other noise patterns. We found that this issue can be done using CWT. However CWT is redundant and computationally costly but still maintains most relevant information of the signal. We considered these issues of CWT by dyadic scaling and wavelet threshold method of Johnstone et al. as explained above.

Second, Sahambi et al used a first-order derivative of the Gaussian function as a wavelet for the characterization of the ECG waveforms [3]. Their method was motivated and somewhat similar to Senhadji’s work. But they consider different characteristics of wavelet transformations such as modulus maxima points to detect various parts of signal, especially the location of the onset and offset of the QRS complexes. Their method was probably most promising method at times. If compared with Sahambi’s method our approach is fast, robust and can not only detect QRS complexes, but also classify the normal, abnormal cardiac events, which is crucial in clinical diagnostics.

Even if the ECG studies is not limited to the mentioned algorithms, which are earlier attempts, and other recent detectors, such as those recently proposed Romero et al.[10] wavelet based and Li Gang [14] based on neural networks as well as Zumray et. al. [13] worked upon developing a novel method using hybrid neural networks. Obviously, the implementation of all these kinds of approaches depends on correct estimation (feature extraction) of the analyzed ECG signal context (noise and expected QRS complexes), which is sometimes a difficult task. In this study we attempted to develop a new approach in the detection of QRS complexes. The results suggest the reliability of our approach for QRS detection only and comparability with the proposed methods to recent days. This is part of our current work results which will lead us to the development of a real time QRS detectors for real-time monitoring in our further research.