Document Type : Original Research


1 Department of Medical Physics and Biomedical Engineering, School of Medicine, Shiraz University of Medical Sciences, Shiraz, Iran

2 Ionizing and Non-ionizing Radiation Protection Research Center (INIRPRC), Shiraz University of Medical Sciences, Shiraz, Iran

3 School of Medicine, Shiraz University of Medical Sciences, Shiraz, Iran

4 Student Research Committee, Shiraz University of Medical Sciences, Shiraz, Iran

5 Novin Iran Specialized Clinic, Shiraz, Iran

6 Faculty of Electrical Engineering, Shiraz University of Technology, Shiraz, Iran

7 Shiraz Neuroscience Research Center, Shiraz University of Medical Sciences, Shiraz, Iran



Background: Phonocardiogram (PCG) signal provides valuable information for diagnosing heart diseases. However, its applications in quantitative analyses of heart function are limited because the interpretation of this signal is difficult. A key step in quantitative PCG is the identification of the first and second sounds (S1 and S2) in this signal.
Objective: This study aims to develop a hardware-software system for synchronized acquisition of two signals electrocardiogram (ECG) and PCG and to segment the recorded PCG signal via the information provided in the acquired ECG signal.
Material and Methods: In this analytical study, we developed a hardware-software system for real-time identification of the first and second heart sounds in the PCG signal. A portable device to capture synchronized ECG and PCG signals was developed. Wavelet de-noising technique was used to remove noise from the signal. Finally, by fusing the information provided by the ECG signal (R-peaks and T-end) into a hidden Markov model (HMM), the first and second heart sounds were identified in the PCG signal.
Results: ECG and PCG signals from 15 healthy adults were acquired and analyzed using the developed system. The average accuracy of the system in correctly detecting the heart sounds was 95.6% for S1 and 93.4% for S2.  
Conclusion: The presented system is cost-effective, user-friendly, and accurate in identifying S1 and S2 in PCG signals. Therefore, it might be effective in quantitative PCG and diagnosing heart diseases.



A phonocardiogram (PCG) is acquisition of acoustic waves caused by the mechanical activities of the heart, and reflect cardiovascular pathological conditions [ 1 ]. Segmentation of the PCG signal to identify the first (S1) and second (S2) heart sounds is a crucial step in automated analysis of the PCG signal and diagnosing heart disorders [ 2 ]. Classification of pathological murmurs requires accurate localization of different parts of the PCG signal [ 3 ]. PCG segmentation can also help to analyze the signal in detail, getting further information about each component, and assessing the presence or location of murmurs [ 4 ]. Overall, correct segmentation of heart sounds and extraction of S1 and S2 can lead to an automated system for diagnosing cardiac defects.

Several PCG segmentation methods have been developed. In general, these methods can be categorized into two groups. One group is solely based on PCG signal analysis and attempted to directly segment PCG signal. The second cluster augmented temporal relationships between electrocardiogram (ECG) signal and PCG signal to enhance the performance of the segmentation.

Liang et al. [ 5 ] segmented S1 and S2 by picking up the peaks of the heart sounds’ envelope. This algorithm utilized discrete wavelet analysis and reconstruction to generate intensity envelopes of general signal behavior and phonocardiogram signal details. Another study [ 6 ] proposed a PCG segmentation algorithm based on frequency-domain characteristics of heart sounds using a linear prediction method. Other similar studies also used wavelet transform to analyze heart sound signals [ 7 , 8 ]. In recent years, Markov models were employed for segmentation of heart sound signals. Ricke et al. [ 9 ] developed a technique to segment a heart sound signal into its components using hidden Markov models (HMMs) and Shannon energy. Lima and Barbosa [ 10 ] proposed a PCG-segmentation algorithm using wavelet transform and Markov hidden model. In another study, duration-dependent hidden Markov models were studied for segmentation of the heart sounds [ 11 ]. Convolutional neural networks were also used to segment the PCG signal [ 12 ]. In addition, researchers have proposed several methods using heuristic algorithms, S transform, Shannon energy, artificial neural networks, and dynamic clustering to segment the PCG signal [ 13 - 19 ].

Several methods utilized the information in the ECG signal to improve PCG segmentation. Malarvili et al. [ 20 ] used instantaneous energy of ECG to detect S1 and S2 in heart sound signals. Gamero and coworkers [ 21 ] used ECG signal as a reference and probabilistic models to segment PCG signal. Springer et al. [ 2 ] proposed a PCG segmentation method via a pseudo-Markov pseudonym model. Finally, Oliveira et al. [ 22 ] implemented a coupled hidden Markov model, where two HMMs cooperate to recreate the true state sequence. However, these methods did not use a dataset in which real ECG and PCG signals were recorded synchronously.

In this work, we addressed the identification of S1 and S2 in the PCG signal by integrating ECG signal information into the process of segmenting the PCG signal. A device was designed and developed to record these two signals synchronously. R-peaks and end-Ts on the ECG signal were used to segment the PCG signal using HMMs.

Material and Methods


For this analytical study, we recorded ECG and PCG signals for 15 healthy adults using the designed system. For ECG signals, lead II was acquired. The PCG signals were recorded in the pulmonic spot. A total of 1334 seconds (s) of synchronized ECG and PCG signals was recorded. An expert manually labeled the start and end of the desired events (S1 and S2 in PCG signals) in the test datasets. The results of this manual segmentation were considered as a gold standard and were used to test the performance of the system in correctly segmenting PCG signals.


An overview of the system designed to synchronously record ECG and PCG signals is shown in Figure 1. An electric microphone module (including a pre-amplifier) was used to detect the PCG signal. The output of the microphone is fed into two circuits, one for hearing the heart sound and the other for further analyses (e.g., segmentation) of the signal. The signal processed is band-pass filtered (40 Hz to 300 Hz). Thereafter, the signal is amplified by a high-gain amplifier (AD8232) and digitized using an analog-to-digital converter (ADC) embedded in the microcontroller. Isolation was achieved using an optocoupler.

Figure 1. Block diagram of the hardware system.

Analog to digital conversion was performed by a 32-bit microcontroller (STM32 family, ARM Cortex processor, part number STMf32F103RET6). The sampling rate was set to 4 kHz to minimize the time delay argument. The ADC unit converts analog data to a 12-bit digital number. The laptop’s USB port was isolated to eliminate 50 Hz noise.

This design has several advantages such as high speed, USB data transfer capability, high sampling rate, portability, low-cost construction, and simultaneous recording of ECG and PCG signals.


The software was objected to segment the PCG signal using the information in the ECG signal. The block diagram of the proposed algorithm is shown in Figure 2. As shown, the algorithm consists of three main steps: signal de-noising, ECG event detection, and PCG segmentation. These steps are discussed in detail in the following sub-sections.

Figure 2. Block diagram of the proposed segmentation algorithm.

1. Signal de-noising: We used wavelet-based noise removal [ 23 ] to improve the signal-to-noise ratio. The mother wavelet in wavelet decomposition was chosen based on the similarity of the signal and the mother wavelet. Three mother wavelet coiflet5, daubechie4, daubechie6 were examined. The daubechie6 mother wavelet provided the best results, thus it was used for further process of the signal.

2. ECG event detection: The positions of R-peak and T-end were identified via thresholding applied to the first derivative of the ECG signal [ 24 ]. The synchronized origin of the recorded ECG and PCG signals enabled us to directly relate events at the former to the latter.

3. PCG segmentation: The R-peak and T-end times detected in the previous step were used to identify S1 and S2 in PCG signals. We utilized HMMs for this purpose that were effective in such applications [ 2 ]. The recorded signals were divided into training and test sets. Each set is composed of a PCG and an ECG signal that both were simultaneously recorded from a patient. Cardiac electrophysiological events (R-peak and T-end) detected in the ECG signal were considered as a hidden chain of events in this model. PCG signal, on the other hand, is the observable chain and should be predicted by the model. PCG events in test set were identified by a cardiologist and considered as the gold standard to be used for evaluating the performance of the algorithm.


Figure 3 shows the original and de-noised ECG and PCG signals. As discussed above, noise reduction was conducted using daubechie6 mother wavelet in 6 level decomposition with soft thresholding. As shown, this step was effective and could significantly improve the signal-to-noise ratio.

Figure 3. Original and de-noised electrocardiogram (ECG) and phonocardiogram (PCG) signals.

The accuracy of the developed system in correctly detecting S1 and S2 is presented in Table 1. The results for both training and testing the algorithm were provided. Seven subsets (approximately 758 seconds) were used to train the model and five sunsets (around 576 seconds) were used to test the model. In summary, the accuracy in detecting each heart sound was obtained as 95.6% for S1 and 93.4% for S2.

Dataset Duration (sec) Accuracy with raw PCG Accuracy with de-noised PCG
S1 S2 S1 S2
Train1 105 78.0 69.1 85.2 84.4
Train2 98 81.2 79.7 88.2 86.4
Train3 123 91.4 89.9 98.8 96.8
Train4 120 93.2 91.2 99.0 89.9
Train5 110 83.1 80.1 97.5 94.4
Train6 105 88.6 86.2 92.1 89.9
Train7 97 92.3 91.0 98.5 95.2
Average ------ 86.8 83.9 94.2 91.0
Test1 99 89.7 87.6 95.4 93.9
Test2 130 97.6 82.5 98.9 94.8
Test3 132 84.2 80.5 90.2 89.7
Test4 114 91.5 89.9 96.2 93.9
Test5 101 93.5 90.3 97.3 94.7
Average ------ 91.3 86.2 95.6 93.4
PCG: Phonocardiogram
Table 1.Accuracy (%) of the developed phonocardiogram (PCG) segmentation system in correctly detecting S1 and S2.


In evaluating the algorithms developed for analyzing biomedical signals automatically, the gold standard is the results provided by the expert. Here, we followed the same strategy; the events S1 and S2 identified by a cardiologist were considered as the gold standard in evaluating the performance of the developed system.

Two important points should not be considered when the performance of our system is compared to that of the other algorithms. First, the databases of other methods were collected from highly reputable sources such as the PhysioNet database. Of course, the equipment and data acquisition process were more advanced and expensive compared to the equipment built in our work. As shown in Table 1, the quality of the recorded signals has a significant effect on the performance of the system. The accuracy for de-noised PCG signals was higher than that for the raw signals. Second, the database used in developing previous methods is more comprehensive and extensive because the data has been collected at large research centers over many years, as well as from different people, which in turn improves the evaluation parameters, including the accuracy of the algorithm.

In previous works, coupled hidden Markov model is used, which would be appreciated when one of the signals is noisy or unreliable. We used wavelet transform to de-noise the signals. The hidden semi-Markov model were also used for PCG segmentation and provided average F1 score of 95.6% [ 2 ]. However, the limitation of these studies is the availability of synchronized ECG and PCG signals. We resolved this issue by designing and developing a hardware system.

Our proposed method was less accurate in detecting S2 compared to S1 mainly because detecting the T-end is harder than detecting R-peak, detected using thresholding methods, while for detecting, the end of the T-wave thresholding must be applied to the first derivative, which is susceptible to noises. Another disadvantage with our study is using standard HMM for event classification and detection, which does not model the states’ duration. This issue can be resolved by applying duration-dependent HMMs. Nevertheless, the designed hardware system realized easy access to synchronized ECG and PCG signals, making it possible to obtain further databases for training other models. Besides, de-noising was efficiently performed using wavelet transform.

Heart sounds segmentation is a crucial step in the automatic analysis of the PCG signal [ 1 , 2 ]. Categorizing pathological murmurs in a PCG signal requires accurate detection of different parts of the signal [ 3 ]. PCG segmentation can help to analyze the signal in more detail, getting more information about each component and the presence or location of the murmur [ 4 ]. Labeled PCG signals can be used to train classifier models.

There are some limitations to this study. First, the performance of the developed method depends on de-noising. Second, the software system contains a 12-bit ADC unit for the ECG channel, while it usually should be 24-bit. This is a trade-off between cost and quality. Finally, due to limited resources, the database was relatively small. Nevertheless, as the developed hardware worked well, a large dataset can be acquired, particularly in pediatric cases. Our previous work showed that integrating PCG and ECG features can improve the accuracy of machine learning models in estimating the risk of myocardial infarction [ 25 ]. Future work can explore the features from S1 and S2 events (instead of the whole PCG signal) for this myocardial infarction prediction system.


We addressed segmentation of the PCG signal to identify S1 and S2 by integrating ECG signal information into the segmentation process. An instrument was designed and developed to record these two signals synchronously. The occurrence times of R-peaks and T-ends in ECG signals were used to segment PCG signals using HMMs. The performance of the system in correctly detecting S1 and S2 events is promising, with accuracy >93.4%. De-noising the signals could be effective in improving the performance of the system.

Authors’ Contribution

MM. Movahedi and H. Parsaei designed and directed the project, took the lead in writing the manuscript. Sh. Mousavian Dehkordi contributed to the design and implementation of the research; M. Shakerpour designed instrument and algorithms, performed almost all the experiments; wrote the first draft of the manuscript; Sh. Mousavi and A. Nori. All authors discussed the results and commented on the manuscript.

Ethical Approval

The procedures in this study were conducted in accordance with the ethical standards of the Ethics Committee of Human Experimentation of Shiraz University of Medical Sciences (IR.SUMS.REC.1398.807).

Informed Consent

Informed consent was obtained in for participation in the research.


This study was funded by Shiraz University of Medical Sciences under Grant number 98-01-01-19520 awarded to MM. Movahedi.

Conflict of Interest



  1. Rangayyan RM, Lehner RJ. Phonocardiogram signal analysis: a review. Crit Rev Biomed Eng. 1987; 15(3):211-36. PubMed
  2. Springer DB, Tarassenko L, Clifford GD. Logistic regression-HSMM-based heart sound segmentation. IEEE Trans Biomed Eng. 2016; 63(4):822-32. DOI | PubMed
  3. Leatham A. Auscultation of the Heart and Phonocardiography. Churchill London; 1975.
  4. Castro A, Vinhoza TT, Mattos SS, Coimbra MT. Heart sound segmentation of pediatric auscultations using wavelet analysis. Annu Int Conf IEEE Eng Med Biol Soc. 2013; 2013:3909-12. DOI | PubMed
  5. Huiying L, Sakari L, Iiro H. IEEE: Chicago, IL, USA; 1997. DOI
  6. Iwata A, Ishii N, Suzumura N, Ikegaya K. Algorithm for detecting the first and the second heart sounds by spectral tracking. Med Biol Eng Comput. 1980; 18(1):19-26. DOI | PubMed
  7. Omran S, Tayel M. IEEE: Hammamet, Tunisia; 2004. DOI
  8. Yamacli M, Dokur Z, Olmez T. IEEE: Istanbul, Turkey; 2008. DOI
  9. Ricke AD, Povinelli RJ, Johnson MT. IEEE: Lyon, France; 2005. DOI
  10. Lima CS, Barbosa D. Automatic segmentation of the second cardiac sound by using wavelets and hidden Markov models. Annu Int Conf IEEE Eng Med Biol Soc. 2008; 2008:334-7. DOI | PubMed
  11. Schmidt SE, Holst-Hansen C, Graff C, Toft E, Struijk JJ. Segmentation of heart sound recordings by a duration-dependent hidden Markov model. Physiol Meas. 2010; 31(4):513-29. DOI | PubMed
  12. Renna F, Oliveira J, Coimbra MT. IEEE: Rome, Italy; 2018. DOI
  13. Moukadem A, Dieterlen A, Hueber N, Brandt C. A robust heart sounds segmentation module based on S-transform. Biomedical Signal Process Control. 2013; 8(3):273-81. DOI
  14. Gupta CN, Palaniappan R, Swaminathan S, Krishnan SM. Neural network classification of homomorphic segmented heart sounds. Applied Soft Computing. 2007; 7(1):286-97. DOI
  15. Gavrovska A, Zajić G, Bogdanović V, Reljin I, Reljin B. Identification of S1 and S2 heart sound patterns based on fractal theory and shape context. Complexity. 2017; 2017:1-9. DOI
  16. Singh M, Cheema A. Heart sounds classification using feature extraction of phonocardiography signal. In J Comput Appl. 2013; 77(4):13-7. DOI
  17. Wang X, Li Y, Sun C, Liu C. IEEE: Tianjin, China; 2009. DOI
  18. Bassiouni M, Khalifa W, El Dahshan ES, Salam AB. IEEE: Cairo, Egypt; 2015. DOI
  19. Tang H, Li T, Qiu T, Park Y. Segmentation of heart sounds based on dynamic clustering. Biomedical Signal Processing and Control. 2012; 7(5):509-16. DOI
  20. Malarvili MB, Kamarulafizam I, Hussain S, Helmi D. IEEE: Thessaloniki, Greece; 2003. DOI
  21. Gamero LG, Watrous R. IEEE: Cancun, Mexico; 2003. DOI
  22. Oliveira J, Sousa C, Coimbra MT. IEEE: New Orleans, LA, USA; 2017. DOI
  23. Giron-Sierra JM. Digital Signal Processing with Matlab Examples. Springer: Singapore; 2017.
  24. Vázquez-Seisdedos CR, Neto JE, Reyes EJ, Klautau A, De Oliveira RC. New approach for T-wave end detection on electrocardiogram: Performance in noisy conditions. Biomed Eng Online. 2011; 10(1):1. Publisher Full Text | DOI | PubMed
  25. Zarrabi M, Parsaei H, Boostani R, Zare A, Dorfeshan Z, Zarrabi K, Kojuri J. A system for accurately predicting the risk of myocardial infarction using PCG, ECG and clinical features. Biomedical Engineering: Applications, Basis and Communications. 2017; 29(3):1750023. DOI