# LabVIEW and heart rate variability (+ source)

Good day to all! I study at a technical university and develop software and hardware for processing and recording biomedical signals and data. Since I started doing this about three years ago, at the present time I have accumulated some developments, with one of which I would like to introduce you.

One of the most common biomedical signals is an electrocardiogram. It is its processing that our teaching staff is engaged in. This signal is relatively easy to receive. Currently, only two electrodes applied to the human body are enough to see the electrocardiogram. In our work, we used three electrodes according to the standard Einthoven circuit:

Work began with building the hardware of the device. The whole circuit was assembled on a breadboard. The circuit includes the following components: AD620 biopotential amplifier, Atmega16 microcontroller, AD7739 sigma-delta ADC (8 channels, 24 bits, 16 are actually used). At the beginning of the work, it was possible to see what data the ADC gives out only through the audio file editor using filtering.

In high school, as a student, I studied the program for the controller, where the ADC was initialized, received samples and transferred them to the port. The command system, books on microcontrollers, the game with LEDs ... Then, gradually, with the leader, they began to set mini-tasks for this device.

Once it was decided to visualize the signal and carry out its further processing. Since the employees of our department have experience in the LabVIEW environment, we decided to also try to use it.

Let's pass directly to the software product itself, which turned out as a result of work. Once I asked one experienced LabVIEW developer how much he spent on average writing software, and he replied that a program can be written from two weeks to infinity. And indeed, one always wants to correct something in its final version - there is no limit to perfection!

The program for analyzing heart rate variability includes two main modes: recording an ECG signal and its subsequent analysis. In the first mode, ECG and rhythmograms are recorded and data is written to the file in parallel. So it looks on the front panel:

and the block diagram:

The rhythmogram processing mode is much more complicated than the registration itself. And it includes several components. Firstly, the statistical characteristics of the rhythmogram are calculated, such as HR, MxDMn, Mn, Mx, SDNN, CV, D, RRav, RMSSD, PNN50, SI. In fact, these parameters are the standard deviation, variance, max and min, which are often used in statistics. Just some of them are named differently, and some are a little more complicated in the calculation. For example, SI (stress index) - the index of tension of regulatory systems, is calculated on the basis of a histogram formed by the method of variational pulsometry. The formula for it is as follows:

where Amo is the amplitude of the histogram mode, Mo is the histogram mode, and MxDMn is the difference between the largest and smallest RR intervals.

A histogram is a graphical representation of the grouped values of heart intervals, where time values are plotted along the abscissa axis, and their number in percent on the ordinate axis [1]. To build a histogram, the General Histogram function was used. In fact, all these many different parameters are nothing more than a statistical processing of the heart rhythm. A heart rhythm or rhythmogram is an array of values of the durations of RR intervals, i.e. the time distance between the two largest peaks of the ECG. To determine cardiocycles, you can take not only RR, but also other teeth. This is what the block diagram looks like for isolating heart rhythm from an ECG.

And this is the front panel of the statistical analysis analysis tab:

Along with the above characteristics, a scattergram representing the implementation of the method of correlation rhythmography is displayed in the same window. This is a method of graphically representing the dynamic range of cardio intervals in the form of a “cloud” by constructing a series of points in a rectangular coordinate system. At the same time, each current RR interval is plotted along the ordinate axis, and each subsequent interval along the abscissa axis [2]. The block diagram is as follows:

A lot of time was devoted to the implementation of a spectral analysis of the heart rhythm. Spectral analysis evaluates the contribution of certain periodic components to the dynamics of changes in heart rate. For this purpose, the so-called spectral power of oscillations corresponding to each identified period is estimated. Spectral methods are used almost exclusively for the analysis of short sections of the rhythmogram - from 2 to 5 minutes [3]. The boundaries of each period in domestic medical practice have recently been normalized at one of the largest meetings of specialists in this field. There are specific values for each frequency range. Spectrum Analysis Front Panel:

The autocorrelation function (ACF) graphically represents the statistical relationship of each subsequent RR interval with the previous ones and reflects the degree of centralization of control of regulatory processes. When creating ACF, the Correlation Coefficient function from the Probability and Statistics palette was used.

General view of the block diagram for rhythmogram analysis:

Pairing a PC with hardware is implemented on the VISA library. The maximum speed of the port was set at 115200. According to the latest published data, the range of the electrocardiogram signal can reach maximum frequencies in the region of 500 Hz. But we set up digital filters to limit the width of the spectrum from 0 to 100 Hz.

The device is fully functional and performs ECG registration in real time with simultaneous visualization of data, recording the results of the study and patient data in a file.

Recently, we have included data analysis using

System operation video:

1. The clinical significance of the study of heart rate variability and methods for its assessment.

2. Dembo A.G., Zemtsovsky E.V. Sports Cardiology: A Guide for Physicians. ─ L .: Medicine, 1989 .-- 464 p.

3. Belyaev K.R. Methods for analyzing heart variability.

4. Analysis of heart rate variability when using various electrocardiographic systems (guidelines)

5. Standards of heart rate variability of the Working Group of the European Cardiology Society and the North American Society of Stimulation and Electrophysiology

One of the most common biomedical signals is an electrocardiogram. It is its processing that our teaching staff is engaged in. This signal is relatively easy to receive. Currently, only two electrodes applied to the human body are enough to see the electrocardiogram. In our work, we used three electrodes according to the standard Einthoven circuit:

Work began with building the hardware of the device. The whole circuit was assembled on a breadboard. The circuit includes the following components: AD620 biopotential amplifier, Atmega16 microcontroller, AD7739 sigma-delta ADC (8 channels, 24 bits, 16 are actually used). At the beginning of the work, it was possible to see what data the ADC gives out only through the audio file editor using filtering.

In high school, as a student, I studied the program for the controller, where the ADC was initialized, received samples and transferred them to the port. The command system, books on microcontrollers, the game with LEDs ... Then, gradually, with the leader, they began to set mini-tasks for this device.

Once it was decided to visualize the signal and carry out its further processing. Since the employees of our department have experience in the LabVIEW environment, we decided to also try to use it.

##### Heart Rate Analysis Software

Let's pass directly to the software product itself, which turned out as a result of work. Once I asked one experienced LabVIEW developer how much he spent on average writing software, and he replied that a program can be written from two weeks to infinity. And indeed, one always wants to correct something in its final version - there is no limit to perfection!

The program for analyzing heart rate variability includes two main modes: recording an ECG signal and its subsequent analysis. In the first mode, ECG and rhythmograms are recorded and data is written to the file in parallel. So it looks on the front panel:

and the block diagram:

The rhythmogram processing mode is much more complicated than the registration itself. And it includes several components. Firstly, the statistical characteristics of the rhythmogram are calculated, such as HR, MxDMn, Mn, Mx, SDNN, CV, D, RRav, RMSSD, PNN50, SI. In fact, these parameters are the standard deviation, variance, max and min, which are often used in statistics. Just some of them are named differently, and some are a little more complicated in the calculation. For example, SI (stress index) - the index of tension of regulatory systems, is calculated on the basis of a histogram formed by the method of variational pulsometry. The formula for it is as follows:

where Amo is the amplitude of the histogram mode, Mo is the histogram mode, and MxDMn is the difference between the largest and smallest RR intervals.

A histogram is a graphical representation of the grouped values of heart intervals, where time values are plotted along the abscissa axis, and their number in percent on the ordinate axis [1]. To build a histogram, the General Histogram function was used. In fact, all these many different parameters are nothing more than a statistical processing of the heart rhythm. A heart rhythm or rhythmogram is an array of values of the durations of RR intervals, i.e. the time distance between the two largest peaks of the ECG. To determine cardiocycles, you can take not only RR, but also other teeth. This is what the block diagram looks like for isolating heart rhythm from an ECG.

And this is the front panel of the statistical analysis analysis tab:

Along with the above characteristics, a scattergram representing the implementation of the method of correlation rhythmography is displayed in the same window. This is a method of graphically representing the dynamic range of cardio intervals in the form of a “cloud” by constructing a series of points in a rectangular coordinate system. At the same time, each current RR interval is plotted along the ordinate axis, and each subsequent interval along the abscissa axis [2]. The block diagram is as follows:

A lot of time was devoted to the implementation of a spectral analysis of the heart rhythm. Spectral analysis evaluates the contribution of certain periodic components to the dynamics of changes in heart rate. For this purpose, the so-called spectral power of oscillations corresponding to each identified period is estimated. Spectral methods are used almost exclusively for the analysis of short sections of the rhythmogram - from 2 to 5 minutes [3]. The boundaries of each period in domestic medical practice have recently been normalized at one of the largest meetings of specialists in this field. There are specific values for each frequency range. Spectrum Analysis Front Panel:

The autocorrelation function (ACF) graphically represents the statistical relationship of each subsequent RR interval with the previous ones and reflects the degree of centralization of control of regulatory processes. When creating ACF, the Correlation Coefficient function from the Probability and Statistics palette was used.

General view of the block diagram for rhythmogram analysis:

Pairing a PC with hardware is implemented on the VISA library. The maximum speed of the port was set at 115200. According to the latest published data, the range of the electrocardiogram signal can reach maximum frequencies in the region of 500 Hz. But we set up digital filters to limit the width of the spectrum from 0 to 100 Hz.

The device is fully functional and performs ECG registration in real time with simultaneous visualization of data, recording the results of the study and patient data in a file.

Recently, we have included data analysis using

**non-linear techniques**in the program . I would also like to note that some components of this treatment serve us to assess the emotional state of the subject. The appearance of the device is as follows:System operation video:

**Source code for subframes**#### Literature

1. The clinical significance of the study of heart rate variability and methods for its assessment.

2. Dembo A.G., Zemtsovsky E.V. Sports Cardiology: A Guide for Physicians. ─ L .: Medicine, 1989 .-- 464 p.

3. Belyaev K.R. Methods for analyzing heart variability.

4. Analysis of heart rate variability when using various electrocardiographic systems (guidelines)

5. Standards of heart rate variability of the Working Group of the European Cardiology Society and the North American Society of Stimulation and Electrophysiology