 Research
 Open Access
Improved Bat algorithm for the detection of myocardial infarction
 Padmavathi Kora†^{1}Email author and
 Sri Ramakrishna Kalva†^{2}
 Received: 29 March 2015
 Accepted: 25 September 2015
 Published: 3 November 2015
Abstract
The medical practitioners study the electrical activity of the human heart in order to detect heart diseases from the electrocardiogram (ECG) of the heart patients. A myocardial infarction (MI) or heart attack is a heart disease, that occurs when there is a block (blood clot) in the pathway of one or more coronary blood vessels (arteries) that supply blood to the heart muscle. The abnormalities in the heart can be identified by the changes in the ECG signal. The first step in the detection of MI is Preprocessing of ECGs which removes noise by using filters. Feature extraction is the next key process in detecting the changes in the ECG signals. This paper presents a method for extracting key features from each cardiac beat using Improved Bat algorithm. Using this algorithm best features are extracted, then these best (reduced) features are applied to the input of the neural network classifier. It has been observed that the performance of the classifier is improved with the help of the optimized features.
Keywords
 Myocardial infarction
 ECG
 Improved Bat algorithm
 Neural network classifier
Background
Heart diseases are the most important cause of human mortality globally. Every year, 9.4 million deaths are attributed to heart diseases. This includes 51 % of deaths due to strokes and 45 % of deaths due to coronary heart diseases. Most of the cardiac diseases are caused due to the risk factors such as unhealthy diet, high blood pressure, tobacco usage, obesity, diabetes and physical inactivity.
Abnormal cardiac beat identification is a crucial step in the detection of heart diseases. Normally, electrical impulses within the heart muscle stimulate the heart to contract or beat. The heart requires a constant supply of oxygen and nutrients, like any other muscle in the body. A heart attack or myocardial infarction (MI) is usually caused by a blood clot, which prevents the blood flowing through arteries or veins. Our present study describes a procedure for the detection of ECG patterns with MI. There are two types of MI in general. They are Type 1 MI (non Q type, with ST elevation and attenuated QRS complex) and Type 2 MI (Q type MI with deep Q and inverted T). This study focuses on the detection of Type 1 MI.
Figure 1 provides information regarding amplitudes and relative time intervals of ECG. These changes in the ECG are called morphological transitions. The morphological changes (P, QRS complex, T, U waves) of ECG are due to the abnormalities in the heart. MI is one such morphological abnormality seen in the heart diseases. In the previous studies (Spilka et al. 2010) morphological features are extracted for clinical observation of heart diseases. The feature extraction using traditional techniques generally yield a large number of features, and many of these might be insignificant. Therefore, the common practice is to extract key features useful in the classification. This paper presents IBA as a feature extraction method instead of using traditional (Chatterjee et al. 2011) feature extraction techniques. In the present paper, feature extraction is based on extracting key features using nature inspired algorithm called Improved Bat algorithm (IBA) (Fister et al. 2014). Earlier studies extracted the key features using statistical and morphological techniques like Cross Wavelet transform (WT) (Banerjee and Mitra 2013), Morphological features and SVM (Spilka et al. 2010), Multiple Instance Learning (MIL) (Sun et al. 2012) which give less accuracy in the classification of MI compared to the proposed IBA.
Nature has inspired many researchers for developing algorithms to suit their needs. These algorithms are categorized basically into two types: one is based on evolutionary approach and the other is based on swarm intelligence (SI). Evolutionary algorithms mimic the Darwinian principle of “survival of the fittest” using processes of natural selection, recombination and mutation. Swarm optimization is based on the collective behavior of a group of animals. The algorithm first finds the global minimum and then searches for the best local minimum. Examples for the nature inspired optimization algorithms are ant colony optimization (Dorigo et al. 2008), particle swarm optimization (Kennedy 2010), cuckoo search (Yang and Gonzalez 2010), bacterial foraging optimization (BFO) (Passino 2002; Kora and Kalva 2015), Bat algorithm (Yang 2011), and firefly algorithm (Mishra et al. 2014; Sahu et al. 2015). IBA is a special class of swarm intelligence used for extracting a reduced feature set of 20 samples out of 200 samples taken from each beat of ECG. Without using the traditional feature extraction methods, IBA can be used for selecting the best 20 features out of 200 features in each beat. The proposed IBA can also be used for finding the most important information from a given set of samples.
There are two important things to be balanced in the nature inspired metaheuristic algorithms (Yılmaz et al. 2014): they are exploitation and exploration. The former is used for capturing the local minimum point. On the other hand, the latter is used for finding out the global minimum. The algorithm must reach the global minimum point with out being trapped into the local minimum. A success of an algorithm depends on well balanced of these components. Too little exploration but too much exploitation may cause premature convergence, on the other hand too much exploration but too little exploitation may cause difficulties that algorithm convergences towards optimal solutions. The previous studies (Yang and Gonzalez 2010) had the advantage of exploration approach first and exploitation approach later.
Methods
The proposed methodology consists of denoising of ECG data followed by the R peak detection and beat segmentation. The heart rate is a variable quantity and accordingly the beat duration changes. So, each segmented beat is resampled into 200 samples. These beats are subjected to further analysis.
Data acquisition
MIT/BIH PTB data base
MI records  Normal records 

s0043lre  s0301lre 
s0088lre  s0303lre 
s0100lre  s0306lre 
s0235lre  s0311lre 
s0242lre  s0472lre 
s0386lre  s0469lre 
s0559lre 
Noise removal and R peak detection
Denoising of ECG data is a preprocessing step that removes noise and makes ECG file useful for subsequent steps in the algorithm. The Sgolay FIR smoothing filter is used for filtering.
ECG feature selection using BAT algorithm
The customary feature extraction methods generally yields a large number of features, and many of these might be insignificant. Therefore, the effective technique in this study is to extract the key features useful in the classification of ECG beats. In this subsection, 20 key features from 200 samples are extracted using BA, IBA algorithms.
Standard Bat algorithm
Bats (Yang and He 2013) are the most fascinating group of birds. They rely on echolocation. There are a total of 1200 species of bats (Fister 2013). More than half of them rely on echolocation to locate their prey.
Echolocation capability of bats
Most of the bats use a sophisticated sense of hearing. They release sounds that bounce(echoes) back from the insects or objects in their path. From these echoes, the bats can identify how far the insects or objects are from their current position and the also estimate the size of insects or objects within a fraction of second (Yang 2011).
The structure of Bat algorithm
 (a)Initialization: The fitness of the initial bat population is evaluated using the Rosen brock function as shown in the Eq. (1) and the values of pulse rate \(r_{i}\), loudness \(A_{i}\) and frequency \(f_{min}\), \(f_{max}\) are initialized.where j is the dimension and x(i) is the ith bat.$$\begin{aligned} f(x)=\textstyle \sum _{i=1}^{j1}[100(x_{i+1}x_{i}^2)^2+(x_{i}1)^2] \end{aligned}$$(1)
 (b)Movement of Virtual Bats: The new bat population is generated by adjusting the position \(x_{i}\) and the velocity \(v_{i}\) for each bat in the population as given in Eqs. (2) and (3) respectively (lines 12–13 of algorithm 1).$$\begin{aligned} f_{t}= fmin + (fmax fmin) \times rand \end{aligned}$$$$\begin{aligned} {v_{i}(t+1)= v_{i}(t) + (x_{i}(t)  x_{Gbest})f_{t}} \end{aligned}$$(2)The velocity and position updates of the \(i\)th bat are calculated using Eqs. (2) and (3). The wavelength \(\lambda\) and loudness A are varied according to the location and size of the food. The \(v_{i}\) and \(x_{i}\) are initialized with some initial random values and a fitness function f is calculated, using the particles positional coordinates as input values. The best fitness value among all the bats is denoted as \(x_{Gbest}\). The difference between \(x_{i}(t)\) and \(x_{Gbest}\) is a positive value which means \(x_{Gbest}\) bat has more number of features than those of ith bat. This difference is summed up with the previous velocity to accelerate the movement of ith bat towards the \(x_{Gbest}\)bat. If the difference is negative, it means ith bat has more number of features than those of \(x_{Gbest}\) bat. This difference is added to the previous velocity to decrease the velocity of ith bat.$$\begin{aligned} x_{i}(t+1)= x_{i}(t) + v_{i}(t) \end{aligned}$$(3)
 (c)Local search capability of the algorithm:In order to enhance the local search capability of the algorithm, Yang (2011) has created the best solution using the equation (4) where \(x_{Gbest}\) is a high quality solution chosen by some mechanism. \(A^{t}\) is the average loudness value of all the bats at tth time step and the \(\epsilon\) is generated by some random mechanism ranging between \(\) 1 and 1.$$\begin{aligned} x_{new}= x_{Gbest} + \epsilon A^{t} \end{aligned}$$(4)
 (d)Loudness (A): Loudness \(A_{i}\) has been updated using Eq. (5) as the iterations proceed. As bats approach their food, the loudness usually decreases as depicted in Fig. 6. Generally, the loudness value will decrease when the bat starts approaching the best solution as shows in the following equation:The amount of decrease is determined by \(\alpha\)where \(0 < \alpha < 1\).$$\begin{aligned} A_{i}(t+1)= \alpha A_{i}(t) \end{aligned}$$(5)
 (e)Pulse emission rate (r): The pulse emission rate \(r_{i}\) has been updated using the Eq. (6) as the bats approach their food. r increases as depicted in Fig. 7. Pulse rate r yields a better solution near \(X_{Gbest}\), higher pulse rate doesn’t yield best solution in local search space.where \(\gamma > 0\) The r and A are updated only when the new solution is made better than the previous solution, where \(\gamma\) is constant.$$\begin{aligned} r_{i}(t+1)= r_{i}^{0}[1 e^{\gamma t}] \end{aligned}$$(6)
The original BA has been demonstrated in the following algorithm and the flowchart is as shown in Fig. 8. In this algorithm, the bat behavior has been analyzed based on the its fitness function. It consists of the following points:
 1.
Calculating the optimum value of a function.
 2.
Reducing feature set of a population.

We have considered the initial size of Population as 2086 beats (BBB and normal).

Load the population using Matlab command X = xlsread (‘Normal BBB. xlsx’);

The rows of ’X’ represents the features and the columns of ‘X’ represents the size of population.

Calculate the fitness of the above population using Eq. (1).

The minimum value of the fitness among all the population is stored as the best value.

Move the population to a new location using Eqs. (2) and (3).

If rand <ri

Generate the local solution around the best solution using Eq. (4).

Else again calculate the fitness.


if (rand <Ai) and new fitness <previous fitness

Store the best solution and update A and r.

Else rank the features of the population according to the best fitness values.

Proposed method: improved Bat algorithm (IBA)
The global search mechanism of the algorithm is carried out by updating Eqs. (2) and (3), whereas the local search is carried out using the Eq. (4). In BA at the beginning of iterations, exploitation capability of the algorithm is high while exploration is low. It is understood that, if new candidate solutions are generated by using Eqs. (2) and (3) only, the algorithm becomes good at exploration but it turns out bad at exploitation. If new candidate solutions are generated using Eq. (4) only, then the algorithm shows good results at exploitation but it indicates bad results at exploration. Thus, the algorithm can easily get trapped into the local minimum. Actually, pulse emission rate r is a key factor which provides a balance between exploration and exploitation. It is observed that as the iterations proceed the constraint rand > \(r_{i}\) decreases. Previous studies show that exploration has to be applied at the beginning and exploitation must be applied in the following iterations.
At the beginning of the iterations, A is high, so the possibility of satisfying condition rand \(< A_{i}\) is high. At the ending of iterations, loudness A is low. So, the possibility of satisfying condition rand \(<\) \(A_{i}\) is low. This means that the inclusion possibility of newly formed solution, which have been generated by exploration technique at the end of the iterations, into the bat population is weak. At the beginning of the iterations, if the algorithm gets trapped into the local minimum, the newly generated solution also gathers around such local minimum. Hence, the escaping possibility of BA from the local minimum decreases.
Classification of ECG features taken from the Bat algorithm
The extracted features (20 best features from 200 features) from BA, IBA algorithm are given as the input for the classifiers: SVM, KNN, LM NN, SCG NN.
Support vector machines
A support vector machine is a supervised machine learning method applicable for classification. It is an example for binary linear classifier, established from statistical theory of learning. It exhibits high accuracy and has capability to handle with high dimensional data sequences.
The data can be taken from II, III, and AVF leads of ECG for classifying the MI. For this study standard lead III data was taken. Total 2806 beats are used for classification. Out of total beats 1800 beats are given for training and 1006 beats are given for testing.
Knearest neighbour (KNN)
Levenberg–Marquardt neural network (LM NN)
In this work for the detection of MI, back propagation Levenberg–Marquardt neural network (LMNN) was used. This NN provides rapid execution of the network to be trained, which is the main advantage in the neural signal processing applications (Sapna et al. 2012). The NN was designed to work well if it was built with 20 input neurons, 10 neurons in the hidden layer and 3 neurons in the output layer. The performance of this algorithm is compared with Scalar Conjugate Gradient (SCG) NN. The LM NN algorithm is a robust, and very simple method for approximating a function. SCG NN method provides conjugate directions of search instead of performing linear search. The network is trained with 1800 beats, and tested with 1006 beats. The total number of iterations was set to 1000 and Mean square error less than 0.001. The main advantage of this algorithm is that the time required to train the network is less.
Results
Parameter settings and analysis
The bioinspired IBA has been implemented in Matlab 7.12.0. The experiment has been employed with a population size of 2086 for 30 generations. where increase pulse rate(r) and decrease loudness (A) have been set to 0.95. The initial value of pulse rate was set to 0.2. The \(f_{max}\) and \(f_{min}\) have been set to 0, 2 kHz respectively. The \(A_{max}\) and \(A_{min}\) value have been set to 3,1kHz respectively as shown in the Table 2.
We have selected different feature sizes for the classification. The purpose is to investigate the influence of the feature size on the classification accuracy. The accuracy was gradually decreases while the feature size increases. The accuracy value is high when features are 20 samples/beat. The original features present in each beat of ECG = [1, 2, \(\ldots\), 200];
The best 20 features (column numbers) selected from IBA = [41, 14, 198, 17, 189, 139, 22, 81, 177, 117, 82, 134, 40, 49, 38, 80, 86, 129, 138].

Total number of beats used for classification 2806

Count of Normal beats used for classification 1296

Count of MI beats user for classification 1505

Count of correctly classified beats 2754

Total misclassified beats 52
Parameters and values
Parameter values  

Population size  2086 
Generations  −30 
fmin  0 
fmax  1 
Loudness A  −0.95 
Pulse rate r  0.85 
Classification with KNN classifier
Classifier  Sensi (%)  Speci (%)  Accuracy (%) 

BA + KNN  53.5  52.2  53.22 
IBA + KNN  52.5  53.2  65.1 
Classification with SVM classifier
Classifier  Sensi (%)  Speci (%)  Accuracy (%) 

BA + SVM  76.2  75.47  72.13 
IBA + SVM  75.5  76.9  76.74 
Classification with SCG NN classifier
Classifier  Sensi (%)  Speci (%)  Accuracy (%) 

BA + SCG NN  84.42  82.28  83.13 
IBA + SCG NN  88.2  87.2  87.9 
Classification with LM NN classifier
Classifier  Sensi (%)  Speci (%)  Accuracy (%) 

BA+LM NN  58.97  58.7  58.7 
IBA+LM NN  93.342  92.2  98.9 
Discussion
Conclusion
Early changes of MI are important because immediate treatment can save the life of the patient from heart failure.There are several methods to detect features of MI. The RR interval, P wave, Statistical methods for feature extraction has some limitations.
Accurate detection of features are important for detection of MI. Nature inspired algorithms have gained increased attention of scientists and engineers in solving the problems which can not be solved by above traditional methods. In our approach IBA features for each beat(MI, normal) are extracted and the results shows that accuracy for the detection of MI has increased.
In the present study we developed a simple computational model for the detection of ECG MI using the IBA algorithm. It also projected that IBA algorithm can be used for ECG feature extraction with a view to improving its exploration behavior and decreasing the error in the final output. It can be easily observed that standard version of BA is poor at exploration, thus it is insufficient for most of the problems. In our proposed method, the modifications increases exploration capabilities at the beginning of cycles and increases exploitation capabilities towards the end of the cycles. BA and IBA are compared with bench mark ECG MI data set.
The future modifications to the algorithm are, use of multiple variants of BA such as, Gaussian distribution for random movement. The chaos enhanced BA for tuning of parameters \(\alpha\), \(\beta\) and \(\gamma\) seems to be a better idea for solving practical problems such as feature extraction and classification.
Notes
Declarations
Authors' contributions
PK involved in the ECG data collection, Preprocessing. Dr. SRK explained the Bat algorithm concept, classification methods of ECG features and given the design flow for preparing the rough draft of the manuscript. Then PK prepared Matlab coding for these concepts. Dr. SRK also corrected the syntax and grammar mistakes in the final prepared manuscript. All authors read and approved the final manuscript.
Acknowledgements
The authors would like to thank the anonymous reviewers for their comments and suggestions that helped to improve the quality of this paper.
Competing interests
The authors declare that they have no competing interests.
Open AccessThis article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.
Authors’ Affiliations
References
 Banerjee S, Mitra M (2013) Classification of ST and Q Type MI variant using thresholding and neighbourhood estimation method after cross wavelet based analysis. arXiv preprint arXiv:1311.5639
 Chatterjee H, Gupta R, Mitra M (2011) A statistical approach for determination of time plane features from digitized ecg. Comp Biol Med 41(5):278–284View ArticleGoogle Scholar
 Dorigo M, Birattari M, Blum C, Clerc M, Stützle T, Winfield A (eds) (2008) Ant colony optimization and swarm intelligence. In: Proceedings of 6th International Conference, ANTS 2008, Brussels, Belgium, September 22–24, 2008, vol 5217. Springer, BerlinGoogle Scholar
 Fister I (2013) A comprehensive review of bat algorithms and their hybridization (Doctoral dissertation, Master’s thesis, University of Maribor, Slovenia)Google Scholar
 Fister I, XinShe Y, Fong S, Yan Z (2014) Bat algorithm: recent advances. In: IEEE 15th International Symposium on Computational Intelligence and Informatics (CINTI), pp 163–167Google Scholar
 Goldberger AL, Amaral LA, Glass L, Hausdorff JM, Ivanov PC, Mark RG, Stanley HE (2000) Physiobank, physiotoolkit, and physionet components of a new research resource for complex physiologic signals. Circulation 101(23):e215–e220View ArticleGoogle Scholar
 Kennedy J (2010) Particle swarm optimization. In: Encyclopedia of Machine Learning. Springer US, pp 760–766Google Scholar
 Kora P, Kalva SR (2015) Hybrid bacterial foraging and particle swarm optimization for detecting Bundle Branch Block. SpringerPlus 4(1):481View ArticleGoogle Scholar
 Mishra A, Agarwal C, Sharma A, Bedi P (2014) Optimized grayscale image watermarking using DWTSVD and Firefly Algorithm. Exp Syst Appl 41(17):7858–7867View ArticleGoogle Scholar
 Passino KM (2002) Biomimicry of bacterial foraging for distributed optimization and control. Control Syst IEEE 22(3):52–67View ArticleGoogle Scholar
 Sahu RK, Panda S, Padhan S (2015) A hybrid firefly algorithm and pattern search technique for automatic generation control of multi area power systems. Int J Elect Power Energy Syst 64:9–23View ArticleGoogle Scholar
 Sapna S, Tamilarasi A, Kumar MP (2012) Backpropagation learning algorithm based on Levenberg Marquardt Algorithm. Comp Sci Inform Technol (CS and IT) 2:393–398Google Scholar
 Spilka J, Chudáček V, Kužílek J, Lhotská L, Hanuliak M (2010) Detection of inferior myocardial infarction: a comparison of various decision systems and learning algorithms. In: Computing in Cardiology, 2010. IEEE, pp 273–276Google Scholar
 Sun L, Lu Y, Yang K, Li S (2012) ECG analysis using multiple instance learning for myocardial infarction detection. IEEE Trans Biomed Eng 59(12):3348–3356View ArticleGoogle Scholar
 Yang XS (2011) Bat algorithm for multiobjective optimisation. Int J BioInsp Comp 3(5):267–274View ArticleGoogle Scholar
 Yang XS, He X (2013) Bat algorithm: literature review and applications. Int J BioInsp Comp 5(3):141–149View ArticleGoogle Scholar
 Yang XS (2010). A new metaheuristic batinspired algorithm. In: Nature inspired cooperative strategies for optimization (NICSO 2010). Springer, Berlin Heidelberg, pp 65–74Google Scholar
 Yang XS, Deb S (2009) Cuckoo search via Lévy flights. In: World Congress on Nature and Biologically Inspired Computing, 2009. NaBIC 2009, IEEE, pp 210–214Google Scholar
 Yang XS, Gonzalez J (2010) A new metaheuristic batinspired algorithm. In: Nature inspired cooperative strategies for optimization (NICSO 2010). Springer, Berlin Heidelberg, pp 65–74Google Scholar
 Yılmaz S, Kucuksille EU, Cengiz Y (2014) Modified bat algorithm. Elektronika ir Elektrotechnika 20(2):71–78Google Scholar