Heart Sound Signals Segmentation and Multiclass Classification

—The heart is the organ that pumps blood with oxygen and nutrients into all body organs by a rhythmic cycle overlapping between contraction and dilatation. This is done by producing an audible sound which we can hear using a stethoscope. Many are the causes affecting the normal function of this most vital organ. In this respect, the heart sound classification has become one of the diagnostic tools that allow the discrimination between patients and healthy people; this diagnosis is less painful, less costly and less time consuming. In this paper, we present a classification algorithm based on the extraction of 20 features from segmented phonocardiogram “PCG” signals. We applied four types of machine learning classifiers that are k-Near Neighbor “KNN”, Support Vector Machine “SVM”, Tree, and Naïve Bayes “NB” so as to train old features and predict the new entry. To make our results measurable, we have chosen the PASCAL Classifying Heart Sounds challenge, which is a rich database and is conducive to classifying the PCGs into four classes for dataset A and three classes for dataset B. The main finding is about 3.06 total precision of the dataset A and 2.37 of the dataset B.


Introduction
According to statistics published by World Health Organization, 54 per cent of the 56.9 million deaths worldwide in 2016 are caused by the 10 facts. The heart diseases are the cause of over than 15.2 million deaths in 2016, which makes them the leader world's killer [1]. Heart diseases come as a set of disorders affecting the heart and blood vessels; those disorders can be categorized as a cerebra-vascular disease, rheumatic heart disease, coronary heart disease and other infections. People with hypertension, diabetes, hyperlipidemia or an illness already installed are more exposed to a high risk of cardiovascular disease. An early detection of signs of cardiac abnormality represents an interesting initiative to take care of the patient [2].
Many tools are used in clinical practices to diagnose heart diseases; auscultation is a fundamental diagnostic tool in this disease's category. It is the act of listening to the noises produced by the cardiac cycle to make a diagnosis.
The heart makes some mechanical movements through the closing of cardiac valves during each heartbeat; those are the source of the vibrations in the myocardial wall that are translated into sounds known as heart sounds or phonocardiogram "PCG" [3] [4].
The cardiac cycle is described by four components as shown in the figure below. The first one is "S1" with a frequency spectrum of 10 to 200 Hz, a high amplitude and long duration of 100 to 200ms compared to other components; it happens in the beginning of the systole phase and corresponds to the closure of the mitral and tricuspid valves. A second one, named "S2", characterizes the end of the systole phase and marks the beginning of the diastole phase, matching the closing of the aortic and pulmonary valves. Its frequency spectrum occurs between 50 and 250 Hz. The third component is "S3", corresponding to the end of the fast filling of the ventricle. The last one is "S4", matching the atrial systole, which means the active filling phase of the ventricle [5].
The PCG signal comes in the form of periodic cycle called cardiac cycle split into two parts. The first part represents the systolic phase, which reflects the contraction of the heart and lasts about 0.27 seconds; it is followed by a diastolic phase representing the dilatation of the heart, and its release takes about 0.49 seconds. The two phases alternate in order to build the cardiac cycle [6].

Fig. 1. Cardiac cycle
Depending on the nature of the PCG signals, we can judge the state of the heart. We enumerate six classes of the heart state as presented in figure 2 [7].
In this study, we presented an answer to the PASCAL classifying heart sound challenge, which consists of the categorization of the given PCGs records into four classes for dataset A; these are Normal, Murmur, Extra Heart Sound, and Artifact. For dataset B, it is categorized into three classes -Normal, Murmur, and Extrasystole.
So, we proposed a classification algorithm containing four elementary phases. The first one is a preprocessing phase, followed by a segmentation phase which permits good identification for the nature of the PCG signal. Afterwards, we proceeded to the phase of features extraction and, finally, we applied one of the chosen classifiers -knn, svm, tree, nb -in this study.

Fig. 2. PCG Signal Analysis
A comparison of classifiers' results was presented in this paper to justify our choice. Also, we compared our results with those of the finalists who participated in the PASCAL Classifying Heart Sounds Challenge and the findings of some research papers published recently.

Literature Review
A plethora of research papers were published on the classification of the PCG signals thanks to the abundance of information on those signals (give examples). In this respect, many methods and algorithms were applied except that the used databases on every work were different and the results achieved maybe plausible but still relative and less comparable.
To compare the findings of previously published studies, we made reference to the same database. In other words, we applied the classification methods and algorithms to the same dataset of training, validation and test. In this respect, several challenges have been launched, among which is the PASCAL Classifying Heart Sound Challenge published in 2011. This challenge is composed of two tasks; the first one consists of the segmentation of the PCGs signals and the second task is devoted to the classification.
Balili et al. [8] participated in the PASCAL Classifying Heart sound Challenge by proposing an algorithm to answer the tasks of the challenge. The algorithm consisted of a segmentation phase where it detected the S1 and S2 components by using the Shannon energy. Then, it proceeded to wavelet analysis to extract some time-frequency features from DWT (discrete wavelet transforms) and CWT (continuous wavelet transforms). The features were concatenated in vector which was the base of training the random forest classifier. Finally, it classified the test database using the model found after the training phase.
The work [9] presented by Y. Deng & P. Bentley with the aim of answering the tasks of the challenge is summarized as a de-noise phase from PCGs signals by a combination of STFT (short time Fourier transform) and wavelet transform. Then, they decomposed the original signal by wavelet decomposition, reconstructed the signal from the approximations and part of the details, and re-filtered the signal using the spectrogram. Exceeding the selected threshold of amplitude and slope allowed them to find peaks location and all the extra-peaks were rejected. The identification of S1 and S2 components was mainly based on the intervals between two succeeded peaks.
All the previous steps were followed to ensure a good segmentation. After that, they calculated N (Number of heart beats per minute) for each sound clip so as to classify the PCGs signals. If N was within the range from 30 to 140 beats/minute, the signal went to the next step of judgment; or it was labeled as artifact. Then, they compared L1 (length of the signal before peak rejection) and Ls (length of the signal after peak rejection). If L1 was more than 3.3 times of Ls, the signal was classified as murmur; otherwise, they moved to the last step that focuses on the mean and the standard deviation (Std) of the systole and the diastole period. If the Std was larger than its corresponding mean, the signal was considered an extra sound; otherwise it was normal.
Chakir's work [10] came with the preprocessing step where the datasets are downsampled by 20; then the signals were filtered by the sixth order Butterworth band-pass filter with a cut-off frequency from 25 to 900Hz, and, as a final step in the preprocessing phase, the signal was normalized to the absolute maximum.
The segmentation phase began by detecting the peaks using the normalized average Shannon energy and the function findpeaks (). Then Chakir proceeded to extra-peaks rejection, and the S1 and S2 peaks identification by reasoning on the time interval between two successive peaks. After that, she extracted 12 features from all signals of training datasets and used the KNN (k-near neighbors) classifier to classify the test datasets.
Other studies were developed based on the segmentation of PCG signals using different methods of envelope extraction, such as Shannon energy [11], Shannon entropy [12], Hilbert-Huang transform [13], and the autocorrelation [14]. There are other approaches based on the wavelet transform to add the frequency features of S1 and S2 [15]. Afterward, they proceeded to extract the temporal frequency and timefrequency features from the PCG signals in order to classify heart sound records into normal or abnormal by using one of most recognized classifiers (SVM, KNN, ANN, etc.).

Used Database
In this paper, the used database is the one provided by the PASCAL Classifying Heart Sound Challenge [16]. This database was split into two groups of datasetsdataset A and dataset B. The sounds clips, as is clear in figure 3, were collected at four different locations on the body: the aortic (AR), the pulmonary (PR), the tricuspid (TR) and the mitral areas (MR).

Fig. 3. PCG record locations
Dataset A comprises data crowd-sourced from the general public via the iStethoscope Pro iPhone app. Dataset B comprises data collected from a clinical trial in hospitals using the digital stethoscope DigiScope [17].
Dataset A contains 176 files in .wav format, organized in five classes: • The first -31 filesis a training normal category in which there is a healthy heart sound. • The second one -34 filespresents a training murmur category, where we can find the PCGs signals with noise in one of two temporal locations; it can be a symptom of many serious heart disorders. • The third -19 filesis named the training extra heart sound category because in each sound clip, we can identify an additional sound which usually doesn't mean a sign of disease, but sometimes it could be a sign of some heart disorders; if they are detected early, this can be helpful to the patient. • The Artifact category is the fourth class -40 files. There is a wide range of different sounds, depending on the recording environment. Those records include feedback squeals and echoes, speech, music and noise. • The last category -52 filesis the unlabeled category designated to the test.
Dataset B contains 656 files in .wav format, organized in four classes: • The fist category -320 filesis a training normal category.
• The second one -95 filesis a training murmur category.
• The third one -46 filesis a training extrasystole category; it occasionally presents some identified extrasystole sounds because there is a heart sound that is out of rhythm. This type of signals can usually happen even if the person is healthy, but sometimes it can be a sign of a serious heart problem. So, detecting this type of signals may be useful.
The last category -195 filesis an unlabeled category designated to the test.

Methods
To answer the tasks of the PASCAL Classifying Heart Sound Challenge, we suggested an approach based on the main code given by the Physionet/CinC Challenge 2016 as a template.
We proposed an algorithm that mainly contains five phases from acquisition to classification of the PCG signals. We began by a preprocessing phase of record to hold just the useful part of the signal. Then, we moved to a segmentation phase which permitted us to identify and locate the S1 and S2 components.
The third phase was where we extracted features from each segmented signal; those features became the base of the classifier training phase.
Finally, we classified the unlabeled signals using the model found by the training classifier phase. Figure 4 shows the block diagram of our approach.

Pre-processing phase
This phase can be summarized into resampling the heart sound to 1000 Hz. Then we applied the 5th order, a Butterworth low-pass filter, whose cutoff is 400Hz; another 5th order, a Butterworth high-pass filter, with 25Hz of cutoff frequency was applied. This was done in order to conserve the bandwidth between [25....400Hz], where we have the useful signal.
The cutoffs are chosen based on a statistical analysis which showed that the major concentration of energy for both first heart sound "S1" and second heart sound "S2" is below 150Hz [18]. Further, the Nyquist-Shannon sampling criterion [19] justified the resampling frequency (1000Hz).
A phase of normalization to the absolute maximum was applied before each treatment phase so as to limit the effect of variable auscultation conditions. Assuming that x (t) is the signal to be processed, its normalized version [20] xnorm (t) is: (1)

Segmentation phase
To segment PCG signals we adopted an algorithm published by B. Springer et al. [21]; it uses a combination of four input features.
The first one allowed us to extract the envelope of PCG signals, using the homomorphic envelogram obtained by exponentiation of the low-pass filtered natural logarithm of the heart sound [22].
The second is the Hilbert envelope; this feature uses the Hilbert transform which extracts the analytic signal and excludes the negative frequency component. Then, the absolute value of the Hilbert transform allowed us to calculate the Hilbert envelope [21].
The third feature is the wavelet envelope, which was extracted by a wavelet analysis of the PCG signal. After an optimization algorithm, the choice was the reverse biorthogonal 3.9 or Daubechies 10 wavelet at decomposition level three.
The last one is the power spectral density "PSD" envelope, deducted from a short time Fourier transform "STFT" after a Hamming windowing. It should be pointed here that the main frequency components of PCG records are located below 150 Hz with a peak at 50Hz [23] and that the PSD envelope was obtained by calculating the mean of PSD between [40...60Hz] found in overlapping windows of 0.05 sec in width with 50% overlap [21]. The chosen window size is to cover the useful frequency content by an analysis window.
Using the features previously introduced to construct a hidden semi-Markov model "HSMM" and incorporate the logistic regression "LR" into the model permitted the improvement of the segmentation of heart sound signals.
To detect the peaks of the PCG signal envelope, we used a predefined functionfindpeak () -that locates them, adjusting the minimum value of the amplitude and the distance between two successive peaks. Since the diastolic duration was greater than the systolic duration, we could identify the first heart sound (S1) and the second heart sound (S2) [24].
In figure 5, we present the block diagram of our segmentation approach:

Features extraction phase
In this part of algorithm, we tried to get 20 features from each segmented heart sound signal. These features can be summarized in the following mean value of S1 intervals sd_IntS1 SD value of S1 intervals mean_IntS2 mean value of S2 intervals sd_IntS2 SD value of S2 intervals mean_IntSys mean value of systole intervals sd_IntSys SD value of systole intervals mean_IntDia mean value of diastole intervals sd_IntDia SD value of diastole intervals m_Ratio_SysRR mean value of the interval ratios between systole and RR in each heart beat sd_Ratio_SysRR SD value of the interval ratios between systole and RR in each heart beat m_Ratio_DiaRR mean value of the interval ratios between diastole and RR in each heart beat sd_Ratio_DiaRR SD value of the interval ratios between diastole and RR in each heart beat m_Ratio_SysDia mean value of the interval ratios between systole and diastole in each heart beat sd_Ratio_SysDia SD value of the interval ratios between systole and diastole in each heart beat m_Amp_SysS1 mean value of the mean absolute amplitude ratios between systole period and S1 period in each heart beat sd_Amp_SysS1 SD value of the mean absolute amplitude ratios between systole period and S1 period in each heart beat m_Amp_DiaS2 mean value of the mean absolute amplitude ratios between diastole period and S2 period in each heart beat sd_Amp_DiaS2 SD value of the mean absolute amplitude ratios between diastole period and S2 period in each heart beat

Training & classification phase
This phase allowed us to train a chosen classifier -knn, svm, naive Bayes, treeusing a train-dataset previously introduced. The training of each classifier is based on the 20 extracted features.
After getting the classifier model from training, we could proceed to classify a new entry taken from the test-dataset in order to evaluate the performance of our classifiers.

• K-Near Neighbor classifier (KNN): The first classifier we tested is the k-Near
Neighbor. It is a non-linear classifier which follows a simple rule to classify the test entities. The rule is that the new entity to test is classified according to the class of the closest neighbor defined in the training model of the classifier. In our algorithm, we classified the heart sounds from test-dataset many times by k-NN classifier via changing the main proprieties of the classifier, the number of neighbor "k" and the type of the distance between the sample to test and the neighbors. That was done with the aim of optimizing the results of this classifier.
• Support Vector Machine classifier (SVM): Support vector machine classifier is one of the most used classifiers. The classification in this case was achieved by defining a decision boundary which could be assimilated to a hyper-plane maximizing the separating distance between classes.
To choose an optimal hyper-plane, we can substitute the used SVM kernel function which can be linear, quadratic, polynomial, MLP (multi-layer perceptual), RBF (gaussian radial basis function) or other; each time we trained the classifier. Then, we classified the test-dataset. The best result identified the optimal parameters. • Tree classifier: In computer science, Tree classifier is a supervised learning technique that uses a decision tree to conclude about the target from a previous observation.
We did a lot of experiences, training the Tree classifier by changing the proprieties of the tree (number of node leaf observation, number of branches, algorithm...). Then, we kept the proprieties allowing the most reliable result. • Naïve Bayes classifier: The naive Bayes classifier is one of the linear classifiers.
This type of classifier calculates the posterior state based on Bayes' theorem with strong independence between calculated features for each class.
In our case, we trained the naive Bayes classifier many times but with different parameters (distribution, kernel, and support) to optimize the results reached after the classification of the test-data.

Evaluation
To calculate the effectiveness of our classification method, three metrics to be calculated from the tp, fp, tn and fn values of our approach were required. For the classification task, we had to calculate: Where the necessary equations are: 1. Precision provided us with the positive predictive valuethe proportion of samples that belong to and are correctly placed in category c.
2. Youden's Index has traditionally been used to compare diagnostic abilities of two tests by evaluating the algorithm's ability to avoid failure. In dataset A, we evaluated the Youden's Index of the Artifact category. In dataset B, we calculated the Youden's Index of problematic heartbeats (Murmur and Extrasystole categories combined). Here we calculated the Discriminant power of problematic heartbeats (Murmur and Extrasystole categories combined). Where:

Results
In this section, we present the findings of all tested classifiers by specifying the optimal proprieties found for each classifier. Then, we move to compare between our results, on the one hand, and, on the other hand, between our results and the results previously published by finalists for the PASCAL challenge heart sound classification.

6.1
Results of challenge 1: The heart sound segmentation Results of the heart sound segmentation that is the first task of the PASCAL heart sound challenge were previously published by our team [25]. The following figure shows the results of the segmentation phase: The efficiency of the segmentation method was measured by comparing the total error of the S1 and S2 components localization. The following table summarizes the comparison we made to show the contribution of our method:

Results of challenge 2: heart sound classification
After the segmentation phase, we tried to increase the accuracy reached by the finalists of the PASCAL heart sound challenge classification using many classifiers. The classification phase was done on unlabeled samples and did not belong to the training datasets. The label result of each sample had to be assigned to the given evaluation sheet which automatically calculated the metrics. What follows is a presentation of the applied classifiers, the used classifier properties, and the results reached by each classifier. a) KNN classifier: We have firstly trained the KNN model by the detected properties after the optimization phase. The proprieties are: • Number of neighbors "k =7".
• Type of calculated distance between neighbors and sample to predict, Distance = Minkowski.
b) SVM classifier: For the support vector machine, experimentally we tried a lot of parameters, but we concluded that the nature of the data did not match this type of classifier because it is a two-classes classifier not a multi-classes classifier; however, MATLAB provides a function to train it as a multi-class model; it is "fitcecoc ()". And, we applied this function with default proprieties. c) Tree classifier: We used "fitctree ()" that is a predefined function in MATLAB. The tree classifier model used in the classification of the unlabeled samples was obtained by the optimal parameters. These parameters are fixed after an optimization phase where we trained the classifier with different parameters many times, and we kept the best result, which is: • AlgorithmForCategorical = Exact.
Naïve Bayes classifier: MATLAB permitted us to get a Naïve Bayes model by fitcnb (), a predefined function. The best result found was by the naïve Bayes classifier which we trained by the optimal parameters kept after an optimization phase. These parameters are:

Discussion
To judge our proposed algorithm and method in answering the PASCAL Classification Heart Sound Challenge, we did two types of comparison. The first comparison was between all the classifiers used in this paper-KNN, SVM, Tree, and Naïve Bayes. The second one aimed to prove that our algorithm using naïve Bayes classifier exceeded all the results previously published.

Comparison between used classifiers
To compare the successfulness of our classifiers, we had to refer to three parameters for test dataset_A: Also, for the test dataset B, we had to refer to three parameters:

Fig. 8. Classifiers comparison for DATASET_B
In our case, we can conclude from the column's representation that the naïve Bayes classifier exceeds all classifiers not only in the total precision parameter but also in almost all other parameters. So, the naïve Bayes classifier is the best, and it is the concurrent classifier for the finalists in the PASCAL Classification Heart Sound Challenge.

Comparison between published results
In the literature review section, we presented the work of three finalists of the PASCAL classification heart sound challenge. Also, we cited Chakir's work which exceeded the results of the finalists in test dataset A, but it was not the case with the test dataset B. The table below shows the comparison of all the cited studies with ours:

Conclusion
This paper aimed to answer the tasks of the PASCAL Classification Heart Sound Challenge, increasing the total precision to reach a good result. So, we started by a preprocessing phase for the heart sound. Then, we moved to a segmentation phase based on HSMM with logistic regression, trained by four parameters to define the signal envelope which allowed us to precisely detect the peaks.
Afterwards, according to the systolic & diastolic duration and the fact that the amplitude of S1 was greater than S2, we could locate the position of S1 and S2.
An extraction features phase began directly after S1 and S2 identification. We extracted 20 features, with which we trained our classifiers.
To predict the label for a new entry, we tested four types of classifiers -SVM, KNN, Tree, and Naive Bayes. Based on the findings achieved for both test datasets, the naive Bayes classifier proved to be the best.
To sum up, the comparisons we carried out with the results of previously published studies showed that our methodology using the naive Bayes classifier yielded better outcomes.