1 Introduction

It is important to extract the features of ECG signals to find the weakness of the heart of a patient. Electrocardiogram contains different types of wave such as P, Q, R, S, T, U wave (Fig. 1). Most of the time U waves are hidden. Q, R, S waves are called QRS Complex. Due to heart rhythm, the shape of ECG signal changes over time. At the end of S wave J point starts, this detection is important for detecting myocardial ischemia. Most of the studies focus on P, R and T wave detection and T wave alternation [1].

Fig. 1
figure 1

ECG signal with P, QRS complex, T and U wave

It is not easy for physicians to extract features of ECG from visual perception. So, developing an algorithm on ECG signal for finding required features will be more helpful for physicians. Reduction of blood flow to our heart for myocardial ischemia prevents the supply of enough oxygen. This reduced blood flow sometimes partially blocks our heart arteries. This myocardial ischemia may also be called cardiac ischemia which can damage our heart muscle by decreasing the ability of pump.

Myocardial ischemia is identified by monitoring end point of S wave to start point of T wave. This part is a segment of ECG signal which is called ST segment. Our proposed method focuses on this ST segment changes and classifies it based on cross correlation method. Naturally ST segment is isoelectric with slightly slanted upwards form contained in the middle of ventricular depolarization and repolarization (Fig. 2).

Fig. 2
figure 2

ECG signal with ST-segment

Most of the available methods are developed based on time domain or sloping based for detecting ST segment. Some methods also focus on support vector machine (SVM) [2]. Different kinds of algorithms monitor the ECG signal. Some of them provide normality and abnormalities of regular ECG sinus rhythm. A new approach is proposed to detect normal and abnormal ECG signal but does not give detailed information [3]. Another method [4] provides ECG arrhythmia classification based on discrete wavelet transform (DWT). Classification task is performed by Multi-Layer Perceptron (MLP) neural network and it shows two arrhythmias Paced Beat (PB) and Atrial Premature Beat (APB). Two step classification process is described in the work. ST-T elevation and depression are classified from the average pattern of ECG. Paper [5] provides the variation of ST-T complex changes. A detector, which finds the changes of ST-T complex and average pattern of ST segment amplitude. Method [6] monitors the ST segment elevation and depression in different lead for occlusion of coronary arteries. It monitors the ST Segment on 45 patients of 19 leads with the sensitivity or specificity. They also have measured the elevation of ST segment based on their amplitude value (mV). Paper [7] shows non–ST-segment elevation, myocardial infraction, unstable angina detection. They also have developed the standard protocol for selecting ST segment and ST-segment elevations for new-born. Diffusion of ST segment provides for only depression of ST segment. Significance of ST segment for general people is done and compared with hypothermia patients in [8]. Fatal ST segment is detected from fatal heart rate monitoring in [8]. They have also compared the ST segment with normal patient and has given the additional information of fatal ST segment [9]. A process is developed for detecting ST segment and classified six major groups, i.e. Normal, Ventricular, Atrial, Fusion, Right Bundle, and Left Bundle Branch Block beats by Discrete Wavelet Transformation (DWT), Windowing Technique and Slope Detection process [10]. ST segment abnormalities detection based on Signal Block Averaging Technique (SBAT) is also developed in [11]. They have developed an algorithm and applied SBAT for each ECG episode. Exact point of ST segment is end point of QRS complex and start point of T wave. Most of the time ST segment has monitored as depression and elevation type also traced abnormal ST Segment in ECG tracing [12].

Our proposed method automatically detects ST segment and classifies those ST segment into five categories using cross correlation based on supervised data.

The remaining part of this paper is structured as follows: Sect. 2 describes the proposed methodology as well as ST segment detection and classification process. The experimental results are analyzed in Sect. 3. Finally, discussion and conclusions are drawn in Sects. 4 and 5 respectively.

2 Methodology

Our proposed method consists of following steps shown in (Fig. 3). This figure describes overall summary of our proposed system. Every section is important for monitoring the ST segment.

Fig. 3
figure 3

Flow chart of our proposed method

2.1 ECG database

Here, we use MIT-BIH ST change database as a training data and European ST-T change database as a testing data. Training database contains a total of Twenty-eight ECG signals and the testing database contains a total of Nineteen ECG signals.

Training database is used to train our proposed method. Testing database is used to verify our proposed method. MIT-BIH ST change database is used for training where every ECG signal has its individual name from 301 to 327 m and sampling frequency is 360 Hz. On the other hand, the European ST-T change database is used for testing where every ECG signal has its individual name from e0103 to e0606m and the sampling frequency is 250 Hz [13].

Training and testing databases are separated from their name and sampling frequency.

2.2 Data pre-processing

2.2.1 Filtering data

There are several types of denoising techniques developed for smoothing and denoising the ECG signal [14,15,16] such as denoise using Intrinsic Mode Function based on EMD (Empirical Mode Decomposition) for detecting QRS complex. Here we use the MIT-BIH database and European ST-T database which is sampled at 360 Hz and 250 Hz, respectively. We use FIR bandpass filter of 0.05–45 Hz with 100 order and Savitzky–Golay smoothing filtering technique. Every ECG signal contains 30 min or above episode.

2.2.2 Detrending data

After denoising ECG signal contains a trend. Every ECG signal may contain linear and nonlinear trends. For detrending, we use polynomial Eq. (1) of degree n. Then we have calculated mean, the standard deviation of time series signal. Figures 4 and 5 are showing before detrending and after detrending operations respectively. After detrending, we can easily identify the baseline.

Fig. 4
figure 4

ECG signal with linear and non-linear trend

Fig. 5
figure 5

ECG signal after removing linear and non-linear trend

$$P\left( x \right) \, = p_{1} x^{n} + p_{2} x^{n - 1} + \cdots + p_{n} x + p_{n + 1}$$
(1)
$$\hat{x} = \, \left( {x - \mu_{1} } \right)/\mu_{2}$$
(2)

Here p1, p2……… pn are the coefficients of the polynomial, x is the independent variable of signal in time domain. μ1 is the mean of x and μ2 is standard deviation of x.

2.3 R wave and S wave detection

For detecting R wave peak value, we use following function.

$$f(d,h) = \left\{ {n,e\left( n \right) \;\; when\;\; \Delta n \ge d\;\; and\;\; e\left( n \right) \ge h} \right.$$
(3)

where h parameter denotes minimum peak height from the base line where amplitude value mV = 0 and d denotes minimum peak distance from previous R to R peak interval, \(\Delta n\) is the minimum peak distance after selecting peak. For every ECG signal n is the time value and e(n) is the amplitude value at the time n. Above function provides local maxima in minimum interval which is the main R peak value. Here local maxima mean maximum amplitude value between the time interval \(\Delta n\) [17].

For detecting S wave peak value, we use following function.

$$f^{\prime}(d^{\prime},h^{\prime}) = \left\{ {n,e^{\prime}\left( n \right) \;\;when\;\; \Delta n \ge d^{\prime}\;\;and\;\; e\left( n \right) \ge h'} \right.$$
(4)

where \(\varvec{ h'}\) parameter denotes minimum peak height from the baseline where amplitude value mV = 0 and \(\varvec{d '}\) denotes minimum peak distance from previous S to S peak interval.\(\varvec{ \Delta n}\) is the minimum peak interval after selecting peak.

After using Eqs. (3) and (4) we have found the R wave and S wave peak value. Figure 6 shows R wave and S wave detection where S wave is marked with ‘ ’ R wave is marked with ‘ ’.

Fig. 6
figure 6

R wave and S wave detection in ECG

2.4 Start and endpoint detection of ST segment

ST segment can be defined by ending point of S wave and start point of T wave [18, 19].

2.4.1 J point detection

J point is the indicator of the end of ventricular depolarization [20]. It is the start point of ST segment. It can be identified on different R–R interval. Sometimes it provides pattern of normality and abnormality of ST segment. Different J point can be detected on different leads [20]. We have applied R + x method to detect it [21]. Here R is the highest peak position (getting time domain value) in R wave and x is also time domain value. After getting R wave highest peak position then x is added with that position to get J point. Here x depends on the RR interval or SS interval. Because RR interval or SS interval duration is not fixed in ECG signal. If RR or SS interval increase, then position of J point position also increases.

For R based we use

$$\left\{ {\begin{array}{*{20}c} {if\;\;\Delta R < 160\;\; then\;\; x = 10} \\ {if\;\; 160 \le \Delta R < 180 \;\;then \;\;x = 12} \\ {if\;\; 180 \le \Delta R \le 270\;\;then\;\; x = 14} \\ {if\;\; 270 <\Delta R \le 390 \;\;then \;\;x = 16} \\ {if \;\;\Delta R >390\;\; then \;\;x = 20} \\ \end{array} } \right\}$$
(5)

For S based we use

$$\left\{ {\begin{array}{*{20}c} {if \;\;\Delta S < 160 \;\;then \;\;x = 2} \\ {if\;\; 160 \le \Delta S \le 180 \;\;then \;\;x = 4} \\ {if\;\; 180 <\Delta S \le 270 \;\;then \;\;x = 6} \\ {if\;\; 270 <\Delta S \le 360 \;\;then\;\; x = 8} \\ {if\;\;\Delta S > 360\;\; then\;\; x = 10} \\ \end{array} } \right\}$$
(6)

Here \(\Delta R\) is the RR interval and \(\Delta S\) is the SS interval. That’s mean if first R wave height peak found in R1 time and second R wave height peak found in R2 time. Then ΔR is the difference between two R waves that is ΔR = R2 − R1. RR interval detects R peak and SS interval detects S peak. Here x is the time domain value. After detecting R or S waves highest peak position x is added to that position to get the start point of ST segment or J point. Sometimes some lead contains less magnitude of R peak. They contain dissimilar R peak value [22]. In these cases, missing of R wave for example Lead V1 we use S wave and then apply the above method. That means if R peak is not detected then S based process is used. If R or S wave is not detected, then above method will not work.

2.5 ST segment endpoint detection

Endpoint of ST segment is the start point of T wave. We calculate the angle from ST segment start point to T wave peak value. Though T wave detection method is developed [2326] but we have used slope-based process.

$$\begin{aligned} \tan \theta & = \frac{{y_{2} - y_{1} }}{{x_{2} - x_{1} }} \\ & \Rightarrow \theta = \tan^{ - |} \frac{{y_{2} - y_{1} }}{{x_{2} - x_{1} }} \\ \end{aligned}$$
(7)

We calculate the angle using Eq. (7) where x1, y1 is the start point and x2, y2 is the end point.

From the angle value, we can see (Fig. 7) \(\theta_{{\mathbf{1}}} < \, \theta_{{\mathbf{2}}} < \, \theta_{{\mathbf{3}}} < \, \theta_{{\mathbf{4}}} < \theta_{k} < \theta_{{\mathbf{n}}}\) that means when angle goes closer to perpendicular it increases. We applied the above process for detecting T wave start point.

Fig. 7
figure 7

Right triangle with different hypotenuse

From the angle value, we calculate the maximum angle then select the start point of T wave (Fig. 8).

Fig. 8
figure 8

ST segment endpoint detection and T wave detection in ECG

2.6 ST segment separation and dissimilarities find out

For every ST segment, we have applied supervised learning. Firstly, we select some ST segments from our European ST-T change and MIT-BIH ST change database. This reference ST segment is treated as supervised ST signal. We selected 5 categories of supervised ST signal. Each ST category contains 2 or 3 ST segments. Then we compare this selected reference ST segment with our main ECG ST segment using Cross Correlation (Fig. 9).

Fig. 9
figure 9

Five kinds of supervised data

2.6.1 Cross Correlation Applied

Cross correlation is useful for estimating the similarities between two signals corresponding to time domains. Here, we take two signal parts, one is the main ST Segment that should be classified which is denoted by Xk(t) and the other is our supervised signal Yj(t) which is compared with Xk(t) signal. Where k is the kth number of ST segment of main ECG and j is jth supervised signal.

The cross-correlation r can be defined as

$$r = \frac{{\sum {\left[ {\left( {X\left( i \right) - mx} \right)} \right.*\left( {Y\left( {\left( {i - d} \right) - my} \right)} \right]} }}{{\sqrt {\sum {\left( {\left( {X\left( i \right) - mx} \right)} \right)^{2} } } \sqrt {\sum {\left( {Y\left( {i - d} \right) - my} \right)^{2} } } }}$$
(8)

where mx and my are the means of the corresponding series, d is the time delay and d = 0 to N − 1.

$$\varvec{r}\left( \varvec{d} \right) = \frac{{\sum {\left[ {\left( {\varvec{X}\left( \varvec{i} \right) - \varvec{mx}} \right)} \right.\varvec{*}\left( {\varvec{Y}\left( {\left( {\varvec{i} - \varvec{d}} \right) - \varvec{my}} \right)} \right]} }}{{\sqrt {\sum {\left( {\left( {\varvec{X}\left( \varvec{i} \right) - \varvec{mx}} \right)} \right)^{2} } } \sqrt {\sum {\left( {\varvec{Y}\left( {\varvec{i} - \varvec{d}} \right) - \varvec{my}} \right)^{2} } } }}$$
(9)

The range of r(d) is − 1<= r(d)<=1, where 1 indicating maximum correlation and 0 indicating no correlation. Here we have applied cross correlation between Xk(t) and \(\mathop \sum \nolimits_{{\varvec{j} = 0}}^{\varvec{M}} \varvec{Y}_{\varvec{j}} \left( \varvec{t} \right)\) where M is total number of supervised signals. For every j value, cross correlation between Yj(t) and Xk(t) returns rj(d) where r(d) is − 1<= r(d)<=1. For all rj(d) value we find out the maximum r(d) value. If kth number of r(d) is maximum, then we can say Xk(t) is cross correlated with kth supervised signal. If kth supervised signal is upslope or downslope, then we can say Xk(t) is upslope or downslope (Fig. 10) and (Fig. 11).

Fig. 10
figure 10

Cross correlation between similar signal

Fig. 11
figure 11

Cross correlation between negatively correlated signal

3 Result

We have used European ST-T change database and MIT-BIH ST change database total 1,34,879 beat. Nineteen ECG signals from European ST-T and twenty-eight ECG signals from MIT-BIH ST change database are selected. Every database contains minimum 30 min to maximum 1 h 6-min episode.

ST segment start point means the J point. In our proposed method J point detection depends on R wave peak or S wave peak. In this case if R wave select correctly or S wave select correctly then J point detection is more accurate [Eqs. (5) and (6)]. If R wave or S wave detection is wrong that time J point position is also wrong. In this case we marked R wave with ‘ ’ symbol, S wave with ‘ ’ symbol and J point marked with ‘o’ symbol. After marking with symbol, we monitored each ECG signal and noted down which point is correctly selected or not. Sometimes R wave or S wave detects wrongly that time J point select wrongly. That type of case ST segment selects wrongly.

ST segment end point means T wave start point. In this case, we applied the T wave pattern detection process using the right triangle hypotonus system [Eq. (7)]. In T wave pattern we find out T wave start point which is marked with ‘x’ symbol.

Using above process ST segment start point marked with ‘o’ symbol and end point marked with ‘x’. In every ECG signal ST segment is monitored.

In our selection process ST segment start point depends on R or S wave and end point depends on T wave. If ST segment start point marked position varies ± 3 ms and end point marked position varies ± 6 ms and their time duration varies from 0.005 to 0.150 s, then it is treated as correctly selected ST segment otherwise it is treated as wrongly selected ST segment. If any of the start point or end point selects wrongly such as marking position is not between S and T wave interval or start point position is inside the interval and end point position is outside the interval or any of them then that type of case ST segment treated as wrongly selected ST segment.

Only correctly selected ST segment is classified. We classified ST segment into 5 categories which are concave, convex, upslope, downslope and horizontal. Another study [27] also classified ST segment based on ST segment start point amplitude value (mV), end point amplitude value (mV) and average amplitude value (mV). If ST segment average amplitude value is greater than ST segment start and end point amplitude value, then this type of ST segment is treated as convex type ST segment. If ST segment average amplitude value is less than ST segment start and end point amplitude value, then this type of ST segment is treated as concave type ST segment. If ST segment average amplitude value is between the ST segment start and end point amplitude value and end point amplitude value is greater than start point amplitude value, then this type of ST segment is treated as upslope type ST segment. If ST segment average amplitude value is between the ST segment start and end point amplitude value and end point amplitude value is less than start point amplitude value, then this type of ST segment is treated as upslope type ST segment. If ST segment average amplitude value is approximate to the ST segment start and end point amplitude value, then this type of ST segment is treated as horizontal type ST segment.

Using the above rules, we selected 5 categorized of supervised data (Fig. 9). Our tested ST segment type is annotated using both rules. In our tested ST segment, we applied the cross-correlation process [Eqs. (8), (9)]. Our tested ST segment type is verified by average amplitude value [27]. Our tested ST segments type is treated as correctly selected type when it is satisfied both average amplitude value rules [27] and our proposed rule (cross-correlation).

3.1 Classification result

ST segment is classified based on cross correlation. Figures 12, 13, 14, 15 and 16 shows classification result of ST segment. Here Figs. 12b and 12c are the zoomed version of Fig. 12a. Duration of ST segment varies from 0.005 to 0.150 s (5–150 ms).

Fig. 12
figure 12figure 12

Concave ST segment

Fig. 13
figure 13

Convex ST segment

Fig. 14
figure 14

Up slop ST segment

Fig. 15
figure 15

Down slop ST segment

Fig. 16
figure 16

Horizontal ST segment

We classify the result based on correctly selected ST segment and Wrongly selected ST segment. Total correctly selected ST segment is denoted by Tst and wrongly selected ST segment is denoted by Fst. Now we have applied the formula \(\frac{{\sum Tst_{i}}}{{\sum Tst_{i}^{+} \sum Fst_{i}}}\) for calculating the total accuracy. Sometimes same ECG episode contains different types of ST segment as Horizontal and Upslope. Our method selects all segments and ramifies them. Total number of correctly identified ST segment for each shape is divided by the total number of shapes existed in the signal, as find the accuracy.

From the Tables 1 and 2 we see ST segment accuracies are 96.79% and 98.96%. Classification accuracy for European ST-T change database are 95.58% for concave, 95.92% for convex, 97.86% for upslope, 95.18% for downslope, 96.36% for horizontal. For MIT-BIH ST change database Horizontal accuracy is less than 70% because of at the same signal it contains horizontal and convex shape. Some horizontal shape contains upslope or other up down shape. Cross Correlation process can’t easily identify this. But in European ST-T change database it provides more accuracy because its database contains smoother horizontal shape, Cross Correlation process identifies this shape 96.36% accurately which is more than MIT-BIH ST change database.

Table 1 ST segment selection table
Table 2 ST segment classification accuracy

4 Discussion

Previous study [27] shows a rule-based method for ST segment classification. It measures the amplitude value of ST segment start and endpoint. If average amplitude value is greater than start point then it is considered as elevation, otherwise it is considered as depression. It is one kind of baseline-based ST Segment classification. Sometimes some horizontal shapes are found in ST segment depression type. Average accuracy is 90.1% for testing data [27]. Another method shows ST segment upslope and downslope type over 31 patients [28]. This study [28] selects the ST segment from J point to 60 ms and has classified the ST Segment based on their amplitude value. Curvature Scale Space based ST segment classification is also developed [29]. This study [29] shows 91.60% accuracy for small amount of ECG data. It eliminates the endpoint detection of the ST segment. Philips Medical Systems [30] shows ST segment monitoring process. They also show the ST segment selecting process and selected the ST segment from the voltage difference between the value at a point 60 or 80 ms after the J-point and the isoelectric baseline [30]. This study [30] show only four types of ST segment which are normal, abnormal, elevation and depression types [30]. Although above study have achieved good result and classification but most of the study applied on small duration of ECG data, small amount of testing and training data with over all accuracy 90%.

Our present study has proposed detection and classification of ST Segment. In this study MIT-BIH ST change database is used for training. Here we have used both R, S and T wave pattern for detecting ST Segment. For detecting J point we have used both R wave pattern and S wave pattern by R +x method [21]. In absence of R wave or low amplitude of R wave we have used Eq. (6). Thus, J point detection is more accurate than the other existing method [30]. On the other hand, for detecting ST segment end point most of the methods used time domain value were 5–60 ms counting from J point [28,29,30]. But in our proposed method we have used T wave pattern for detecting T wave start point that is, ST segment end point. Here we have used T wave slope value for detecting T wave start point. Thus, ST segment detection is totally new method from the existing other methods [27, 28].

In addition, in previous study [27,28,29,30] ST segment is classified based on their amplitude value in mV or μV. In our proposed method we used cross-correlation process where ST segment amplitude value is not mandatory. Another study [27] classified the ST segment based on their average amplitude value from base line of ECG signal. But in our proposed method base line is important only for detrending ECG signal not for classify the ST Segment. Sometimes convex type ST segment is found under the baseline. That time amplitude-based ST segment classification is not work properly. In this case our proposed method works correctly. Previous works [2730] use short term ECG signal most of them are less than 20 min. But in our proposed method we used minimum 30-min durations ECG signal and maximum 1-h episode. In this case, our proposed method is also applicable for long term ECG signal.

From the Tables 1 and 2 we have got the charts (Fig. 17) and (Fig. 18). Here Figs. 17 and 18 shows the bar chart of data classification accuracy. ST segment classified into five categories where we used two types of databases MIT-BIH ST change database and European ST-T change database. In Fig. 17, it shows the correctly identification of ST Segment in MIT-BIH ST change database. That means Concave, Convex, Up Slope, Down Slope and Horizontal type ST segment correctly selection accuracy bar-chart is given in Fig. 17. On the other hand, in Fig. 18 shows the bar chart of correctly selection accuracy of European ST-T change database. Comparing between both chart European ST-T change database ST segment classification accuracy more better than MIT-BIH ST change database.

Fig. 17
figure 17

ST segment classification accuracy chart for MIT-BIH ST change database

Fig. 18
figure 18

ST segment classification accuracy chart for European ST-T change database

Analysing the tables and charts we can say that overall accuracy of ST segment classification is more accurate in European ST-T change database than MIT-BIH ST change database. Most of the method provides ST shape elevation and depression [10] but does not provide any classification. This method [10] provides only R wave-based process. Our proposed method correctly classifies the ST segment in absence of R wave [22]. While automatic detecting, R wave may be absent. In absence of R wave, we have selected S wave for detecting ST segment. So, we can easily identify the ST segment. Overall accuracy of selecting ST segment is 97.87%.

Long-term ECG contains trend which may be linear or non-linear. After detrending this we can easily identify the base line and quality of ECG. Our proposed method based on Cross-Correlation process provides 92.1% accuracy where we have identified 3331 concave shape out of 3485, 13,414 convex shape out of 13,984, 25,362 horizontal shape out of 26,318, 1265 downslope shape out of 1329 and 26,802 up slopes shape out of 27,386. We have used total 47 database which contain total 1, 34,879 beats. Our proposed method exhibits more accuracy than other existing methods [27,28,29,30].

For clinical diagnosis, our proposed method will be more helpful in myocardial ischemia and ST segment monitoring. This method will also help the physicians to easily identify the different types of ST shapes in the ECG signal. Our proposed method has verified all 12 lead ECG signal and their performance accuracy is 92.1%. We hope it will enrich the craniological research also.

Though we get 92.1% accuracy for ST segment classification but there are some drawbacks and limitations. For classifying ST Segment ECG data pre-processing must be needed. Without ECG data pre-processing ST Segment cannot be detect correctly. For low amplitude of R wave and S wave it is too difficult to detect ST segment. For long term ECG signal our proposed method takes time to evaluate.

5 Conclusion

Cross-Correlation process is used for the first time to classify ST segments. That is our main contribution. On the other hand, we used the Right Triangle hypotenuse system for detecting ST segment end point. We also used long length ECG signal of minimum 30 min or above. As a result, our proposed method is totally new for classifying ST segment in the ECG signal. Selection and classification of ST segment is very important for detecting myocardial ischemia. Total Twenty-Eight MIT-BIH ST change databases, Nineteen European ST-T change database are used, and 5 supervised signals are selected for comparing with signal shape. We have used total 134,879 beats where 58,331 beats from MIT BIH database and 74,609 beats from European ST-T database. We have correctly selected total 126,608 ST segment. ST segment classification accuracy is 88.02% for MIT BIH data base and 96.18% for European ST-T database. Overall accuracy for all database is 92.1%. Using this method, we can easily identify the ST segment shape using cross correlation. We hope it will be more and more helpful in clinical diagnosis for detecting major heart diseases like Myocardial Ischemia hence will reduce the number of deaths occurring all through the year in the whole world.