Smart Device for the Determination of Heart Rate Variability in Real Time

This work presents a first approach to the design, development, and implementation of a smart device for the real-time measurement and detection of alterations in heart rate variability (HRV). The smart device follows a modular design scheme, which consists of an electrocardiogram (ECG) signal acquisition module, a processing module and a wireless communications module. From five-minute ECG signals, the processing module algorithms perform a spectral estimation of the HRV. The experimental results demonstrate the viability of the smart device and the proposed processing algorithms.


Introduction
Cardiovascular diseases are among the main causes of population death [1].It is estimated that 17.3 million people worldwide die as a result of cardiovascular disease, which represents 30% of all cases [2].High blood pressure, smoking habits, diabetes, visceral obesity, dyslipidemia, physical inactivity, and unhealthy eating patterns are the main modifiable risk factors associated with the development of cardiovascular diseases [2].Cardiac autonomic dysfunction is a risk factor that is also related to the development of cardiovascular diseases and can be noninvasively measured through heart rate variability (HRV) assessment [3].
HRV refers to the continuous heart rate or continuous RR wave intervals extracted from electrocardiogram (ECG) signal [4] (time distance between the R waves in the ECG signal is denoted as RR intervals).Short-and long-term variations in heart rate (HR) can be due to different causes.The parasympathetic nervous system causes that HR, and in turn, blood pressure (BP) decreases, while the sympathetic nervous system favors an antagonistic action, increasing both HR and BP.The interaction of these systems is known as the sympathetic-vagal balance of the autonomic nervous system (ANS) [5].Many studies have shown that HRV is a useful quantitative indicator to assess the balance between the cardiac sympathetic nervous system and the parasympathetic nervous system and can be used in the diagnosis and prevention of some cardiovascular diseases such as congestive heart failure, sudden cardiac death, arrhythmia, or Holmes-Adie syndrome [4,[6][7][8][9].
In the last decades, an attempt has been made to analyze and quantify HRV so that it can serve as a clinical utility.Measurements of HRV are made over long-and short-term periods.Long-term recordings typically last 24 hours and are carried out by means of a Holter, while short-term recordings last 2-5 minutes and are usually performed with a dynamic ECG [10].
The analysis of HRV is of interest in other multiple conditions, such as respiratory diseases.This analysis can be used as a simple and noninvasive method for the estimation of aerobic capacity in subjects with COPD [11], and it can also be used as a prognostic tool, since in these patients, a reduced HRV has been related to an increase in morbidity and mortality [12].In addition, respiratory muscle strength has been related to the sympathetic-vagal response, which can be evaluated by HRV [13].Other applications of HRV range from the early biomarker for the evaluation of diabetes mellitus progress [14], and diagnostic marker in chronic neck pain [15], to mental and physical health [16], or sleep quality [17], and work stress [18], among others.
Methods for the measurement of HRV can be classified into temporal and frequency domain methods.The first ones consist mainly of a statistical analysis of RR intervals.However, their capabilities are limited, as they do not show sufficient specificity and sensitivity, in addition to the need of long recording periods [10].
The methods in the frequency domain or spectral estimation of HRV can be classified into parametric and nonparametric methods.Nonparametric methods based on the fast Fourier transform (FFT) have as main advantage their simplicity and algorithmic speed [10], while parametric methods, such as autoregressive (AR) models, provide a more defined, smooth, and easy-to-identify spectral component [10].In addition, for short-duration measurements, parametric methods provide better spectral resolution than nonparametric methods [10].
To the knowledge of the authors, there are no devices that allow real-time analysis of HRV through the aforementioned methods.Some adapted methods have been proposed for the real-time analysis [19], such as the short-time Fourier transform (STFT), wavelet transform, Hilbert-Huang transform, and from infinite impulse response (IIR) filters [20], but always executed off-line with ECG signals from previously acquired records.
The present work shows a first approach to the design of a portable, customizable, and low-cost smart device for the real-time measurement of HRV in the frequency domain through AR models.

Materials and Methods
In the context of the present work, smart device is referred to as a device that not only has sensing capabilities for the measurement of certain variables, but is also equipped with a wireless communications unit and has the capability of carrying out a process of the acquired information.The design, development, and evaluation processes of the device have been performed in an iterative (or spiraling) methodology, testing the developments before and more often than in the traditional cascaded life cycle.In the design and simulation stage, Orcad software (version 16.0) of Cadence has been used.For the implementation of the prototypes CircuitCam (version 5.2) and BoardMaster (version 5.0), programs have been used, as well as a ProtoMat S62 milling machine, all of LPKF.
A first evaluation of the device performance was made by considering its most representative characteristics, comparing them with other devices and systems recently proposed in the literature.The gain and the bandwidth were calculated from the simulation of the electronic design using the Tina-TI software of Texas Instruments.The power consumption was estimated using the procedure described in [21].For that purpose, a resistor of 10 ohms was placed in series in the line that feeds the Front-End stage from the battery.With an oscilloscope (MSO6032A of Agilent Technologies), the voltage at the resistor was measured to approximate, according to Ohm's law, the input current to the circuit.This current, constant over time, was multiplied by the supply voltage of 3.3 V to obtain the power consumption.
The interest of the present device is its capability to compute the HRV parameters in the frequency domain in real time.For this process, it is common to make an estimation of the power spectral density (PSD) of the HRV signal.As shown in Figure 1, very low frequency (VLF) spectral components are obtained in the range 0.0033-0.04Hz [22], low frequency (LF) spectral components in the range of 0.04-0.15Hz, and high frequency (HF) spectral components in the range of 0.15-0.4Hz [19].These components provide clinical information about the variation in the sinus rhythm of the heart.LF components reflect both sympathetic and parasympathetic influences, although LF may be indicative of baroreflex sensitivity [23].HF components are related to the parasympathetic system; thus, the LF/HF ratio is indicative of sympathovagal balance [23].
The power spectral components are quantified by measuring the area under the three frequency bands: VLF power, LF power, and HF power.The spectral components of HRV should be presented in the natural base; hence, a logarithmic transformation could be necessary.In order to ease the comparison among different studies, the components are usually presented in normalized units, according to the following expressions [24]: For the validation of the sensor and the algorithms used, two sets of experiments were carried out.The subjects 2 Journal of Sensors breathed spontaneously but were not allowed to talk.Informed consent was obtained from all subjects.
In the first set of experiments, two ECG signal acquisition experiments with a duration of 5 minutes were performed on a 23-year-old male volunteer weighing 90 kg, having an apparent healthy condition and under different situations.In the experiments, the volunteer remained motionless, without speaking and avoiding any kind of biofeedback.For the first experiment (sitting experiment), the subject was asked to sit in a chair in a comfortable and relaxed manner with the eyes closed.The second experiment (stimuli experiment) was performed under the same conditions as the first experiment, but in this case, the volunteer was subjected to random auditory stimuli with the purpose of analyzing the influence of external disturbances on the ANS.Each of the experiments was in turn repeated on two separate occasions.
In the second set of experiments, a standardized protocol for the study of HRV was used [25], to allow a comparative analysis of the system against results obtained in the previous studies [23,[26][27][28].The study involved 5 volunteers, of apparent healthy condition.Table 1 shows a detail of the anthropometric characteristics of the volunteers.Measurements were performed in the morning.Each subject performed two experiments, each with a duration of five minutes: (i) Rest experiment: the volunteer remains immobile in a supine position.
(ii) Tilt experiment: the volunteer remains immobile in a standing position.

Design Results
3.1.Smart Device Design.Figure 2 shows the design of the smart device following a modular scheme comprising the following elements: (i) Sensing module: its function is to provide an electrochemical interface between the tissue and the electronic measurement subsystem (front-end module) for voltage detection.This interface is performed through the electrode-skin contact, consisting of a metal electrode, an electrolytic gel (usually containing Cl − ), and human skin.For such purpose, three diagnostic DORMO-TAB electrodes (Ag-AgCl pregelled flexible electrodes with dimensions of 26.4 mm × 22.5 mm) were placed on the test users, the first located under the clavicle on the right shoulder, the second under the collarbone on the left shoulder, and the third on the abdomen on the lower left side.These electrodes were connected to the front-end module via cables.
(ii) Front-end module: it is the acquisition element of the monitored signal.It consists of an ECG signal capture system based on an instrumentation amplifier (INA), a feedback circuit through the third electrode, three filter stages, and an amplification step, all implemented through operational amplifiers.
(iii) Processing module: it is responsible for the processing of the ECG signal and the frequency analysis for the spectral estimation of the HRV.An OLIMEX PIC32-PINGÜINO-OTG module has been used for data processing, which can be sent wirelessly in real time.The OLIMEX module makes use of a PIC32MX440F256H microcontroller, with 256 KB of program memory, 32 KB of data memory, and a maximum speed of 80 MHz.
(iv) Communication module: it is responsible for the bidirectional wireless communications of the smart device: the transmission of the result of the signal processing to an external unit (a computer in this first prototype) in one sense, and the reception of configuration commands for the personalization of the processing algorithms in the other.In this case, an RN42-I/RM module from microchip has been used to implement communications based on the Bluetooth standard.
3.2.Design of the Front-End Module.The front-end input stage consists of an INA composed by three operational amplifiers with an approximate gain of 33 dB.The input differential impedance is bootstrapped to increase the input resistance and increase the quality of the signal-to-noise ratio [29,30].Through a voltage follower, the INA common mode is obtained, which is inverted and amplified so that it is subsequently feedbacked through the right leg to obtain an increase of the common-mode rejection ratio (CMRR), reducing the impact of interferences in the output signal [31].
A high-pass filter with a cutoff frequency of 0.5 Hz is then implemented.This filtering is performed from a low-pass filter, with the same cutoff frequency, which feedbacks the continuous level of the INA output signal as its reference voltage.This configuration allows a higher gain in the amplifier avoiding the saturation in the subsequent stages due to a high DC level.
Next, two-unit gain filtering steps are included.The interference of the electrical installation is attenuated by a notch filter adjusted to the frequency of 50 Hz.Then, a low-pass filter is configured with a cutoff frequency of 150 Hz to minimize the effects of other possible sources of noise, usually at a high frequency.Finally, an inverter amplifier with an approximate gain of 30 dB is used as the last gain stage to provide a measurable signal to the analog-to-digital converter (ADC) of the processing module.
The ADC was implemented taking advantage of one of the available peripherals of the PIC32MX440F256H microcontroller, which is the core of the OLIMEX PIC32-PINGÜINO-OTG module.This device allows up to 16channel 10-bit ADC, with a maximum sampling rate of 1000 ksps.Although it was shown that a sampling rate as low as 50 Hz could be used to measure the ECG signal without compromising the accuracy of the calculated time domain HRV parameters [32], other studies recommend the frequency of 200 Hz to avoid possible distortions in the frequency spectrum of the signal [33], the basis of the analysis shown in the present work.For this reason, a sampling frequency of 200 Hz was selected as the working frequency of the device, to minimize computational load and energy consumption, while ensuring a quality in the results after processing.
For the front-end design, surface mount resistors and capacitors of standard size 0603 and surface mount operational amplifiers of the Texas Instruments OPA211 series have been used.The OPA211 was chosen because it has a main characteristic, a very low input noise (80nVpp), and is ideal for medical applications.(i) In a first step, the signal S 0 corresponding to the output signal of the ECG front-end is elevated to the third power.In this way, the signal S 1 is obtained, allowing a better definition of the QRS complex.
(ii) In the second stage, from the second derivative of S 1 , a new signal S 2 is generated corresponding to the following expressions: 4 Journal of Sensors where n represents the current sample.This processing allows the easy detection of the R wave.
(iii) In the third stage, the signal S 3 is obtained as the estimation of the RR intervals, expressed in seconds.
A register of the last maximum values of the R-wave in the signal S 2 is saved, eliminating the older values to dynamically adapt to changes in the amplitude of the signal.
From this register, the detection threshold Th d is defined as 30% of the maximum value of all of them.This threshold allows limiting the search interval of the R-wave.The instant at which the wave is maximum in the search interval is set as the R-instant.A new value is then defined in the RR interval vector as the difference between the current R-instant and the previous one.5 Journal of Sensors (iv) In the fourth stage, the spectral estimation of S 3 using AR models is obtained by the Burg method of order N, where N is a configurable parameter [34].As the signal acquisition time is small, the use of the Burg method is an appropriate option, since it has the advantage of a higher resolution and stability for a small amount of data [35].The algorithm was implemented by following the recommendations described in [36] to improve the frequency estimation.
(v) Finally, in the fifth stage, LF nu , HF nu , and LF/HF parameters were calculated according to the equations and procedures described in the Materials and Methods section.

Validation Results
As a sample of the signals with which the processing module operates, Figure 3 shows the result of the first three stages of the algorithm described in the previous section for a sitting experiment.Figure 3(a) shows a 20-second segment of S 0 output signal from the ECG front-end.Figure 3(b) shows the signal S 1 as a result of raising the S 0 signal to the third power to increase the definition of the QRS complex of the ECG signal.Figure 3(c) shows the signal S 2 , which allows the easy detection of the R wave.Finally, Figure 3(d) shows the complete signal S 3 as the result of the estimation of the RR intervals of the S 2 signal.This last signal represents a time signal distributed along the horizontal axis, also of a temporal nature, which will be the basis of the subsequent analysis in the frequency domain.
Given the interest represented by the calculation of the power spectral density for the analysis of the HRV signal, the Burg parameter N in the fourth stage of the algorithm was optimized.To select the order of the filter, different values were tested from N = 10 to N = 32, which is the recommended range for this type of applications [34], increasing their value in steps of two.
Figure 4 shows the results obtained for some of the analyzed values of the parameter N. The value that allowed a correct spectral estimation was considered as optimum.The smaller the N the smoother the signal, making it difficult to detect the spectral components, while the higher the N the higher the number of peaks generated in the frequency spectrum, thus making it difficult to analyze and requiring in this case a longer computational time.After this analysis, N = 16 was established as the optimal value of the parameter, since it was the minor order that offered an adequate definition of the spectral components.
The implementation of the smart device prototype is shown in Figure 5.
The spectral analysis of the first set of experiments (sitting experiment and stimuli experiment) was applied in a first validation of the device and its processing algorithm.

6
Journal of Sensors This evaluation was done in this case in a qualitative way, analyzing the spectrum of the signals by inspection.Figure 6 shows a comparison of the spectral estimation of two of the experiments performed, in which the spectral components LF and HF are identified.
In the sitting experiment, in which the user was relaxed, it can be seen that the HF component is dominant over the LF component.This outcome is in agreement with the expected result, since in this case, there should be a greater activity of the parasympathetic system above the sympathetic, as it corresponds to a state of rest and relaxed.In the stimuli experiment, the volunteer was subject to different disturbances.In this case, the LF component was dominant, which also agrees with the expected results.
The results obtained encouraged a more detailed study using the standardized protocol described in Materials and Methods section and the second set of experiments (rest experiments and tilt experiments).As an example, Figures 7  and 8 show the HRV spectral estimation of a female volunteer and a male volunteer, respectively.Each of the figures also represents the PSD of the two experiments performed by each volunteer: rest and tilt experiments.In both graphs, an increase in the LF component and a decrease in the HF component are observed when going from the supine position to the standing position.In the case shown in Figure 7, there is even an inversion in the position of the maximum of the spectral components, located in HF during the rest experiment and in LF during the tilt experiment.
To define more precisely the relation between the spectral components when comparing the two cases (rest and tilt), a quantitative analysis was also performed using normalized parameters of the HRV spectral characteristics described above: LF nu , HF nu , and LF/HF.
The use of standardized parameters and a standard protocol favors the comparison with other results in the literature.Table 2 shows the results obtained in this study and a sample of equivalent data obtained by other authors for healthy subjects.2 show results comparable to those found in other studies, both in absolute and relative values.In addition, the same trend and the same relationships between the parameters are observed.LF nu is higher in tilt experiments than in the rest experiments.The reverse is true for HF nu .The LF/HF ratio has a value close to unity in the rest experiments, but is much higher for tilt experiments.
It can also be seen from Table 2 that the maximum and minimum values of the different parameters do not overlap.In this sense, a threshold can then be set for each of the parameters that could be employed in a hypothetical recognition and classification of the experiments.For LF nu , the average value between the maximum value of the parameter in the rest experiments and the minimum value of the parameter in the tilt experiments is set as the classification threshold.The same procedure is used to calculate the threshold of the LF/HF parameter.In contrast, the threshold of the parameter HF nu is calculated as the average value between the minimum value in the rest experiments and the maximum value in the tilt experiments.Table 3 shows the classification rules according to the previous thresholds.
Figure 9 graphically displays the distribution of the parameters around the classification thresholds, marked with a solid line.The graphs also show the confidence interval of 68.27% (±standard deviation) obtained for each parameter in each of the experiments.These intervals are marked with dash lines and serve to highlight the statistical distribution of the results.
Regarding the device performance, Table 4 summarizes some features of the device and compared to a few recent works.The main advantage of the device compared to other commercial and literature proposals is its capacity for the real-time detection of alterations in heart rate variability (HRV) through frequency analysis.To the knowledge of the authors, this capacity is not implemented in portable devices, being the offline analysis from the data stored in memory the most common method [45].
In the first set of experiments, corresponding to the functional evaluation of the front-end, the ECG data captured by the device were wirelessly sent in real time to a computer, acting as the processing module, where they were analyzed with Matlab software (version 2016a).Each sample was sent sequentially by the Bluetooth communication module, used as a serial port, with a transmission rate of 200 samples per second (two bytes per sample).
After these positive results, in the second set of experiments, the algorithm was embedded in the physical processing module of the prototype.Table 5 shows some details of the implementation of the algorithm in the sensor prototype.The second set of experiments was conducted using the device in stand-alone mode according to which the device carried out the following tasks: (ii) On-line S 3 calculation as the estimation of the RR intervals.This process, executed within the device, requires a time of 193 μs to run, enough to be executed in real time whenever a new sample is received at 200 Hz, without interfering with the next sample.
(iii) Every five minutes, estimation of HRV in the frequency domain from the RR intervals.This process, also executed within the device, requires a time of 409.2 ms to run, enough for a real-time application.
(iv) Calculation of LF nu , HF nu , and LF/HF from the PSD of the HRV signal and wireless transmission of the result.
The algorithm was also executed simultaneously on a computer with the ECG samples sent by the device.The coincidence in the results obtained by the device with respect to the computer demonstrates the viability of the prototype for the execution of the proposed algorithm in real time.

Conclusions
In the present work, a first approximation to a smart device and a processing algorithm for the spectral analysis of HRV in real time has been shown.To the best of our knowledge, this capability is not available in any portable ECG measurement device.Under the requirements of low-cost, customizable, and low power consumption, the hardware and software required for ECG signal capture and its subsequent processing have been designed and implemented.
A qualitative validation was performed in two different experiments, repeated twice each.In a first experiment, in which the volunteer was relaxed, the observed spectral components indicated a greater activity of the parasympathetic system above the sympathetic one.In a second experiment, in which the volunteer was subjected to external stimuli, the spectral components showed a greater activity of the sympathetic system above the parasympathetic one.The results obtained in this first approximation show the viability of the device and the algorithms proposed for a real-time qualitative analysis of the ANS and the influence of different perturbations.
For a more exhaustive evaluation, a second set of experiments was performed.Standard parameters were used in the spectral analysis of the HRV as well as a standardized measurement protocol (rest and tilt experiments).A comparative analysis with respect to the results obtained in other studies has shown the validity of both the device and the proposed algorithms for the quantitative evaluation of the HRV spectral components.In addition, a method has been established for the classification of rest and tilt activities from an ECG signal.

Figure 1 :
Figure 1: Example of the signal PSD obtained by the smart device.

3. 3 .
Processing Module.The estimation of HRV in the frequency domain from the ECG signal is obtained by a five-step algorithm:

Figure 3 :
Figure 3: Signals obtained in one of the experiments: (a) fragment of the output signal of the ECG front-end (S 0 ); (b) signal S 1 ; (c) signal S 2 ; (d) RR intervals of the complete signal (S 3 ).

Figure 4 :
Figure 4: Spectral estimation of the HRV of the experimental signal for some of the analyzed orders of the AR model by the Burg method.

Figure 5 :
Figure 5: Prototype of the smart device for the measurement of HRV.

Figure 6 :
Figure 6: Example of the spectral estimation of the first set of experiments: (a) sitting experiment and (b) stimuli experiment.

Figure 7 :
Figure 7: Example of the spectral estimation of HRV (female volunteer) in the second set of experiments.

Figure 8 :
Figure 8: Example of the spectral estimation of HRV (male volunteer) in the second set of experiments.

Figure 9 :
Figure 9: Results of parameters in the second set of experiments: (a) LF nu , (b) HF nu , and (c) LF/HF.
VLF indicates the power of the VLF component.LF/HF ratio is calculated as the ratio of LF nu and HF nu .

Table 1 :
Characteristics of the experiments performed in the second set of experiments (mean value ± standard deviation).

Table 2 :
Comparison of the results obtained with the prototype in the second set of experiments with respect to other studies (mean, standard deviation (SD), maximum (M), and minimum of LF nu , HF nu , and LF/HF).

Table 3 :
Thresholds and classification rules depending on the value of LF nu , HF nu , and LF/HF.

Table 4 :
Characteristics of the experiments performed in the second set of experiments (mean value ± standard deviation).

Table 5 :
Implementation details of the algorithm in the device microcontroller.