This paper presents a Novel Windowing Algorithm for Electrocardiogram Feature Extraction and Pattern Recognition. The work presented here deals with a simple and efficient way of detecting ECG features that are P, Q, R, S and T waves. Windowing method is used to select these waves. Windows are based on varying R-R intervals. It has been tested on ECG simulator data and also on different records of the MIT-BIH arrhythmia database, producing satisfactory results. ECG timing intervals are also required for monitoring the cardiac condition of patients. Hence after feature detections ECG timing intervals like the PR interval, QRS duration, the QT interval, the QT corrected interval and Vent Rate are efficiently calculated using proposed Formulae.
An electrocardiogram is a graph depicting the electrical activity generated by the depolarization and repolarization of atria and ventricles. An ECG wave is a periodic wave with one cycle consisting of a P wave, the QRS complex and a T wave as shown in
Most of the clinically useful information in an ECG signal is present in the intervals and amplitudes defined by its features. An ECG feature extraction algorithm is also helpful in the detection of cardiac problems known
as arrhythmias including tachycardia, bradycardia, heart rate variation etc. Beat detection is used to determine the heart rate and identify arrhythmias while further processing is performed to detect abnormal beats. A number of techniques have already been proposed for detection of ECG features. A novel algorithm based on the windowing technique is discussed in this paper which is used for high precision ECG feature extraction and pattern recognition.
This paper is organized as follows. The next Section, Section 2, explains the preprocessing required before ECG signal analysis. It also explains the different steps involved in implementing the windowing algorithm. Section 3 deals with the mathematical formulae involved in calculating ECG wave intervals and other parameters. Section 4 contains figures illustrating the results of the windowing algorithm. Section 5 concludes the paper.
An ECG signal acquired from the body contains interference from a variety of sources. Power Line Interference (PLI) and baseline wandering are two major sources of noise in an ECG signal. Therefore preprocessing is required to obtain a signal that is useful for analysis. Power line interference is 50 - 60 Hz noise superimposed on the ECG signal as illustrated in
Baseline wandering is low frequency noise caused by the movement of the patient during signal acquisition as shown in
Once the effects of interference are removed, the clean ECG signal shown in
The windowing algorithm is based on the following:
· The most prominent peaks in an ECG signal are the R-peaks. These peaks are detected by imposing a threshold condition on the amplitude of the signal as shown in Equation (1)
where
· R-peaks occur periodically in an ECG signal. The threshold condition will also give different values in each period containing R-peaks. The particular R-peak in any period is selected by taking the mean of the R values in that period.
· Different periods are selected by finding the difference between consecutive values obtained by the threshold condition. Values in one period are very close to each other and a sharp variation appears as one period ends. That sharp variation is useful in identifying one particular period.
· Once the R-peaks have been identified, RR intervals denoted by trr are calculated as given by Equation (2)
· P and T waves exist in one R-R interval, T waves lie next to the 1st R-peak, and P-waves are present nearer to the 2nd R-peak in one R-R interval.
· The window for the T-wave in one R-R interval is selected by starting from 15% of the R-R interval added to the 1st R-peak location and continuing to 55% of the R-R interval added to the same location.
· The window for the P-wave in one R-R interval is selected by starting from 65% of the R-R interval added to the 1st R-peak location and continuing to 95% of the R-R interval added to the same location.
· The particular P and T peak location is selected by taking the highest value in their respective windows.
· The Q-peak is chosen by selecting minimum value in the window starting from 20 ms before the corresponding R-peak and that particular R-peak.
· Similarly the S-peak is chosen by selecting the lowest value in the window starting from R-peak to 20 ms after that R-peak. These windows are adaptive because they depend upon R-R interval values and as this interval changes the window will also change.
ECG timing intervals are calculated as follows.
P-R interval, denoted by tpr, is calculated using following formula
where fs denotes sampling frequency, Rloc denotes R peak locations and Ploc denotes P peak locations. The above formula yields an array of tpr values, which are then averaged out to get single tpr.
QRS duration tqrs is calculated using following formula
where x denotes immediate 5 ms, these samples are added to Sloc and are subtracted from Qloc because QRS duration is defined from start of Q peak till end of S peak as shown in
QT interval tqt is calculated using following formula
Tloc indicates T peak locations. 0.13 Factor is multiplied with trr and added to Tloc, it has same effect as addition of 5 ms. Particular tqt value is selected by taking mean of all values of an array.
QT interval depends on heart rate. An increase in heart rate results in lower RR and QT intervals [
This correction also improves the detection of patients at increased risk of ventricular arrhythmia.
Vent rate or BPM is calculated using Equation (7)
A particular BPM value is selected by taking mean of all values of an array.
The algorithm has been tested on MATLAB using a large number of normal ECG signals taken from Fluke PS- 410 ECG simulator ranging from 30 BPM to 200 BPM shown in
Record No. | Sensitivity Calculation in Percentage (%) | ||||
---|---|---|---|---|---|
P | Q | R | S | T | |
100 | 91.6 | 100 | 100 | 100 | 90 |
101 | 100 | 100 | 100 | 100 | 100 |
103 | 100 | 100 | 100 | 100 | 100 |
105 | 100 | 100 | 100 | 100 | 100 |
106 | 78.5 | 100 | 80 | 100 | 100 |
112 | 100 | 82.35 | 82.35 | 87.5 | 100 |
115 | 90 | 100 | 100 | 100 | 100 |
116 | 100 | 100 | 100 | 100 | 100 |
118 | 100 | 100 | 92 | 100 | 100 |
119 | 90 | 100 | 100 | 100 | 90 |
121 | 100 | 100 | 100 | 100 | 100 |
200 | 100 | 80 | 80 | 80 | 85 |
201 | 100 | 100 | 100 | 100 | 100 |
202 | 100 | 100 | 100 | 100 | 100 |
203 | 93.75 | 93.75 | 93.75 | 93.75 | 93.75 |
205 | 100 | 100 | 100 | 100 | 100 |
207 | 100 | 100 | 100 | 100 | 100 |
209 | 100 | 76.19 | 76.19 | 76.19 | 94.54 |
210 | 100 | 92.85 | 92.85 | 92.85 | 100 |
214 | 100 | 100 | 100 | 100 | 100 |
219 | 100 | 100 | 100 | 100 | 100 |
220 | 100 | 100 | 100 | 100 | 100 |
221 | 87.5 | 100 | 100 | 100 | 100 |
223 | 100 | 100 | 100 | 100 | 100 |
230 | 83.33 | 100 | 100 | 100 | 83.33 |
234 | 100 | 100 | 100 | 100 | 100 |
Average | 96.72 | 97.12 | 96.04 | 97.32 | 97.56 |
where TP denotes true positive, a condition in which certain peak is present and is detected correctly. FP is false positive, a condition in which a certain feature is present but not detected. FN is false negative, a condition in which a feature was detected but it was not actually present. For normal data 99% accurate results are obtained. For MIT-BIH arrhythmia database 10 seconds long data was used for analysis and a high sensitivity and specificity values are achieved for PQRST detection.
Now comparing results of proposed algorithm with existing techniques, it is observed that algorithms based on Autoregressive (AR), Wavelet Transform (WT), Eigenvector, Fast Fourier Transform (FFT), Linear Prediction (LP), and Independent Component Analysis (ICA) approaches exist [
Record No. | Specificity Calculation in Percentage (%) | ||||
---|---|---|---|---|---|
P | Q | R | S | T | |
100 | 100 | 100 | 100 | 100 | 50 |
101 | 90.90 | 100 | 100 | 100 | 72.72 |
103 | 100 | 100 | 100 | 100 | 72.73 |
105 | 84.61 | 100 | 100 | 100 | 50 |
106 | 100 | 100 | 100 | 100 | 70 |
112 | 85.71 | 100 | 100 | 100 | 74.3 |
115 | 100 | 100 | 100 | 100 | 80 |
116 | 92.3 | 100 | 100 | 100 | 100 |
118 | 91.6 | 100 | 100 | 100 | 90 |
119 | 90 | 90 | 100 | 91.6 | 100 |
200 | 79 | 100 | 100 | 100 | 72 |
201 | 70.1 | 100 | 100 | 100 | 85.71 |
202 | 100 | 100 | 100 | 100 | 100 |
203 | 100 | 100 | 100 | 100 | 100 |
205 | 64.28 | 100 | 100 | 100 | 57.14 |
207 | 100 | 100 | 100 | 100 | 100 |
209 | 64.7 | 100 | 100 | 100 | 42.85 |
210 | 15.38 | 100 | 100 | 100 | 84.61 |
219 | 90 | 100 | 100 | 100 | 100 |
220 | 100 | 100 | 100 | 100 | 94 |
221 | 70 | 100 | 100 | 100 | 94 |
222 | 55 | 100 | 100 | 100 | 100 |
223 | 83.33 | 100 | 100 | 100 | 100 |
230 | 50 | 100 | 95 | 100 | 50 |
231 | 100 | 100 | 100 | 100 | 70 |
234 | 93.33 | 100 | 100 | 100 | 62 |
Average | 83.47 | 99.61 | 99.80 | 99.68 | 80.41 |
Parameter | Existing Approaches | |||||
---|---|---|---|---|---|---|
FFT | AR | WT | LP | Eigenvector | ICA | |
Sensitivity (%) | 81 | 97.28 | 61 | 96.9 | 97.78 | 97.8 |
Specificity (%) | 98 | 97.3 | 75 | 80.4 | 99.25 | 99 |
specificity values for all these existing algorithms. Comparison of sensitivity and specificity values shows that proposed windowing algorithm is comparable with Eigenvector method that is regarded as best method [
It is observed that sensitivity and specificity values for P and T detection are moderate because it is difficult to detect them as compared to QRS complex features irrespective of the approach or algorithm used. Reliable detection of P and T wave is more difficult than QRS complex detection for several reasons including low amplitudes, low signal-to-noise ratio, amplitude and morphological variability and possible overlapping of the P wave with the QRS complex [
A novel windowing algorithm has been proposed for electrocardiogram wave feature detection. Feature extraction and pattern recognition have been achieved on normal ECG data ranging from 30 BPM to 200 BPM with accuracy of 99%. Same algorithm was tested on patient data from MIT-BIH [
This work of research is result of joint collaborative team effort supervised by Dr. Tahir Zaidi, Dr. Shoab Ahmed Khan, and Maj. General Imran Majeed. Doctors from Armed forces institute of cardiology (AFIC) Rawalpindi also played their part in development of concept and algorithm.