A heart rate detection method, device and readable storage medium based on electrocardiogram signal
By pre-processing, segmented flip and convolution processing of the ECG signal, combined with adaptive threshold detection, the problem of insufficient accuracy and stability in heart rate detection is solved, and more efficient heart rate information extraction is achieved.
Patent Information
- Application Number
- CN202510408893.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-02
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2045-04-02
AI Technical Summary
When existing heart rate detection methods face interference from factors such as skin color difference, movement status, ambient light and poor electrode contact, they lack accuracy and stability, making it difficult to effectively identify R waves and calculate heart rate.
By preprocessing the original ECG signal, flipping in segments, convolution with the reference signal, peak detection and other steps, the frequency and phase information of the signal are extracted, the peak data is detected using adaptive thresholds, and the heart rate information is calculated.
It significantly improves the accuracy and anti-interference ability of heart rate detection, can more accurately identify R waves and calculate heart rate, and improves the stability of heart rate detection.
Smart Images

Figure CN119908693B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of diagnosis, and in particular to a heart rate detection method based on electrocardiogram (ECG) signals. Background Art
[0002] As a common and indispensable tool for monitoring heart health, the electrocardiogram (ECG) waveform is complex and intricate, consisting of key components such as the P wave, QRS complex, and T wave. These waveforms each reflect the heart's activity at different physiological stages, with the QRS complex being particularly prominent. The R wave, as the peak of the QRS complex, is crucial in ECG signal analysis. The R wave not only possesses distinct characteristics but also carries crucial information for calculating the time difference between two adjacent R peaks (i.e., the RR interval). Accurately calculating this time difference is fundamental to heart rate estimation and is crucial for assessing heart rate and rhythm.
[0003] When it comes to ECG heart rate detection, current mainstream methods rely on filtering techniques to extract valid ECG signals. Filters, such as low-pass, high-pass, or band-pass filters, effectively remove noise and interference from ECG signals by precisely controlling their frequency range. This step is crucial for subsequent ECG signal analysis, as it directly impacts the accuracy and reliability of subsequent peak detection or R-wave identification.
[0004] After filtering, researchers typically use two methods to identify R waves and calculate heart rate. One involves setting a reasonable threshold for peak detection, locating the R wave by comparing the ECG signal's amplitude with the preset threshold. The other employs more complex algorithms, such as the Pan-Tompkins algorithm and wavelet transform. These algorithms can more accurately identify R waves and effectively address noise and variability in ECG signals. However, while these methods achieve good detection results in most cases, they still face numerous challenges in practical applications. Due to interference from various factors, such as skin color, movement, ambient light, and poor electrode contact, the collected ECG signals are often accompanied by a certain degree of noise and interference. This noise and interference not only increases the complexity of heart rate detection but also poses a significant challenge to its accuracy. Therefore, further improving filtering algorithms, enhancing the accuracy and stability of R-wave identification, and developing more robust heart rate detection methods remain important challenges in the field of ECG signal processing. Summary of the Invention
[0005] The purpose of the present invention is to provide a heart rate detection method based on electrocardiogram signals, aiming to solve the problem of insufficient accuracy and stability of existing heart rate detection. The heart rate detection of electrocardiogram signals provided in this application includes:
[0006] A first aspect of an embodiment of the present application provides a heart rate detection method based on an electrocardiogram signal, comprising:
[0007] Obtain original ECG signal;
[0008] Preprocessing the original electrocardiogram signal to obtain a preprocessed electrocardiogram signal;
[0009] Segmenting the preprocessed ECG signal to obtain multiple segments of preprocessed ECG signals;
[0010] Flipping the multiple segments of pre-processed ECG signals in the time domain to obtain multiple segments of reference signals;
[0011] Convolving the preprocessed ECG signal of each segment with the reference signal of the corresponding segment to obtain a signal to be detected;
[0012] Perform peak detection based on the signal to be detected to obtain multiple peak data;
[0013] Heart rate information is calculated based on the peak data.
[0014] Based on the heart rate detection method based on electrocardiogram signals provided in the first aspect of the embodiment of the present application, optionally, the preprocessing process includes:
[0015] performing bandpass filtering on the original electrocardiogram signal to obtain a first intermediate signal;
[0016] performing secondary differential filtering on the first intermediate signal to obtain a second intermediate signal;
[0017] performing an absolute value operation on the second intermediate signal to obtain a third intermediate signal;
[0018] Set the sliding integration window length;
[0019] Perform sliding integration on the third intermediate signal to obtain a preprocessed electrocardiogram signal.
[0020] Based on the heart rate detection method based on the electrocardiogram signal provided in the first aspect of the embodiment of the present application, optionally, segmenting the preprocessed electrocardiogram signal includes:
[0021] Set the reference signal window duration;
[0022] The preprocessed electrocardiogram signal is segmented based on the reference signal window duration.
[0023] Based on the heart rate detection method based on ECG signals provided in the first aspect of the embodiment of the present application, optionally, the multiple segments of pre-processed ECG signals are flipped in the time domain to obtain multiple segments of reference signals, including:
[0024] Normalization processing is performed on the multiple segments of pre-processed ECG signals, and each segment of the reference signal is flipped in the time domain to obtain multiple segments of reference signals.
[0025] Based on the heart rate detection method based on ECG signals provided in the first aspect of the embodiment of the present application, optionally, convolving each segment of the preprocessed ECG signal with the reference signal of the corresponding segment to obtain the signal to be detected includes:
[0026] Convolving the preprocessed ECG signal of each segment with the reference signal of the corresponding segment based on Fourier transform to obtain the frequency domain preprocessed ECG signal of each segment and the frequency domain reference signal of the corresponding segment;
[0027] Multiplying each segment of the frequency domain preprocessed ECG signal with the corresponding segment of the frequency domain reference signal to obtain the frequency domain signal to be detected;
[0028] The frequency domain signal to be detected is processed based on inverse fast Fourier transform to obtain the signal to be detected.
[0029] Based on the heart rate detection method based on ECG signals provided in the first aspect of the embodiment of the present application, optionally, after the step of convolving each segment of the preprocessed ECG signal with the corresponding segment of the reference signal to obtain the signal to be detected, and before performing peak detection based on the signal to be detected to obtain multiple peak data, the method further includes:
[0030] The signal to be detected is used as the preprocessed signal, and the preprocessed ECG signal is segmented again to obtain multiple segments of preprocessed ECG signals. The multiple segments of preprocessed ECG signals are flipped in the time domain to obtain multiple segments of reference signals. Each segment of the preprocessed ECG signal is convolved with the reference signal of the corresponding segment to obtain the signal to be detected.
[0031] Based on the heart rate detection method based on the electrocardiogram signal provided in the first aspect of the embodiment of the present application, optionally, performing peak detection based on the signal to be detected to obtain multiple peak data includes:
[0032] Set the duration of the peak detection sliding window;
[0033] Calculating the mean and standard deviation of the signal to be detected within the peak detection sliding window;
[0034] calculating an adaptive threshold based on the mean and standard deviation;
[0035] extracting a plurality of candidate regions whose detection signals are greater than the adaptive threshold;
[0036] The maximum value is determined as peak data in each of the multiple candidate areas to obtain multiple peak data.
[0037] A second aspect of an embodiment of the present application provides a heart rate detection device based on an electrocardiogram signal, comprising:
[0038] An acquisition unit, used for acquiring original ECG signals;
[0039] a preprocessing unit, configured to preprocess the original ECG signal to obtain a preprocessed ECG signal;
[0040] A segmentation unit, configured to segment the preprocessed ECG signal to obtain multiple segments of preprocessed ECG signals;
[0041] A flipping unit, configured to flip the plurality of pre-processed ECG signals in the time domain to obtain a plurality of reference signals;
[0042] a convolution unit, configured to convolve the preprocessed ECG signal of each segment with the reference signal of the corresponding segment to obtain a signal to be detected;
[0043] A detection unit, configured to perform peak detection based on the signal to be detected to obtain a plurality of peak data;
[0044] A calculation unit is used to calculate the heart rate information based on the peak data.
[0045] In the heart rate detection device based on an electrocardiogram signal provided in the second aspect of the embodiment of the present application, optionally, the preprocessing unit is specifically configured to:
[0046] performing bandpass filtering on the original electrocardiogram signal to obtain a first intermediate signal;
[0047] performing secondary differential filtering on the first intermediate signal to obtain a second intermediate signal;
[0048] performing an absolute value operation on the second intermediate signal to obtain a third intermediate signal;
[0049] Set the sliding integration window length;
[0050] Perform sliding integration on the third intermediate signal to obtain a preprocessed electrocardiogram signal.
[0051] According to the second aspect of the embodiment of the present application, a heart rate detection device based on an electrocardiogram signal is provided. Optionally, the segmentation unit is specifically configured to:
[0052] Set the reference signal window duration;
[0053] The preprocessed electrocardiogram signal is segmented based on the reference signal window duration.
[0054] According to the second aspect of the embodiment of the present application, a heart rate detection device based on an electrocardiogram signal is provided. Optionally, the flip unit is specifically configured to:
[0055] Normalization processing is performed on the multiple segments of pre-processed ECG signals, and each segment of the reference signal is flipped in the time domain to obtain multiple segments of reference signals.
[0056] According to the second aspect of the embodiment of the present application, a heart rate detection device based on an electrocardiogram signal is provided. Optionally, the convolution unit is specifically configured to:
[0057] Convolving the preprocessed ECG signal of each segment with the reference signal of the corresponding segment based on Fourier transform to obtain the frequency domain preprocessed ECG signal of each segment and the frequency domain reference signal of the corresponding segment;
[0058] Multiplying each segment of the frequency domain preprocessed ECG signal with the corresponding segment of the frequency domain reference signal to obtain the frequency domain signal to be detected;
[0059] The frequency domain signal to be detected is processed based on inverse fast Fourier transform to obtain the signal to be detected.
[0060] According to the second aspect of the embodiment of the present application, a heart rate detection device based on an electrocardiogram signal is provided, optionally, the device further includes:
[0061] An iterative unit, configured to: convert the signal to be detected into a reference signal;
[0062] Retrigger the convolution unit.
[0063] According to the second aspect of the embodiment of the present application, a heart rate detection device based on an electrocardiogram signal is provided, optionally,
[0064] The detection unit is specifically used for:
[0065] Set the duration of the peak detection sliding window;
[0066] Calculating the mean and standard deviation of the signal to be detected within the peak detection sliding window;
[0067] calculating an adaptive threshold based on the mean and standard deviation;
[0068] extracting a plurality of candidate regions whose detection signals are greater than the adaptive threshold;
[0069] The maximum value is determined as peak data in each of the multiple candidate areas to obtain multiple peak data.
[0070] A third aspect of the embodiments of the present application provides a heart rate detection device based on an electrocardiogram signal, comprising:
[0071] CPU, memory, input and output interfaces, wired or wireless network interfaces, and power supply;
[0072] The memory is a transient storage memory or a persistent storage memory;
[0073] The central processing unit is configured to communicate with the memory and execute instruction operations in the memory on the device to perform the method described in any one of the first aspects of the embodiments of the present application.
[0074] A fourth aspect of the embodiments of the present application provides a computer-readable storage medium, comprising instructions, which, when executed on a computer, enable the computer to execute the method described in any one of the first aspects of the embodiments of the present application.
[0075] A fifth aspect of the embodiments of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any one of the methods described in the first aspect of the embodiments of the present application.
[0076] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages: The present application provides a heart rate detection method based on an ECG signal, comprising: obtaining an original ECG signal; preprocessing the original ECG signal to obtain a preprocessed ECG signal; segmenting the preprocessed ECG signal to obtain multiple segments of preprocessed ECG signals; flipping the multiple segments of preprocessed ECG signals in the time domain to obtain multiple segments of reference signals; convolving each segment of the preprocessed ECG signal with the corresponding segment of the reference signal to obtain a signal to be detected; performing peak detection based on the signal to be detected to obtain multiple peak data; and calculating the heart rate information based on the peak data. Based on the above method, by comparing the similarity between the original signal and the reference signal, the reference signal obtained after flipping retains the original frequency information, while the noise is eliminated, so that the frequency and phase information of the original signal can be effectively extracted, significantly improving the accuracy and anti-interference ability of heart rate detection. The present application also provides a heart rate detection device and a readable storage medium, which have the same beneficial effects as the above method. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] To more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present application. A person of ordinary skill in the art can also derive other drawings based on the provided drawings without inventive effort. It should be understood that the drawings provided in this section are only used to better understand the present solution and do not constitute a limitation of the present application.
[0078] Figure 1This is a flow chart of an embodiment of a heart rate detection method based on electrocardiogram signals provided in this application.
[0079] Figure 2 This is a schematic diagram of the processing flow of the raw ECG signal preprocessing stage provided in this application.
[0080] Figure 3 A schematic diagram of the original ECG signal provided in this application.
[0081] Figure 4 A schematic diagram of the preprocessed signal provided in this application.
[0082] Figure 5 A schematic diagram of the convolution processing process based on the reference signal provided in this application.
[0083] Figure 6 This is a schematic diagram of the signal to be detected provided by this application.
[0084] Figure 7 This is a schematic diagram of heart rate detection based on the signal to be detected provided in this application.
[0085] Figure 8 A structural diagram of a heart rate detection device based on electrocardiogram signals provided in this application;
[0086] Figure 9 This is another structural schematic diagram of the heart rate detection device based on electrocardiogram signals provided in this application. DETAILED DESCRIPTION
[0087] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application are clearly and completely described below. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work should fall within the scope of protection of this application. At the same time, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0088] The terms "first," "second," "third," "fourth," and so forth (if any) in the specification and claims of this application and in the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that shown or described herein. In addition, the terms "including" and "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, product, or apparatus comprising a series of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, product, or apparatus.
[0089] As a common and indispensable tool for monitoring heart health, the electrocardiogram (ECG) waveform is complex and intricate, consisting of key components such as the P wave, QRS complex, and T wave. These waveforms each reflect the heart's activity at different physiological stages, with the QRS complex being particularly prominent. The R wave, as the peak of the QRS complex, is crucial in ECG signal analysis. The R wave not only possesses distinct characteristics but also carries crucial information for calculating the time difference between two adjacent R peaks (i.e., the RR interval). Accurately calculating this time difference is fundamental to heart rate estimation and is crucial for assessing heart rate and rhythm.
[0090] When it comes to ECG heart rate detection, current mainstream methods rely on filtering techniques to extract valid ECG signals. Filters, such as low-pass, high-pass, or band-pass filters, precisely control the frequency range to effectively remove noise and interference from ECG signals, such as myoelectric interference, baseline drift, and power frequency interference. This step is crucial for subsequent ECG signal analysis, as it directly impacts the accuracy and reliability of subsequent peak detection or R-wave identification.
[0091] After filtering, researchers typically use two methods to identify R waves and calculate heart rate. One involves setting a reasonable threshold for peak detection, locating the R wave by comparing the ECG signal's amplitude with the preset threshold. The other employs more complex algorithms, such as the Pan-Tompkins algorithm and wavelet transform. These algorithms can more accurately identify R waves and effectively address noise and variability in ECG signals. However, while these methods achieve good detection results in most cases, they still face numerous challenges in practical applications. Due to interference from various factors, such as skin color, movement, ambient light, and poor electrode contact, the collected ECG signals are often accompanied by a certain degree of noise and interference. This noise and interference not only increases the complexity of heart rate detection but also poses a significant challenge to its accuracy. Therefore, further improving filtering algorithms, enhancing the accuracy and stability of R-wave identification, and developing more robust heart rate detection methods remain important challenges in the field of ECG signal processing.
[0092] To solve the above problems, this application provides a heart rate detection method based on ECG signal. Figure 1 An embodiment of a heart rate detection method based on electrocardiogram signals provided in the present application includes: steps 101 to 107.
[0093] 101. Obtain the original ECG signal.
[0094] Typically, ECG signals are collected from the human body using electrocardiogram (ECG) devices. These devices typically contain multiple electrodes placed at specific locations on the body (such as the chest or limbs) to capture the heart's electrical activity. The collected ECG signals are analog and may contain noise and interference. This solution uses a wrist ECG watch to collect raw ECG signals. As an everyday wearable device, wrist ECG watches can easily collect the user's raw ECG signals.
[0095] 102. Preprocess the original ECG signal to obtain a preprocessed ECG signal.
[0096] Specifically, the raw ECG signal is preprocessed to obtain a preprocessed ECG signal. The preprocessing step is intended to improve the quality of the ECG signal, making it more suitable for subsequent analysis. Preprocessing typically includes operations such as filtering and denoising. In actual implementation, preprocessing methods such as bandpass filtering and differential filtering may be used. The specific preprocessing method can be determined based on actual conditions and is not limited here.
[0097] 103. Segment the preprocessed ECG signal to obtain multiple segments of preprocessed ECG signals.
[0098] Specifically, the ECG signal is usually a continuous signal. In order to reduce the data processing pressure and facilitate analysis and processing, it needs to be divided into multiple shorter segments. The length of the segment depends on the actual equipment situation and application analysis requirements. It should be noted that the pre-processed ECG signal after segmentation needs to be used for heart rate analysis, and the heart rate determination requires analysis of the peak interval in the signal. Therefore, the segmented ECG signal should include at least two peak values, that is, the duration after segmentation should be at least not less than the interval between the two peaks. There is no specific limitation here.
[0099] 104. Flip the multiple segments of pre-processed ECG signals in the time domain to obtain multiple segments of reference signals.
[0100] Specifically, each of the multiple pre-processed ECG signals is flipped in the time domain to obtain multiple reference signals.
[0101] The flipping operation means reversing the time axis of the signal, that is, the signal point that was originally in front is now in the back, and vice versa. The flipped signal is used as the reference signal for convolution with the original signal. Here, the input signal itself is defined as the reference signal after flipping. By comparing the similarity between the received signal and the pre-set reference signal, the frequency and phase information of the signal can be effectively extracted to achieve the purpose of signal enhancement, which helps to detect heart rate more accurately and quickly. The specific reasons are as follows:
[0102] 1) Temporal Symmetry: The flipped signal can better capture the temporal characteristics of the signal. If the input signal is temporally symmetric, comparing the flipped signal with itself can effectively identify similar parts of the signal.
[0103] 2) Improving Correlation: Flipping the signal helps improve its correlation, allowing the corresponding part of the signal to be accurately found even in the presence of time delays. This is particularly important when processing time-varying signals.
[0104] 3) Simplified computation: By using a flipped signal, the problem can be transformed into finding the correlation between the signal and the reference, which can then be efficiently computed through operations such as convolution. This approach is particularly effective in the frequency domain.
[0105] 4) Reduce the impact of noise: Flipping the signal helps reduce the impact of noise on signal similarity calculation, thereby improving the accuracy of signal detection.
[0106] 105. Convolve the preprocessed ECG signal of each segment with the reference signal of the corresponding segment to obtain a signal to be detected.
[0107] Specifically, each segment of the preprocessed ECG signal is convolved with the corresponding segment of the reference signal to produce a signal to be detected. Convolution is a mathematical operation that multiplies two signals (in this case, the preprocessed ECG signal and the flipped reference signal) sequentially in time and then sums them. The result of the convolution is a new signal that reflects the similarity between the two signals. The convolution operation is used to detect specific features or patterns in the ECG signal, effectively extracting the signal's frequency and phase information, thereby achieving signal enhancement.
[0108] 106. Perform peak detection based on the signal to be detected to obtain multiple peak data.
[0109] Specifically, peak detection is performed based on the signal to be detected to obtain multiple peak data points. Peak detection is the process of identifying local maxima in a signal. In ECG signal processing, peaks typically correspond to the location of the R wave (ventricular depolarization wave). By detecting these peaks, information about the heartbeat can be obtained. After processing in steps 101 to 104, the peak position of the signal to be detected has changed, but the frequency information is still retained and amplified. Therefore, the peak data obtained based on the identification of the signal to be detected is more accurate. In actual implementation, peak detection can use techniques such as threshold setting and window sliding to ensure accurate peak identification and eliminate noise interference. The specific means can be determined according to actual conditions and are not limited here.
[0110] 107. Calculate and obtain heart rate information based on the peak data.
[0111] Specifically, heart rate information is calculated based on the peak data. Peak data carries time information, and corresponding heart rate information is calculated based on the time intervals between multiple peak data points, providing information about the heart's activity rate. Furthermore, parameters such as heart rate variability can be further analyzed to assess heart health.
[0112] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages: The present application provides a heart rate detection method based on an ECG signal, comprising: obtaining an original ECG signal; preprocessing the original ECG signal to obtain a preprocessed ECG signal; segmenting the preprocessed ECG signal to obtain multiple segments of preprocessed ECG signals; flipping the multiple segments of preprocessed ECG signals in the time domain to obtain multiple segments of reference signals; convolving each segment of the preprocessed ECG signal with the corresponding segment of the reference signal to obtain a signal to be detected; performing peak detection based on the signal to be detected to obtain multiple peak data; and calculating the heart rate information based on the peak data. Based on the above method, by comparing the similarity between the original signal and the reference signal, the reference signal obtained after flipping retains the original frequency information, while the noise is eliminated, so that the frequency and phase information of the original signal can be effectively extracted, significantly improving the accuracy and anti-interference ability of heart rate detection. The present application also provides a heart rate detection device and a readable storage medium, which have the same beneficial effects as the above method.
[0113] In order to facilitate the use of this method in actual processes, this application also provides a more detailed embodiment that can be optionally implemented. This embodiment consists of three stages: preprocessing stage, convolution processing stage and heart rate data calculation stage. For details, please refer to Figure 2 、 Figure 5 and Figure 7 , which are described one by one below.
[0114] Figure 2 The processing flow diagram of the preprocessing stage provided in this application includes: steps 201 to 206.
[0115] 201. Obtain original ECG signals.
[0116] Specifically, the process of obtaining the original ECG signal is similar to Figure 1 The corresponding embodiment is similar to step 101, and the details can be referred to the above content, which will not be repeated here. Figure 3 , Figure 3 This is a schematic diagram of the original ECG signal provided in this application.
[0117] 202. Perform bandpass filtering on the original electrocardiogram signal to obtain a first intermediate signal.
[0118] Specifically, the original ECG signal is band-pass filtered to obtain a first intermediate signal. The design of the filter and the selection of parameters need to comprehensively consider factors such as signal characteristics, filter performance and actual application needs, and make reasonable selections and adjustments. At the same time, the frequency range of resting heart rate will also be affected by individual differences, age, physical condition and other factors. Therefore, personalized adjustment and optimization are required in actual applications. The heart rate detection range of normal adults is usually 30bpm to 180bpm, and the frequency range of the QRS waveform representing the heart rate signal contained in the ECG signal is usually between 5 Hz and 15 Hz. Therefore, the passband range of the band-pass filter can be set to 0.5Hz, The filter is set to 15Hz to retain most of the energy required for heart rate detection in the R wave band and remove noise. That is, the filter parameters are set to:
[0119]
[0120] 203. Perform secondary differential filtering on the first intermediate signal to obtain a second intermediate signal.
[0121] Specifically, after the original signal is band-pass filtered, the first intermediate signal is subjected to secondary differential filtering to obtain the second intermediate signal. Differential filtering calculates the derivative by slightly offsetting the signal and taking the difference, so as to better remove the low-frequency components in the signal and highlight the high-frequency components in the signal, thereby ensuring the stability of the baseline. In this solution, by performing secondary differential filtering on the signal after the heart rate band-pass filtering in the ECG resting scene, the slope of the R wave is enhanced while the P wave and T wave are suppressed. In the actual processing process, a secondary differential operation will be performed from the 3rd data to the Lth data point, and the differential formula is as follows:
[0122]
[0123] In actual implementation, this step may also be processed using a quadratic moving average removal or a quadratic median filtering method, which is not specifically limited here.
[0124] 204. Perform an absolute value operation on the second intermediate signal to obtain a third intermediate signal.
[0125] Specifically, the absolute value of the second intermediate signal is taken to obtain the third intermediate signal. That is, the positive value operation is performed on all L data points, so that the output after the above-mentioned secondary differential filtering is nonlinearly amplified, avoiding the peak pointing downward and preventing the appearance of an inverted R peak. The specific formula is as follows:
[0126]
[0127] 205. Set the sliding integration window length.
[0128] 206. Perform sliding integration on the third intermediate signal to obtain a preprocessed ECG signal.
[0129] Specifically, the ECG signal after the positive operation of all L data points is subjected to sliding window integration to enhance the amplitude of the R wave and obtain the candidate R peak. In this step, the most important thing is to design the sliding window integration window length. Generally speaking, the data length should be long enough to ensure that the filter can accurately capture the candidate R peak. If the integration window length is not long enough, high-frequency noise similar to the R wave morphology is likely to be obtained, making it impossible for the algorithm to distinguish the candidate R peak well, which will directly lead to false detection. The detection range of the heart rate in the ECG signal is usually 30bpm to 180bpm, so 0.5 to 3 peaks can be detected in a one-second data window, that is, at most 3 heart rate peaks can be generated within 1000ms. The sliding window integration window length can be designed to be about 300ms, approximately The data length.
[0130] The sliding window integral formula can be expressed as:
[0131]
[0132] Since the subscript of the formula in step 203 starts from 3, the sliding window integral formula needs to start from data points, forward The data length is integrated by sliding window to obtain the preprocessed signal. Specifically, the pattern of the preprocessed signal can be referred to Figure 4 .
[0133] After the preprocessing is completed, the preprocessed signal can be used to generate a reference signal, and convolution is performed based on the reference signal and the preprocessed signal to further extract the frequency and phase information of the signal, thereby extracting more accurate heart rate information. The specific convolution process can be referred to Figure 5 , including: steps 501 to 508.
[0134] 501. Set the reference signal window duration.
[0135] The reference signal window length directly affects the accuracy and robustness of heart rate detection. Generally, the window length should be selected based on the sampling rate of the ECG signal and the range of change of the heart rate. In general, the data length should be long enough to ensure that the reference signal can accurately match the shape of the input signal. However, too long a data length will also lead to an increase in computational complexity and an expansion of the amplitude range after signal enhancement, thereby reducing the real-time performance of ECG signal heart rate detection. In the present invention, the optimal data length of the reference signal is determined through experiments and simulations. The time duration is 5-10s, which can ensure the accuracy of the filter while keeping the computational complexity within an acceptable range.
[0136] 502. Segment the preprocessed ECG signal based on the reference signal window duration.
[0137] In order to ensure the real-time performance of the filtering and heart rate detection algorithm, it is assumed that L sequences are input and the sampling rate is The original ECG data is divided into The group has small data segments with a data length of t seconds, and each small data segment is represented as , the length of each data segment satisfies:
[0138]
[0139] 503. Normalize the multiple segments of pre-processed ECG signals, and flip each segment of the reference signal in the time domain to obtain multiple segments of reference signals.
[0140] Each segment described in step 502 The data in the data window Perform normalization operation, subscript from 0 to In order to avoid excessive convolution and amplitude after signal enhancement, the specific formula is as follows:
[0141]
[0142] in, is the sample index of the integrated signal.
[0143] The periodic signal has the same periodic characteristics as the signal itself, and the optimal sampling time is:
[0144]
[0145] The signal-to-noise ratio between the instantaneous square power of the signal at the output and the noise power reaches the maximum value, so that when the signal and noise are input at the same time, the signal component will reach a peak at a certain moment, while the noise component will be suppressed, thereby achieving the purpose of signal enhancement.
[0146] Therefore, in the S24 operation, for each segment described in step 502 Get the reference signal within the data window :
[0147]
[0148] 504. Convolve the preprocessed ECG signal of each segment with the reference signal of the corresponding segment based on Fourier transform to obtain the frequency domain preprocessed ECG signal of each segment and the frequency domain reference signal of the corresponding segment.
[0149] Specifically, in the time domain, the signal enhancement algorithm can be implemented by the convolution and formula of discrete signals. Specifically, given the part Input signal segments and its reference signal Output value of the convolution operation The formula is:
[0150]
[0151] Represents the input sliding window integral signal at a given The value of the location point, Represents the reference signal in The value of the location point, Represents the input signal position index, Represents the output signal position index. From the above formula, it can be seen that the computational complexity in the time domain is directly affected by the parameter sampling rate. The influence of the signal window length leads to high computational complexity, such as When It is obviously unreasonable to perform convolution operation on the data, so we can calculate it from the frequency domain. That is, we need to convolve each segment of the pre-processed ECG signal and the corresponding segment of the reference signal based on Fourier transform to obtain each segment of the frequency domain pre-processed ECG signal and the corresponding segment of the frequency domain reference signal.
[0152] Integrate signal segments separately and its reference signal The Fourier transform of the input signal segment The Fourier transform result of , and its reference signal The Fourier transform result of .
[0153]
[0154] in is the sample index in the frequency domain, is the sample index in the time domain, is the length of the discrete Fourier transform, Represents an imaginary unit.
[0155] 505. Multiply each segment of the frequency domain preprocessed ECG signal and the corresponding segment of the frequency domain reference signal to obtain a frequency domain signal to be detected.
[0156] In the convolution formula of step 504, the time-domain convolution operation between the preprocessed signal and the reference signal can be converted into a frequency-domain multiplication operation according to the convolution theorem. Specifically, the convolution theorem states that performing a time-domain convolution operation on two signals is equivalent to performing a product operation on the two signals in the frequency domain and then performing an inverse Fourier transform to obtain the time-domain result. Therefore, we have:
[0157]
[0158] in, represents the output signal in step 504 In the frequency domain The complex value corresponding to each discrete frequency.
[0159] 506. Process the frequency domain signal to be detected based on inverse fast Fourier transform to obtain the signal to be detected.
[0160] The inverse fast Fourier transform (IFFT) is the inverse operation of the Fourier transform, which can convert frequency domain data back to time domain data. Specifically, the frequency domain signal to be detected is processed based on the IFFT to obtain the signal to be detected. The formula used is as follows:
[0161]
[0162] in, Representatives Perform inverse Fourier transform to obtain time domain data.
[0163] Finally got This is the signal to be detected. The signal to be detected diagram obtained after processing can be referred to Figure 6 , Figure 6 This is a schematic diagram of the signal to be detected provided in this application.
[0164] 507. Convert the signal to be detected into a reference signal and perform iteration.
[0165] It is worth noting that based on step 506 There may still be a certain deviation in accuracy. In this case, the signal to be detected can be converted into a reference signal; and the step of convolving each segment of the pre-processed ECG signal with the corresponding segment of the reference signal to obtain the signal to be detected can be re-executed. Specifically, the signal to be detected can be processed based on the methods described in steps 502 and 503 to obtain a new reference signal, and the new reference signal and the pre-processed signal are processed as described in steps 504 to 506. That is, the first output result of step 506 does not directly enter the processing process of the subsequent step 508, but is re-iterated and the final iterative result is used as the signal to be detected and entered into step 508 for processing, thereby further refining the estimation of the target result. In actual implementation, the number of iterations depends on the actual situation. Specifically, it can be set to a fixed number of iterations, that is, the number of steps 504 to 506 is set to 3 or 5 times. When the number of repetitions meets the preset requirements, step 508 is executed to perform heart rate detection based on the results of the repeated execution. The output result of step 506 may also be analyzed. If the output result meets specific requirements, the iteration result is determined to be relatively accurate, and step 508 is executed. In actual implementation, the specific settings may be determined according to actual conditions and are not limited here.
[0166] 508. Perform heart rate detection based on the signal to be detected.
[0167] Specifically, the heart rate detection is performed based on the iterated signal to be detected. Figure 7 The corresponding embodiments are not described in detail here.
[0168] Figure 7 This is a schematic diagram of a heart rate detection process based on a signal to be detected provided by the present application, including: steps 701 to 706.
[0169] 701. Set the duration of the peak detection sliding window.
[0170] The calculation of heart rate usually depends on the accuracy of R-peak detection. In adaptive peak detection, the output value can be compared with the current mean and standard deviation. If the output exceeds a certain multiple of the current mean and standard deviation, it will be considered a peak, and the peak detection threshold will be adaptively adjusted as the data changes. To perform peak detection, the peak detection process first needs to set the duration of the peak detection sliding window. In actual implementation, the duration of the peak detection sliding window can be set according to actual needs and is not limited here.
[0171] 702. Calculate the mean and standard deviation of the signal to be detected in the peak detection sliding window.
[0172] To dynamically adjust the threshold for adaptive peak detection, the mean and standard deviation of the signal are calculated within a sliding window. These two parameters determine the baseline level and fluctuation amplitude of the signal, respectively.
[0173]
[0174]
[0175] in is the mean, is the standard deviation, is the signal value, N is the window size used to calculate the mean, and m is the current time.
[0176] 703. Calculate an adaptive threshold based on the mean and standard deviation;
[0177] Based on the mean and standard deviation of the current signal, an adaptive detection threshold is set. The threshold is usually a multiple of the mean and standard deviation, representing the significance of the signal change. The formula for calculating the adaptive threshold is as follows:
[0178] .
[0179] 704. Extract multiple candidate regions whose detection signals are greater than the adaptive threshold;
[0180] 705 . Determine the maximum value in each of the multiple candidate regions as peak data to obtain multiple peak data.
[0181] When the signal value Exceeding the threshold When the signal exceeds the threshold, it can be considered a potential peak region. However, simply exceeding the threshold is not enough to determine the existence of a peak, because sometimes the signal fluctuates for a short period of time. Therefore, the peak maximum strategy is usually adopted. That is, in the region where the signal exceeds the threshold, the maximum value in the region is selected as the final peak value, ensuring that the detected peak is the maximum value of the candidate peak region.
[0182] The specific formula is:
[0183]
[0184] 706. Calculate and obtain heart rate information based on the peak data.
[0185] The RR interval refers to the time interval between two adjacent R peaks in the ECG signal. Changes in the RR interval not only reflect the speed of the heart rate, but are also closely related to the activity of the autonomic nervous system, and can provide deeper insights into the health status of the heart. By accurately calculating the RR interval, the real-time heart rate (HR) of the ECG signal can be effectively estimated, thereby providing important data support for heart health monitoring. The specific RR period is the time interval between two adjacent peak data. Based on the multiple peak data obtained in step 705 above, multiple RR periods can be calculated. Specifically, the calculation of the heart rate is usually achieved through the following formula:
[0186]
[0187] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages: Figure 2 、 Figure 5 、 Figure 7 The embodiments together provide a heart rate detection method based on an ECG signal, including: obtaining an original ECG signal; preprocessing the original ECG signal to obtain a preprocessed ECG signal; segmenting the preprocessed ECG signal to obtain multiple segments of preprocessed ECG signals; flipping the multiple segments of preprocessed ECG signals in the time domain to obtain multiple segments of reference signals; convolving each segment of the preprocessed ECG signal with the corresponding segment of the reference signal to obtain a signal to be detected; performing peak detection based on the signal to be detected to obtain multiple peak data; and calculating heart rate information based on the peak data. Based on the above method, by comparing the similarity between the original signal and the reference signal, the reference signal obtained after flipping retains the original frequency information, while the noise is eliminated, so that the frequency and phase information of the original signal can be effectively extracted, significantly improving the accuracy and anti-interference ability of heart rate detection. The present application also provides a heart rate detection device and a readable storage medium, which have the same beneficial effects as the above method.
[0188] The above content describes the heart rate detection method based on ECG signal provided by this application. To support the implementation of the above embodiment, this application also provides a heart rate detection device based on ECG signal. Figure 8 An embodiment of a heart rate detection device based on an electrocardiogram signal provided by the present application includes:
[0189] A second aspect of an embodiment of the present application provides a heart rate detection device based on an electrocardiogram signal, comprising:
[0190] An acquisition unit 801 is used to acquire an original ECG signal;
[0191] The preprocessing unit 802 is configured to preprocess the original ECG signal to obtain a preprocessed ECG signal;
[0192] A segmentation unit 803 is used to segment the preprocessed ECG signal to obtain multiple segments of preprocessed ECG signals;
[0193] A flipping unit 804 is configured to flip the plurality of pre-processed ECG signals in the time domain to obtain a plurality of reference signals;
[0194] The convolution unit 805 is used to convolve the pre-processed ECG signal of each segment with the reference signal of the corresponding segment to obtain a signal to be detected;
[0195] A detection unit 806 is configured to perform peak detection based on the signal to be detected to obtain a plurality of peak data;
[0196] The calculation unit 807 is configured to calculate the heart rate information based on the peak data.
[0197] Optionally, the preprocessing unit is specifically configured to:
[0198] performing bandpass filtering on the original electrocardiogram signal to obtain a first intermediate signal;
[0199] performing secondary differential filtering on the first intermediate signal to obtain a second intermediate signal;
[0200] performing an absolute value operation on the second intermediate signal to obtain a third intermediate signal;
[0201] Set the sliding integration window length;
[0202] Perform sliding integration on the third intermediate signal to obtain a preprocessed electrocardiogram signal.
[0203] Optionally, the segmentation unit is specifically configured to:
[0204] Set the reference signal window duration;
[0205] The preprocessed electrocardiogram signal is segmented based on the reference signal window duration.
[0206] Optionally, the flip unit is specifically used to:
[0207] Normalization processing is performed on the multiple segments of pre-processed ECG signals, and each segment of the reference signal is flipped in the time domain to obtain multiple segments of reference signals.
[0208] Optionally, the convolution unit is specifically configured to:
[0209] Convolving the preprocessed ECG signal of each segment with the reference signal of the corresponding segment based on Fourier transform to obtain the frequency domain preprocessed ECG signal of each segment and the frequency domain reference signal of the corresponding segment;
[0210] Multiplying each segment of the frequency domain preprocessed ECG signal with the corresponding segment of the frequency domain reference signal to obtain the frequency domain signal to be detected;
[0211] The frequency domain signal to be detected is processed based on inverse fast Fourier transform to obtain the signal to be detected.
[0212] Optionally, the device further includes:
[0213] The iterative unit is used to: input the signal to be detected as the pre-processed signal back into the segmentation unit, and re-process it by the flip unit and the convolution unit.
[0214] Optionally,
[0215] The detection unit is specifically used for:
[0216] Set the duration of the peak detection sliding window;
[0217] Calculating the mean and standard deviation of the signal to be detected within the peak detection sliding window;
[0218] calculating an adaptive threshold based on the mean and standard deviation;
[0219] extracting a plurality of candidate regions whose detection signals are greater than the adaptive threshold;
[0220] The maximum value is determined as peak data in each of the multiple candidate areas to obtain multiple peak data.
[0221] In this embodiment, the processes performed by each unit in the device are the same as those described above. Figure 1 、 Figure 2 、 Figure 5 or Figure 7 The method processes described in the corresponding embodiments are similar and will not be repeated here.
[0222] Figure 9 1 is a structural diagram of a heart rate detection device based on an electrocardiogram signal provided in an embodiment of the present application. The heart rate detection device 900 may include one or more central processing units (CPUs) 901 and a memory 905 , wherein the memory 905 stores one or more applications or data.
[0223] In this embodiment, the specific functional module division in the central processing unit 901 can be the same as the above Figure 8 The functional module division method of each unit described in is similar and will not be repeated here.
[0224] The memory 905 can be volatile or persistent storage. The program stored in the memory 905 can include one or more modules, each of which can include a series of instruction operations on the server. Furthermore, the central processing unit 901 can be configured to communicate with the memory 905 and execute the series of instruction operations in the memory 905 on the heart rate detection device 900.
[0225] The heart rate detection device 900 may further include one or more power supplies 902 , one or more wired or wireless network interfaces 903 , one or more input and output interfaces 904 , and / or one or more operating systems.
[0226] The CPU 901 can execute the aforementioned Figure 1 、 Figure 2 、 Figure 5 or Figure 7 The operations performed by the heart rate detection method in the illustrated embodiment will not be described in detail here.
[0227] An embodiment of the present application also provides a computer storage medium for storing computer software instructions used for the above-mentioned heart rate detection method based on electrocardiogram signals, which includes a program designed for executing a heart rate detection device.
[0228] The heart rate detection method based on the electrocardiogram signal can be as described above. Figure 1 、 Figure 2 、 Figure 5 or Figure 7 The heart rate detection method based on ECG signal is described in.
[0229] The present application also provides a computer program product, which includes computer software instructions that can be loaded by a processor to implement the above Figure 1 、 Figure 2 、 Figure 5 or Figure 7 The process of any one of the heart rate detection methods based on electrocardiogram signals.
[0230] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the equivalent transformation of circuits and the division of units are only a kind of logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0231] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0232] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0233] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions or improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A heart rate detection method based on electrocardiogram signal, characterized in that: include: Obtain original ECG signal; Preprocessing the original electrocardiogram signal to obtain a preprocessed electrocardiogram signal; Segmenting the preprocessed ECG signal to obtain multiple segments of preprocessed ECG signals; Flipping the multiple segments of pre-processed ECG signals in the time domain to obtain multiple segments of reference signals; Convolving the preprocessed ECG signal of each segment with the reference signal of the corresponding segment to obtain a signal to be detected; Perform peak detection based on the signal to be detected to obtain multiple peak data; Calculating heart rate information based on the peak data; After the step of convolving each segment of the preprocessed ECG signal with the corresponding segment of the reference signal to obtain a signal to be detected, and before performing peak detection based on the signal to be detected to obtain a plurality of peak data, the method further includes: converting the signal to be detected into a reference signal; The step of convolving each segment of the preprocessed ECG signal with the corresponding segment of the reference signal to obtain a signal to be detected is re-executed.
2. The heart rate detection method based on electrocardiogram signal according to claim 1, characterized in that: The preprocessing of the original electrocardiogram signal comprises: performing bandpass filtering on the original electrocardiogram signal to obtain a first intermediate signal; performing secondary differential filtering on the first intermediate signal to obtain a second intermediate signal; performing an absolute value operation on the second intermediate signal to obtain a third intermediate signal; Set the sliding integration window length; Perform sliding integration on the third intermediate signal to obtain a preprocessed electrocardiogram signal.
3. The heart rate detection method based on electrocardiogram signal according to claim 1, characterized in that: Segmenting the preprocessed electrocardiogram signal comprises: Set the reference signal window duration; The preprocessed electrocardiogram signal is segmented based on the reference signal window duration.
4. The heart rate detection method based on electrocardiogram signal according to claim 1, characterized in that: The step of flipping the multiple segments of pre-processed ECG signals in the time domain to obtain multiple segments of reference signals includes: Normalization processing is performed on the multiple segments of pre-processed ECG signals, and each segment of the reference signal is flipped in the time domain to obtain multiple segments of reference signals.
5. The heart rate detection method based on electrocardiogram signal according to claim 1, characterized in that: The convolution of the pre-processed ECG signal of each segment with the reference signal of the corresponding segment to obtain the signal to be detected includes: Convolving the preprocessed ECG signal of each segment with the reference signal of the corresponding segment based on Fourier transform to obtain the frequency domain preprocessed ECG signal of each segment and the frequency domain reference signal of the corresponding segment; Multiplying each segment of the frequency domain preprocessed ECG signal with the corresponding segment of the frequency domain reference signal to obtain the frequency domain signal to be detected; The frequency domain signal to be detected is processed based on inverse fast Fourier transform to obtain the signal to be detected.
6. The heart rate detection method based on electrocardiogram signal according to claim 1, characterized in that: The peak detection is performed based on the signal to be detected to obtain a plurality of peak data, including: Set the duration of the peak detection sliding window; Calculating the mean and standard deviation of the signal to be detected within the peak detection sliding window; calculating an adaptive threshold based on the mean and standard deviation; extracting a plurality of candidate regions whose detection signals are greater than the adaptive threshold; The maximum value is determined as peak data in each of the multiple candidate areas to obtain multiple peak data.
7. A heart rate detection device based on electrocardiogram signal, characterized in that: include: An acquisition unit, used for acquiring original ECG signals; a preprocessing unit, configured to preprocess the original ECG signal to obtain a preprocessed ECG signal; A segmentation unit, configured to segment the preprocessed ECG signal to obtain multiple segments of preprocessed ECG signals; A flipping unit, configured to flip the plurality of pre-processed ECG signals in the time domain to obtain a plurality of reference signals; a convolution unit, configured to convolve the preprocessed ECG signal of each segment with the reference signal of the corresponding segment to obtain a signal to be detected; A detection unit, configured to perform peak detection based on the signal to be detected to obtain a plurality of peak data; a calculation unit, configured to calculate heart rate information based on the peak data; The device further comprises: An iterative unit, configured to: convert the signal to be detected into a reference signal; Retrigger the convolution unit.
8. A heart rate detection device based on electrocardiogram signal, characterized in that: include: CPU, memory, input and output interfaces, wired or wireless network interfaces, and power supply; The memory is a transient memory or a persistent memory; The central processing unit is configured to communicate with the memory and execute instructions in the memory on the device to perform the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that The method comprises instructions, which, when executed on a computer, cause the computer to perform the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Heart rate detection method capable of resisting motion interference
CN118975788A