Accurate Localization of First and Second Heart Sounds via Template Matching in Forcecardiography Signals

Cardiac auscultation is an essential part of physical examination and plays a key role in the early diagnosis of many cardiovascular diseases. The analysis of phonocardiography (PCG) recordings is generally based on the recognition of the main heart sounds, i.e., S1 and S2, which is not a trivial task. This study proposes a method for an accurate recognition and localization of heart sounds in Forcecardiography (FCG) recordings. FCG is a novel technique able to measure subsonic vibrations and sounds via small force sensors placed onto a subject’s thorax, allowing continuous cardio-respiratory monitoring. In this study, a template-matching technique based on normalized cross-correlation was used to automatically recognize heart sounds in FCG signals recorded from six healthy subjects at rest. Distinct templates were manually selected from each FCG recording and used to separately localize S1 and S2 sounds, as well as S1–S2 pairs. A simultaneously recorded electrocardiography (ECG) trace was used for performance evaluation. The results show that the template matching approach proved capable of separately classifying S1 and S2 sounds in more than 96% of all heartbeats. Linear regression, correlation, and Bland–Altman analyses showed that inter-beat intervals were estimated with high accuracy. Indeed, the estimation error was confined within 10 ms, with negligible impact on heart rate estimation. Heart rate variability (HRV) indices were also computed and turned out to be almost comparable with those obtained from ECG. The preliminary yet encouraging results of this study suggest that the template matching approach based on normalized cross-correlation allows very accurate heart sounds localization and inter-beat intervals estimation.


Introduction
Cardiac auscultation, i.e., listening to heart sounds via a stethoscope, has long been practiced by physicians as an essential part of physical examination [1,2].Several pathological conditions, such as valvular stenosis or regurgitation, abnormalities in heart rhythm, or heart failure, may be detected via auscultation well before the appearance of any symptoms.For this reason, the assessment of the heart sounds plays a key role in the early diagnosis of many cardiovascular diseases (CVDs) [1][2][3][4].
The origin of the heart sounds has been identified in the motion of the heart valves, the contraction and relaxation of the cardiac muscle, pressure variations in the heart cavities, and the flow of blood through the heart and great vessels during the cardiac cycle.These events cause mechanical vibrations that are transmitted to the chest surface, where they can be heard.Generally, two physiological heart sounds can be auscultated from a healthy adult.They mainly capture the high-frequency and high-amplitude vibrations produced by the heart valves activity.Specifically, the first physiological heart sound, commonly referred to as "S1", is generated by the closure of the mitral and tricuspid valves and the subsequent opening of the semilunar valves at the onset of ventricular systole, while the second physiological heart sound, commonly referred to as "S2", is caused by the closure of the aortic and pulmonary valves at the onset of ventricular diastole [1][2][3][4][5][6].Most of the information content of S1 and S2 is found at frequencies lower than 150 Hz [3].Occasionally, additional heart sounds, due to low-pitch and low-intensity vibrations of cardiac structures, can be heard.The third heart sound (S3) is attributed to vibrations of the ventricular walls, which are produced by blood deceleration when the ventricles reach their limit of distensibility at the end of rapid filling.S3 is commonly auscultated in young people, but it could be a sign of different CVDs, such as heart failure, mitral stenosis, aortic regurgitation and more, above the age of 40 years.The fourth heart sound (S4) is caused by atrial contraction and blood flowing through the valvular orifice in late ventricular diastole.The presence of S4 is usually associated with a severe pathological condition, such as coronary artery disease, left ventricular hypertension, ischemic heart disease, etc. Apart from S1, S2, S3 and S4, other acoustic phenomena originating from blood flow turbulences, known as murmurs, can be auscultated.Pathological murmurs are very useful in detecting valvular dysfunctions, like stenoses and regurgitations [1][2][3][4][5][6].
Despite its great diagnostic capability, cardiac auscultation is a qualitative examination, which strongly depends on the hearing acuity and the expertise of the physician [1,3,4].To overcome these limitations, some techniques have been proposed that apply frequency shifts to heart sounds, in order to move their energy to a frequency band corresponding to superior human ear sensitivity [7][8][9].Phonocardiography (PCG) is the method of recording the heart sounds by means of electronic stethoscopes.This technique retrieves the diagnostic significance of cardiac auscultation while obviating the problem of the subjectivity related to the human hearing sense.PCG enables not only the amplification, digitization, storage, and visualization of the heart sounds, but also the recording of vibrations that cannot be perceived by the human ear.A more effective discrimination between physiological and pathological heart sounds, as well as between heart sounds and murmurs, can be accomplished through the visual inspection of PCG signals, and different types of murmurs can also be distinguished.In addition, information on the timing of the heart sounds with respect to the cardiac cycle, as well as measurements of their intensity, frequency, and duration, can be obtained from the analysis of PCG signals.The correlation between variations of these parameters and different pathological conditions could be used to provide a valuable aid in the diagnosis of many CVDs [2, 3,6,[10][11][12][13][14][15][16].A challenging task in PCG signals analysis is the localization of the heart sounds, especially S1 and S2.Because stethoscopes are sensitive to environmental noises and other sounds from the human body (e.g., respiratory sounds, lung sounds, rumbling of the stomach and intestine), denoising is strongly required to improve the accuracy of heart sounds localization [10,[17][18][19][20][21].Several techniques, such as short-time Fourier transform, fast Wavelet transform, tunable-Q Wavelet transform, and S transform, have been used to accomplish this task [17][18][19][20][21][22][23][24][25][26][27].Different approaches have been proposed in the literature for heart sounds localization.Most of these methods take advantage of simultaneous Electrocardiography (ECG) tracing as a reference signal.However, in the last two decades, research has focused on the development of automated algorithms that perform heart sounds localization without using any reference signal.These tools can be essentially categorized into envelogram-based methods and artificial intelligence-based methods [10,[17][18][19][20][21].Envelogram-based methods generally extract an envelope from the PCG signal by using a Shannon energy operator [24,28,29], a Hilbert transform [30][31][32], or a Teager-Kaiser energy operator [26], among others [33,34].A fixed or adaptive threshold is then applied to the envelope to locate the peaks, to therefore identify the boundaries of the signal chunks corresponding to heart sounds.However, the sole thresholding operation often fails to selectively detect peaks related to heart sounds.Nevertheless, the great part of the envelogram-based methods is unable to discriminate S1 and S2 [23,26,29,32], or they need to consider additional criteria such as the typical duration of systole and diastole, to distinguish them [22,24,28,31,33,34].
On the other hand, the artificial intelligence-based methods extract many time-domain, frequency-domain, or time-frequency-domain features from each PCG segment, which are then used to train a classification model.Several machine learning or deep learning algorithms, such as k-nearest neighbor, support vector machine, hidden Markov model, decision tree, k-means clustering, logistic regression, and neural networks, have been implemented to discriminate between S1, S2, S3, and S4 heart sounds, and also to distinguish heart sounds from murmurs [25,27,[35][36][37][38][39][40][41][42][43] and to recognize abnormal heart sounds [44,45].Although they achieve high classification performance, artificial intelligence-based methods are far more complex than envelogram-based algorithms in terms of computational burden and require the a priori knowledge of the heart sounds for labelling PCG segments and training a classifier.
Recently, Forcecardiography (FCG) has been introduced as a novel, non-invasive technique for cardio-respiratory monitoring [46][47][48][49].FCG records the local forces induced on the chest wall by the mechanical activity of the heart and lungs by means of piezoresistive and piezoelectric force sensors, which have also been used to record sphygmic waves [50].These sensors are equipped with dome-shaped mechanical couplers to ensure an efficient transmission of the force from human tissues to the sensors active area [46,47].The wide bandwidth of FCG sensors allows them to monitor respiration [48], infrasonic cardiac vibrations [46,49], and heart sounds, all simultaneously from a single contact point on the chest [47].This capability supports the accurate estimation of inter-breath and inter-beat intervals [46][47][48], as well as cardiac time intervals, such as the pre-ejection period and the left ventricular ejection time [51,52].The infrasonic cardiac vibrations captured using FCG can be divided in two components: a low-frequency component related to emptying and filling of heart chambers, and a high-frequency component, related to the opening and closure of heart valves, which also exhibits a very high similarity with accelerometric Seismocardiography (SCG) signals [46,47].The infrasonic FCG components have also been shown to be affected by respiration, which causes both amplitude modulations and morphology variations [48,52,53].In [47], a morphological comparison was carried out that confirmed the high similarity between PCG signals and the audible component of FCG signals, both in terms of morphology and acoustic impression.
All measurements and analyses related to events of the cardiac cycle require a fundamental task, i.e., the localization of heartbeats.In cardio-mechanical signals, such as PCG, SCG, and FCG, this task is usually performed with the support of a concurrent ECG tracing, which, however, poses a limitation to the standalone application of these cardiomechanical monitoring techniques.To address this issue, a template matching algorithm has been proposed for ECG-free heartbeat localization in cardio-mechanical signals [54,55].A template is selected from the analyzed signal to capture the typical heartbeat morphology and the algorithm evaluates the similarity between the template and the whole signal by calculating the normalized cross-correlation (NCC) function.A high similarity between the template and any signal chunk results in a local maximum of the NCC function, which is assumed as heartbeat marker.The template matching algorithm has been tested on SCG and Gyrocardiography signals from 29 healthy subjects and 100 patients with valvular pathologies.The high accuracy achieved in heartbeat localization, as well as the high correlation and negligible errors obtained in inter-beat intervals estimation, demonstrated that the template matching approach is a very simple, effective, and robust solution for continuous heart rate monitoring via a standalone cardio-mechanical approach.Moreover, the feasibility of heart rate variability (HRV) analysis on the inter-beat intervals obtained by using the ECG-free heartbeat localization method based on template matching was investigated [56].Many time-domain, frequency-domain, and non-linear HRV indices were computed from the time series of these inter-beat intervals and resulted in very close agreement with those provided by the reference ECG signals.
In this study, the template matching algorithm described above was applied to the HS-FCG signals of healthy subjects to investigate its suitability in localizing and discriminating physiological S1 and S2 heart sounds without using any reference tracing.Then, the temporal locations of S1 and S2 were considered for the estimation of inter-beat intervals.Finally, an HRV analysis was carried out on these intervals.Both the inter-beat intervals estimates and the HRV indices obtained using the proposed approach were compared with those provided using simultaneous ECG recordings.
The article is organized as follows: Section 2 summarizes the measurement setup and data collection procedure adopted for FCG signals acquisition in [47] and describes the proposed template matching approach and the methodology for performance evaluation; Section 3 describes the results of performance evaluation; Section 4 discusses the results and highlights the limitations of the study; Section 5 presents the conclusions of the study and suggests possible future developments.

Measurement Setup and Signal Acquisition
FCG signals acquired in a previous study [47] were considered in this work.Indeed, no measurements were carried out in this study, but a retrospective analysis was conducted instead.The FCG signals were acquired on six healthy subjects, during quiet breathing, by means of an FCG sensor placed on their chest.The FCG sensor was placed approximately on the point of maximal impulse [47,57] of each subject via medical adhesive tape and secured by means of a belt fastened around the thorax.The point of maximal impulse was localized by searching for the point where the FCG signal exhibited the highest amplitude around the fifth intercostal space on the midclavicular line.
ECG lead II tracings have also been acquired concurrently, by means of a multiparameter monitor (Welch-Allyn Propaq Encore model).In this study, such ECG signals were considered as a ground truth for the estimation of inter-beat intervals and HRV indices.The simultaneous acquisitions of FCG and ECG signals have been performed via a National Instruments NI-USB4431 DAQ board (National Instruments Corp., 11500 N Mopac Expwy, Austin, TX 78759-3504, USA) with 24-bit precision and a sampling rate of 10 kHz.

Signal Pre-Processing
As in [48,53,54], the respiratory component of the raw FCG sensor signal was first extracted via a Savitzky-Golay filter [58] with frame length approximately corresponding to a time interval of 1.5 s.The respiratory component was then subtracted from the raw FCG sensor signal to obtain the actual FCG signal (cardiac component).The heart sounds component was extracted via a fourth order zero-lag Butterworth band-pass filter with cut-off frequencies of 30-200 Hz, as shown in Figure 1.On the other hand, the ECG signal was first band-pass filtered in the 0.5-40 Hz frequency band via a fourth order zero-lag Butterworth filter.Then, notch filters were used to remove powerline interference and its higher harmonics.Finally, the well-known Pan and Tompkins algorithm [59] implemented in the "BioSigKit" MATLAB ® toolbox [60] was used to locate the R-peaks (see Figure 1).MATLAB ® R2018b (MathWorks, Inc., Natick, MA, USA) was used to perform all processing operations described in this study.

Template Matching Approach
A template-matching technique, previously applied on SCG [54] and Gyrocardi raphy [55] signals, was applied in this study to separately localize S1 and S2 heart soun in FCG recordings.The template matching approach consists of three steps, namely te plate selection, computation of the NCC function between the whole signal and the te plate previously selected, and the localization of the NCC local maxima.Such local m ima correspond to the temporal locations at which the signal exhibits the local high similarity with the selected template and are used as timings of the events to be localiz In this study, the template matching approach was used for two purposes, i.e., separat locating S1 and S2 heart sounds with two distinct templates and locating heartbeats using a single heartbeat template consisting of both heart sounds (S1-S2 pair).Furth details on the selection of such templates are provided in the following paragraph.

Templates Selection Criteria
First, templates were identified in each heart sounds recording to capture the typi heart sounds waveforms, which were regarded as a morphological reference.Indeed, t different templates were chosen to separately locate S1 and S2 sounds.In addition, a th template was selected, which included the S1-S2 pair belonging to a single heartbeat.
The templates were selected manually, according to the following criteria.The S1 a S2 templates enclosed all the oscillations of the sound and short tracts at the beginn and at the end of the sound.The S1-S2 template enclosed the S1 and S2 sounds, the int val in between, and short tracts at the beginning and at the end of the S1-S2 pair.Examp of selected templates are shown in Figures 2 and 3.

Template Matching Approach
A template-matching technique, previously applied on SCG [54] and Gyrocardiography [55] signals, was applied in this study to separately localize S1 and S2 heart sounds in FCG recordings.The template matching approach consists of three steps, namely template selection, computation of the NCC function between the whole signal and the template previously selected, and the localization of the NCC local maxima.Such local maxima correspond to the temporal locations at which the signal exhibits the local highest similarity with the selected template and are used as timings of the events to be localized.In this study, the template matching approach was used for two purposes, i.e., separately locating S1 and S2 heart sounds with two distinct templates and locating heartbeats by using a single heartbeat template consisting of both heart sounds (S1-S2 pair).Further details on the selection of such templates are provided in the following paragraph.

Templates Selection Criteria
First, templates were identified in each heart sounds recording to capture the typical heart sounds waveforms, which were regarded as a morphological reference.Indeed, two different templates were chosen to separately locate S1 and S2 sounds.In addition, a third template was selected, which included the S1-S2 pair belonging to a single heartbeat.
The templates were selected manually, according to the following criteria.The S1 and S2 templates enclosed all the oscillations of the sound and short tracts at the beginning and at the end of the sound.The S1-S2 template enclosed the S1 and S2 sounds, the interval in between, and short tracts at the beginning and at the end of the S1-S2 pair.Examples of selected templates are shown in Figures 2 and 3

Localization of Single Heart Sounds and Heartbeat Detection
The NCC function, as defined in [61][62][63], is considered as a similarity measure between the selected template and signal chunks.Local maxima of the NCC function correspond to signal chunks with the highest local similarity to the template and allow localizing the patterns of interest.The NCC local maxima were detected via the Matlab ® function findpeaks.The S1 and S2 templates were used separately to locate the S1 and S2 heart sounds, while the S1-S2 template was used to locate the whole heartbeats (i.e., S1-S2 pairs).Examples of the results obtained by using the S1, S2, and S1-S2 templates are shown, respectively, in Figure 4a-c.Three series of time markers were obtained, i.e., the timings of S1, S2, and S1-S2 pairs.
Sensors 2024, 24, x FOR PEER REVIEW 8 of

Localization of Single Heart Sounds and Heartbeat Detection
The NCC function, as defined in [61][62][63], is considered as a similarity measure b tween the selected template and signal chunks.Local maxima of the NCC function cor spond to signal chunks with the highest local similarity to the template and allow local ing the pa erns of interest.The NCC local maxima were detected via the Matlab ® functi findpeaks.The S1 and S2 templates were used separately to locate the S1 and S2 he sounds, while the S1-S2 template was used to locate the whole heartbeats (i.e., S1pairs).Examples of the results obtained by using the S1, S2, and S1-S2 templates a shown, respectively, in Figure 4a-c.Three series of time markers were obtained, i.e., t timings of S1, S2, and S1-S2 pairs.

Performance Analysis
The performances achieved by using the S1 and S2 templates were evaluated v quantitative analyses of their ability to correctly recognize the related events of intere and to accurately provide the timings of such events.The performances obtained by usi the S1-S2 template were also evaluated, since in previous studies on Seismocardiograp and Gyrocardiography signals it had been observed that be er results could be obtain in heartbeat localization by using templates comprising both systolic and diastolic vib tions.
For the analysis of recognition accuracy, true events (true positives, TPs), miss events (false negatives, FNs), and false events (false positives, FPs) were annotated each subject and for each template, as in [54,55].Then, sensitivity and positive predict value (PPV) were eventually computed, according to the following equations, to provi statistical evaluations of template matching performance: For the analysis of localization accuracy, inter-beat intervals were estimated sep rately from the series of S1 timings, S2 timings, and S1-S2 timings, as they all mark t presence of heartbeats.The higher the accuracy in estimation of inter-beat intervals, t higher the accuracy in the localization of S1, S2, and S1-S2 events.Inter-beat intervals we computed as time differences between couples of subsequent recognized events.Figur shows some examples of inter-beat intervals estimation from the timings of S1, S2, a S1-S2 pairs.These results were compared with those obtained using ECG (considered reference) via Passing-Bablok linear regression [64], correlation, and Bland-Altman an yses [65,66].To this end, the Matlab ® functions "Passing-and-Bablok-regression" [67] a .Please note that each NCC function was re-aligned according to the relative position of the absolute maximum within the selected template.In the case of the S1-S2 template selected from the HS-FCG signal of subject #4, the absolute maximum of the S1-S2 template coincided with the S1 peak, therefore, also the NCC peaks in panel (c) turned out to be aligned with the S1 peaks in the HS-FCG signal.

Performance Analysis
The performances achieved by using the S1 and S2 templates were evaluated via quantitative analyses of their ability to correctly recognize the related events of interest, and to accurately provide the timings of such events.The performances obtained by using the S1-S2 template were also evaluated, since in previous studies on Seismocardiography and Gyrocardiography signals it had been observed that better results could be obtained in heartbeat localization by using templates comprising both systolic and diastolic vibrations.
For the analysis of recognition accuracy, true events (true positives, TPs), missed events (false negatives, FNs), and false events (false positives, FPs) were annotated for each subject and for each template, as in [54,55].Then, sensitivity and positive predictive value (PPV) were eventually computed, according to the following equations, to provide statistical evaluations of template matching performance: For the analysis of localization accuracy, inter-beat intervals were estimated separately from the series of S1 timings, S2 timings, and S1-S2 timings, as they all mark the presence of heartbeats.The higher the accuracy in estimation of inter-beat intervals, the higher the accuracy in the localization of S1, S2, and S1-S2 events.Inter-beat intervals were computed as time differences between couples of subsequent recognized events.Figure 5 shows some examples of inter-beat intervals estimation from the timings of S1, S2, and S1-S2 pairs.These results were compared with those obtained using ECG (considered as reference) via Passing-Bablok linear regression [64], correlation, and Bland-Altman analyses [65,66].To this end, the Matlab ® functions "Passing-and-Bablok-regression" [67] and "bland-altmanand-correlation-plot" [68] were used.The inter-beat intervals related to missed and false events were removed from the analyses.
"bland-altman-and-correlation-plot" [68] were used.The inter-beat intervals related to missed and false events were removed from the analyses.

Heart Rate Variability Analysis
The heartbeats localization accuracy was further assessed by comparing several HRV indices estimated from the inter-beat intervals series (tachograms) computed from the timings of the S1-S2 pairs and those estimated from ECG.The inter-beat intervals related to missed and false events were included in this analysis.To this aim, the time-domain, frequency-domain, and non-linear HRV indices listed in Table 1 were computed, for each subject, via the well-known software "Kubios HRV Standard" [69][70][71][72].As in [56], the tachograms were analyzed to detect and correct possible artifacts by following the Kubios HRV guidelines [73].Linear regression, correlation, and Bland-Altman analyses were carried out to compare the HRV indices obtained from the S1-S2 pairs with those obtained from ECG.

Recognition and Localization Accuracy
Tables 2-4 summarize the results obtained in the recognition of S1 and S2 sounds, and S1-S2 pairs, respectively.In particular, each table outlines the number of events recognized via the template matching method, as well as the number of TPs, FPs, and FNs, and the number of inter-beat intervals considered.The number of inter-beat intervals included depended on the distribution of the missed detections (FN), particularly if there were isolated FNs or multiple subsequent FNs.A total of 1429 cardiac cycles were analyzed.The template matching approach achieved a sensitivity and PPV of 97.9% and 97.6% for S1 recognition, 96.6% and 95.2% for S2 recognition, 87.0% and 91.2% for S1-S2 pairs.
The results of regression, correlation, and Bland-Altman analyses of inter-beat intervals are reported in Tables 5 and 6 and depicted in Figures 6-8.The regression and correlation analyses reported almost unitary slopes and intercepts of about 1 ms, with Pearsons's r in excess of 0.999.The Bland-Altman analyses reported negligible biases (zero was comprised in the 95% confidence interval of the bias) for all templates, as well as limits of agreement (LoA) of ±9.2 ms for S1, ±7.6 ms for S2, and ±4 ms for S1-S2 pairs.

HRV Indices Extraction
Tables 7 and 8 outline the results of linear regression, correlation, and Bland-Altman analyses performed on HRV indices extracted from FCG and ECG signals.In particular, the results of linear regression and correlation analyses reported no statistically significant differences from unity for the slopes, no statistically significant differences from zero for the intercepts, and Pearson's correlation coefficients in excess of 0.8 for all HRV indices.The Passing-Bablok cusum test also confirmed the linearity between all HRV indices extracted from FCG and ECG signals (p > 0.1).The results of Bland-Altman analyses reported no statically significant bias on any of the HRV indexes (all the confidence intervals include zero).The HRV indices extracted from each subject are reported in Appendix A (Table A1).

HRV Indices Extraction
Tables 7 and 8 outline the results of linear regression, correlation, and Bland-Altman analyses performed on HRV indices extracted from FCG and ECG signals.In particular, the results of linear regression and correlation analyses reported no statistically significant differences from unity for the slopes, no statistically significant differences from zero for the intercepts, and Pearson's correlation coefficients in excess of 0.8 for all HRV indices.The Passing-Bablok cusum test also confirmed the linearity between all HRV indices extracted from FCG and ECG signals (p > 0.1).The results of Bland-Altman analyses reported no statically significant bias on any of the HRV indexes (all the confidence intervals include zero).The HRV indices extracted from each subject are reported in Appendix A (Table A1).

Discussion
This study proposes the use of the template-matching technique for accurate recognition of heart sounds.In particular, the effectiveness of this technique in separately recognizing S1 and S2 heart sounds was investigated.The template-matching technique has several advantages with respect to other approaches.The approaches based on energy or envelope operators can easily recognize the presence of heart sounds but are usually unable to distinguish between S1 and S2 sounds and are very sensitive to various sources of noise.Instead, the template matching based on normalized cross-correlation is able to recognize the waveform of a specific heart sound because it evaluates the morphological similarity, which also prevents other noises to be incorrectly recognized as heart sounds, regardless of their amplitude.On the other hand, machine learning techniques have a much higher computational load, as opposed to the template-matching technique, which could easily be implemented in real time on microcontrollers, paving the way for long-term patient monitoring applications.It is worth underlining that the proposed technique does not require a synchronously acquired ECG signal: it was only used here for performance evaluation.
The results of this preliminary study are exceptionally encouraging.In fact, the proposed approach proved capable of separately classifying S1 and S2 sounds in more than 96% of all heartbeats.Linear regression, correlation, and Bland-Altman analyses showed that the template matching method allowed the estimation of inter-beat intervals with high accuracy.Indeed, 95% of the estimation errors were confined within 10 ms, which corresponds to relative errors lower than 2% by considering heart rates between 50 and 120 bpm.Further statistical analyses showed that HRV indices were estimated with reasonable accuracy, by achieving mean absolute percentage errors within 8% for all time-domain and non-linear indices, apart from NN50 and pNN50.Higher errors, within 32%, were found for frequency-domain indices.
It is interesting to note that the best results were obtained by considering only the first sound S1.This can be explained by recalling that the second sound undergoes substantial morphological changes in relation to respiration (the well-known physiologic splitting of S2).

Limitations of the Study
The heart sounds recording considered in this study had been acquired in a quiet environment.The proposed algorithm needs to be further verified in the presence of relevant external noises in order to be adopted as a sound recognizer in applications of long monitoring of patients during the performance of their daily activities.
All the tests were carried out on a limited number of subjects sitting at rest.Studies on a larger cohort of subjects are undoubtedly needed for a proper assessment of this technique, also considering the circumstance that the subject may change posture and may freely move.In such cases, morphological variations of heart sounds might occur, which might make the template-matching technique less effective.However, a dynamic update of the template might be considered to overcome such possible drawbacks.
The cardiac sound recordings considered in this study had been acquired only from healthy subjects: it was not possible to verify the recognition of S1 and S2 sounds in conjunction with other heart sounds (i.e., S3 and S4) or murmurs, which are generally associated with pathologies.Therefore, further tests on pathological subjects are foreseen to thoroughly assess the accuracy of heart sounds recognition via template matching.

Conclusions
The template matching approach proposed for accurate localization of first and second heart sounds in FCG signals has shown great promise and it could be effective on heart sounds recorded via common electronic stethoscopes.Future studies could evaluate its performance on public databases of heart sounds.However, various electronic stethoscopes are known to suffer from a noticeable sensitivity to external noises, while FCG sensors are, in principle, less sensitive to external noises, being essentially contact microphones without a chest piece bell.
FCG sensors are small, lightweight, nonobstructive, and wearable, therefore they are particularly suitable for a long-term monitoring, which could lead to much more accurate and early diagnosis of various heart diseases [74][75][76][77].Furthermore, specific cardiac diseases manifest with pronounced S3 and S4 sounds and murmurs.Indeed, murmurs have a higher frequency content than S1 and S2 sounds, while S3 and S4 are low-pitched, low-intensity sounds, which may be difficult to perceive via auscultation, so that chest palpation, i.e., perception of inaudible vibrations, is also recommended.The very large bandwidth of FCG sensors make them very sensitive to both low (subsonic) and high frequency vibrations and sounds, and could greatly help in the detection of S3 and S4 sounds and murmurs.This could be the subject of future studies.

Figure 1 .
Figure 1.An excerpt of signals from subject #4: ECG (blue line) and heart sounds from FCG (bl line).Blue circles mark the locations of R-peaks in the ECG signal.

Figure 1 .
Figure 1.An excerpt of signals from subject #4: ECG (blue line) and heart sounds from FCG (black line).Blue circles mark the locations of R-peaks in the ECG signal. .

Figure 2 .
Figure 2. Examples of template selection.(a)The portion of the HS-FCG signal selected as a template of S1 sound is enclosed within the light green box, while the green dashed line marks the position of the absolute maximum within the S1 template; (b) the portion of the HS-FCG signal selected as a template of S2 sound is enclosed within the light red box, while the red dashed line marks the position of the absolute maximum within the S2 template; (c) the portion of the HS-FCG signal selected as a template of S1-S2 pair is enclosed within the light blue box, while the blue dashed line marks the position of the absolute maximum within the S1-S2 template.The positions of the absolute maxima within the templates were used to re-align the corresponding NCC functions.

Figure 2 .
Figure 2. Examples of template selection.(a)The portion of the HS-FCG signal selected as a template of S1 sound is enclosed within the light green box, while the green dashed line marks the position of the absolute maximum within the S1 template; (b) the portion of the HS-FCG signal selected as a template of S2 sound is enclosed within the light red box, while the red dashed line marks the position of the absolute maximum within the S2 template; (c) the portion of the HS-FCG signal selected as a template of S1-S2 pair is enclosed within the light blue box, while the blue dashed line marks the position of the absolute maximum within the S1-S2 template.The positions of the absolute maxima within the templates were used to re-align the corresponding NCC functions.

Figure 4 .
Figure 4. Examples of events localization via the template matching method in FCG signals of subject #4: (a) S1 sounds localization: heart sounds signal (black line), NCC function computed by using the S1 template (green line), NCC peaks indicating temporal locations of S1 sounds (red points); (b) S2 sounds localization: heart sounds signal (black line), NCC function computed by using the S2 template (orange line), NCC peaks indicating temporal locations of S2 sounds (violet points); (c) S1-S2 pairs localization: heart sounds signal (black line), NCC function computed by using the S1-S2 template (red line), NCC peaks indicating temporal locations of S1-S2 pairs (black points).Please note that each NCC function was re-aligned according to the relative position of the absolute maximum within the selected template.In the case of the S1-S2 template selected from the HS-FCG signal of subject #4, the absolute maximum of the S1-S2 template coincided with the S1 peak, therefore, also the NCC peaks in panel (c) turned out to be aligned with the S1 peaks in the HS-FCG signal.

Figure 5 .Figure 5 .
Figure 5. Examples of inter-beat intervals estimation in signals of subject #4.Inter-beat intervals were estimated in the ECG signal as the temporal difference between two consecutive R-peaks (double black arrow), and in the heart sounds signals as the temporal difference between two consecutive peaks in the NCC function obtained via: (a) S1 template (double purple arrow); (b) S2 template (double red arrow); (c) S1-S2 template (double green arrow).

Figure 6 .Figure 7 .
Figure 6.Results of statistical analyses on inter-beat intervals obtained from S1 sounds and from ECG: (a) Regression and correlation plot (regression line is depicted in red); (b) Bland-Altman plot.

Figure 6 .Figure 6 .Figure 7 .
Figure 6.Results of statistical analyses on inter-beat intervals obtained from S1 sounds and from ECG: (a) Regression and correlation plot (regression line is depicted in red); (b) Bland-Altman plot.(a)(b) Figure 6.Results of statistical analyses on inter-beat intervals obtained from S1 sounds and from ECG: (a) Regression and correlation plot (regression line is depicted in red); (b) Bland-Altman plot.

Figure 7 .Figure 8 .
Figure 7. Results of statistical analyses on inter-beat intervals obtained from S2 sounds and from ECG: (a) Regression and correlation plot (regression line is depicted in red); (b) Bland-Altman plot.Figure 7. Results of statistical analyses on inter-beat intervals obtained from S2 sounds and from ECG: (a) Regression and correlation plot (regression line is depicted in red); (b) Bland-Altman plot.

Figure 8 .
Figure 8. Results of statistical analyses on inter-beat intervals obtained from S1-S2 pairs and from ECG: (a) Regression and correlation plot (regression line is depicted in red); (b) Bland-Altman plot.

Table 1 .
Time-domain, frequency-domain, and non-linear HRV indices considered in this study.

Table 2 .
Result of S1 sounds detection for each subject.The numbers of TPs, FNs, and FPs are reported.The numbers of inter-beat intervals considered in subsequent analyses are also reported.

Table 3 .
Result of S2 sounds detection for each subject.The numbers of TPs, FNs, and FPs are reported.The numbers of inter-beat intervals considered in subsequent analyses are also reported.

Table 4 .
Result of S1-S2 pairs detection for each subject.The numbers of TPs, FNs, and FPs are reported.The numbers of inter-beat intervals considered in subsequent analyses are also reported.

Table 5 .
Results of linear regression and correlation analyses on inter-beat intervals obtained from heart sounds with S1, S2, and S1-S2 pairs, as compared to those obtained from ECG.

Table 6 .
Results of Bland-Altman analyses on inter-beat intervals obtained from heart sounds with S1, S2, and S1-S2 pairs, as compared to those obtained from ECG.

Table 7 .
Results of regression and correlation analyses performed on HRV indices obtained from heart sounds and ECG.

Table 7 .
Results of regression and correlation analyses performed on HRV indices obtained from heart sounds and ECG.

Table 8 .
Results of Bland-Altman analyses performed on HRV indices obtained from heart sounds and ECG.In cases of measurement differences with non-normal distribution, the bias was estimated as the median of differences, and the limits of agreement as the 2.5th and 97.5th percentiles.