Introduction

Sudden cardiac death (SCD) is reported as one of the most common causes of death in recent years. While early recognition of any abnormality of heart can considerably reduce the danger of this kind of death, many studies have been investigated a vast variety of algorithms to detect and classify well-known abnormalities in electrocardiogram (ECG) signals automatically to increase the accuracy of heart disease recognition. Figure 1 illustrates ECG recorded signals of some different heart arrhythmias such as T-Wave Alternant (TWA), Premature Ventricular Contractions (PVCs), Atrial Premature Contraction (APC), and Ventricular fibrillation (V) compared with a normal one.

Fig. 1
figure 1

ECG signal of some kind of heart arrhythmia

While it is an irrefutable fact that the ECG signal represents extremely fertile information about the heart functionality, and accordingly, heart arrhythmias are due to any disturbance in the regularity, rate, and site of origin or conduction of the cardiac electric impulse (Clifford et al. 2006; Thaler 1999), it is considered one of the most important non-invasive tools in cardiac arrhythmia detection.

As an arrhythmia occurs, the formation of the normal signal heartbeats changes, which affect the morphological characteristics of the signal dramatically, as well as its frequency content. Various studies have shown that frequency, chaotic and morphological features of cardiac signals vary from one arrhythmia to another and most well-known ECG classifiers are based on features extracted from QRS or T section of the ECG signal (Dong et al. 2017; ławiak 2018; Rajesh Kandala and Dhuli 2017; Appathurai et al. 2019). Therefore, different statistical features (Ghorbani Afkhami et al. 2016; Jovic and Bogunovic 2011), spectral features (Khalaf et al. 2015; Rahman et al. 2017), time-domain features (Venkatesan et al. 2018; Bhagyalakshmi et al. 2018), and several complexity measures (Silipo and Marchesi 1998) are selected as informative features to classify different arrhythmias.

One of the early methods in ECG classification is proposed by Jain (Jain 1973). As a discrete nature of ECG signal, he claimed that the statistical algorithms are not proper methods in the classification process and hence, proposed a method representing each ECG lead by its z-domain modes to enhance discrimination of the subtle changes in QRS and T sections. In this method, the derivatives of the waves were employed to extract the z-domain modes. On the other hand, Lin et al. (Lin and Chang 1989) used linear prediction to extract features from QRS complexes, which has been applied to speech signals and is known as a powerful technique in digital speech processing. Having applied the linear prediction, Lin detected PVC arrhythmia with an accuracy rate of 92%. Osowski et al. (Osowski and Linh 2001) applied a fuzzy neural network to ECG beat recognition and classification, and higher-order statistical features have utilized in the study. Meanwhile, Engin (Engin 2004) performed a similar method, using autoregressive model coefficient, higher-order cumulate and wavelet transform variances to enhance the algorithm’s performance. By adding these new features to the classifier, authors could slightly improve the results. Albeit the final result was satisfactorily high, but the variety of arrhythmias classified was limited up to just four types. Jekova et al. (Jekova et al. 2008) implemented four different classifiers based on 26 morphological features which have been extracted from lead I, II, and VCG signals, such as area, slopes, peaks, time intervals, and VCG diagram in QRS complex. The classification methods were applied to five different arrhythmias from MIT-BIH dataset (MIT-BIH 2011). By applying these four classifiers to the dataset, it was shown that the performance of morphological classifiers greatly depends on the used learning set. Asl et al. (Asl et al. 2008) presented an effective cardiac arrhythmia classification algorithm using Support Vector Machine (SVM) classifier, based on the Generalized Discriminate Analysis (GDA) to reduce feature scheme. Initial 15 different linear and nonlinear features extracted from QRS complex have been reduced to five features by the GDA technique. The authors also examined two more feature reduction methods, Linear Discriminant Analysis (LDA) and Principal Component Analysis (PCA), and final reduced features were applied to two different classification methods, SVM and MLP. The results showed that combining GDA and SVM can lead to the best classification accuracy rate for six arrhythmia types.

In some recent studies, simulated and synthetic TWA signals were generated and analyzed. These augmented beats are detected using wavelets (Boix et al. 2009; Romero et al. 2008; Small et al. 2000) and 91% sensitivity is achieved (Romero et al. 2008), but this method strongly depends on heart rate and the maximal predictive accuracy is achieved at heart rates between 100 and 120 bpm, and hence, these TWA signals are usually measured during exercise, pharmacological stress, or atrial pacing. In other studies, wavelet/FFT (Sharma and Rajendra 2019; Ghaffari et al. 2008) and correlation/FFT methods (Ghaffari et al. 2008) were also investigated. Roopaei et al. (Roopaei et al. 2010) proposed an algorithm to classify VF, VT and normal signals based on chaotic characteristics of these signals. Although it is a fast and accurate algorithm, it can classify only three types of arrhythmias. On the other hand, there are some studies developed to classify a wide variety of abnormalities, more than ten types, and have gained a high accuracy rate of classification. Ozbay et al. (Ozbay et al. 2011) used an algorithm by combining fuzzy type-2 C-mean clustering, wavelet, and neural network and classified ten types of abnormality. While they have gained a high degree of classification accuracy, the method is complex and time-consuming.

Many researchers have utilized a specific part of heartbeat, QRS complex, in a wide range of classification algorithms to distinguish different types of abnormalities (Silipo and Marchesi 1998; Lin and Chang 1989; Osowski and Linh 2001; Jekova et al. 2008; Asl et al. 2008; Tafreshi et al. 2014; Chen 2000). On the other hand, some researchers have recently considered other ECG-derived biomarkers as remarkably effective ones in classification algorithms, and hence, researcher’s efforts have been devoted to T-wave features in the last few years (Boix et al. 2009; Romero et al. 2008; Shakibfar et al. 2012; Vaglio et al. 2008). Vaglio et al. (Vaglio et al. 2008) and Couderc et al. (Couderc et al. 2006) implemented algorithms to identify the differentiation of LQT1 and LQT2 carriers based on T-wave morphology features, such as the QT peak to peak interval, the T-peak to T-end interval, T-wave magnitude, and T-loop slopes. It is an indisputable fact that using a specific part of ECG signal in classification algorithms exerts an extra “detection” step to an algorithm, which affects the total speed. In the MV-MLBP algorithm, the classification is based on the morphological features associated with the entire ECG signal, in which QRS or T-wave detection step is omitted, and consequently leads to a faster algorithm. In real-time heartbeat classification applications, accuracy, reliability, and rapid response are integral factors, while a considerable extent of algorithms developed, which are suitable in offline applications, just aim for a high accuracy rate. Although using the whole signal would lead to more complex calculations, thanks to the simplicity of the MV-MLBP algorithm, a fast and robust one is obtained, which can be used in online applications.

Local binary pattern (LBP) is a simple, fast, and straightforward method initially applied to texture classification methods, which was mainly to classify steel roll, paper, wood, carpet, and textile (Young 1995; Sheen et al. 1997; Dorrity and Vachtsevanos 1998; Chan and Pang 2000; Sari-Sarraf and Goddard 1999; Kumar and Pang 2000; Tajeripour et al. 2007; Kaya et al. 2014). Although LBP is intrinsically a 2-dimensional algorithm, 1-dimensional LBP was developed by Tajeripour (Tajeripour et al. 2007) to detect defects in pattern fabrics. Considering interesting features of the 1-dimensional form of LBP, it can be used as a proper approach for real-time biomedical signal processing such as ECG classification. Kaya (Kaya et al. 2014) applied the 1-D LBP to the EEG signals as a feature extractor combined with different machine learning classifiers to classify epileptic EEG signals. Jaiswal (Jaiswal 2017) introduced two feature extraction algorithms based on LBP to classify epileptic EEG signals and a high accuracy rate obtained. Rigouid (Regouid and Benouis 2019) proposed a biometric recognition system based on Shifted 1D-LBP as a feature extraction method and K Nearest Neighborhood, where a correct recognition rate of 100 is reported for normal ECG signals. Continuing the Rigouid method, Benouis et al. (Benouis et al. 2021) developed an algorithm based on 1-D Local Difference Pattern combined with SVM and Neural Network and classified normal signals and ECG arrhythmias. While high accuracy rates are reported in these researches, the number of ECG classes are limited to normal and abnormal one.

In this paper, the basic form of LBP is presented and the M V-MLBP algorithm based on one dimensional LBP, variance and mean operators are proposed. The feasibility of the LBP to classify a wide range of arrhythmia was examined and two more morphological characteristics of the ECG signals were applied to enhance the classification result. Having applied the MV-MLBP algorithm to 11 heart beat classes, the classification result was compared with similar workflows.

Method

Local binary pattern (LBP) is a simple, fast, and straightforward classification method initially applied to texture classification methods initially introduced by Ojala (Ojala et al. 2002), which is used mainly to classify steel roll, paper, wood, carpet, and textile. Although LBP is intrinsically a two-dimensional algorithm, one-dimensional LBP is developed by Tajeripour (Tajeripour et al. 2007) to detect defects in pattern fabrics. Considering interesting features of the 1-D LBP, it can be used as a proper approach for real-time biomedical signal processing such as ECG or even EEG signals.

LBP principle

Original LBP, as a 2D method, consists of labeling a pixel by comparing its gray value with that of all other pixels in a circular neighborhood. Figure 2 illustrates symmetric neighbor sets, which are usually in circular form, for various radii, R, and different numbers of neighbors, P.

Fig. 2
figure 2

Circularly symmetric neighborhoods for different P and R

As shown in Fig. 2, in the basic form of the method, LBP operator is defined in a circular neighborhood and returns a P bit binary vector with 2P distinct values, which greatly depends on the gray value of the neighbors. Considering the fact that the basic form of LBP specifies 2P distinct labels to each neighborhood, it is known as a complex algorithm, which exerts a huge computational burden on the algorithm. To decrease the complexity, and at the same time to speed up the algorithm, modified LBP is developed. In M-LBP, a uniformity measure is defined as the number of spatial transitions between 1 and 0 s in the pattern (Chan and Pang 2000), and any pattern with uniformity measure less than Ut is defined as a uniform pattern. Otherwise, it is supposed to be a non-uniform pattern.

In the next step, the probability of encountering a specific label can be calculated by the ratio of all number of neighbors labeled as that label to the number of all neighbors according to Eq. (1).

$${P}_{i}\cong \frac{{N}_{{P}_{i}}}{{N}_{Total}}$$
(1)

where, \({N}_{{P}_{i}}\) is the number of neighbors labeled as Pi and NTotal is the number of all neighbors. Therefore, at the end of this process, P + 2 probabilities will be computed which can be used as a distinguishing feature for classification (Tajeripour et al. 2007). For any sample under test, the log-likelihood ratio is computed in the way that it belongs to class K if the computed probabilities minimize this ratio:

$$L\left(S,K\right)=\sum_{i=0}^{P+1}{S}_{i}\mathrm{log}\left(\frac{{S}_{i}}{{M}_{iK}}\right)$$
(2)

where, MiK represents the probability of encountering a label i in the patterns of each class k, and Si is the probability of encountering label i in the sample under test.

The proposed algorithm

One dimensional LBP

The MV-MLBP method is based on a modified version of 1-D LBP, and consequently, the neighborhood of the LBP operator is a row-wise line segment. According to the 1-D LBP developed by Tajeripour (Tajeripour et al. 2007) used, the value of the first element of the ECG data vector in a segment is compared with the value of other elements. In this case, the notation of local binary patterns is renamed from LBPP,R to \({{\mathrm{LBP}}_{\mathrm{l}}}_{\mathrm{LBP}}^{{\mathrm{U}}_{\mathrm{t}}}\).

$${LBP}_{l_{LBP}}^{u_T}=\left\{\begin{array}{l}\sum_{p=0}^{l_{LBP}-1}s\left({g}_p-{g}_c\right)\kern0.5em if\ U\le {U}_T\\ {}\begin{array}{cc}{l}_{LBP}& Otherwise\end{array}\end{array}\right.$$
(3)

where the size of the segment for applying LBP operator is lLBP pixels, gc is the value of the analyzing point, which is the first data in the segment, and gp is that of all other points in the selected segment. U is uniformity measure and Ut is non-uniformity threshold. Figure 3 illustrates the process of applying the LBP operator to a sample ECG signal. In this figure, the lLBP is chosen as ten, and the operator is applied to 3 sequential points.

Fig. 3
figure 3

Applying LBP on ECG signal points with a segment chosen of the length of 10 pixels

The periodic characteristics of the ECG signal have led to a fixed lLBP equal to the length of a complete heartbeat period (P-P interval) in ECG vector data. Applying the 1-D LBP to these segments leads to a vector of probabilities of encountering each label in segments. The average of all vectors extracted from all segments in each signal is considered a feature for that signal.

The ECG signal classification process is divided into two steps: training and testing. To have a fair comparison between the final results of different kinds of arrhythmias, all signals are re-sampled to the same sampling rate. According to MIT-BIH Arrhythmia Database, all ECG signals provided are of two leads, modified limb lead II (MLII) and modified lead V1, which are obtained by placing the electrode on the chest (MIT-BIH 2011). While the normal QRS are usually prominent in the former one, according to the MIT-BIH Arrhythmia Database, this is the one used in this research.

LBP/VAR

To develop an algorithm, accurate enough to classify wide range of arrhythmia categories, two extra features are added to the 1D LBP feature. These two features are based on morphological characteristics of the signal too. The first one considers the variance, and the other considers the mean value of the signal, which both are widely used in heartbeat signal classification.

The LBPP,R operator is a greyscale invariant measure, i.e., its output is not affected by any monotonic transformation of the greyscale. It is an excellent measure of the spatial pattern, but it, by definition, discards contrast (Tajeripour et al. 2007). To engage the contrast of local image texture as well, we can measure it with a rotation-invariant measure of local variance:

$${\mathrm{VAR}}_{\mathrm{P},\mathrm{R}}=\frac{1}{P}\sum_{p=0}^{P-1}{\left({g}_{p}-\mu \right)}^{2}$$
(4)

where

$$\mu =\frac{1}{P}\sum_{p=0}^{P-1}{g}_{p}$$
(5)

and gp is the gray value of the specific pixel.

The 1-D variance applied to the ECG signal is as follows:

$${\mathrm{VAR}}_{{l}_{v}}=\frac{1}{{l}_{v}}\sum_{p=0}^{{l}_{v}}{\left({g}_{p}-\mu \right)}^{2}$$
(6)

where lv is the length of the segment under the test. A vector showing the variance of all points in the range is calculated by applying the variance operator on a segment of the length lv for all points. After sorting this vector, it is divided into r bins, and the number of variances falling in each bin is calculated. The final vector shows the number of similar variances in all r bins, which is represented as \({\mathrm{VAR}}_{{\mathrm{l}}_{\mathrm{V}}}^{\mathrm{r}}\). To improve the capability of the proposed algorithm in ECG classification and to incorporate the rate of variance in the amplitude of the signal, the 1-D variance is augmented to LBP:

$$\left\{\begin{array}{c}{F}_{1}={LBP}_{{l}_{LBP}}^{{u}_{T}}\\ {F}_{2}={VAR}_{{l}_{V}}^{r}\end{array}\right.$$
(7)

The variance probability vector, F2, is sorted and divided into r bins. In the test stage, the number of variance values, which belong to each bin, is calculated; the sample under test belongs to class K if the computed probabilities minimize the following ratio:

$$L\left(S,K\right)={L}_{LBP}+{L}_{V}$$
(8)

where

$$\left\{\begin{array}{c}{L}_{LBP}\left({S}_{P},{K}_{P}\right)=\sum_{i=0}^{{l}_{LBP}+1}{S}_{{P}_{i}}\mathrm{log}\left(\frac{{S}_{{P}_{i}}}{{M}_{{iK}_{p}}}\right)\\ {L}_{V}\left({S}_{V},{K}_{V}\right)=\sum_{i=0}^{r}{S}_{{V}_{i}}\mathrm{log}\left(\frac{{S}_{{V}_{i}}}{{M}_{{iK}_{V}}}\right)\end{array}\right.$$
(9)

LBP/VAR/MEAN

Albeit the LBP/VAR method is considered a powerful classifier, but experimental results show that the capability of the LBP/VAR method is not satisfactory enough for a vast range of abnormalities compared with other reported results. Meanwhile, morphological properties of the ECG signal are one of the most important features used in ECG classification, among which the area under the signal is one of the widely used features in ECG classification. To investigate this feature in the MV-MLBP algorithm, the mean value of the signal is considered too. Considering the fact that the ECG signal is a discrete vector, by adding all samples in the range of a specific segment, the area covered by this segment can be calculated as shown in Fig. 4.

$${S}_{L}=\sum_{i=0}^{L}F\left({x}_{i}\right)\Delta \left(x\right)$$
(10)
Fig. 4
figure 4

Area covered by a signal is proportional to the mean value

where SL represents the area covered by the function F(xi) and \(\Delta \mathrm{x}\) denotes the interval of sampling time (period of sampling T) in ECG signal.

On the other hand, the mean value of a discrete signal F(x) is:

$${M}_{L}=\frac{1}{L}\sum_{i=0}^{L}F\left({x}_{i}\right)$$
(11)

where L denotes the segment in which the operator ML is applied. By considering both Eqs. (10) and (11), it reveals the fact that the area under the ECG signal can be calculated through the operator ML. Just like the variance operator, a vector illustrating the mean value of all points in the segment L is calculated by applying the mean operator. In the next step, the vector is sorted and divided into s bins, and finally, the number of mean values which belong to each bin is calculated. The final vector shows the number of similar mean values in all s bins and is represented as \({\mathrm{Mean}}_{{\mathrm{l}}_{\mathrm{m}}}^{\mathrm{s}}\).

The structure of the LBP/VAR algorithm is promoted to LBP/VAR/MEAN in order to get a better classification rate:

$$\left\{\begin{array}{c}{F}_{1}={LBP}_{{l}_{LBP}}^{{u}_{T}}\\ {F}_{2}={VAR}_{{l}_{V}}^{r}\\ {F}_{3}={Mean}_{{l}_{m}}^{s}\end{array}\right.$$
(12)

LBP, variance, and mean vectors are of the length lLBP + 2, r + 1, and s + 1, respectively, so the final formulation of the augmented LBP proposed in this paper is shown in Eq. (13). In the testing stage, the sample under test belongs to class K if the computed probabilities minimize the following ratio:

$$L\left(S,K\right)={L}_{LBP}+{L}_{V}+{L}_{m}$$
(13)

where

$$\left\{\begin{array}{c}{\mathrm{L}}_{\mathrm{LBP}}\left({\mathrm{S}}_{\mathrm{P}},{\mathrm{K}}_{\mathrm{P}}\right)=\sum_{\mathrm{i}=0}^{{\mathrm{l}}_{\mathrm{LBP}+1}}{\mathrm{S}}_{{\mathrm{P}}_{\mathrm{i}}}\mathrm{log}\left(\frac{{\mathrm{S}}_{{\mathrm{P}}_{\mathrm{i}}}}{{\mathrm{M}}_{{\mathrm{iK}}_{\mathrm{p}}}}\right)\\ {\mathrm{L}}_{\mathrm{V}}\left({\mathrm{S}}_{\mathrm{V}},{\mathrm{K}}_{\mathrm{V}}\right)=\sum_{\mathrm{i}=0}^{\mathrm{r}}{\mathrm{S}}_{{\mathrm{V}}_{\mathrm{i}}}\mathrm{log}\left(\frac{{\mathrm{S}}_{{\mathrm{V}}_{\mathrm{i}}}}{{\mathrm{M}}_{{\mathrm{iK}}_{\mathrm{V}}}}\right)\\ {\mathrm{L}}_{\mathrm{m}}\left({\mathrm{S}}_{\mathrm{m}},{\mathrm{K}}_{\mathrm{m}}\right)=\sum_{\mathrm{i}=0}^{\mathrm{s}}{\mathrm{S}}_{{\mathrm{m}}_{\mathrm{i}}}\mathrm{log}\left(\frac{{\mathrm{S}}_{{\mathrm{m}}_{\mathrm{i}}}}{{\mathrm{M}}_{{\mathrm{iK}}_{\mathrm{m}}}}\right)\end{array}\right.$$
(14)

By combining LBP with variance and mean operator, the final operator is a multi-resolution one. As lLBP, lv, and lm are selected independently, the algorithm proposes a multi-resolution interpretation of the signal simultaneously. This interesting feature provides an appropriate context to find the best length of operation for each operator independently. Combining these operators with their corresponding effective length of operation leads to the best efficiency for the final algorithm.

In order to find the optimal length of operation for each operator, Eq. (12) is applied to all test signals with different length of operation for each arrhythmia individually, and the results are compared with reference feature vectors extracted from the same arrhythmia category with similar length, and consequently, the rate of similarity of the test signal with all categories is obtained by Eq. (13). The maximum value of these similarity rates is selected by Eq. (15) to show an effective length of operation. It should be noted that this maximum similarity is obtained by minimizing L(S,K) as defined in:

$$\left[{l}_{LBP},{l}_{V},{l}_{m}\right]=\mathrm{arg}\underset{i}{\mathrm{min}}\left(L\left(S,\left[{l}_{{LBP}_{i}},{l}_{V},{l}_{{m}_{i}}\right]\right)\right)$$
(15)

where I=1,2,...,11 is an index corresponding to all eleven ECG signal categories.

In Eq. (15), the length of optimum operation is selected in each category. The final algorithm is a combination of mean, LBP, and variance operators with different lengths, which have been calculated as optimal lengths in each signal category by Eq. (15).

Classification procedure

Training stage

In each category and for each heart signal, the reference feature vector for each operator is calculated in the training stage according to the following procedure:

  1. 1.

    Dividing the signal into segments containing one period of heartbeats

  2. 2.

    Selecting a segment of each period with the length M

  3. 3.

    Applying LBP, variance, and mean operator to each point in the segment with its corresponding length of operation

  4. 4.

    Calculating the final probability vectors for each segment in the signal using Eq. (1).

At the end of this process, three reference vectors are computed for each segment by applying LBP, variance, and mean operators R1, R2, and R3, respectively, where R1 is a vector with the lengthlLBP + 2, R2 is a vector with the length r + 1, and R3 is a vector with the length s + 1.

The mean value of all derived vectors for each operator is calculated to minimize any noise effects combined with the ECG signals. These final vectors are much less prone to the risk of noises such as electromyogram noise, additive white Gaussian noise, and power line. R1, R2, and R3 represent the final vectors indicating the reference vector used in the LBP, variance, and mean operators, respectively.

$${R}_{1}=\frac{1}{\mathrm{K}}\sum_{i=1}^{K}{R}_{1i};{R}_{2}=\frac{1}{K}\sum_{i=1}^{K}{R}_{2i};{R}_{3}=\frac{1}{K}\sum_{i=1}^{K}{R}_{3i}$$
(16)

where K is the number of cases considered in each class of arrhythmia.

Testing stage

All five training phase steps are applied to each test signal, and indicating vector for each operator is calculated.

Final resulting vectors are compared with the corresponding vectors of all arrhythmia using Eq. (13) and the similarity of each testing signal to a specific arrhythmia is calculated using Eq. (15).

Experimental results

To evaluate the MV-MLBP algorithm, eleven arrhythmias selected from MIT/BIH arrhythmia database (MIT-BIH 2011) are investigated in which eleven types of arrhythmias and normal ECG are included and are summarized in Table 1. One-third of the selected signals are used in the training procedure, and the rest are used to test and validate the algorithm. The algorithm is undergone using MATLAB software, version 7.5, 2007.

Table. 1 The number and type of heart beat signals used in this study

In the “Train phase” section and the “Test phase” section, three operators are applied to all signals in the train and test phase. In order to achieve better classification efficiency, operators are applied to signals containing ten periods of the heartbeat (N = 10 × M). According to Table 2, experimental results show that if the length of LBP operator (lLBP) is chosen as M/5, the MV-MLBP algorithm’s result is more accurate, and only a negligible portion of the arrhythmia in the dataset are labeled as non-uniformed. These results show that if the probability of encountering label lLBP, which is assigned to all non-uniform signals, is small (less than 1%), the algorithm can classify the ECG heartbeats with a high accuracy rate.

Table. 2 Simulation results for different length of operation for LBP operator

Train phase

In the train phase, the first step consists of dividing every signal in a specific class of arrhythmia into segments of the length 10 × M and the LBP operator is applied to these segments individually. The probability of encountering each label is used as an instrumental factor in MV-MLBP ECG classification method. To have a fair comparison between different classes of arrhythmia, all signals are re-sampled to 204 samples in each heartbeat. Figure 5 illustrates the probability of encountering each label in the LBP operator in different heartbeats. Having applied the LBP to all signals, the algorithm labeled all non-uniform signals in all categories as lLBP to increase the classification accuracy in the test phase. Tajeripour (Tajeripour et al. 2007) raised the threshold to reduce the number of signals labeled as lLBP to zero and reported a higher classification accuracy. As a result, the value of threshold (UT) is chosen as lLBP/5 to minimize the number of arrhythmias labeled as lLBP. These figures contain 41 bars, where the height of 41th bar (lLBP), which represents the probability of encountering label lLBP, is equal to zero.

Fig. 5
figure 5

Probability of encountering each label in different heartbeat

In order to find the efficient length of operation for variance and mean operators, each one is examined with a different length combined with LBP individually. Table 2 shows the simulation results examined for LBP and the best length is chosen accordingly. After choosing the LBP efficient length of operation, it is used to evaluate the accuracy rate for variance and mean operators with different lengths of operation (M/10, M/8, M/6, M/2, and M) and different bin numbers (32, 64, and 128) reported in Table 3 and 4. In these simulations, the accuracy rate is calculated by Eq. (17):

$$Accuracy=\frac{number of heart beats in a class which are classified correctly}{number of all heart beats in a class}$$
(17)
Table 3 Simulation results for different length of operation in mean operator and different segmentation of the range of the resulting vector
Table 4 Simulation results for different length of operation in variance operator and different segmentation of the range of the resulting vector

Highlighted cells emphasized in Tables 2, 3, and 4 represent the best similarity rate acquired for LBP, variance, and mean operator respectively, considering different length of operation.

The highlighted cells illustrate the best accuracy rate obtained for each arrhythmia. These simulation results reveal the fact that to have a pervasive algorithm, the best classification accuracy is obtained with different lengths of operation for variance and mean operator. According to these results, the final algorithm is as follows:

$$\left\{\begin{array}{c}{F}_{1}={LBP}_\frac{M}{5}^{{U}_{T}}\\ {F}_{2}={VAR}_\frac{M}{10}^{64},{F}_{3}={VAR}_\frac{M}{5}^{32},{F}_{4}={VAR}_\frac{M}{5}^{128},{F}_{5}={VAR}_\frac{M}{2}^{128},{F}_{4}={VAR}_{M}^{32},{F}_{7}={VAR}_\frac{M}{2}^{32}\\ {F}_{8}={Mean}_\frac{M}{10}^{128},{F}_{9}={Mean}_\frac{M}{2}^{32},{F}_{10}={Mean}_\frac{M}{6}^{32},{F}_{11}={Mean}_\frac{M}{8}^{32},{F}_{12}={Mean}_\frac{M}{10}^{32}\end{array}\right.$$
(18)

And the final similarity ratio is obtained as:

$$L=\sum_{i=1}^{12}L\left(S,{F}_{i}\right)$$
(19)

Figures 6 and 7 show the procedure of applying variance and mean operators on a segment containing five heartbeats.

Fig. 6
figure 6

Probability of encountering label zero to lv = M/6 in a normal sinus heartbeat

Fig. 7
figure 7

Probability of encountering label zero to lm = M/6 in a normal sinus heartbeat

Test phase

In this section, three operators are applied to all signals to calculate corresponding feature vectors using Eq. (18). By comparing these three vectors of each signal with indicating vectors in each class using Eq. (19), the similarity of the tested signal with each arrhythmia class is calculated and is shown in Table 5. According to the proposed algorithm, the test signal attributes to a class of arrhythmia which results in a higher similarity coefficient. The criteria to evaluate the accuracy rate of the MV-MLBP is by Eq. (20).

$$Accuracy\left(AC\right)=\frac{TP+TN}{TP+TN+FP+FN}\times 10$$
(20)
Table. 5 Classification results in the test phase

where TP, TN, FP, and FN are true positive, true negative, false positive, and false negative, respectively. Moreover, the precision, recall, and F-measure are calculated according to (21), (22), and (23).

$$\mathrm{Precision}=\frac{TP}{TP+FP}$$
(21)
$$\mathrm{Recall}=\frac{TP}{TP+FN}$$
(22)
$$F-measure=\frac{2TP}{2TP+FP+FN}$$
(23)

Discussion

The capability of the MV-MLBP with other similar studies is compared in Table 6, which illustrates the accuracy of the MV-MLBP algorithm.

Table. 6 Comparing the results of preceding researches

According to Table 6, the proposed morphological-based method is applied to 11 different arrhythmias, and high accuracy is achieved. The new proposed algorithm is the combination of 1-D LBP, variance, and mean operators. While the length of operation for each operator in the method can be selected individually, and hence is known as a multi-resolution method. Considering the low computational complexity of the MV-MLBP, it can be used as a suitable algorithm for online ECG classification too.

Conclusion

This paper aims at a fast and accurate ECG classification algorithm capable of classifying a wide range of arrhythmias with a high accuracy rate. The primary purpose of this study was to develop a fast, easy to implement, and practical algorithm to be transferred to clinical applications. According to the simplicity and satisfactorily accurate rate of classification shown in Table 6, it is evident that a broader range of arrhythmia can be considered and classified by the proposed algorithm. On the other hand, interesting features of LBP can trigger researchers to apply the method in other medical signal and image processing applications.