Introduction

Myocardial Infarction (MI) results from death of the heart muscle due to lack of blood supply to the heart (Ischemia) because of blockage in the coronary artery. MI leads to heart attack and is a potentially lethal disease. MI produces certain changes in the ECG signal (Q wave, ST deviation, and T wave inversion), using which medical doctors are able not only to properly diagnose it but they can also localize the part of the coronary artery that has been blocked and the part of the heart muscle which has been affected.

Several research groups have used ECG to detect and locate myocardial infarction. In [1], Reddy et al. proposed a classification method based on QRS measurement and neural networks to classify healthy and patients with myocardial infarction. Their accuracy was 79% with a specificity of 97%. Zheng et al. [2] used 192 lead body surface specific potential maps to detect myocardial infarction using support vector machines (SVM), Naïve Bayes (NB) and random forecast (RF) methods. Optimized accuracies for these classifiers are 81.9% for NB, 82.8% for SVM and 84.5% for RF. Using 192 leads for the detection is not practical for detection of myocardial Infarction. Yang et al. [3] used Dower transformation that linearly transforms a 12-lead ECG signals into 3-lead vector-cardiogram. Using Radial basis neural networks, testing accuracy of MI was 97% and accuracy of normal was 75%. Discrete wavelet transform [4] is used to discriminate the ECGs of normal and MI. ROC analysis is used to report the discrimination power which is found to be about 75%. In [5], Jayachndrum et al. used energy-entropy characteristics using discrete wavelet transform to achieve MI detection accuracy of 95%. Nugent et al. [6] used the concept of classifier fusion for detection of MI using standard 12 leads ECG. Fusion of classifiers produced a MI detection accuracy of 81.3%. A neural-fuzzy approach for classifying myocardial Infarction in [7] uses ST elevation as an input parameter. The accuracy of detecting healthy patients was 89.4% and accuracy of detecting infarction was 95.0%. Sadao and Senya [8] used Purpose oriented feature extraction method to classify three classes of myocardial infarction (Anterior Mi, Inferior MI and Flat T wave) and normal subjects. Only 15 records per class of 12 lead ECG are used and sensitivities of 86% for normal, 93% for Anterior, 80% for Inferior and 93% for Flat T are achieved. Matveev et al. [9] used Signal-averaged electrocardiography to evaluate acute myocardial infarction. They have achieved classification accuracy of about 90% for Healthy, Anterior ST Elevation MI and Inferior ST Elevation MI using QRS and T vectors in vector cardiography patterns. O’Dwyer [10] have used number of feature sets including wavelet based and standard cardiology features to detection different types of MI. Overall accuracy of seven classes for different feature sets and classifier model combinations ranged between 60% and 75%. Bozzola et al. [11] proposed a hybrid neuro-fuzzy system for classification of Inferior, Anterior and Combined Myocardial Infarction along with other class including normal and hypertrophy cases. Total accuracy of 88% is reported for all classes using fuzzy multi-layer perceptron. As time domain features are considered by the cardiologist as an indicator of myocardial infarction and by using efficient signal processing techniques, it is possible to extract time domain features from ECG. In this paper time domain features are used for detection and localization of myocardial infarction. Understandability of time domain features by cardiologists is an advantage of the proposed method. Moreover, simple K nearest neighbor (KNN) classifier is used with pruning to classify different location of myocardial infarction. In KNN classifier, no training is required and addition of new data points is easy. KNN classifier stores example data points for comparison and hence requires large memory and search time may be a problem for online classification. Pruning method is proposed to overcome these limitations of KNN classifier. By using our proposed pruning method, a fraction of data points are selected by removing redundant or less important data points from the stored examples without compromising the classification accuracy. Hence memory requirement to store the examples can be reduced drastically and search time can also be reduced. Moreover, new data point insertion policy is devised so that only important examples can be added. Ten locations of myocardial infarction are used as separate classes.

Organization of the paper is as follows; section 2 illustrates the Materials and methods. Results and discussions are described in section 3 and Conclusions are given in section 4.

Materials and methods

PTB ECG database is used which is available free on the Physio-Bank [12]. The ECGs in this database were obtained using a non-commercial prototype recorder and were digitized at 1,000 samples per second, with 16 bit resolution over a range of ±16.384 mV with 2000 A/D units per mV. Data of Twelve leads ECG of Myocardial Infarction is used in this paper. A subset of PTB database is used and some ECGs are ignored from which time domain features cannot be calculated due to noise. This is a limitation of our method. If we cannot extract time domain features accurately, classification accuracy will suffer. Hence we need some extra processing before feature extraction module so that noise cannot effect the detection of time domain features. In our future research, we are focusing on this aspect. Number of beats of ten types of Myocardial Infarction and healthy subjects are given in Table 1. Total of 20,160 ECG beats of healthy and ten types of MI are used in this paper.

Table 1 Number of beats for different types of MI

ECG signal pre processing

The raw ECG from the PTB database is pre processed. The pre processing stages are QRS detection and delineation, baseline removal, and iso-electric level detection as shown in Fig. 1. At pre processing stage, QRS detection and delineation is performed which include finding QRS start point, QRS end point and QRS feducial point. These points are used as reference when removing the baseline and further ECG segmentation during feature extraction. Many methods have been proposed in the literature for QRS delineation [13] including derivative based methods, use of digital filters and filter-banks etc. Since ECG signal is non-stationary, wavelet transform is also used in detection and delineation of different waves and segments in the ECG [14]. Some of the methods using wavelet transform for this purpose are [1517]. The approach given by Martínez et al. [17] uses Dyadic Wavelet Transform (DWT) and offers very high delineation accuracy and uses. In this paper, QRS detection and delineation is done using wavelet transform [14]. Wavelet transform of a signal x(t) is given by,

$$ {W_a}x(b) = \frac{1}{{\sqrt {a} }}\int\limits_{ - \infty }^\infty {x(t)\psi \left( {\frac{{t - b}}{a}} \right)} dt,\quad a > 0 $$
(1)

where \( \psi \left( {\frac{{t - b}}{a}} \right) \) is used as bases for wavelet decomposition of the input signal [18]. It is a shifted and scaled version of a mother wavelet. If the wavelet Ψ(t) is the derivative of a smoothing function θ(t), it can be shown that the wavelet transform of a signal x(t) at a scale a is [19]:

$$ {W_a}x(b) = - a\left( {\frac{d}{{db}}} \right)\int\limits_{ - \infty }^{ + \infty } {x(t){\theta_a}\left( {t - b} \right)dt} $$
(2)

where \( {\theta_a}(t) = \left( {1/\sqrt {a} } \right)\theta \left( {t/a} \right) \) is the scaled version of the smoothing function. It can be observed from above equation that wavelet transform at scale a is proportional to the derivative of the filtered signal with a smoothing impulse response at scale a. Therefore, local maxima or minima of the smoothed signal will occur on the zero crossings of the wavelet transform at different scales. Maximum absolute values of the wavelet transform will show the maximum slopes in the filtered signal.

Fig. 1
figure 1

ECG pre processing steps block diagram

In dyadic wavelet transform, scale and the translation parameters are discretized such that a = 2k and b = 2k l, and basis functions are defined as below

$$ {\psi_{k,l}}(t) = {2^{ - k/2}}\psi \left( {{2^{ - k}}t - l} \right)\quad k,l \in {Z^{+} } $$
(3)

The dyadic wavelet transform can be implemented as a cascade of identical low and high pass FIR filters as shown in Fig. 2(a) (Mallat’s Algorithm) [20].

Fig. 2
figure 2

a Mallat’s Algorithm for wavelet transform b Algorithm a’trous for wavelet decomposition

Redundancy in signal representation is removed by down sampling of 1/2 after each filter. In this case, the signal representation becomes time-variant, and temporal resolution of wavelet coefficients for increasing scales is reduced. In order to overcome this problem, a modified version of this algorithm, called algorithm a’trous (see Fig. 2(b)) [21] is used. In this algorithm, the decimation stages have been removed and the filter impulse responses of the previous scale are interpolated to contain twice as many points as in the previous scale.

For the purpose of this application we have used the same wavelet as in [17]. The wavelet is taken to be the derivative of a low pass filter which offers inherent noise suppression. This wavelet has been used in other works on ECG analysis and delineation [15] and is given by,

$$ \Psi \left( \Omega \right) = j\Omega {\left( {\frac{{\sin \left( {\frac{\Omega }{4}} \right)}}{{\frac{\Omega }{4}}}} \right)^4} $$
(4)

From the implementation viewpoint, it can be implemented through FIR low pass (H) & high pass (G) filters whose frequency responses are given by:

$$ H\left( {{e^{j\omega }}} \right) = {e^{j\omega }}{\left( {\cos \frac{\omega }{2}} \right)^3} $$
(5)
$$ G\left( {{e^{j\omega }}} \right) = 4j{e^{j\omega }}\left( {\sin \frac{\omega }{2}} \right) $$
(6)

These filters are adapted to a sampling frequency of 250 Hz. In order to acquire same filtering characteristics for other sampling frequencies, we can either resample the input signal or design filters which produce the same analog frequency response through, for instance, frequency sampling techniques for FIR filter design [22].

As we are dealing primarily with the QRS complex which has significant zero crossing associated with the maxima and minima of the small but pathologically significant Q and S waves in the Wavelet Transform only up to scale 22 [17]. Figure 3 shows delineation points of QRS complex.

Fig. 3
figure 3

ECG QRS delineation (Plus sign = QRS Onset, Circle sign = QRS peak, Cross sign = QRS Offset)

The algorithm keeps track of the signal derivative information (zero crossing and threshold) to determine a wave’s start peak point and end points. Baseline wander is an extraneous, low-frequency artifact in the ECG which may interfere with the signal analysis, and makes the clinical interpretation inaccurate and misleading. In the presence of baseline wander, iso-electric line is not well defined and hence accurate measurements of the parameters from ECG are not possible. Its spectral content is usually confined to a frequency band below 1 Hz, but it may contain higher frequencies as well. A number of different techniques have been implemented for baseline wander removal [2325]. We have used cubic Spline based technique for baseline removal [23]. This method takes the ECG signal along with QRS delineation points such as QRS onset as inputs. It finds the knots (i.e. the flattest point in the PQ region as shown in Fig. 4) as the reference point and fits a third order cubic spline polynomial on these knots to obtain the baseline estimate which is then subtracted from ECG signal to get baseline removed signal. Figure 5 shows ECG with baseline wandering and after the removal of baseline wandering. Region after the end of P wave and before the start of the QRS complex is known as PQ region and can be used to locate the iso-electric level. Mean value of the flattest region in the PQ interval is considered as the iso-electric level. The iso-electric level detection is required because ECG amplitude at different locations in the beat is measured relative to the iso-electric level. We search the flattest region (where the absolute value of the slope is minimum) about 60 millisecond backward from the start of the QRS complex [14]. The procedure divides the search space into small windows and the line in each window is approximated with a first order polynomial then the slope of the line is calculated and the window with minimum slope (the window with slope close to zero) is selected to be the flattest region. The mean value of the selected window is taken as the iso electric level. In the Fig. 6 small dots show the iso electric level points that are detected by the algorithm. Time domain features as described in the next section are extracted using iso electric level points as a reference point in each beat i.e. measurements such T wave amplitude is taken relative to iso electric level.

Fig. 4
figure 4

ECG baseline removal (Blue line is ECG with baseline, Red circles are the estimated knots and blue line is the third order cubic polynomial fitted on these knots)

Fig. 5
figure 5

a ECG with a complex baseline pattern b Baseline removed ECG

Fig. 6
figure 6

Iso-electric level detection (Red dots are the estimated iso-electic level)

Feature extraction

Presence or absence of myocardial infarction is characterized by specific waves or segments in the ECG beats. The main indicators are Q wave, T wave and ST level elevation or depression. Two types of myocardial infarction exist. Q wave infarction is diagnosed by the abnormality of Q wave which is present in the ECG. Non Q wave infarction is diagnosed by looking at ST depression and T wave abnormalities. Location of myocardial Infarction can be predicted by analyzing 12 leads ECG as different leads correspond to different areas of the heart. In this paper, Q wave amplitude, ST level deviation and T wave amplitude are used as features extracted from the 12 leads ECG. ST segment is from the end of the QRS complex to the start of the T wave. ST elevation is usually measured 60 or 80 ms after the J point depending on heart rate. We extract the ST segment using QRS end point and T wave start point or we can take directly the elevation point 80 ms after the J point. Figure 7 shows ST level points in each ECG beat. After locating the ST level points, ST deviation is measured with respect to the iso-electric level.

Fig. 7
figure 7

ST level detection points (Plus signs show ST level)

The presence of Q wave is detected using DWT based QRS detector and its amplitude is measured with reference to the Iso electric level. Once Q wave is detected, its amplitude is measured with reference to iso-electric level. Figure 8 shows Q wave detection points as dots generated by the DWT based detector.

Fig. 8
figure 8

Q wave detection (Red dots are the Q wave amplitude)

To determine T wave amplitude, a T wave delineator which has been implemented by using discrete wavelet transform is used. T wave amplitude can be calculated by finding extreme value (minimum in case of negative or inverted T wave and maximum in case of positive T wave) in the T wave start and T wave end region or alternately the point where the derivative of the curve (slope) is zero can be considered as T wave peak. ECG in Fig. 9 shows location of T wave points and T wave amplitudes.

Fig. 9
figure 9

T wave detection and amplitude extraction (Plus sign shows T-wave onset and Red dot with line shows T-wave amplitude)

The above mentioned three time domain features i.e. T wave amplitude, Q wave amplitude and ST deviation measure are extracted for each beat and combined for 12-leads forming a 36 dimensional feature vector. These features are used for the MI detection purpose.

Classification using K-nearest neighbor

Let a training set T composes of N data points of dimension d × 1 and class labels of training set is also available. In K-nearest neighbor (KNN) search, training set T is stored in the memory with class labels. Let a data point x i from testing set whose class label is unknown. Training set is searched for the closest K nearest neighbor set based on Euclidean distance from the data point x i . In KNN, every data point can belong to only one class which is the majority class in the K-nearest neighbor set.

Arif-Fayyaz pruning method

It involves pruning of the training data set T to obtain the prototype set P. Following steps explain Arif-Fayyaz Pruning Algorithm [26].

  1. Step 1:

    Start with an empty prototype set, P = ϕ and training set T.

  2. Step 2:

    Find K-Nearest Neighbors, x j , j = 1…K, of each training point, x, such that \( c\left( {{x_j}} \right) \ne c(x) \) and add them to the prototype set P. This gives us the border points of different clusters in the data.

  3. Step 3:

    Classify each training point using the prototype set P through KNN explained earlier. If the training point is misclassified, add it to the prototype set P and re-evaluate class weights and membership values of prototype set P. This is done in order to accommodate any clusters which may have been missed in Step 2.

  4. Step 4:

    For each i th class in the training set, W(i) is initialized for i = 1,2,…,N c Pruned , where N c Pruned is the number of prototypes in P for i th class. For each training point in the class, find the winner from the pruned set of same class. After all the training points are finished, remove all the prototype from set P whose W(i) is an empty set.

The prototype set P will be a pruned set of prototypes obtained from the training set T.

Inclusion of new data point in the training set

When a new data point is available to be included in the training set T, following procedure is adopted for the inclusion of new data point.

  1. Step 1:

    For a new data point y, find K nearest neighbors from the training set T. Find majority class of K nearest neighbors.

  2. Step 2:

    If majority class is different from the class of data point y, then include y in the training set T.

  3. Step 3:

    If majority class of the K nearest neighbor set is the same class of data point y, then check the importance of the new data point. Let δ sy is the mean of the Euclidean distance of the majority class of K nearest neighbor set and let δ dy is the mean of the Euclidean distance of the minority classes of K nearest neighbor set. If \( \left| {{\delta_{dy}} - {\delta_{sy}}} \right| \leqslant \varepsilon \) where ε is a user defined small number then include the new data point y in the training set T. Otherwise y will not increase any information in the training set.

Results and discussions

As shown in Table 1, about 20,000 ECG beats of Normal and different types of myocardial Infarction are used to analyze the performance of the proposed feature set with K-nearest neighbor classifier.

Performance measures

The classifier performance is measured in terms of sensitivity, specificity and accuracy.

Sensitivity (SE) is calculated by the equation,

$$ SE = \frac{{TP}}{{TP + FN}} $$
(7)

Where TP, TN, FP, and FN represents the number of true positives, true negatives, false positives, and false negatives respectively.

Specificity (SP) is calculated as follows,

$$ SP = \frac{{TN}}{{TN + FP}} $$
(8)

Classification accuracy is defined as follows,

$$ ACC\left( \% \right) = \frac{{TP + TN}}{{TP + FN + TN + FP}} $$
(9)

To assess the performance of pruning method, an index γ is defined which is the ratio of data points retained after the pruning. It is defined as follows,

$$ \gamma = \frac{{{N_{Pruned}}}}{N} $$
(10)

Where N Pruned is the number of data points in the pruned set P and N is the total number of data points in the training set.

Detection of MI

In this section, myocardial infarction detection is treated as two class classification problem with infracted and non infracted classes. T-wave amplitude, Q-wave amplitude and ST segment deviation of each lead of 12 leads ECG are extracted. Hence 36 dimensional feature set is formed for one ECG beat. Feature set of all ECG beats are divided into training set and testing set. Half of the features set is selected as training set randomly and ten fold cross validation are used to describe the sensitivity and specificity of MI detection. Sensitivity and specificity of KNN for MI detection is found to be 99.97% and 99.9% respectively. Detailed results in the form of confusion matrix are shown in the Table 2. Results of MI detection reported in the literature are tabulated in Table 7. Results reported in this paper are better than the results of MI detection in the literature as evident from Table 7.

Table 2 Confusion matrix for detection of MI

One drawback of KNN classifier is the memory requirement to store large training set. To decrease the memory requirement for KNN and to reduce the search time, Arif-Fayyaz pruning algorithm is used to prune the training set. Results of classification accuracy after pruning of training pattern are tabulated in Table 2. Sensitivity of 97 ± 2% and specificity of 99.6 ± 0.8% is achieved with only about 7% (711 out of 10,080) of the training patterns with value of γ is 0.07. Arif-Fayyaz pruning algorithm select only those data points in the training pattern which are important for classification and lies near the decision boundary. Advantage of using K-nearest neighbor classifier is the incorporation of new data points with known class label. Procedure mentioned in “Inclusion of new data point in the training set” will be adopted for this purpose.

Localization of MI

In this section, ECG beats mentioned in Table 1 is treated as eleven classes. Half of the ECG beats are selected randomly as training set and rest of the ECG beats are used for testing. KNN classifier is applied to 36 dimensional features vector. Confusion matrix of all classes is shown in Table 3. We can make certain observations from Table 3. In case of a group of Anterior (Anterior, Anterio-Lateral, Anterio-Septal), most of the wrong beats are lying within this group. Similarly in case of Inferior group (Inferior, Inferio-Lateral, Inferio-Posterior, Inferio-Posterio-Lateral), again wrongly classified beats are confused within this group. This observation is very obvious as classes within these groups are located close to each other. Overall classification accuracy for eleven classes is 98.8%. Furthermore, ten folds cross validation is done and sensitivity and specificity of each classes as mean with standard deviation is reported in Table 4. Most of the sensitivity and specificity of most of the classes are above 99%. Sensitivity of Inferior group (Inferior, Inferio-Lateral, Inferio-Posterior, Inferio-Posterio-Lateral) are about 95% due to confusion within this group.

Table 3 Confusion matrix for MI localization without pruning (Overall Accuracy = 98.8%, Training Beats = 10,080)
Table 4 Senitivity and specificity of ten fold validation test for MI localization

Pruning algorithm is applied to the training set of 10,080 ECG beats of eleven classes. The value of γ is found to be 0.3. Hence, only 30% of the training beats are retained and confusion matrix of MI classification results on testing ECG beats (10,080 beats) is given in Table 5. Overall accuracy is 98.3% which is almost equals to the MI classification without pruning. Ten fold cross validation results of sensitivity and specificity of eleven classes is tabulated in Table 6. Results are presented as mean with its standard deviation. Again same behavior is observed in the confusion matrix. Misclassified ECG beats are confused within their respective groups, i.e. Anterior and Inferior groups.

Table 5 Confusion matrix for MI localization with pruning (Overall Classification Accuracy = 98.3%, Training Beats = 3,054)
Table 6 Senitivity and specificity of ten fold validation test for MI localization with pruning

In Table 7, reported results of myocardial infarction detection and localization are presented along with results of our proposed methodology. It can be observed from the table that our proposed methodology has achieved higher accuracy in myocardial infarction and sensitivities and specificities of ten locations of myocardial infarction are also impressive. We have used a significant number of ECG beats and ten different locations of MI.

Table 7 MI classification accuracies reported in the literature

Conclusions

In this paper time domain features namely Q wave amplitude, T wave amplitude and ST segment deviation are used for myocardial infarction detection (separation of normal subjects and subjects having myocardial infarction). Wavelet transform is used to extract these time domain features accurately from the ECG beats. Classification is done by using KNN classifier. As expected these time domain features perform very well in MI detection and localization. High values of sensitivity and specificity are achieved in MI detection. Localization of myocardial infarction for ten locations treated as ten separate classes is also performed using same time domain feature set with KNN classifier. Arif-Fayyaz pruning algorithm is used to reduce the computational cost of KNN classifier. A slight decrease in the classification accuracy of MI detection is observed with major reduction in the number of data points in the training set (Only 7%). Furthermore, same pruning algorithm is also applied for MI localization (Eleven classes including Normal and ten locations of MI). Again slight decrease in the overall accuracy is observed while using pruned training set (only 30% of the training set). Results mentioned in “Results and discussions” established the effectiveness of the proposed feature set with KNN classifier. The proposed method will be a useful component of the clinical decision support system for the cardiologist. Since time domain features are used for detection and localization of myocardial infarction, descriptive nature of the features will be cardiologist friendly. As discussed in this paper, MI detection and localization strongly depends on correct extraction of time domain features. Hence, robustness of the features extraction is an issue which must be handled. In our future research, we are focusing on ways to remove noise which is in the frequency bandwidth of the ECG signal. Independent Component Analysis can be used to solve this problem.