Ibrahim Sadek
email: ibrahim.sadek@usherbrooke.ca

Bessam Abdulrazak

A comparison of three heart rate detection algorithms over ballistocardiogram signals

Keywords: Ballistocardiography, Mobile health, Homecare, Heart rate, Wavelet transform, Template matching

Heart rate (HR) detection from ballistocardiogram (BCG) signals is challenging because the signal morphology can vary between and within-subjects. Also, it differs from one sensor to another. Hence, it is essential to evaluate HR detection algorithms across several datasets and under different experimental setups. In this paper, we studied the potential of three HR detection algorithms across four independent BCG datasets. The three algorithms are as follows: the multiresolution analysis of the maximal overlap discrete wavelet transform (MODWT-MRA), continuous wavelet transform (CWT), and template matching (TM). The four datasets were obtained using a microbend fiber optic sensor, a fiber Bragg grating sensor, electromechanical films, and load cells, respectively.

The datasets were gathered from: a) 10 patients during a polysomnography study, b) 50 subjects in a sitting position, c) 10 subjects in a sleeping position, and d) 40 subjects in a sleeping position. Overall, CWT with derivative of Gaussian provided superior results compared with the MODWT-MRA, CWT (frequency B-spline), and CWT (Shannon). That said, a BCG template was constructed from DataSet1. Then, it was used for HR detection in the other datasets. The TM method achieved satisfactory results for DataSet2 and DataSet3, but it did not detect the HR of two subjects in DataSet4. The proposed methods were implemented on a Raspberry Pi. As a result, the average time required to analyze a 30-second BCG signal was less than one second for all methods. Yet, the MODWT-MRA had the highest performance with an average time of 0.04 seconds.

Introduction

Remote monitoring of vital signs, i.e., body temperature, heart rate (HR) [START_REF] Sohail | An ECG Processor for the Detection of Eight Cardiac Arrhythmias with Minimum False Alarms[END_REF], blood oxygen saturation [START_REF] Saadeh | A 0.5V PPG-based Heart Rate and Variability Detection System[END_REF], respiratory rate (RR), and blood pressure, has attracted public health attention due to rapidly emerging infectious diseases, e.g., coronavirus disease [START_REF] Negishi | Contactless vital signs measurement system using RGB-thermal image sensors and its clinical screening test on patients with seasonal influenza[END_REF]. Besides, changes in vital signs are critical in assessing the severity and prognosis of epidemic diseases. Specifically, these changes are significant signs of deteriorating patient health and thus present an opportunity for early detection and intervention. In hospital practice, nursing staff, and doctors rely on intermittent vital signs, usually measured every 8-hour shift. Hence, early deterioration indicators could be overlooked, particularly at night, when deterioration could progress undetected until the next morning [START_REF] Breteler | Vital signs monitoring with wearable sensors in high-risk surgical patients a clinical validation study[END_REF].

Bed-embedded ballistocardiogram (BCG) sensors have presented encouraging results for detecting particular vital signs, namely HR and RR [START_REF] Sadek | Ballistocardiogram signal processing: a review[END_REF][START_REF] Penzel | Alternative algorithms and devices in sleep apnoea diagnosis[END_REF].

Additionally, these sensors have been implemented for diagnosing severe sleep disorders, specifically sleep apnea [START_REF] Sadek | A New Approach for Detecting Sleep Apnea Using a Contactless Bed Sensor: Comparison Study[END_REF][START_REF] Cimr | Automatic detection of breathing disorder from ballistocardiography signals[END_REF][START_REF] Cimr | Computer aided detection of breathing disorder from ballistocardiography signal using convolutional neural network[END_REF]. BCG-based sensors can be used for remote monitoring of vital signs [START_REF] Hossein | Accurate Detection of Dobutamine-induced Haemodynamic Changes by Kino-Cardiography: A Randomised Double-Blind Placebo-Controlled Validation Study[END_REF]. However, they do not support continuous monitoring. In contrast, wearable sensors such as actigraphs can support this function [START_REF] Mondal | Wearable Sensing Devices for Point of Care Diagnostics[END_REF]. Still, they can introduce various challenges, especially for vulnerable populations with behavioral symptoms. For example, if the sensor is not waterproof, it has to be taken off before showering. Moreover, if the sensor has a short battery life, it needs to be taken off frequently for charging. These situations will inevitably cause inconvenience to patients and likewise disrupt the data collection [START_REF] Ye | Challenges in Collecting Big Data in A Clinical Environment with Vulnerable Population: Lessons Learned from A Study Using A Multi-modal Sensors Platform[END_REF]. The choice between wearable and non-wearable sensors should be made to cope with each patient group's medical conditions. There will always be a compromise between the continuity of data and patient convenience. Although BCG sensors can help alleviate some shortcomings of wearable sensors, they are highly prone to motion artifacts, e.g., body movements. Furthermore, they can only be practical for observing patients in a single bed setting. That is to say, these sensors are not designed to deliver spot readings for substituting nurse observations. However, they are intended for monitoring trends in vital signs, taking into account their capacity to collect longitudinal data [START_REF] Breteler | Vital signs monitoring with wearable sensors in high-risk surgical patients a clinical validation study[END_REF]. Various signal processing and machine learning algorithms have been suggested to scrutinize BCG signals, considering the multiple factors that affect the signal quality. The goal of these algorithms is to automatically identify the "J" peak of the "I-J-K" complex [START_REF] Sadek | Ballistocardiogram signal processing: a review[END_REF]. Under controlled conditions, if the subject sleeps on the bed without movement, this peak can be detected using a classical peak detector. Nonetheless, this is not conceivable in real-life scenarios. The sensor location is another element that can largely affect the signal quality. Ideally, the closer the sensor is to the chest and abdomen region, the better the signal quality. Hence, the sensor's desired location is under the upper part of the body, in which it can be placed under the bed sheet or the mattress. In real-life scenarios, we cannot predict subjects' sleep positions, and thus, unless the bed is covered entirely by pressure sensors, the signal quality can be highly degraded. Still, this arrangement will increase the deployment's cost. Furthermore, the BCG signal morphology can vary from one sensor to another and between and within patients. These restrictions should always be considered when a system is designed for analyzing BCG signals [START_REF] Wiens | Toward Continuous, Noninvasive Assessment of Ventricular Function and Hemodynamics: Wearable Ballistocardiography[END_REF][START_REF] Albukhari | Bed-embedded heart and respiration rates detection by longitudinal ballistocardiography and pattern recognition[END_REF]. Fast Fourier transform (FFT), Hilbert transform, template matching, autocorrelation, cepstrum, wavelet transform, and empirical mode decomposition, among others, have been implemented for automatic HR detection from BCG signals [START_REF] Sadek | Ballistocardiogram signal processing: a review[END_REF][START_REF] Suliman | Performance Comparison for Ballistocardiogram Peak Detection Methods[END_REF][START_REF] Sadek | Nonintrusive heart rate measurement using ballistocardiogram signals: a comparative study[END_REF].

Moreover, convolutional neural networks (CNNs) have been employed to segment the "I-J-K" complexes and detect HR in BCG signals [START_REF] Lu | A Novel Deep Learning based Neural Network for Heartbeat Detection in Ballistocardiograph[END_REF][START_REF] Cathelain | U-Net Neural Network for Heartbeat Detection in Ballistocardiography[END_REF][START_REF] Chen | Ballistocardiography monitoring system based on optical fiber interferometer aided with heartbeat segmentation algorithm[END_REF]. Although CNNs yielded satisfactory results, the training was performed in a controlled setting with a small sample size, including only healthy individuals. Besides, BCG signals were recorded over a short time, i.e., 35 seconds [START_REF] Cathelain | U-Net Neural Network for Heartbeat Detection in Ballistocardiography[END_REF]. Wavelet analysis, in particular, has proved to be a useful tool in analyzing BCG signals because of its ability to handle nonlinear and nonstationary physiological signals [START_REF] Suliman | Performance Comparison for Ballistocardiogram Peak Detection Methods[END_REF][START_REF] Sadek | Nonintrusive heart rate measurement using ballistocardiogram signals: a comparative study[END_REF].

To our knowledge, most of the proposed approaches were not evaluated across different datasets or under experimental setups. In other words, the generalization of one method across different datasets or settings is not yet feasible. This problem occurs because BCG signals are not benchmarked as is the case with electrocardiogram signals. As a result, proposed methods are mainly applied to proprietary data.

To this end, this research aims to compare three HR detection algorithms across four independent BCG datasets.

These algorithms include the Maximal Overlap Discrete Wavelet Transform (MODWT), Continuous Wavelet Transform (CWT), and Template Matching (TM). The objective of this comparative study is to examine the efficacy of each method across the various datasets and under different experimental setups. Also, we evaluate whether a BCG template from one dataset can be used to detect HR in the other datasets. The rest of the paper is structured as follows. Section 2 discusses related approaches that use wavelet transform or template matching for HR detection from BCG signals. Section 3 describes the experimental setup and data collection protocols. Also, it outlines the principles of the three proposed methods. Findings and contributions made are presented in Section 4. The technical implementation is discussed in Section 5. Finally, the paper is concluded in Section 6.

Related Work

The wavelet transform (WT) aims at decomposing the signal into smooth and detail components. Thus, the component (or the sum of multiple components), including the most similar pulse-like peaks, can be adopted to locate the J-peaks of the BCG signal.

Zhu et al. [START_REF] Zhu | Accurate Determination of Respiratory Rhythm and Pulse Rate Using an Under-Pillow Sensor Based on Wavelet Transformation[END_REF][START_REF] Zhu | Real-Time Monitoring of Respiration Rhythm and Pulse Rate During Sleep[END_REF] applied the "à trous" WT to raw sensor data acquired via a liquid pressure sensor under a pillow.

The signals were gathered from 13 healthy subjects during sleep for about two hours. Motion artifacts caused by head and body movements were reduced by a threshold method using the raw signals' standard deviation (SD).

The "Cohen-Daubechies-Feauveau" 9/7 (CDF 9/7) biorthogonal wavelet was selected for designing the decomposition and reconstruction filters. The 4 th and 5 th detail components were realigned in the signal phases, and their amplitudes were summed to estimate the BCG signal. Finally, J-peaks were detected using a modified Pan-Tompkins algorithm [START_REF] Pan | A real-time QRS detection algorithm[END_REF] after noise reduction with a soft threshold method.

Jin et al. [START_REF] Jin | A novel heart rate detection algorithm in ballistocardiogram based on wavelet transform[END_REF] employed a translation-invariant WT based on adaptive threshold wavelet shrinkage for signal denoising. The Symlet wavelet of order 8 (sym8) was adopted for detecting cardiac cycles because it was closer in shape to the BCG signal. The signal was collected from a healthy subject but there was no information on the data acquisition process. Then, J-peaks were detected using a pseudo-period detection approach that can locate the signal's largest swings [START_REF] Smrcka | New methods for precise detection of systolic complexes in the signal acquired from quantitative seismocardiograph[END_REF]. Postolache et al. [START_REF] Postolache | Physiological Parameters Measurement Based on Wheelchair Embedded Sensors and Advanced Signal Processing[END_REF] designed a framework for measuring HR from two EMFi sensors embedded in the seat and backrest of a wheelchair. BCG signals were gathered from eight subjects seated in the chair over 15 minutes. At first, signals were denoised using discrete stationary WT combined with a soft threshold method. Secondly, the denoised signals were decomposed via a discrete WT-Daubechies (db5) wavelet function.

In addition, the cardiac signal was reconstructed by summing the 8 th , 9 th , and 10 th detail components. At last, a time-domain peak detection algorithm was used to detect J-peaks. A similar approach was introduced by Pino et al. [START_REF] Pino | Noninvasive ambulatory measurement system of cardiac activity[END_REF], in which BCG signals were acquired via two EMFi sensors embedded in the seat and backrest of a typical chair. Raw sensor data were collected from 19 subjects in a laboratory for over 1 minute and 35 subjects in a hospital waiting area for over 2 minutes. Daubechies (db6) wavelet function was used for the decomposition, and the cardiac signal was reconstructed by summing the 4 th to 7 th detail components. J-peaks were detected using a customized peak detector algorithm.

Gilaberte et al. [START_REF] Gilaberte | Heart and respiratory rate detection on a bathroom scale based on the ballistocardiogram and the continuous wavelet transform[END_REF] proposed to use CWT to detect HR from subjects standing on a bathroom scale. Six subjects participated in the study, and data were recorded over ten seconds in different days and conditions (i.e., before and after meals). Subjects were instructed not to talk or move to eliminate noise. The cardiac signal was located using Daubechies (db10) wavelet function at different scale ranges. The authors suggested that two ranges must be explored in the case of very different HR values.

Alvarado-Serrano et al. [START_REF] Alvarado-Serrano | An algorithm for beat-to-beat heart rate detection from the BCG based on the continuous spline wavelet transform[END_REF] implemented CWT with B-splines to detect HR using data from subjects in a sitting position. A piezo-electric sensor was fixed to a typical chair seat, and raw sensor data were gathered from seven subjects for about 100 seconds. The 5 th scale of CWT was defined as the optimal scale for HR detection. J-peaks were detected through learning and decision stages. In these stages, several experimental parameters were determined that could limit their use in another dataset. Table 1 presents a summary of wavelet-based methods used in the literature to detect HR from BCG signals.

On the other hand, Shin et al. [START_REF] Shin | Automatic ballistocardiogram (BCG) beat detection using a template matching approach[END_REF] proposed to use a TM approach for BCG beat detection. BCG signals were recorded using three sensors: air-mattress, loadcell, and EMFi-film. An individual BCG template was constructed for each sensor using ensemble averaging of valid BCG cycles centered at J-peak points. Five records of 30-second were gathered for each sensor, and the matching was performed using the correlation coefficient function.

Paalasmaa et al. [START_REF] Paalasmaa | Adaptive heartbeat modeling for beat-to-beat heart rate measurement in ballistocardiograms[END_REF] presented a method for detecting interbeat intervals from BCG signals acquired with a piezoelectric sensor. A BCG template was created using a clustering-based method. Then, interbeat intervals were detected via a customized cross correlation-based approach. The BCG template was continually being updated based on the detected interbeat intervals. Raw sensor data were recorded overnight from 40 patients in a sleep clinic and 20 subjects at their homes. Nevertheless, only 46 overnight recordings were used in the study. Cathelain et al. [START_REF] Cathelain | Dynamic Time Warping for Heartbeat Detection in Ballistocardiography[END_REF] introduced a similar approach to [START_REF] Shin | Automatic ballistocardiogram (BCG) beat detection using a template matching approach[END_REF]. However, the matching was achieved using dynamic time wrapping. In this study, a Murata SCA11H BCG sensor was deployed, and data were acquired from ten healthy subjects over 20 to 50 minutes long naps. The initial BCG template was updated with the newly detected J-peaks to alleviate the variabilities in the BCG signal shape. So far, we discussed how the wavelet transform and template matching methods were implemented for HR detection. Next, we provide detailed information about our proposed methods.

Methodology

In this section, we describe the proposed framework. First, in subsection 3.1, we demonstrate how the four BCG datasets were collected. Second, we introduce the MODWT, CWT, and TM methods in subsections 3.2, 3.3, and 3.4, respectively. Third, in subsection 3.5, we demonstrate how we detect HR through each method.

Experimental Setup and Data Collection

1) The first dataset (DataSet1) was acquired by a microbend fiber optic sensor (MFOS) from 10 sleep apnea patients. The patients underwent polysomnography (PSG) at the sleep lab of Khoo Teck Puat Hospital, Singapore (elapsed time: 8.12 ± 0.54 hours). The MFOS was placed under the patient's mattress in the upper part of the bed. The PSG electrocardiogram (ECG) signals were used as a gold-standard to assess the proposed HR detection methods. For more details about the MFOS and dataset, readers are referred to [START_REF] Sadek | A New Approach for Detecting Sleep Apnea Using a Contactless Bed Sensor: Comparison Study[END_REF].

2) The second dataset (DataSet2) was collected in a realistic setting by an MFOS from 50 participants sitting in a massage chair (elapsed time: 1.01 ± 0.11 hours). The MFOS was installed on the chair's headrest, and BCG signals were transmitted wirelessly to a computer by Bluetooth. The study aimed to evaluate the participants' stress levels at various time points. The participants underwent a sequence of stress-induced activities, rest (no-activity), and relaxation therapy [START_REF] Sadek | Sensor data quality processing for vital signs with opportunistic ambient sensing[END_REF][START_REF] Sadek | Continuous and unconstrained vital signs monitoring with ballistocardiogram sensors in headrest position[END_REF]. The continuity of contact was a significant issue in this study. If the participants had lifted or relocated their heads, we could not have recorded the BCG signals. We manually discarded participants' data with artifacts severe enough to degrade BCG signal quality in light of this issue. Therefore, we could only analyze data from 39 participants. ECG signals were simultaneously recorded, and they were used as a reference for HR detection.

3) The third dataset (DataSet3) was gathered from 10 subjects using a sensor mat combining four fiber Bragg were obtained by averaging signals from the six sensors in the time domain [START_REF] Sadek | Automatic heart rate detection from FBG sensors using sensor fusion and enhanced empirical mode decomposition[END_REF]. As a result, the fused signal was employed for HR detection.

4) The fourth dataset (DataSet4) was recently published by Carlson et al. [START_REF] Carlson | Bed-Based Ballistocardiography: Dataset and Ability to Track Cardiovascular Parameters[END_REF] and they were obtained from 40 subjects using: a) four electromechanical films (EMFis) and b) four load cells. The EMFis were placed underneath the mattress and the load cells were positioned under the bedposts. Overall, 4.5 hours of data were collected. The EMFis and load cells were set to collect data at a sampling rate of 1 kHz. For the EMFis, HR was computed by fusing the four EMFis signals using a pairwise maximum operation. Average fusion was also examined. Nevertheless, the fused signal was distorted and the main features of a typical BCG signal (i.e., "I-J-K" complexes) were missed. For the load cells, HR was detected by fusing signals from two load cells denoted as "LC2" and "LC3" using a pairwise maximum operation.

Across the four datasets, acquired BCG signals were preprocessed to separate motion artifacts and no-activity intervals. The preprocessing step was carried out using a sliding time window of 30-seconds with an overlap of 15-seconds. The standard deviation (SD) of each time window was computed. Then, the median absolute deviation (MAD) of the SDs was calculated. Time windows with SD greater than 2 times the MAD were considered as motion artifacts. Furthermore, time windows with SD less than a fixed value (10 mV) were regarded as noactivity intervals and discarded from further analysis. No-activity implies that no pressure force was applied to the MFOS. The remaining time windows were considered informative signals wherein BCG signals could be extracted.

Following the preprocessing step, a bandpass filter was applied to the informative signals (artifact-free) for obtaining BCG signals. The bandpass filter was constructed by cascading high and low pass filters as follows: 1) second-order Chebyshev type I high-pass filter with a maximum ripple of 0.5 dB, and a critical frequency of 2.5Hz followed by 2) fourth-order Chebyshev type I low-pass filter with a maximum ripple of 0.5dB and critical frequency of 5Hz.

Maximal Overlap Discrete Wavelet Transform

Wavelet transform is a suitable tool for analyzing nonstationary signals as is the case with BCG signals. In other words, it is a logical approach for analyzing signals with localized features whose locations are unknown a priori.

Fourier transform, on the other hand, performs best for stationary signals. Unlike DWT, the MODWT skips the downsampling after filtering the signal. The reason is that it gains other features, e.g., invariant to time-shifting, the ability to analyze any time series with arbitrary sample size, and increased resolution at a coarser scale.

Besides, it generates a more asymptotically efficient wavelet variance estimator than DWT [START_REF] Whitcher | Wavelet analysis of covariance with application to atmospheric time series[END_REF][START_REF] Percival | The Maximal Overlap Discrete WaveletTransform[END_REF]. MODWT decomposes a signal into a number of details and a single smooth. The details describe variations at a particular time scale, whereas the smooth describes the low-frequency variations. Given a time series 𝑋𝑋 𝑡𝑡 of 𝑁𝑁 samples, the level 𝐽𝐽 0 MODWT is a transform consisting of 𝐽𝐽 0 + 1 vector that is, 𝑊𝑊 � 1 , ⋯ , 𝑊𝑊 � 𝐽𝐽 0 and 𝑉𝑉 � 𝐽𝐽 0 . All these vectors have a dimension 𝑁𝑁. The vector 𝑊𝑊 � 𝑗𝑗 comprises wavelet coefficients linked to changes on the scale 𝜏𝜏 𝑗𝑗 = 2 𝑗𝑗-1 , whereas the 𝑉𝑉 � 𝐽𝐽 0 comprises the MODWT scaling coefficients linked to averages on the scale 𝜆𝜆 𝐽𝐽 0 = 2 𝐽𝐽 0 [START_REF] Macías-Pérez | A wavelet analysis of CMB time-ordered data applied to Archeops[END_REF]. The 𝑊𝑊 � 𝑗𝑗 and 𝑉𝑉 � 𝑗𝑗 can be constructed by filtering 𝑋𝑋 𝑡𝑡 as follows:

𝑊𝑊 � 𝑗𝑗,𝑡𝑡 = � ℎ � 𝑗𝑗,𝑙𝑙 ∘ 𝑋𝑋 𝑡𝑡-𝑙𝑙 𝑚𝑚𝑚𝑚𝑚𝑚 𝑁𝑁 𝑁𝑁-1 𝑙𝑙=0 , (1)
𝑉𝑉 � 𝑗𝑗,𝑡𝑡 = � 𝑔𝑔 � 𝑗𝑗,𝑙𝑙 ∘ 𝑋𝑋 𝑡𝑡-𝑙𝑙 𝑚𝑚𝑚𝑚𝑚𝑚 𝑁𝑁 𝑁𝑁-1 𝑙𝑙=0 , (2)
𝑡𝑡 = 0, ⋯ , 𝑁𝑁 -1 and 𝑗𝑗 = 1, 2, ⋯ ,
𝑋𝑋 = � 𝐷𝐷 𝑗𝑗 + 𝑆𝑆 𝑗𝑗 𝐿𝐿 𝑗𝑗=1 , (3)
𝐷𝐷 𝑗𝑗,𝑡𝑡 = � ℎ � 𝑗𝑗,𝑙𝑙 ∘ 𝑁𝑁-1 𝑙𝑙=0 𝑊𝑊 � 𝑗𝑗,𝑡𝑡+𝑙𝑙 𝑚𝑚𝑚𝑚𝑚𝑚 𝑁𝑁 , (4)
𝑆𝑆 𝑗𝑗,𝑡𝑡 = � 𝑔𝑔 � 𝑗𝑗,𝑙𝑙 ∘ 𝑁𝑁-1 𝑙𝑙=0 𝑉𝑉 � 𝑗𝑗,𝑡𝑡+𝑙𝑙 𝑚𝑚𝑚𝑚𝑚𝑚 𝑁𝑁 , (5)
Where 𝐷𝐷 𝑗𝑗 is the wavelet detail at decomposition 𝑗𝑗, and 𝑆𝑆 𝑗𝑗 is the wavelet smooth at decomposition 𝑗𝑗. Figure 1 shows an example of the MODWT multiresolution analysis for a 10-second BCG signal. It can be seen that the 4 th level smooth coefficient (S4) represents the J-Peaks of the BCG signal. We briefly discuss the CWT in the next subsection.

Figure 1 MODWT multiresolution analysis for a 10-second BCG signal. Wavelet Biorthogonal 3.9 (bior3.9) with 4 decomposition levels were opted to analyze the BCG signal. The maximum peaks of the 4 th level smooth coefficient (S4) correspond to the J-Peaks. The amplitude was normalized (z-score) for better visualization.

Continuous Wavelet Transform

Continuous wavelet transform (CWT) is a time-frequency (more correctly, a time-scale) transform that is a useful tool for examining nonstationary signals. CWT is a generalization of the short-time Fourier transform (STFT) commonly used to analyze nonstationary signals at multiple scales [START_REF] Shoeb | Chapter 16-wavelets; multiscale activity in physiological signals[END_REF]. In a similar way to STFT, CWT applies an analysis window, i.e., a wavelet, to extract segments from a signal. In contrast to STFT, the wavelet is not only translated but dilated and contracted to consider the scale of the activity under consideration. The wavelet's dilation and contraction serve two purposes, i.e., increasing the CWT's sensitivity to long-and short-time scale events, respectively. Given a continuous input signal 𝑥𝑥(𝑡𝑡), the CWT can be defined as follows:

𝐶𝐶(𝑎𝑎, 𝜏𝜏) = � 1 √2 𝜓𝜓 � 𝑡𝑡 -𝜏𝜏 𝑎𝑎 � 𝑥𝑥(𝑡𝑡)𝑑𝑑𝑡𝑡, (6)
Where 𝜓𝜓(𝑡𝑡) is the mother wavelet, 𝑎𝑎 is a scale, 𝜏𝜏 is a shift parameter; 𝐶𝐶(𝑎𝑎, 𝜏𝜏) is a bivariate function obtained by mapping 𝑥𝑥(𝑡𝑡) and a wavelet scaled by 𝑎𝑎 at a given time 𝜏𝜏. The localized correlation in time is determined over an integral starting with 𝑡𝑡 = 𝜏𝜏 and ending duration 𝑡𝑡 = 𝜏𝜏 + 𝐿𝐿, where 𝐿𝐿 is the wavelet's duration. It is noteworthy that short-term events (high-frequency signal components) such as spikes and transients can be determined when the wavelet is contracted (𝑎𝑎 < 1), whereas long-time events (low-frequency signal components) such as baseline oscillations can be determined when the wavelet is stretched (𝑎𝑎 > 1) [START_REF] Shoeb | Chapter 16-wavelets; multiscale activity in physiological signals[END_REF][START_REF] Akay | Wavelets in biomedical engineering[END_REF]. The result of the CWT can be shown in a graph known as a scalogram. It can be created by estimating the correlation between a signal and wavelets with different scales and then plotting how the correlation of each wavelet changes over a given period [START_REF] Shoeb | Chapter 16-wavelets; multiscale activity in physiological signals[END_REF].

Figure 2 shows a CWT example for a 10-second BCG signal. Gaus2 wavelet was opted to analyze the signal, and the wavelet coefficients at scale 20 (scales 1 to 30) are used to detect the J-Peaks.

Figure 2 An example of a BCG signal (top), scalogram (center), and coefficients line at scale 20 (bottom). Gaus2 wavelet was designated for analyzing the BCG signal. The dashed black line on the scalogram was the scale (i.e., scale 20) where the J-Peaks were detected. The amplitude was normalized (z-score) for better visualization.

Template Matching

The main challenge of the template matching (TM) approach is to choose the prototype/template and the similarity measure. The prototype (cardiac cycle) was constructed from DataSet1 due to the close contact between the MFOS mat and the participants. However, in DataSet2, BCG signal morphology was primarily affected by the frequent movement of the massage chair. We specified the prototype as follows. Firstly, we manually selected high-quality BCG segments with a size of 30-seconds (1500-samples). The term "high-quality" implies that the segment does not include any signs of motion artifacts. Furthermore, cardiac cycles are easily identified. Secondly, we divided each 30-second segment into equal slices of 1-second (50-samples) with an overlap of 0.5-second. The redundancy created by the overlapped slices enabled us to accurately detect cardiac cycles, considering the relatively small sampling frequency of the MFOS. Thirdly, we only considered slices containing the "I-J-K" complex of the BCG signal. The remaining slices were discarded from our analysis. The minimum peak distance (MPD) was 0.3 seconds, and it was selected using experimental observation.

Several peak distances were evaluated, i.e., ranging from 0.2 to 0.7 seconds with a step size of 0.05 seconds (Figure 4). The MPD was appointed by examining the effects of two measures, i.e., precision (Prec) and mean absolute error (MAE), on HR detection across the 10 patients. Detected HR values were classified into correct and incorrect detections for each MPD. Then, Prec was calculated to provide "a rough estimate of how a large portion of the detected HR values are correct", that is, "how correct the detected HR values are" [START_REF] Paalasmaa | Adaptive heartbeat modeling for beat-to-beat heart rate measurement in ballistocardiograms[END_REF][START_REF] Brüser | Robust inter-beat interval estimation in cardiac vibration signals[END_REF][START_REF] Mitsukura | Sleep Stage Estimation from Bed Leg Ballistocardiogram Sensors[END_REF]. It was calculated as follows: 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃 = 𝑃𝑃𝑐𝑐𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑡𝑡/(𝑃𝑃𝑐𝑐𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑡𝑡 + 𝑖𝑖𝑖𝑖𝑃𝑃𝑐𝑐𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑡𝑡). The average MAE (i.e., between true and correctly predicted HR values) in beats per minute (BPM) tended to increase with increasing the distance. In addition, the average precision tended to decrease with increasing the distance. Therefore, the 0.3-second interval was assigned as an optimal interval to strike a balance between lower MAE (5.02) and higher precision (68.91%). Finally, the prototype was constructed by an ensemble averaging the valid slices centered at J-peak points (Figure 3). For each cardiac cycle, a candidate J-peak was detected by finding the maximum peak of the cross-correlation function (CCF) between the template and the BCG signal. CCF is defined by calculating the correlation coefficients between the samples of the template (𝑥𝑥) and the BCG signal shifted by 𝑘𝑘, (𝑦𝑦(𝑖𝑖 -𝑘𝑘)) [START_REF] Kohn | Autocorrelation and Cross-Correlation Methods[END_REF]. The formula is as follows:

𝜌𝜌 𝑥𝑥𝑥𝑥 (𝑘𝑘) = 1 𝑁𝑁 ∑ (𝑥𝑥(𝑖𝑖) -𝑥𝑥̅ ) . (𝑦𝑦(𝑖𝑖 -𝑘𝑘) -𝑦𝑦 �) 𝑁𝑁-1 𝑛𝑛=0 � � 1 𝑁𝑁 ∑ (𝑥𝑥(𝑖𝑖) -𝑥𝑥̅ ) 2 𝑁𝑁-1 𝑛𝑛=0 � . � 1 𝑁𝑁 ∑ (𝑦𝑦(𝑖𝑖) -𝑦𝑦 �) 2 𝑁𝑁-1 𝑛𝑛=0 � , (7)
Both signals were supposed to have 𝑁𝑁 samples each (50 samples). At last, J-peaks with minimal intervals of 0.3 seconds were only deemed to be heartbeats.

Heart Rate Detection

The HR was computed on a 30-second window and sliding the window by 15 seconds. The time window choice was based on previous studies [START_REF] Sadek | A New Approach for Detecting Sleep Apnea Using a Contactless Bed Sensor: Comparison Study[END_REF][START_REF] Sadek | Continuous and unconstrained vital signs monitoring with ballistocardiogram sensors in headrest position[END_REF][START_REF] Sadek | Nonintrusive Vital Signs Monitoring for Sleep Apnea Patients: A Preliminary Study[END_REF], taking into account the sampling rate of the sensor (50Hz). Regarding the MODWT-MRA, the Biorthogonal 3.9 (bior3.9) wavelet was appointed to detect cardiac cycles. The bior3.9 wavelet proved to be the most suitable to characterize the profile of cardiac cycles across different wavelets, precisely Daubechies 1 (db1), Symlet 2 (sym2), Coiflets 1 (coif1), and Reverse Biorthogonal 3.1 (rbior3.1) [START_REF] Sadek | Nonintrusive heart rate measurement using ballistocardiogram signals: a comparative study[END_REF]. BCG signals were analyzed using 4 decomposition levels, and the 4 th level smooth coefficient was employed for J-peaks detection [START_REF] Sadek | A New Approach for Detecting Sleep Apnea Using a Contactless Bed Sensor: Comparison Study[END_REF][START_REF] Sadek | Continuous and unconstrained vital signs monitoring with ballistocardiogram sensors in headrest position[END_REF][START_REF] Sadek | Nonintrusive Vital Signs Monitoring for Sleep Apnea Patients: A Preliminary Study[END_REF]. The periodicity of the smooth coefficient reflected the same periodicity as the HR (Figure 1).

At last, J-peaks were localized using a peak detector. For CWT, Gaussian Derivative (GausP), Frequency B-Spline (FbspM-B-C), and Shannon (ShanB-C) wavelets were tested for HR detection. 𝑃𝑃 is an order-dependent normalization constant, 𝑀𝑀 is the spline order, 𝐵𝐵 is the bandwidth, and 𝐶𝐶 is the center frequency. For each wavelet, BCG signals were analyzed at different scales using the scalogram (Figure 2), and then the scale reflecting the same periodicity as the HR was designated for J-peaks detection [START_REF] Gilaberte | Heart and respiratory rate detection on a bathroom scale based on the ballistocardiogram and the continuous wavelet transform[END_REF]. The designated parameters and scales of the three wavelets are given in Table 2. For the rest of the paper, Gaus2, Fbsp2-1-1, and Shan1.5-1.0 will be used to refer to the CWT wavelets.

Table 2 Parameters and scales of the CWT for HR detection; 𝑃𝑃 is an order-dependent normalization constant, 𝑀𝑀 is the spline order, 𝐵𝐵 is the bandwidth, and 𝐶𝐶 is the center frequency. The created template was then employed to detect HR in the remaining datasets, as outlined in subsection 3.4.

Wavelet

The HR value at a time 𝑡𝑡 𝑛𝑛 , at which the 𝑖𝑖𝑡𝑡ℎ maximum occurred, was defined as follows:

𝐻𝐻𝐻𝐻 𝑛𝑛 = 60 𝑡𝑡 𝑛𝑛 -𝑡𝑡 𝑛𝑛-1 , (8)
Where 𝑡𝑡 𝑛𝑛 is the time at 𝑖𝑖𝑡𝑡ℎ local maxima and t n-1 is the time at (𝑖𝑖 -1)𝑡𝑡ℎ local maxima in the designated MODWT coefficient or CWT scale.

Results and Discussion

This section presents the results of the three proposed methods across the four datasets. For each method, the BPM error between the reference ECG and the measurement device was evaluated separately using the MAE, mean absolute percentage error (MAPE), and root mean square error (RMSE). All figures were generated using Python (Matplotlib, Plotnine, Bokeh, and Seaborn).

Performance Evaluation of Heart Rate Detection: DataSet1

As presented in More importantly, Prec value for patient 8 was highly improved from 30.77% to 45.98%. On the other hand, Fbsp2-1-1 attained the smallest and largest values of the error measures for patients 1 and 7, such as (2.27, 3.32%, 3.07) and (6.76, 11.48%, 7.51), respectively. The Prec value for patient 7 was 31.75% that is comparable to the Prec of patient 8 when the MODWT-MRA was applied. It is worth mentioning that patient 7 had been diagnosed with hypertension and severe OSA with an AHI such as 76.6 [START_REF] Sadek | A New Approach for Detecting Sleep Apnea Using a Contactless Bed Sensor: Comparison Study[END_REF]. Compared to Gaus2 and Shan-1.5-1.0 wavelets, small Prec values (47.22%, 45.73%, and 39.67%) were obtained for patients 3, 4, and 6 despite their moderate OSA (i.e., AHI were 23, 27, and 33, respectively). These findings suggest that Fbsp2-1-1 can be more susceptible to patients' comorbidities. As a result, cardiac cycles were not appropriately captured for various time intervals, triggering a total Prec of 69.57% (25.91). Based on these results, Gaus2 seems to provide information about cardiac cycles more accurately than other wavelets.

The total Prec accomplished by Gaus2, i.e., 78.83% (17.84), was slightly inferior to MODWT-MRA, i.e., 80.22% (19.01). Nonetheless, Gaus2 generated more favorable results with respect to the error measures (Table 4). HR absolute errors for each wavelet method are represented as histograms in Figure 5. It is clear from the figure that the HR detection performances of Gaus2 and MODWT-MRA are comparable.

Moreover, Figure 6 shows the Bland-Altman plot of HR for Gaus2 function across DataSet1. The limits of agreement (LoA) were computed as described in [START_REF] Bland | Agreement Between Methods of Measurement with Multiple Observations Per Individual[END_REF][START_REF] Zou | Confidence interval estimation for the Bland-Altman limits of agreement with multiple observations per individual[END_REF] given the fact that multiple observations per individual are available. The upper and lower LoA values are 10.95 and -11.17 BPM (𝑟𝑟 𝑚𝑚𝑚𝑚 = 0.38, 𝑃𝑃 < .001); 𝑟𝑟 𝑚𝑚𝑚𝑚 is the "repeated measures correlation" described in [START_REF] Bakdash | Repeated Measures Correlation[END_REF]. Heretofore, we examined the effectiveness of each wavelet function across DataSet1. After that, we discuss the performance of the wavelet functions and the template matching method across DataSet2.

Figure 6 Bland-Altman plots of Gaus2 method across DataSet1. Markers' colors were randomly assigned for each patient.

Performance Evaluation of Heart Rate Detection: DataSet2

This particular dataset is challenging because BCG signals were gathered in a noisy environment. The signal quality was affected to a large degree by the massage chair's movement and loss of contact with the MFOS. The maximum, minimum, and overall Prec values for each wavelet-based function are specified in Table 5. Up to this point, the provided results demonstrate the superiority of Gaus2 for HR detection across two independent datasets. In the following, we discuss the findings of the TM method and compare them with Gaus2.

Table 5 The maximum, minimum, and total values of the precision for the 4 wavelet-based functions (i.e., MODWT-MRA, Gaus2, Fbsp2-1-1, and Shan1.5-1.0) and the template matching approach. The TM method's performance depends mainly on the template and similarity measure, i.e., a cross-correlation in our case. The BCG template was created from DataSet1. Accordingly, the intention is to utilize this template for HR detection across DataSet2. Overall, the TM achieved MAE, MAPE, and RMSE such as 4.74 (0.66), 7.46% (1.42), and 5.67 (0.68). As illustrated in Figure 8, the smallest values are 2.59, 4.04%, and 3.17 for participant 21, while the largest values are 5.96, 11.40%, and 6.84 for participant 13. Although obtained results are reasonable, the total Prec, i.e., 72.83% [START_REF] Suliman | Performance Comparison for Ballistocardiogram Peak Detection Methods[END_REF], is not as good as Gaus2 (Table 5).

Methods

Figure 9 Bland-Altman plot of the TM approach across DataSet2. Markers' colors were randomly assigned for each subject.

Still, this fairly small Prec value is expected given the fact that the template was generated from a different dataset. Moreover, the BCG signals in DataSet2 were heavily corrupted by head movement artifacts. Figure 9 shows the Bland-Altman plot of HR for the TM approach across DataSet2. The upper and lower LoA values are 12.12 and -10.04 BPM (𝑟𝑟 𝑚𝑚𝑚𝑚 = 0.34, 𝑃𝑃 < .001). Similarly, it can be seen from the plot the relatively small number of HR points (i.e., Prec) in contrast to Gaus2. Additionally, 𝑟𝑟 𝑚𝑚𝑚𝑚 was 0.38; however, for Gaus2 it was 0.37.

Performance Evaluation of Heart Rate Detection: DataSet3

For further checking the effectiveness of the TM approach, we used the BCG template generated from DataSet1 to detect HR in DataSet3. We down-sampled the FBG signals to 50Hz so that cardiac cycles can match the BCG template. As given in Table 6, reasonable results were obtained, in which the total MAE, MAPE, and RMSE were 3.43 (1.26), 5.51% (2.31), and 4.58 (1.26). Also, the total Prec was acceptable, i.e., 80.88% (14.72). This Prec value is fairly similar to a previous work in which the fusion was performed in the frequency domain using the cepstrum, and the total Prec reported was 84% [START_REF] Yongwei Zhu | Heart rate estimation from FBG sensors using cepstrum analysis and sensor fusion[END_REF]. Figure 10 demonstrates the performance of the TM approach for Jpeaks detection across DataSet3. The top section of the figure shows a 30-second BCG signal with the J-peaks marked by up-pointing triangles. Besides, the bottom section of the figures shows the equivalent ECG signal with the R-peaks labeled by up-pointing triangles.

Figure 11 shows the repeated measures correlation (Rmcorr) plot for HR detection across DataSet3 using the TM method. Across the ten subjects, Rmcorr and p-value were as follows: 𝑟𝑟 𝑚𝑚𝑚𝑚 = 0.39 𝑎𝑎𝑎𝑎𝑎𝑎 𝑃𝑃 < .001. In summary,

these results may support the potential of using a BCG template from a particular dataset to detect HR in a different dataset and under different conditions. The three methods described thus far have provided consistent results for HR detection from BCG signals. Moreover, the total Prec values achieved by the three methods were fairly reasonable, considering that BCG signals were recorded in non-restricted environments; in other words, subjects' movements were allowed. It is important to highlight that our findings for the Gaus2 and TM methods provided accepted overall aggregated results that were less than 10% MAPE. As stated in [START_REF] Nelson | Accuracy of Consumer Wearable Heart Rate Measurement During an Ecologically Valid 24-Hour Period: Intraindividual Validation Study[END_REF], an error rate of ±10% can be regarded as an accurate threshold for medical ECG monitors. To this end, preferring one method over the other will depend on the application requirements. To illustrate, TM method produced a little better result in detecting HR than Gaus2

(Figure 12 and Figure 13). Yet, the total Prec was smaller than Gaus2. Thus, it will be more appropriate to use the TM in a well-controlled environment where motion artifacts can be minimized, despite that template selection is time-consuming and labor-intensive. On the other hand, the Gaus2 method seems less susceptible to motion artifacts. Hence, it can be more practical in real-life situations. Still, selecting an optimal wavelet function and scale requires prior knowledge about the BCG signal morphology. These two parameters will vary from one specific sensor to another. Besides, it should be pointed out that the HR detection results can differ significantly from one scale to another.

Figure 11 Repeated measures correlation (rmcorr) coefficient plot [START_REF] Bakdash | Repeated Measures Correlation[END_REF] for HR detection across DataSet3 using the TM method.

That is to say, a particular scale and/or wavelet can only provide adequate results for individual cases while the opposite happens for other cases. A situation like this occurred, for example, with Fbsp2-1-1 in DataSet1 (Section 4.2). In addition to the results mentioned above, Gaus2 and TM methods were applied to DataSet4, a recently published dataset [START_REF] Carlson | Bed-Based Ballistocardiography: Dataset and Ability to Track Cardiovascular Parameters[END_REF], and our findings are presented in Section 4.4.

Figure 12 HR distribution for the reference ECG, Gau2, and TM methods for participant 2 (DataSet2). Time-windows were included in the diagram if they had been evaluated by both methods. 15) demonstrate the superiority of Gaus2 for HR detection compared with the TM. Table The practical implementation of the proposed methods is another important element that should be considered for measuring the efficiency of each method. To that end, the three methods were implemented on a Raspberry PI (Section 5).

Practical Implementation

The proposed methods were implemented using Python 3.8 on a Raspberry Pi 3 Model B (Quad-Core 1.2GHz and 1GB RAM). The MODWT-MRA method was applied using the "wmtsa-python" library 1 , while CWT-based methods were applied using the "Scaleogram" library 2 . In short, the average time needed to analyze a 30-second BCG signal was less than one second for the 5 methods. Yet, the MODWT-MRA took less time compared to other methods, i.e., 0.04 seconds. Shan1.5-1.0 and Fbsp2-1-1 required more time to analyze a BCG signal, i.e., 0.43 and 0.44 seconds. This performance is expected because a large number of scales were used, specifically 100. The time required for the TM was 0.12 seconds. The improved performance for the MODWT-MRA occurred because the "wmtsa-python" library is written in Python and Cython. However, "Scaleogram" library uses an adaptive convolution algorithm selection, that is, the scale processing loop switches to FFT-based convolution when the complexity is better in 𝑁𝑁 * 𝑙𝑙𝑙𝑙𝑙𝑙2(𝑁𝑁). MODWT-MRA is going to be more efficient for the applications that require real-time processing of the data considering its improved performance. Further information about acquiring raw sensor data from the MFOS can be found in the Appendix. Table 7 The average time (in seconds) for analyzing a 30-second BCG signal using MODWT-MRA, Gaus2, Fbsp-2-1-1, Shan1.5-1.0, and TM methods.

Method

Conclusion

The primary objective of this comparative study is to investigate the usefulness of three HR detection algorithms (MODWT-MRA, CWT, and TM) across several datasets and under different experimental setups. To this goal, we tested the three algorithms using two local datasets and one publicly available dataset. Besides, the performance of each method was assessed using four error measures, namely MAE, MAPE, RMSE, and Prec. For MODWT-MRA, wavelet bior3.9 with four decomposition levels were adopted. Besides, the 4 th level smooth coefficient was assigned for detecting cardiac cycles. For CWT, three wavelets were analyzed, i.e., Gaus2 (20 th scale of 30), Fbsp2-

Declaration of Competing Interest

None.

  grating (FBG) sensor arrays. Each sensor array consisted of six sensors, and they were set to collect signals at 250Hz. The sensor arrays were placed under the subjects' a) head, b) chest, c) chest and abdomen, and d) under hip. The experiment was split into two phases: 10 minutes of supine sleeping and 10 minutes of side sleeping. The ideal sensor's location was under the chest and abdomen. Similarly, optimal results

Figure 3

 3 Figure 3 An ensemble averaging of BCG signals. The "I-J-K" represents the ejection phase of the cardiac cycle.

Figure 4

 4 Figure 4 HR detection performance metrics (i.e., MAE and Prec) against the minimum peak distances.

= 2 ,

 2 𝐵𝐵 = 1, 𝐶𝐶 = 1 Range(1, 100), HR scale: 45 ShanB-C 𝐵𝐵 = 1.5, 𝐶𝐶 = 1 Range(1, 100), HR scale: 75 On the other hand, BCG signals obtained from DataSet1 were used to construct a BCG template (training phase).

Figure 5

 5 Figure 5 Distribution of the HR absolute error as histograms for each wavelet function across DataSet1.

  For waveletbased functions, average error measures (MAE, MAPE, and RMSE) for a) MODWT-MRA, b) Gaus2, c) Fbsp-2-1-1, and d) Shan1.5-1.0 were as follows: a) 4.95 (1.19), 7.57% (1.74), and 5.77 (1.09); b) 4.85 (1.20), 7.45% (2.17), and 5.66 (1.11); c) 5.19 (1.63), 8.04% (3.17), and 5.96 (1.48); d) 4.95 (1.07), 7.57% (1.63), and 5.80 (0.97). Overall, Gaus2 and Shan1.5-1.0 performed slightly better than MODW-MRA and Fbsp2-1-1. Similar to DataSet1, the largest error values were scored by Fpsp2-1-1, such as 9.58, 16.68%, and 9.73. Figure 7 illustrates the HR detection error of each wavelet-based function across all participants. That said, Gaus2 scored the largest Prec value, i.e., 81.14% (14.36), whereas the Prec values for MODWT-MRA, Fbsp2-1-1, and Shan1.5-1.0 were as follows 77.12% (18.72), 76.24% (23.68), and 76.02% (14.63).

Figure 7

 7 Figure 7 Overall performance measures (MAE, MAPE, RMSE) of the HR detection across DataSet2 using the 4 wavelet-based functions, i.e., MODWT-MRA, Gaus2, Fbsp2-1-1, and Shan1.5-1.0 (top left, top right, bottom left, and bottom right).

Figure 8

 8 Figure 8 Overall performance measures (MAE, MAPE, RMSE) of the HR detection across DataSet2 using the template matching approach.

Figure 10 HR

 10 Figure 10 HR detection results using the TM approach (subject 1, DataSet3). The top figure shows a 30-second BCG signal with the J-peaks annotated by up-pointing triangles. The bottom figure shows the corresponding ECG signal with the R-peaks annotated by up-pointing triangles.

Figure 13

 13 Figure 13 Boxplots with p-values for Gaus2 and TM methods vs. the reference ECG across DataSet2.

Figure 14

 14 Figure 14 Superimposed histograms of the ECG-derived HR and Gaus2-derived HR across DataSet4 (EMFis). HR values are represented as boxplots on top of the figure.

Figure 15

 15 Figure 15 Overall performance measures (MAE, MAPE, RMSE) of the HR detection across DataSet4 using Gaus2 (top left and top right) and TM (bottom left and bottom right) methods.

1- 1 (

 1 45 th scale of 100), and Shan1.5-1.0 (75 th scale of 100). In general, CWT-Gaus2 achieved more favorable outcomes compared with other wavelets. Regarding the TM method, a BCG template was generated from DataSet1 as a training set. Then, it was used for HR detection in the remaining datasets. Hence, satisfactory results were achieved for DataSet1 and DataSet2. Nevertheless, it was unsuccessful to analyze two subjects out of 40 from DataSet4. These results show the shortcoming of the TM method for analyzing BCG signals collected by different sensors. On the other hand, wavelet-based methods have proved successful regardless of sensor types or experimental setups. The proposed methods were implemented on a Raspberry Pi to test their effectiveness for real-time applications. As a result, the average time required to analyze a 30-second BCG signal was less than one second for all methods. However, the MODWT-MRA had the highest performance, with an average time of 0.04 seconds.

Table 1

 1

	Summary of wavelet-based approaches used to detect HR from BCG signals. "CDF": Cohen-Daubechies-Feauveau;
	"sym": Symlet; "db": Daubechies; "D": detail-component; "s": seconds; "min": minutes.
	Authors	Subjects Sensor	Environment	Acquisition time	Wavelet	Wavelet function	Cardiac signal
	Zhu et al. [20,21]	13	Liquid sensor pressure	Sleep lab	120 min	DWT	CDF 9/7	Sum(D4:D5)
	Jin et al. [23]	1	N/A	Lab	N/A	DWT	sym8	N/A
	Postolache et al. [25]	8	EMFi sensor	Lab	15 min	DWT	db5	Sum(D8:D10)
	Pino et al. [26] 35	EMFi sensor	Lab and hospital	2 min	DWT	db6	Sum(D4:D7)
	Gilaberte et al. [27]	6	Strain gauges	Lab	10 s	CWT	db10	N/A
	Alvarado-		Piezo-
	Serrano et al.	7	electric	lab	100 s	CWT	B-splines	Scale 5
	[28]		sensor

  𝐿𝐿, where ℎ � 𝑗𝑗,𝑙𝑙 ∘ and 𝑔𝑔 � 𝑗𝑗,𝑙𝑙 ∘ are the 𝑗𝑗th level MODWT wavelet and scaling filters (highand low-pass filters) obtained by periodizing ℎ � 𝑗𝑗,𝑙𝑙 and 𝑔𝑔 � 𝑗𝑗,𝑙𝑙 to length 𝑁𝑁. These filters can be defined by renormalizing the DWT wavelet and scaling filters such as ℎ � 𝑗𝑗,𝑙𝑙 = ℎ 𝑗𝑗,𝑙𝑙/2 𝑗𝑗/2 and 𝑔𝑔 � 𝑗𝑗,𝑙𝑙 = 𝑔𝑔 𝑗𝑗,𝑙𝑙/2 𝑗𝑗/2 . The multiresolution analysis (MRA) of the MODWT breaks up a signal into high-pass filtered detail components and a low-pass filtered smooth component. The MRA of the MODWT can be expressed as follows:

Table 3 ,

 3 MODWT-MRA achieved overall MAE, MAPE, and RMSE, such as 4.71 (1.07), 7.61% (1.65),

	and 5.59 (1.02), respectively. The smallest and largest error values were (3.13, 4.55%, 4.05) and (7.16, 9.99%, 7.83)
	for patients 1 and 8. Also, both patients had the highest and lowest precision, such as 96.53% and 30.77%. The
	past medical history of patient 8 indicated hypertension and dyslipidemia. Furthermore, this patient had severe
	obstructive sleep apnea (OSA) with an apnea-hypopnea index (AHI) of 78.2 [7]. The BCG signal's quality was poorly
	affected by these health problems. Thus, reported Prec was low compared with other patients. Furthermore, this

Table 3

 3 HR detection performance metrics for DataSet1 using MODWT-MRA.

									Patients Ids
	Metrics											Mean (SD)
			1		2		3	4	5	6	7	8	9	10
	MAE	3.13	4.92	5.06	4.70	3.78	4.68	5.00	7.16	3.87	4.83	4.71 (1.07)
	MAPE (%) 4.55	7.45	8.76	8.15	5.90	8.66	9.07	9.99	6.31	7.26	7.61 (1.65)
	RMSE	4.05	5.81	5.94	5.60	4.68	5.66	5.88	7.83	4.69	5.74	5.59 (1.02)
	Prec (%)	96.53 81.87 81.27 83.66 94.11 70.54 85.99 30.77 94.19 83.23 80.22 (19.01)
	Regarding CWT-based methods, Gaus2 and Shan-1.5-1.0 provided comparable results to MODWT-MRA (Table 4).
	Nevertheless, Gaus2 performed slightly better than MODWT-MRA in which the overall MAE, MAPE, and RMSE
	were 4.71 (1.22), 7.58% (2.17), and 5.58 (1.20).
	Method	Metrics		1		2	3	4	Patients Ids 5 6	7	8	9	10	Mean (SD)
		MAE		2.67	4.33	5.58	5.42	3.35	4.81	5.92	6.70	4.18	4.10	4.71 (1.22)
	Gaus2	MAPE (%) 3.88 RMSE 3.51	6.51 5.25	9.52 6.44	9.30 6.34	5.25 4.22	8.61 5.84	10.61 9.17 6.74 7.40	6.86 5.03	6.11 5.04	7.58 (2.17) 5.58 (1.20)
		Prec (%)	98.35 89.75 73.11 72.63 96.45 58.45 68.43 45.98 93.57 91.62 78.83 (17.84)
		MAE		2.27	4.34	6.26	5.90	4.48	5.63	6.76	5.49	5.29	3.97	5.04 (1.31)
	Fbsp2-1-1	MAPE (%) 3.32 RMSE 3.07	6.64 5.22	10.13 9.45 7.04 6.75	7.15 5.32	9.48 6.48	11.48 7.23 7.51 6.38	8.69 6.17	6.00 4.85	7.96 (2.37) 5.88 (1.30)
		Prec (%)	99.18 91.11 47.22 45.73 93.33 39.67 31.75 76.22 76.28 95.21 69.57 (25.91)
		MAE		3.36	4.46	5.76	5.61	3.60	4.81	5.50	6.57	4.97	4.18	4.88 (1.01)
	Shan1.5-1.0	MAPE (%) 4.90 RMSE 4.26	6.78 5.39	9.74 6.62	9.56 6.51	5.65 4.47	8.60 5.84	9.89 6.40	9.03 7.34	8.14 5.83	6.21 5.10	7.85 (1.83) 5.78 (0.98)
		Prec (%)	95.36 83.37 63.97 70.44 94.54 58.51 70.68 41.26 82.33 89.82 75.03 (17.36)

Table

4

HR detection performance metrics for DataSet1 using CWT-Gaus2, CWT-Fbsp2-1-1, and CWT-Shan1.5-1.0.

Table 6

 6 HR detection performance metrics for DataSet3 using the TM approach.

						Subjects Ids
	Metrics										Mean (SD)
		1	2	3	4	5	6	7	8	9	10
	MAE	3.18 2.76 5.62 4.43 3.02 2.89 1.42 4.79 2.25 3.93 3.43 (1.26)
	MAPE (%)	4.40 4.63 10.17 7.26 5.27 4.82 1.83 6.57 3.38 6.80 5.51 (2.31)
	RMSE	4.33 3.88 6.34 5.24 5.71 4.19 2.37 5.51 2.99 5.22 4.58 (1.26)
	Prec (%)	92.55 60.44 54.44 87.78 81.4 88.04 96.7 85.87 93.48 68.09 80.88 (14.72)

  𝑟𝑟 𝑚𝑚𝑚𝑚 = 0.65, 𝑃𝑃 < .001 and 𝑟𝑟 𝑚𝑚𝑚𝑚 = 0.35, 𝑃𝑃 < .001 for Gaus2 and TM, respectively. For the load Gaus2 outperformed the TM in a similar way to the EMFis. Rmcorr and pvalue were as follows: 𝑟𝑟 𝑚𝑚𝑚𝑚 = 0.66, 𝑃𝑃 < .001 and 𝑟𝑟 𝑚𝑚𝑚𝑚 = 0.36, 𝑃𝑃 < .001 for Gaus2 and TM, accordingly. The results mentioned above (Figure

	cells, the total MAE, MAPE, RMSE were 1.63 (1.40), 2.28% (1.78), and 2.14 (1.62) for Gaus2. Unlike Gaus2, the TM
	failed to analyze signals from two subjects, i.e., "X1008", "X1040". Besides, the total MAE, MAPE, RMSE were 3.98
	(2.18), 6.12% (3.77), and 4.67 (2.20).

4.4. Performance Evaluation of Heart Rate Detection: DataSet4

Firstly, BCG signals obtained from EMFis and load cells were down-sampled to 50Hz. For the EMFis, the overall MAE, MAPE, RMSE were 2.15 (2.33), 2.91% (2.82), and 2.62 (2.42) using Gaus2. On the other hand, the TM failed to analyze signals from subjects "X1001" and "X1005" because the signal's morphology was quite different compared to the MFOS. Besides, the total MAE, MAPE, RMSE were 4.07 (2.35), 5.79% (2.91), and 4.76 (2.29), respectively. Gaus2 achieved close results to the reference ECG compared to the TM (Figure

14

). Moreover, the total Prec attained by Gaus2, i.e., 93.65% (16.57) was better than the TM, i.e., 84.08

(20.89

). Rmcorr and p-value were as follows:

https://gitlab.com/Cimatoribus/wmtsa-python

https://github.com/alsauve/scaleogram

https://kst-plot.kde.org/

Appendix

Technical Implementation of the MFOS

The MFOS is integrated into ambient assisted living (AAL) platforms known as UbiSmart [START_REF] Sadek | Novel Unobtrusive Approach for Sleep Monitoring Using Fiber Optics in an Ambient Assisted Living Platform[END_REF][START_REF] Bellmunt | Agile framework for rapid deployment in ambient assisted living environments[END_REF] and AmI-IoT [START_REF] Sadek | Privacy and Security of IoT Based Healthcare Systems: Concerns, Solutions, and Recommendations[END_REF].

The working principle of the MFOS and its integration into the platforms can be found in [START_REF] Sadek | A New Approach for Detecting Sleep Apnea Using a Contactless Bed Sensor: Comparison Study[END_REF][START_REF] Sadek | Novel Unobtrusive Approach for Sleep Monitoring Using Fiber Optics in an Ambient Assisted Living Platform[END_REF][START_REF] Bellmunt | Agile framework for rapid deployment in ambient assisted living environments[END_REF][START_REF] Sadek | Privacy and Security of IoT Based Healthcare Systems: Concerns, Solutions, and Recommendations[END_REF][START_REF] Aloulou | Simplifying Installation and Maintenance of Ambient Intelligent Solutions Toward Large Scale Deployment[END_REF]. In summary, the MFOS is considered as another sensor that contributes to the knowledge base of the AAL platform (e.g., UbiSmart). The MFOS communicator unit is wired to our Gateway (Figure 16).

Figure 16 The connection between the MFOS and the RPi, i.e., the Gateway.

Voluminous raw data is read and stored on a micro-SD card for a deeper off-line analysis. Simultaneously, the data is preprocessed to generate high-level events, such as bed empty, bed motion, sleep. Currently, it operates on a time window of 10 seconds. For each time window, an event is produced. The events are then sent to the Server as structured sensor data using MQTT protocol over an Internet connection. The Server handles the received structured information (event). The MFOS will appear in the home description interface as available for the association to a house. If confirmed, this association is stored in the knowledge base (KB). Any subsequent events are then inserted into the KB of the associated house, allowing the reasoning engine to be aware of bed occupancy with respect to our ontology (Figure 17). In parallel, the raw data is processed every 5 minutes to extract information about the subject's respiratory effort and heart rate. This information is also inserted into the KB.

Figure 18 shows how we can get raw sensor data from the MSOF via a RPi.

Figure 17 UbiSmart framework in three sections. The UbiGate, the Server, and the Service Provisioning [START_REF] Kodyš | wait, reasoning was wrong! Let's replay[END_REF].

Figure 18 An experimental setup for acquiring raw sensor data from the MFOS. The data were obtained by connecting the communicator unit to the GPIO (general-purpose input/output) of the RPi. Then, the Pi is connected to a PC through an SSH connection. The KST 3 plotting tool (implemented on the RPi) was used to display the data in real-time.