Introduction

Electrocardiogram (ECG) is an important tool to know exact status of health of the heart worldwide [1, 2]. The clinical ECG signal is noisy due to deviations and artifacts that creep in during its acquisition [3,4,5]. These deviations and artifacts exist due to electromagnetic interference in the current carrying cables, muscle artifacts, body movements, and poor quality of electrodes [6]. ECG is graphical recording of the electric potentials [7,8,9] that are produced due to pumping action of the heart. Pumping action refers to depolarization and repolarization of the sinoatrial (SA) node followed by the depolarization and repolarization of the atrioventricular (AV) node [10]. This heart activity is captured using ECG machine through electrodes that are pasted on the body of the subject at specific locations. ECG signal usually consists of P-wave, QRS-complex, ST slope and T-wave components which indicate atrial depolarization, ventricular depolarization, blood supply in the body and ventricular repolarization, respectively [11, 12]. In QRS-complex, R-wave has highest amplitude (i.e., 1 mV) among all wave components of the ECG signal. Detection of R-wave amplitude (R-peak detection) is much useful for extracting clinical information in terms of heart rate (HR) [13,14,15] which is not possible by inspection with naked eye [16]. Therefore, computer-aided diagnosis (CAD) is required for efficient ECG signal interpretation [17,18,19,20]. Various methods have been proposed by researchers in the past, such as heuristic methods [21, 22], adaptive filters [4], chaos theory [23], short-time Fourier transform (STFT) [24], Approximate Entropy (ApEn) [25], Frequency-based methods [17], support vector machine (SVM) [9], S-Transform [6], and higher-order spectra [17]. In [21, 22], heuristic methods were proposed for classifying ECG signal, but outcome was highly dependent on proper selection of the bandpass filter (3 dB frequencies). After few years, wavelet transform (WT) [15] was proposed to overcome such drawbacks, but its performance was dependent on the choice of the mother wavelet [26]. In [4], adaptive filters were used for QRS-complex detection, but an appropriate reference signal was needed for its operation. In the previously published papers by same authors [23, 24], chaos theory and STFT were adopted as feature extraction tools. In STFT, the main limitation is its limited time–frequency resolution. On the other hand, in chaos theory proper selection of time delay dimension (embedding), correlation dimension, Lyapunov exponent, and entropy are challenging tasks. In [17], higher-order spectra method was presented as an emerging ECG signal analysis tool, but there was difficulty in extracting natural frequencies. In [25], automated identification of normal and diabetes heart rate signals were proposed using Approximate Entropy (ApEn), but it required knowledge of the previous amplitude values. In [9], SVM was used for pattern recognition in the ECG signal, but its operation was strongly dependent on the selection of the kernel with necessary speed and size parameters during both training and testing phase. Therefore, these limitations motivated us to explore further the effective processing of ECG signal for efficient R-peak detection. In this paper, Burg method is considered for extracting features using autoregressive (AR) coefficients and associated power spectrum due to its better frequency resolution, faster convergence for small signals and flexibility of choosing different AR model orders. During feature extraction, some spectral components are missed out. For that purpose, Hilbert transform is used to extract spectral estimation of the selected Burg feature vectors. Burg method extracts features by minimizing forward and backward prediction errors [27, 28]. Next, K-nearest neighbor (KNN) classifier discriminates query point (extracted Hilbert transform features) with considered reference vectors. Further, three nearest neighbors (K = 3) are selected to avoid any tie situation and Euclidean distance metric is selected because it does not require any weights for features [29]. After estimating Euclidean distance metric, a simple voting rule is adopted to classify the particular class of an ECG signal. Finally, heart rate (HR) and actual position of R-peaks in the ECG signal are detected by capturing maximum peak amplitude within ± 20 samples of already identified locations.

The paper is organized in the following manner: first section is devoted to literature survey, second section explains the materials and proposed methodology, third section covers results and discussion, and finally last section gives the important findings (observations) followed by conclusion at the end.

Literature Survey

Rai et al. [30] proposed Daubechies wavelet transform for R-peak detection and radial basis function neural network for the classification of ECG signals. They reported sensitivity of 99.8%, positive predictivity of 99.60%, specificity of 99.90%, and classification error rate of 0.12%. Haque et al. [31] proposed several adaptive filtering algorithms for ECG signal. They have found that normalized least mean square (NLMS) algorithm achieves high SNR. Mortezaee et al. [32] have considered singular spectrum analysis (SSA) to separate ECG signal from electromyogram (EMG) noise. For validation, two sub-sets from PhysioNet database [33] were considered. In [34], authors have proposed chaos theory for interpreting ECG signal which came out to be an essential approach for observing right condition of the heart. Chaos examines irregular attitude of the system and fits it into deterministic equations of motion [35]. He et al. [36] have proposed a bandpass filter to remove baseline wander and power-line interference from ECG signal. After filtering operation, K-nearest neighbor (KNN) and particle swarm optimization (PSO) were combined for accurate QRS detection on MIT-BIH arrhythmia database. They reported accuracy, sensitivity and positive predictivity of 99.43%, 99.69%, and 99.72%, respectively. Chakraborty and Ghosh [37] proposed Hurst Rescaled Range Analysis in the assessment of arrhythmia. The main aim of this research was to identify the severity of the disease, monitoring of different medicine and their doses, and also to assess the efficiency of different medicines. For achieving arrhythmia time series, MIT-BIH arrhythmia database was considered. In this research, fractal dimension parameter was adopted and found its values lower than normal. Van and Podmasteryev [38] have proposed support vector machine (SVM) for accurate detection of QRS-complexes on the MIT-BIH arrhythmia database. They reported sensitivity of 98.32% and specificity of 95.46%.

Materials and Methods

In this section, details of used ECG database, preprocessing technique, feature extraction technique, classification algorithm and performance evaluation parameters are provided.

ECG Database

For validation and evaluation of reliability of the proposed approach, Massachusetts Institute of Technology-Beth Israel Hospital (MIT-BIH) arrhythmia database [39] is used. This database includes 48 recordings sampled at 360 Hz using two-lead arrangement. The length of these 48 recordings is 30–60 min.

The whole process of signal classification is divided into three stages: preprocessing, feature extraction and classification as shown in Fig. 1.

Fig. 1
figure 1

Block diagram of proposed R-peak detection approach

Preprocessing

ECG signals are mostly corrupted by baseline wander (BLW) and power-line interference (PLI) noises [13]. This noise changes its own characteristics and affects the diagnostic accuracy. In this paper, KNN classifier is proposed for ECG signal classification whose classification performance severely degrades by the presence of noise [29]. Therefore, independent component analysis (ICA) and principal component analysis (PCA) are used for filtering purpose and dimensional reduction, respectively; ICA is performed on two-channel ECG signal using kurtosis analysis. Filtration using ICA is accomplished in two steps. In the first step, mixing matrix is obtained and in the second step, independent components (ICs) are obtained that indicate kurtosis value. Next, on the basis of kurtosis value, ICs are differentiated as noise or useful component of the ECG signal. Dimensionality reduction is done using PCA on the basis of variance. PCA operation is performed in the following sequence: (1) subtraction of mean from original filtered ECG signal, (2) measurement of the covariance matrix, (3) obtaining eigenvectors and eigenvalues of the covariance matrix, and (4) dimensionality reduction of ECG data in the form of a feature vector.

After preprocessing, features are extracted as illustrated in next subsection.

Feature Extraction Using Burg Method and Hilbert Transform

Based on forward and backward prediction errors, autoregressive estimation has been developed in [40]. Assuming measurements which have data values such as \( \left\{ {q\left( k \right)} \right\} \) for \( k = 1,2,3, \ldots ,M \).

Forward prediction error for nth order modes is expressed as:

$$ \hat{\in }_{{{\text{F}},n}} \left( k \right) = q\left( k \right) + \mathop \sum \limits_{j = 1}^{n} \alpha_{n,j} q\left( {k - j} \right) \quad {\text{for}}\;\; k = n + 1, \ldots M $$
(1)

Backward prediction error for nth order modes is expressed as:

$$ \hat{\in }_{{{\text{b}},n}} \left( k \right) = q\left( {k - n} \right) + \mathop \sum \limits_{j = 1}^{n} \hat{\alpha }^{*}_{n,j} q\left( {k - n + j} \right) \quad for \quad k = n + 1, \ldots M $$
(2)

The Burg’s method minimizes arithmetic mean of the prediction errors.

The autoregressive (AR) model is parametric by nature. In AR modeling, main aim is to choose the appropriate model order that indicates number of poles existing in the model. If model order is less, then more power of the spectrum exists in dominant peaks and vice versa [41]. The main challenge for analyzing ECG dataset exists when feature vectors are more in number. It makes the analysis very complex, and higher level of memory and computational power is required. Thus, optimization of features in such case is very important. To optimize these feature vectors, power spectral density (PSD) and autoregressive (AR) coefficients are used as shown in Fig. 2.

Fig. 2
figure 2

Optimization of the AR model

Some important information present in the underlying ECG dataset is lost, when Burg method is used. Hence, time–frequency Hilbert transform (HT) has been used for extracting important spectral components present in the ECG dataset. Therefore, Hilbert transform supplements the feature extraction resulting in lesser false negatives and false positives during R-peak detection. In signal processing, Hilbert transform is defined as a linear operator given by convolution with the function  \( \frac{1}{\pi t} \) [42]. Hilbert transform of any signal \( f\left( t \right) \) is given by [24]

$$ H\left( f \right)\left( t \right) = \frac{1}{\pi }\int_{ - \infty }^{\infty } {\frac{f\left( \tau \right)}{t - \tau }} {\text{d}}\tau $$
(3)

Hilbert transform gives the analytic view of a real-valued signal (\( f \left( t \right) \)). The Hilbert transform of \( f \left( t \right) \) is its harmonic conjugate \( g \left( t \right) \). It gives the \( \pm \frac{\pi }{2} \) phase shift in the output. It also gives the important features for automated ECG diagnostic system.

After completing feature extraction, classification of ECG dataset has been done as described in next subsection.

K-Nearest Neighbor (KNN) Classifier

KNN classifier is an instance-based classifier that assigns extracted feature vectors to a specific class according to simple voting rule among its K-nearest neighbors [43]. Before voting, the reference signal is selected for a particular class. In KNN, appropriate selection of value of K and type of distance metrics is very important. In Fig. 3, two different classes [where circles with solid fill represent instances in the dataset of normal subject and squares show instances of the abnormal subject (patient)] are used. Here, L denotes query which is classified by its three nearest neighbors (K = 3).

Fig. 3
figure 3

Visualisation of classification using KNN at K = 3

ECG dataset is divided into a test set and a training set during classification process. Any tie situation leads to the inclusion of majority of the data points. In the training phase, feature vectors are stored predicting class label of the unknown record by estimating majority vote. Here, Euclidean distance metric is selected to measure distance between records. Subsequently, three (K = 3) nearest points are selected for classification. The test sample is used as a reference sample, which belongs to particular heart subject (patient) during the classification process. Calculation of distances from stored vectors and new vector is performed. The Euclidean distance metric formula is given as

$$ D\left( {x,y} \right) = \sqrt {\mathop \sum \limits_{i = 1}^{n} \left( {x_{i} - y_{i} } \right)^{2} } $$
(4)

Next, predicted value is obtained by weighted average operation by inverse distance. KNN classifier does its operation in two phases; in the first phase it is applied on complete ECG dataset for computing \( D\left( {x, y} \right) \). In this manner, K points exist in the vicinity of \( x \) for training data. Generally, odd value of the tuning parameter (K) is considered to prevent tie situations. In the second phase, conditional probability is calculated for every class and \( x \) is associated with the class having largest probability. The appropriate value of K gives low test error rates, but it may enhance number of iterations. Thus, the main strategy is to use test set as training set. Figure 4 indicates the steps involved in KNN classification algorithm.

Fig. 4
figure 4

Steps involved in KNN classification algorithm

For validating the dataset, k-fold cross-validation is also applied. In this approach, dataset is segregated into k groups of the same length. The first group is considered as validation set, and then it is applied to the rest \( k - 1 \) groups (folds). The process is repeated and performed up to k times. It gives test error of k-measures by taking averaging of all kth measurement [44]. For achieving highest accuracy, fivefold cross-validation is used in the present paper that is similar to [29].

Finally after KNN classification, R-peak detection is performed as explained in next subsection.

R-peak Detection

R-peaks in ECG signals are defined by the maximum peak amplitude of QRS-complexes. So, actual positions of R-peaks in an ECG signal are found by capturing maximum peak amplitude of ECG signal within ± 20 samples of already identified locations as shown in Fig. 5. Maximum peak amplitudes are identified by determining the shape of R-wave.

Fig. 5
figure 5

Proposed R-peak detection methodology

Heart rate (HR) is computed as

$$ {\text{HR}} = \frac{60}{{{\text{Average RR Interval}}\left( {{\text{RR}}_{\text{Avg}} } \right)}}{\text{beats per minute }}\left( {\text{bpm}} \right) $$
(5)

Different performance parameters are considered for evaluating performance of the proposed algorithm as explained in next subsection.

Performance Evaluating Parameters

For evaluating performance of the proposed method, following parameters are considered [24, 35, 45]

$$ {\text{Sensitivity }}\left( {\text{SE}} \right) = \frac{\text{TP}}{{{\text{TP}} + {\text{FN}}}} $$
(6)
$$ {\text{Positive Predictivity }}\left( {\text{PP}} \right) = \frac{\text{TP}}{{{\text{TP}} + {\text{FP}}}} $$
(7)
$$ {\text{Accuracy}}\left( {\text{Acc}} \right) = \frac{\text{TP}}{{{\text{TP}} + {\text{FN}} + {\text{FP}}}} $$
(8)
$$ {\text{Duplicity }}\left( {\text{D}} \right) = \frac{{{\text{No}}. {\text{of }}\left( {{\text{TP}} + {\text{FP}} + {\text{FN}}} \right) - {\text{Actual beats}}}}{\text{Actual beats}} $$
(9)

where TP is the number of true positives (actual detected R-peaks), FN is the number of false negatives, and FP is the number of false positives (wrongly detected R-peaks).

Results and Discussion

Filtering using ICA results into kurtosis value which when less than 4.3 indicates the noise component present in the underlying ECG dataset [46]. MIT-BIH arrhythmia dataset 105 m yielded a kurtosis value of 2.77 and a variance value of 89.78% (according to eigenvalues of the covariance matrix). Most of the MIT-BIH arrhythmia dataset has secured variance values between 92 and 97.77% and kurtosis value between 11.34 and 43.77. The power spectrum information of short-time data records with estimated AR coefficients is shown in Figs. 6, 7 and 8.

Fig. 6
figure 6

AR coefficients calculation and power spectrum for MIT-BIH_103 at model order: a 2, b corresponding coefficients, c 3, d corresponding coefficients, e 4, f corresponding coefficients, g 5, h corresponding coefficients, i 6, j corresponding coefficients, k 7, l corresponding coefficients, m 8, n corresponding coefficients, o 9, p corresponding coefficients, q 10, r corresponding coefficients, s 11, t corresponding coefficients, u 12, v corresponding coefficients

Fig. 7
figure 7

AR coefficients calculation and power spectrum for MIT-BIH_107 at model order: a 2, b corresponding coefficients, c 3, d corresponding coefficients, e 4, f corresponding coefficients, g 5, h corresponding coefficients, i 6, j corresponding coefficients, k 7, l corresponding coefficients, m 8, n corresponding coefficients, o 9, p corresponding coefficients, q 10, r corresponding coefficients, s 11, t corresponding coefficients, u 12, v corresponding coefficients

Fig. 8
figure 8

AR coefficients calculation and power spectrum for MIT-BIH_113 at model order: a 2, b corresponding coefficients, c 3, d corresponding coefficients, e 4, f corresponding coefficients, g 5, h corresponding coefficients, i 6, j corresponding coefficients, k 7, l corresponding coefficients, m 8, n corresponding coefficients, o 9, p corresponding coefficients, q 10, r corresponding coefficients, s 11, t corresponding coefficients, u 12, v corresponding coefficients

Hilbert transform is used to get exact spectral components of the ECG signal as shown in Figs. 9, 10, 11 and 12. Figure 9 shows that trajectory of a normal ECG recording settles in a specific pattern. In Fig. 10, time–frequency description of all R-peaks is clearly shown.

Fig. 9
figure 9

Hilbert transform of normal ECG recording

Fig. 10
figure 10

Detected ECG beats in the normal ECG recording

Fig. 11
figure 11

Hilbert transform of abnormal ECG recording

Fig. 12
figure 12

Detected ECG beats in the abnormal ECG recording

Figure 11 shows trajectory of abnormal ECG recording obtained using Hilbert transform. It is random in nature due to fast fluctuations in the heart rate. In Fig. 12, time–frequency description is shown, but R-peaks are not visible in the whole spectrum.

Finally, HR and real R-peak locations in the ECG signal are obtained by capturing maximum peak amplitude within ± 20 samples of already identified locations. KNN classifier is applied to get R-peak detection as shown for 103 m in Fig. 13a and for 107 m in Fig. 13b.

Fig. 13
figure 13

a R-peak detection in MIT-BIH (103 m) database by KNN classifier coupled with Burg method and b R-peak detection in MIT-BIH (107 m) database by KNN classifier coupled with Burg method

After implementation, the proposed technique has secured Se of 99.90%, PP of 99.93%, Acc of 99.84% and D of 0.006361%. Table 1 shows TP, FP, FN, and the detected ECG beats, and Table 2 indicates the effectiveness of the proposed research on MIT-BIH arrhythmia database.

Table 1 TP, FP and FN calculation after applying KNN classifier coupled with Burg Method and Hilbert transform
Table 2 Comparison between proposed and existing research works

In Table 3, total number of actual R-peak, total number of (FN + FP), and total number of (TP + FN + FP) have been shown. On the basis of these, %D is calculated and it has been found that the proposed technique outperforms existing state-of-the-art techniques. In existing techniques, number of (FN + FP) is higher as compared to the proposed technique except [30, 35] where small ECG records have been considered. For instance, not all the parameters are consistently up to the desired mark in the existing approaches unlike the proposed approach, where all are consistently up to the desired mark (i.e., high Se, high PP, high Acc, and low D).

Table 3 Duplicity (D)/no. of (FN + FP) in proposed and competing state-of-the-art techniques

Conclusion

Burg method with Hilbert transform is shown to effectively extract features of an ECG signal. Involvement of ICA and PCA reduces the burden over KNN classifier. It has been demonstrated that such projection increases the accuracy of the KNN classifier for K = 3 and Euclidean distance metric. The outcomes reveal that the proposed system is useful in clinical implementation for the classification of arrhythmias, for getting the correct status of heart muscle tissue, and for identifying severe effects on pulmonary chest pain.

In future, KNN classifier may be replaced by any sophisticated classifier due to its laziness, which requires attention to both data splitting and cross-validation for fast and efficient output.