The proposed method distinguishes HS element from non HS element based on the principle that heart sound component has higher area than that of the non heart sound component. A flow chart of the proposed method is given in Figure1. The entire process is comprised of the following steps:

### Amplitude normalization

The amplitude of the mixed signal varies considerably due to various factors such as recording instrument gain, different recording locations over the anterior and posterior chest, physiology, age and sex of the subject. The amplitude variation creates a difficulty during analysis of different signals of non-uniform amplitude. This problem is minimized by setting the maximum value of variance of the signal to +1 and minimum to -1. Let *y*(*n*) be the signal value at *nth* sample, and *M* be the absolute maxima in the sample space. The normalized signal *y*
_{
norm
}(*n*) is given by

{y}_{\mathit{\text{norm}}}(n)=\frac{y(n)}{G}

(9)

G=\underset{i}{\text{max}}\left(\left|y(i)\right|\right)

(10)

Here *n* = 1,2,3,…, *K* and *K* is the total number of samples in the signal.

#### Filtering

The intensity and frequency components of the pulmonary sound change according to the variation in flow rate. The amplitude of the lung sound increases with an increase in respiratory flow (Yadollahi and Moussavi2006). Hence, HS may become invisible for medium and high flow rates. It is very difficult to localize the HS segments for high flow than medium and low flow cases. In this study, the flow rate effect is minimized by filtering the mixed lung sound signals using a 10*t* *h* order Butterworth finite impulse response (FIR) filter with a cutoff frequency of 150 Hz. The filtering operation enhances the HS components by attenuating the higher frequency LS and murmur components as shown in Figure2. The filtered sound is used as input to the next step to detect the HS segments.

#### Hilbert Envelope Extraction

The envelope curve gives a simple and demonstrable representation of a narrow band signal to investigate its intrinsic characteristics (Choi and Jiang2008). The envelope of a signal can be computed by different techniques like Hilbert transform and Shannon energy based approach. In this study, we have chosen HT to compute envelope of HS dominated filtered mixed sound signal because of two reasons. Firstly, Shannon energy based envelope detection algorithm performs well for medium intensity signal and it gives poor result for high and low intensity signal (Choi and Jiang2008; Ari and Saha2007). Secondly, the computational complexity of Shannon envelope is much greater than that of the Hilbert envelope because Shannon method takes into considerations the windowing and overlapping processes (Choi and Jiang2008; Ari and Saha2007). We have experimentally observed that HT takes only 0.02 sec for calculating the Hilbert envelope and Shannon energy based method takes 3.97 sec for computing the Shannon envelope for the same signal of length 40313 samples. As lung sound shows a wide band spectrum and heart sound gives a narrow band spectrum, the Hilbert transform facilitates to detect the heart sound elements in lung sound signals in spite of their spectral overlap. Hilbert envelope can trace the variation of heart sound components in lung sound as a periodic train. The Hilbert envelope is computed based on Hilbert Transform as described in Section "Theoretical background on Hilbert transform and Heron’s formula". Let *x*
_{
nf
}(*n*) be the normalized, filtered mixed signal. The complex analytic signal *A*[*x*
_{
nf
}(*n*)] of the given signal *x*
_{
nf
}(*n*) is expressed as

A[{x}_{\mathit{\text{nf}}}(n)]={x}_{\mathit{\text{nf}}}(n)+{\mathit{\text{jH}}}_{d}\{{x}_{\mathit{\text{nf}}}(n)\}

(11)

The envelope curve *E*
_{
H
}(*n*) of the given signal *x*
_{
nf
}(*n*) can be computed from the magnitude of the analytic signal *A*[*x*
_{
nf
}(*n*)], and is expressed as

{E}_{H}(n)=\sqrt{{x}_{\mathit{\text{nf}}}{(n)}^{2}+{H}_{d}{\{{x}_{\mathit{\text{nf}}}(n)\}}^{2}}

(12)

The phase *ϕ*(*n*) information of the analytic signal *A*[*x*
_{
nf
}(*n*)] is determined by the following equation

\varphi (n)=\mathit{\text{arctan}}[\frac{{H}_{d}\{{x}_{\mathit{\text{nf}}}(n)}{{x}_{\mathit{\text{nf}}}(n)}]

(13)

#### Peak Detection in the Envelope

The Hilbert envelope curve *E*
_{
H
}(*n*) is estimated from the filtered mixed signal using equation (12) and is shown in Figure1(c). The envelope signal consists of many peaks which are originated from the HS components and from the low frequency LS components of the filtered mixed signal as shown in Figure1(b). Each peak of the envelope curve *E*
_{
H
}(*n*) has a rising and a falling edges, respectively. The rising edge gives the positive gradient values and falling edge gives negative gradient values at each point over the envelope. These peaks are detected through the following steps:

Step 1: Smoothening of the envelope: The Hilbert envelope *E*
_{
H
}(*n*) of the signal is not smooth because of the presence of lung sound components. Hence, it is required to smoothen for more accurate peak detection which is associated with HS. To accomplish this, a filtering operation is done using a 5*t* *h* order Butterworth FIR filter with a cutoff frequency varying in a range of 7-25 Hz. We discuss the effect of variation in cut-off frequency in Section "Results and discussion".

Step 2: Identification of local maxima and minima: The extreme points of the envelope signal can be calculated by considering the sign changes across the first derivative of the envelope. A sample value *E*
_{
H
}(*i*) of the smoothed envelope curve will be a minimum valued point for\frac{d({E}_{H}(n))}{\mathit{\text{dn}}}{\mid}_{n=i}=0\parallel \frac{d({E}_{H}(n-1))}{\mathit{\text{dn}}}{\mid}_{n=i}<0\parallel \frac{d({E}_{H}(n+1))}{\mathit{\text{dn}}}{\mid}_{n=i}>0 and will be a maximum valued point for\frac{d({E}_{H}(n))}{\mathit{\text{dn}}}{\mid}_{n=i}=0\parallel \frac{d({E}_{H}(n-1))}{\mathit{\text{dn}}}{\mid}_{n=i}>0\parallel \frac{d({E}_{H}(n+1))}{\mathit{\text{dn}}}{\mid}_{n=i}<0.

Step 3: Estimation of peaks: A peak consists of three consecutive extrema points which include two minima and one maximum. Each peak has a finite extension from one minimum point to another as shown in Figure1(d). The duration of the individual peak varies according to its source characteristics. The peak locations are identified by calculating their extreme points and marked with a white arrow head in Figure1(d).

#### Picking up the S1, S2, S3 and S4 peaks

The peaks detected using the above described peak detection framework do not always correspond to heart sound components. Some peaks occur due to the presence of artifacts and unfiltered lung sound components. The non-heart sound peaks are rejected and the heart sound peaks are selected using a geometrical formula derived by Greek mathematician Heron.

Selection criteria of S1, S2, S3 and S4 peaks: The area of individual peak is calculated using Heron’s triangular formula. The triangles are formed by connecting the extreme points of the peaks. Let us consider the minima and maximum points for *ith* peak are{L}_{\mathit{\text{min}}1}^{i},{L}_{\mathit{\text{min}}2}^{i}, and{L}_{\mathit{\text{max}}}^{i}, respectively. The length of each side of the triangle associated with *ith* peak are calculated as follows:

\begin{array}{l}\left|{a}^{i}\right|=\sqrt{{[{E}_{H}({L}_{max}^{i})-{E}_{H}({L}_{min1}^{i})]}^{2}}\\ \left|{b}^{i}\right|=\sqrt{{[{E}_{H}({L}_{max}^{i})-{E}_{H}({L}_{min2}^{i})]}^{2}}\\ \left|{c}^{i}\right|=\sqrt{{[{E}_{H}({L}_{min2}^{i})-{E}_{H}({L}_{min1}^{i})]}^{2}}\end{array}

(14)

where *c*
^{i} is the base, *a*
^{i} is the left lateral side and *b*
^{i} is the right lateral side of the triangle. The three angles of the triangle are defined by the following equation

\begin{array}{l}{\alpha}^{i}={\angle a}^{i}{c}^{i}=arccos\left(\frac{{({a}^{i})}^{2}+{({c}^{i})}^{2}-{({b}^{i})}^{2}}{{2a}^{i}{c}^{i}}\right)\\ {\beta}^{i}={\angle b}^{i}{c}^{i}=arccos\left(\frac{{({b}^{i})}^{2}+{({c}^{i})}^{2}-{({a}^{i})}^{2}}{{2b}^{i}{c}^{i}}\right)\\ {\gamma}^{i}={\angle a}^{i}{b}^{i}=arccos\left(\frac{{({a}^{i})}^{2}+{({b}^{i})}^{2}-{({c}^{i})}^{2}}{{2a}^{i}{b}^{i}}\right)\end{array}

(15)

where *α*
^{i}, *β*
^{i} and *γ*
^{i} are the angles between the three sides. The lengths of the three sides of the triangle are unequal in magnitude and the angles in between them are also unequal in degree. Hence this triangle satisfies the criterion of scalene triangle. The area △^{i} of the *ith* triangle is calculated as

{\u25b3}^{i}=\sqrt{{S}^{i}({S}^{i}-{a}^{i})({S}^{i}-{b}^{i})({S}^{i}-{c}^{i})}

(16)

{S}^{i}=\frac{{a}^{i}+{b}^{i}+{c}^{i}}{2}

(17)

\mathrm{\Gamma}=\sum _{j=1}^{P}{L}_{\mathit{\text{min}}}^{j}+\sum _{j=1}^{Q}{L}_{\mathit{\text{max}}}^{j}

(18)

where *i* indicates the number of triangle and lies in the range defined by 1 ≦ *i* ≦ Γ-2 × *Q*, *P* and *Q* are the total number of minima and maximum points in the envelope, respectively. The area of heart sound components is higher than that of the artifacts or low frequency lung sound components because heart sound components have a high peak amplitudes as shown in Figure1(b). The heart sound components S1, S2, S3 and S4 are identified by comparing the area of the peak with an adaptive threshold value that is calculated from the variance *σ* of the area vector **A** = [*A*
_{1}, *A*
_{2}, *A*
_{3},…, *A*
_{
Q
}]^{T}, where *A*
_{
r
}(*r* = 1,2,…, *Q*) indicates the area of individual peak in corrupted LS. The heart sound peaks *P*
_{
HS
} are selected using the Algorithm 1.

**Algorithm 1** Calculate *P*
_{
HS
}

#### Boundary estimation of S1, S2, S3 and S4 peaks

The primary HS components (S1 and S2) extend on both sides of its peak position as shown in Figure1(e) for a finite length due to the time gap between the closures and openings of the heart valves (Pourazad2004) but the third (S3) and fourth (S4) HS components extend due to the relaxation of the ventricle and atrium heart chambers (Webster1998; Balasubramaniam and Nedumaran2010). To estimate the HS boundary, peak location identification is needed. The peak locations are detected using Algorithm 1, and after that their boundary *B*
_{
HP
} are calculated by using Algorithm 2.

**Algorithm 2** Calculate *B*
_{
HP
}