# Real-time Heart Rate Calculation Method

Source: Internet
Author: User
If the sampling rate of the ECG machine is 1000, that is, 1000 data is sampled every second, how can we calculate the heart rate based on the sampled data? Computing the heart rate with a computer can give full play to the powerful computing power of the computer, so you don't have to wait a minute to get the results, just like the artificial heart rate, we only need four seconds of ECG data to use computers to calculate the heart rate. That is, we can use 4000 pieces of data to calculate the heart rate. The instantaneous speed is very good, much stronger than the artificial pulse (the heart rate obtained by the artificial pulse is the average heart rate per minute, not the Instantaneous Heart rate ).

Suppose we want the heart rate to be X, then the mathematical formula for heart rate calculation is as follows (R wave refers to the various fluctuations in the heartbeat in the buffer with a size of 4000 ):
X/(60*1000) = (R wave count-1)/(last R wave position-first R wave position)
Obtain x
X = (60*1000) * (number of R waves-1)/(last R wave position-first R wave position)

In this mathematical formula
(The last R wave position-the first R wave position) is the number of data records between the last R wave and the first R wave. If the sampling rate is 1000, this value is actually the number of milliseconds.
(R wave count-1) the number of Heartbeat cycles that have elapsed in so many milliseconds. Why minus one? Suppose there is a two-dimensional wave spreading along the X axis. How many fluctuation periods are there between two peaks? One. How many fluctuation periods are there between the three peaks? Two. By the way, we need to subtract one and get the number of Heartbeat cycles.

Well, with this formula, we can add a good R wave detection.AlgorithmAnd then write a FIFO queue as the buffer zone to achieve real-time cardiac display on the ECG machine.

The implementation of the first-in-first-out queue is relatively simple. I use a queue with a maximum of 4000 word data. If the data reaches 4000, when adding data, we need to squeeze out the earliest data.

However, the R wave detection algorithm is not perfect. After all, the computer is still stupid. It is not as clever as a person. Sometimes, there will be missed checks. For example, there are five R waves in the buffer zone, but only four are detected, the heart rate calculated at this time is low and inaccurate. Although for the Instantaneous Heart rate, the wrong heart rate may only Flash and soon become normal, it is not perfect. I think the solution to this problem is called the "dual-line competition law" (I wrote it by myself:-), because there are a total of 15 links on the ECG machine, the usual practice is to calculate the heart rate with the most signal chest guide. To solve the arrhythmia error caused by r-wave missed detection, we can use two buffers to calculate the heart rate of the two thoracic guides respectively, and then use a larger one of the two heart rate values.

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.