A method and device for detecting an R-wave of an electrocardiosignal, an electronic device and a storage medium

CN120678446BActive Publication Date: 2026-08-18BEIJING ORIENTAL E T MEDICAL EQUIP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510770473.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2026-08-18
Estimated Expiration
2045-06-10

AI Technical Summary

Technical Problem

[0003]本发明提供了一种心电信号R波的检测方法、装置、电子设备及存储介质,能够解决现有技术中并无R波的有效检测方法的问题

Benefits of technology

[0036] This invention provides a method for detecting the R wave in an electrocardiogram (ECG) signal. The method involves acquiring the ECG signal of the current lead; performing first-order difference calculations on each sampling point in the ECG signal to obtain the first-order difference value corresponding to each sampling point; performing second-order difference calculations on each of the first-order difference values ​​to obtain the second-order difference value corresponding to each sampling point; comparing the first-order difference value with a preset first-order difference threshold, and comparing the second-order difference value with a preset second-order difference threshold. If the first-order difference value corresponding to the current sampling point is greater than the first-order difference threshold, and the second-order difference value is greater than the second-order difference threshold, then the method proceeds as follows: If a second-order difference threshold is used, the waveform corresponding to the current sampling point is taken as a candidate R wave; the ECG signal within a preset time period after the current sampling point is taken as the target ECG signal. The first-order difference value of each sampling point in the target ECG signal is compared with the peak value of the ECG signal, and it is determined whether the second-order difference value of each sampling point in the target ECG signal is positive. If the first-order difference value of each sampling point in the target ECG signal is greater than the peak value, and the second-order difference value of each sampling point in the target ECG signal is positive, then the candidate R wave is determined to be an R wave.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120678446B_ABST
    Figure CN120678446B_ABST
Patent Text Reader

Abstract

The application discloses a kind of electrocardiosignal R wave detection method, device, electronic equipment and storage medium, belong to biomedical signal processing technical field, the method is: to each sampling point in electrocardiosignal first-order difference calculation, obtain corresponding first-order difference value;First-order difference value is second-order difference calculation, obtain corresponding second-order difference value;If the first-order difference value corresponding to current sampling point is greater than first-order difference threshold, and second-order difference value is greater than second-order difference threshold, then the waveform corresponding to current sampling point is regarded as candidate R wave;Electrocardiosignal in the preset time length after current sampling point is regarded as target electrocardiosignal, if the first-order difference value of each sampling point in target electrocardiosignal is all greater than the peak value of electrocardiosignal, and the second-order difference value of each sampling point in target electrocardiosignal is all positive, then it is judged that the candidate R wave is R wave, therefore, by implementing the application, the problem that there is no effective detection method of R wave in prior art can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of biomedical signal processing technology, and in particular to a method, apparatus, electronic device, and storage medium for detecting R waves in electrocardiogram signals. Background Technology

[0002] Electrocardiogram (ECG) is an important physiological signal reflecting the electrophysiological activity of the heart. Its core features (such as P wave, QRS complex, and T wave) are key evidence for the clinical diagnosis of diseases such as arrhythmia and myocardial infarction. Among them, the R wave, as the most prominent peak in the QRS complex, is the core reference point for ECG signal analysis. Its accurate detection directly affects the following medical scenarios: (1) Heart rate calculation: Calculating heart rate through the RR interval is the basis for assessing cardiac function; (2) Arrhythmia identification: Such as ventricular premature beats and atrial fibrillation, which rely on R wave localization and morphological analysis; (3) ST segment measurement: Used for the diagnosis of myocardial ischemia or infarction, which requires the R wave as a benchmark; (4) Wearable device application: Smartwatches and implantable ECG monitors (such as ICDs) need to detect the R wave in real time to trigger warnings. Therefore, accurate detection of the R wave is very important, but there is currently no effective method for detecting the R wave. Summary of the Invention

[0003] This invention provides a method, apparatus, electronic device, and storage medium for detecting R waves in electrocardiogram signals, which can solve the problem that there is no effective method for detecting R waves in the prior art.

[0004] To address the aforementioned technical problems, embodiments of the present invention provide a method for detecting the R wave in an electrocardiogram (ECG) signal, comprising:

[0005] Acquire the ECG signal of the current lead;

[0006] First-order difference calculation is performed on each sampling point in the electrocardiogram signal to obtain the first-order difference value corresponding to each sampling point;

[0007] The second-order difference is calculated for each of the first-order difference values ​​to obtain the second-order difference value corresponding to each sampling point;

[0008] The first-order difference value is compared with a preset first-order difference threshold, and the second-order difference value is compared with a preset second-order difference threshold. If the first-order difference value corresponding to the current sampling point is greater than the first-order difference threshold and the second-order difference value is greater than the second-order difference threshold, then the waveform corresponding to the current sampling point is taken as a candidate R-wave.

[0009] The ECG signal within a preset time period after the current sampling point is taken as the target ECG signal. The first-order difference value of each sampling point in the target ECG signal is compared with the peak value of the ECG signal, and it is determined whether the second-order difference value of each sampling point in the target ECG signal is positive. If the first-order difference value of each sampling point in the target ECG signal is greater than the peak value, and the second-order difference value of each sampling point in the target ECG signal is positive, then the candidate R wave is determined to be an R wave.

[0010] As a preferred embodiment, before performing first-order difference calculations on each sampling point in the electrocardiogram signal, the method further includes:

[0011] The electrocardiogram signal is filtered according to a preset second-order IIR notch filter.

[0012] The transfer function of the second-order IIR notch filter is:

[0013]

[0014] Where H(z) is the transfer function of the second-order IIR notch filter; z -1 is the unit delay operator of the second-order IIR notch filter; b0, b1, and b2 are the coefficients of the numerator polynomial; a1 and a2 are the coefficients of the denominator polynomial.

[0015] As a preferred approach, the first-order difference calculation is performed on each sampling point in the electrocardiogram signal using the following formula:

[0016] Δ1(t) = x(t) - x(t - 3ms);

[0017] Where Δ1(t) is the first-order difference value of the ECG signal at time t; x(t) is the value of the ECG signal at time t; t is a continuous time variable; and t-3ms is a time offset of 3ms.

[0018] As a preferred embodiment, the second-order difference is calculated for each of the first-order difference values ​​using the following formula:

[0019] Δ2(t) = Δ1(t) - Δ1(t-1ms);

[0020] Where Δ2(t) is the second-order difference value corresponding to each sampling point; t-1ms is the time offset of 1ms.

[0021] As a preferred option, it also includes:

[0022] If the first-order difference value of a sampling point in the target ECG signal is not greater than the peak value, or the second-order difference value of a sampling point in the target ECG signal is not positive, then the candidate R wave is determined to be an R wave, and the gain of the ECG signal is adjusted according to the preset gain adjustment rule.

[0023] As a preferred option, it also includes:

[0024] Determine whether all candidate R waves in all leads are R waves. If so, determine that the candidate R wave is a valid R wave; otherwise, determine that the candidate R wave is not a valid R wave.

[0025] As a preferred embodiment, after determining that the candidate R-wave is a valid R-wave, the method further includes:

[0026] The refractory period is calculated based on the heart rate corresponding to the electrocardiogram signal and the preset maximum heart rate, and the detection of the R wave of the electrocardiogram signal is paused based on the refractory period.

[0027] Based on the above embodiments, another embodiment of the present invention provides a device for detecting R waves in electrocardiogram signals, including: an electrocardiogram signal acquisition module, a first-order difference calculation module, a second-order difference calculation module, a candidate R wave selection module, and an R wave judgment module;

[0028] The ECG signal acquisition module is used to acquire the ECG signal of the current lead;

[0029] The first-order difference calculation module is used to perform first-order difference calculation on each sampling point in the electrocardiogram signal to obtain the first-order difference value corresponding to each sampling point.

[0030] The second-order difference calculation module is used to perform second-order difference calculation on each of the first-order difference values ​​to obtain the second-order difference value corresponding to each sampling point.

[0031] The candidate R-wave selection module is used to compare the first-order difference value with a preset first-order difference threshold and the second-order difference value with a preset second-order difference threshold. If the first-order difference value corresponding to the current sampling point is greater than the first-order difference threshold and the second-order difference value is greater than the second-order difference threshold, then the waveform corresponding to the current sampling point is taken as a candidate R-wave.

[0032] The R-wave determination module is used to take the ECG signal within a preset time period after the current sampling point as the target ECG signal, compare the first-order difference value of each sampling point in the target ECG signal with the peak value of the ECG signal, and determine whether the second-order difference value of each sampling point in the target ECG signal is positive. If the first-order difference value of each sampling point in the target ECG signal is greater than the peak value, and the second-order difference value of each sampling point in the target ECG signal is positive, then the candidate R-wave is determined to be an R-wave.

[0033] Based on the above embodiments, another embodiment of the present invention provides an electronic device, the device including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement the method for detecting the R wave of the electrocardiogram signal described in the above embodiments of the invention.

[0034] Based on the above embodiments, another embodiment of the present invention provides a storage medium, the storage medium including a stored computer program, wherein, when the computer program is running, it controls the device where the storage medium is located to execute the ECG signal R wave detection method described in the above embodiments of the invention.

[0035] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:

[0036] This invention provides a method for detecting the R wave in an electrocardiogram (ECG) signal. The method involves acquiring the ECG signal of the current lead; performing first-order difference calculations on each sampling point in the ECG signal to obtain the first-order difference value corresponding to each sampling point; performing second-order difference calculations on each of the first-order difference values ​​to obtain the second-order difference value corresponding to each sampling point; comparing the first-order difference value with a preset first-order difference threshold, and comparing the second-order difference value with a preset second-order difference threshold. If the first-order difference value corresponding to the current sampling point is greater than the first-order difference threshold, and the second-order difference value is greater than the second-order difference threshold, then the method proceeds as follows: If a second-order difference threshold is used, the waveform corresponding to the current sampling point is taken as a candidate R wave; the ECG signal within a preset time period after the current sampling point is taken as the target ECG signal. The first-order difference value of each sampling point in the target ECG signal is compared with the peak value of the ECG signal, and it is determined whether the second-order difference value of each sampling point in the target ECG signal is positive. If the first-order difference value of each sampling point in the target ECG signal is greater than the peak value, and the second-order difference value of each sampling point in the target ECG signal is positive, then the candidate R wave is determined to be an R wave. Attached Figure Description

[0037] Figure 1 This is a schematic flowchart of a method for detecting the R wave of an electrocardiogram signal according to an embodiment of the present invention;

[0038] Figure 2 This is a comparison diagram of the waveforms of the first-order and second-order differences near the R-wave.

[0039] Figure 3 This is the logic flowchart for automatic gain control;

[0040] Figure 4 This is a flowchart of the R-wave detection algorithm of the present invention;

[0041] Figure 5 This is a schematic diagram of the structure of a device for detecting the R wave of an electrocardiogram signal according to an embodiment of the present invention. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0043] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application; the terms “comprising” and “having”, and any variations thereof, in the specification, claims, and foregoing description of the drawings are intended to cover non-exclusive inclusion.

[0044] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.

[0045] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0046] In the description of the embodiments in this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.

[0047] In the description of the embodiments of this application, the terms "multiple" and "several" refer to two or more (including two), similarly, "multiple groups" refer to two or more (including two groups), and "multiple pieces" refer to two or more (including two pieces).

[0048] In the description of the embodiments of this application, unless otherwise expressly specified and limited, technical terms such as "installation," "connection," "joining," and "fixing" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. For those skilled in the art, the specific meaning of the above terms in the embodiments of this application can be understood according to the specific circumstances.

[0049] Example 1

[0050] Please refer to Figure 1 To address the challenges of existing R-wave detection algorithms (such as differential moving window integration and wavelet transform) relying on complex computations, making real-time detection within 30ms of R-wave appearance difficult; insufficient suppression of low-amplitude signals (such as ventricular flutter) and pacing signals, and difficulty adapting to dynamic gain changes and multi-lead processing requirements; and the limited resources of embedded devices making it difficult for existing algorithms to balance computational efficiency and detection accuracy, this invention provides a flowchart of an ECG signal R-wave detection method. This method enables efficient R-wave detection (delay ≤30ms) on low-computing-power devices while remaining compatible with complex ECG scenarios (such as pacing suppression, dynamic gain adjustment, and multi-lead collaborative processing). The method includes the following specific steps:

[0051] S1. Obtain the ECG signal of the current lead;

[0052] Specifically, first, the ECG signals of each lead are acquired. If the number of input leads is ≤3 and more than half of the leads are identified as consistent, the data is considered valid. Lead data marked as lost by the host computer can be actively blocked.

[0053] S2. Perform first-order difference calculation on each sampling point in the electrocardiogram signal to obtain the first-order difference value corresponding to each sampling point;

[0054] Preferably, before performing first-order difference calculation on each sampling point in the electrocardiogram signal, the method further includes: filtering the electrocardiogram signal according to a preset second-order IIR notch filter; wherein the transfer function of the second-order IIR notch filter is:

[0055]

[0056] Where H(z) is the transfer function of the second-order IIR notch filter; z -1 is the unit delay operator of the second-order IIR notch filter; b0, b1, and b2 are the coefficients of the numerator polynomial; a1 and a2 are the coefficients of the denominator polynomial.

[0057] Preferably, the first-order difference of each sampling point in the electrocardiogram signal is calculated using the following formula:

[0058] Δ1(t) = x(t) - x(t - 3ms);

[0059] Where Δ1(t) is the first-order difference value of the ECG signal at time t; x(t) is the value of the ECG signal at time t; t is a continuous time variable; and t-3ms is a time offset of 3ms.

[0060] Specifically, after acquiring the ECG signal of the current lead, the ECG signal is preprocessed and differentially calculated:

[0061] S201. First, preprocess the ECG signal with a sampling frequency ≥1000Hz and normalized to 1μV resolution, including using a notch filter with a cutoff frequency of 45-55Hz to suppress power frequency interference. Specifically, the preprocessing is as follows:

[0062] Power frequency notch filter: Employs a second-order IIR filter with a center frequency of 50Hz, bandwidth ±2Hz, and group delay ≤2ms. This power frequency notch filter is primarily used to suppress 50Hz (or 60Hz) AC interference introduced by the power grid in the ECG signal, while preserving as much of the effective components of the ECG signal as possible (such as the QRS complex, frequency range 0.5-40Hz).

[0063] The implementation principle of a second-order IIR notch filter is as follows:

[0064] The double second-order structure is adopted, and the transfer function is in the form of:

[0065]

[0066] In the formula: H(z) is the system transfer function (frequency domain representation), describing the frequency response characteristics of the filter to the input signal; z -1 The unit delay operator represents the signal being delayed by one sampling period in the time domain; b0, b1, and b2 are the coefficients of the numerator polynomial, which control the zero positions of the filter and determine the suppression capability of the stopband frequency (50Hz); a1 and a2 are the coefficients of the denominator polynomial, which control the pole positions of the filter and affect the passband flatness and stability.

[0067] The zero position of a second-order IIR notch filter is located on the unit circle, corresponding to the target frequency of 50Hz, completely suppressing this frequency component. The pole position of a second-order IIR notch filter is close to the zero but slightly inward from the origin, forming a narrow-band attenuation (bandwidth ±2Hz) and maintaining stability.

[0068] S201. Perform first-order difference operations on the preprocessed signal with a time interval of 3ms, and perform low-pass filtering on the first-order difference result:

[0069] First-order difference calculation: Calculated according to the formula Δ1(t)=x(t)-x(t-3ms); where Δ1(t) (first-order difference) represents the first-order difference value of the signal at time point t; x(t) (original signal) represents the value of the signal at time point t; t: continuous time variable; t-3ms: time offset.

[0070] The short-term trend of the signal is initially extracted using first-order differential quantization to eliminate low-frequency components. Then, the first-order differential result is low-pass filtered to retain frequencies below 40Hz. An FIR low-pass filter is used, and for embedded systems, the quantization filter coefficients are fixed-point to reduce computational complexity.

[0071] S3. Perform second-order difference calculation on each of the first-order difference values ​​to obtain the second-order difference value corresponding to each sampling point;

[0072] Preferably, the second difference is calculated for each of the first-order difference values ​​using the following formula:

[0073] Δ2(t) = Δ1(t) - Δ1(t-1ms);

[0074] Where Δ2(t) is the second-order difference value corresponding to each sampling point; t-1ms is the time offset of 1ms.

[0075] Specifically, the filtered first-order difference result is subjected to a second-order difference operation to generate a second-order difference sequence.

[0076] Second-order difference: Δ2(t) = Δ1(t) - Δ1(t-1ms), enhancing the R-wave slope characteristics. The time interval for second-order difference calculation is 1ms; a smaller time interval can capture the instantaneous changes in the R-wave slope and avoid smoothing effects. Then, Δ2(t) is calculated for each sampling point in time sequence, forming a discrete difference sequence {Δ2(1), Δ2(2), ..., Δ2(n)};

[0077] S4. Compare the first-order difference value with a preset first-order difference threshold, and compare the second-order difference value with a preset second-order difference threshold. If the first-order difference value corresponding to the current sampling point is greater than the first-order difference threshold and the second-order difference value is greater than the second-order difference threshold, then the waveform corresponding to the current sampling point is taken as a candidate R-wave.

[0078] Specifically, R-wave candidates are initially determined based on the threshold conditions of the first-order and second-order differences:

[0079] Preliminary conditions: Δ1(t) > Th1 (e.g., 200 μV / ms) and Δ2(t) > Th2 (e.g., 50 μV / ms) 2 ); Th1: Preset first-order difference threshold; Th2: Preset second-order difference threshold;

[0080] If the first-order difference value corresponding to the current sampling point is greater than the first-order difference threshold, and the second-order difference value is greater than the second-order difference threshold, then the waveform corresponding to the current sampling point is taken as a candidate R-wave. Please refer to... Figure 2 This is a comparison of the waveforms of the first-order and second-order differences near the R-wave.

[0081] S5. Take the ECG signal within a preset time period after the current sampling point as the target ECG signal, compare the first-order difference value of each sampling point in the target ECG signal with the peak value of the ECG signal, and determine whether the second-order difference value of each sampling point in the target ECG signal is positive. If the first-order difference value of each sampling point in the target ECG signal is greater than the peak value, and the second-order difference value of each sampling point in the target ECG signal is positive, then determine that the candidate R wave is an R wave.

[0082] Specifically, after selecting a candidate R-wave, the signal amplitude, first-order difference, and second-order difference are verified within a preset time (e.g., 10ms) after the candidate point to confirm the R-wave.

[0083] Confirmation criteria: The signal does not drop to 80% of its peak value within the next 10ms, and Δ2(t) ≥ 0. At this point, an R-wave is confirmed. The signal peak value is the potential difference between the baseline and the peak. A time window is defined (e.g., 10-30ms). Within this window, the maximum amplitude is searched as a candidate peak value. If the signal does not drop to 80% of the current peak value within 10ms after the peak (i.e., the drop ≤ 20%), then if the signal decreases significantly after the first-order difference, an R-wave is confirmed. If it does not decrease significantly, the result of the second-order difference is considered. If the second-order difference is non-negative, an R-wave is confirmed.

[0084] In R-wave detection, the signal amplitude drops rapidly after the R-wave peak, causing the first-order difference value (i.e., the rate of change of the signal) to gradually decrease. By verifying the first-order difference decay characteristics within 10ms after the candidate point, noise interference or the slow decay process of non-R-wave signals can be eliminated. If the signal is R-wave, its first-order difference should show a clear decay trend after the peak, such as the difference sequence gradually decreasing from [5,4,3,2], rather than fluctuating or changing steadily.

[0085] The nonnegativity of the second-order difference indicates that the decay rate of the first-order difference gradually slows down (or remains constant), meaning the "deceleration" of the signal's rate of change no longer intensifies. In R-wave detection, this characteristic can verify whether the signal is in a stable descent phase, avoiding misjudgment as oscillation noise or other interference waveforms. For example, a second-order difference sequence of [1, 0.5, 0] indicates that the decay rate of the first-order difference gradually decreases, consistent with the smooth descent characteristic of the signal after an R-wave.

[0086] Preferably, the method further includes: if the first-order difference value of a sampling point in the target ECG signal is not greater than the peak value, or the second-order difference value of a sampling point in the target ECG signal is not positive, then the candidate R wave is determined to be an R wave, and the gain of the ECG signal is adjusted according to a preset gain adjustment rule.

[0087] Specifically, if no R wave is detected within the preset time window, the gain of the ECG signal can be adjusted. The dynamic gain adjustment strategy includes: (1) Automatic mode: if no R wave is detected within the preset time window, the gain is increased step by step (range 1 to 3); (2) Manual mode: allows users to set the gain value (range 0.3 to 3.0).

[0088] In one specific embodiment, please refer to Figure 3 The following is a logic flowchart for automatic gain adjustment, along with an example of gain adjustment:

[0089] Automatic gain trigger: If the signal is less than 50uV and no R wave is detected within 2 seconds, the gain is increased (the gain adjustment range is 1-3).

[0090] If the signal is not too low, greater than 100uV, but no R wave is detected within 1.6s, increase the gain (the gain adjustment range is 1-3);

[0091] Gain refers to the amplification factor of the input signal during signal processing. Its mathematical expression is: Gain = Output signal amplitude / Input signal amplitude. The effect of increasing gain is to enhance the detection capability of weak signals. After the gain is increased, weak signals that were originally below the threshold (such as heartbeat, breathing, etc.) can be amplified to the effective detection range.

[0092] Preferably, the method further includes: determining whether all candidate R waves in all leads are R waves; if so, determining that the candidate R waves are valid R waves; otherwise, determining that the candidate R waves are not valid R waves.

[0093] Specifically, the present invention can also realize multi-lead collaborative processing, including: input leads ≤ 3, and if more than half of the leads are identified in a consistent manner, it is determined to be valid; actively shielding lead data marked as detached by the host computer.

[0094] In one specific embodiment, a corresponding multi-lead coordinated embodiment is provided:

[0095] If at least two leads simultaneously meet the threshold condition when inputting a 3-lead signal, it is determined to be a valid R wave.

[0096] Preferably, after determining that the candidate R wave is a valid R wave, the method further includes: calculating the corresponding refractory period duration based on the heart rate corresponding to the ECG signal and the preset maximum heart rate, and pausing the detection of the ECG signal R wave based on the refractory period duration.

[0097] Specifically, after determining that the candidate R wave is a valid R wave, i.e., after a valid R wave is detected, the refractory period is set to block repeated detections, and the duration of the refractory period is dynamically adjusted based on the highest heart rate:

[0098] The refractory period refers to the time window during which the device temporarily shuts down its sensing function after detecting a valid signal (such as an R wave) to shield against false triggering by subsequent interference signals. Specifically, this involves: immediately initiating the refractory period timing upon detecting a valid R wave or pacing pulse; shutting down the sensing amplifier during the refractory period to ignore all input signals; avoiding fixed durations that could lead to missed detections or excessive suppression; and adjusting the refractory period length based on the current heart rate or signal characteristics (such as maximum heart rate).

[0099] First, calculate the shortest cardiac cycle: based on the preset maximum heart rate (e.g., 180 bpm), derive the shortest RR interval (e.g., 333 ms);

[0100] Secondly, set the proportional relationship: the refractory period length is usually set to 30%-50% of the shortest RR interval. For example: if the shortest RR interval corresponding to the maximum heart rate is 333ms, then the refractory period can be adjusted to 150ms (45%) or 200ms (60%).

[0101] When the heart rate increases: shorten the refractory period (e.g., from 300ms to 200ms) to avoid covering the detection window of the next expected heartbeat; when the heart rate decreases: prolong the refractory period (e.g., from 200ms to 350ms) to enhance anti-interference ability.

[0102] Finally, if the pacing pulse is a high-frequency narrow pulse (usually lasting 0.4 to 0.5 ms), the start and end of the pacing pin are determined by detecting the rapid rise and fall of the signal amplitude; when the end of the pacing pulse is detected, the subsequent 40 ms of data are immediately skipped to avoid interference.

[0103] Therefore, this invention provides a method for detecting the R wave in an electrocardiogram signal. Please refer to... Figure 4 Here is a flowchart of the R-wave detection algorithm of the present invention, through which the following can be achieved:

[0104] (1) Two-level difference operation: The rising edge of the R wave is captured by the first-order difference (3ms interval), and the second-order difference enhances the abrupt change characteristics and reduces noise interference;

[0105] (2) Dynamic gain adjustment: Combines signal amplitude and time window to automatically / manually adjust the gain (range 0.3 to 3.0) to improve the detection capability of low amplitude signals (such as ventricular flutter);

[0106] (3) Multi-lead collaborative decision-making: The system is considered valid if more than half of the leads are identified, which supports lead detachment shielding and real-time processing efficiency optimization.

[0107] (4) Embedded friendly design: avoid floating-point operations, adopt fixed threshold and short time window strategy to adapt to microcontroller resource limitations.

[0108] In specific embodiments, the effectiveness of the present invention is verified:

[0109] Test data: EC13 database (single lead 720Hz sampling), after interpolation to 1000Hz, R-wave detection rate > 98% (no missed detections outside the transition period of aami4a_h data when gain = 2.5);

[0110] Real-time performance: The STM32F4 series microcontroller has a measured processing latency of ≤25ms and a CPU utilization rate of <15%.

[0111] The following specific effects can be achieved by implementing this invention:

[0112] (1) Low latency: R-wave identification latency ≤30ms, meeting the requirements of real-time monitoring;

[0113] (2) High robustness: Supports heart rates of 30-200 bpm, pacing suppression, ventricular flutter signals and severe arrhythmia scenarios;

[0114] (3) Low resource consumption: Single-lead processing requires only 3ms of time window data, and the CPU load is controllable when multi-lead (≤3) is processed in parallel.

[0115] This invention can be integrated into electrocardiogram monitors, portable defibrillators (AEDs), and pacemakers, significantly improving the reliability of real-time detection in complex electrocardiogram scenarios.

[0116] Example 2

[0117] Please refer to Figure 5 This is a schematic diagram of a device for detecting R waves in electrocardiogram (ECG) signals according to an embodiment of the present invention. The device includes: an ECG signal acquisition module, a first-order difference calculation module, a second-order difference calculation module, a candidate R wave selection module, and an R wave judgment module.

[0118] The ECG signal acquisition module is used to acquire the ECG signal of the current lead;

[0119] The first-order difference calculation module is used to perform first-order difference calculation on each sampling point in the electrocardiogram signal to obtain the first-order difference value corresponding to each sampling point.

[0120] The second-order difference calculation module is used to perform second-order difference calculation on each of the first-order difference values ​​to obtain the second-order difference value corresponding to each sampling point.

[0121] The candidate R-wave selection module is used to compare the first-order difference value with a preset first-order difference threshold and the second-order difference value with a preset second-order difference threshold. If the first-order difference value corresponding to the current sampling point is greater than the first-order difference threshold and the second-order difference value is greater than the second-order difference threshold, then the waveform corresponding to the current sampling point is taken as a candidate R-wave.

[0122] The R-wave determination module is used to take the ECG signal within a preset time period after the current sampling point as the target ECG signal, compare the first-order difference value of each sampling point in the target ECG signal with the peak value of the ECG signal, and determine whether the second-order difference value of each sampling point in the target ECG signal is positive. If the first-order difference value of each sampling point in the target ECG signal is greater than the peak value, and the second-order difference value of each sampling point in the target ECG signal is positive, then the candidate R-wave is determined to be an R-wave.

[0123] It should be noted that the device embodiments described above are merely illustrative. 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 network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.

[0124] Those skilled in the art will clearly understand that, for convenience and brevity, the specific working process of the device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0125] Example 3

[0126] Accordingly, embodiments of the present invention provide an electronic device, the device including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement the method for detecting the R wave of the electrocardiogram signal described in the above embodiments of the invention.

[0127] The electronic device may be a desktop computer, laptop, handheld computer, or cloud server, etc. The device may include, but is not limited to, a processor and a memory.

[0128] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the device, connecting various parts of the device via various interfaces and lines.

[0129] Example 4

[0130] Accordingly, embodiments of the present invention provide a storage medium, the storage medium including a stored computer program, wherein, when the computer program is running, it controls the device where the storage medium is located to execute the ECG signal R-wave detection method described in the above embodiments of the invention.

[0131] The memory can be used to store the computer program. The processor implements various functions of the device by running or executing the computer program stored in the memory and calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function, etc.; the data storage area may store data created based on the use of the mobile phone, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, RAM, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0132] The storage medium is a computer-readable storage medium, and the computer program is stored in the computer-readable storage medium. When executed by a processor, the computer program can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.

[0133] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A method for detecting the R wave in an electrocardiogram (ECG) signal, characterized in that, include: Acquire the ECG signal of the current lead; First-order difference calculation is performed on each sampling point in the electrocardiogram signal to obtain the first-order difference value corresponding to each sampling point; The second-order difference is calculated for each of the first-order difference values ​​to obtain the second-order difference value corresponding to each sampling point; The first-order difference value is compared with a preset first-order difference threshold, and the second-order difference value is compared with a preset second-order difference threshold. If the first-order difference value corresponding to the current sampling point is greater than the first-order difference threshold and the second-order difference value is greater than the second-order difference threshold, then the waveform corresponding to the current sampling point is taken as a candidate R-wave. The ECG signal within a preset time period after the current sampling point is taken as the target ECG signal. The first-order difference value of each sampling point in the target ECG signal is compared with the peak value of the ECG signal, and it is determined whether the second-order difference value of each sampling point in the target ECG signal is positive. If the first-order difference value of each sampling point in the target ECG signal is greater than the peak value, and the second-order difference value of each sampling point in the target ECG signal is positive, then the candidate R wave is determined to be an R wave. The first-order difference calculation for each sampling point in the electrocardiogram signal is performed using the following formula: Δ1(t) = x(t) - x(t-3ms); Where Δ1(t) is the first-order difference value of the ECG signal at time point t; x(t) is the value of the ECG signal at time point t; t is a continuous time variable; t-3ms is a time offset of 3ms; The second difference is calculated for each of the first-order difference values ​​using the following formula: Δ2(t) = Δ1(t) - Δ1(t-1ms); Where Δ2(t) is the second-order difference value corresponding to each sampling point; t-1ms is the time offset of 1ms; Determine whether all candidate R waves in all leads are R waves. If so, determine that the candidate R wave is a valid R wave; otherwise, determine that the candidate R wave is not a valid R wave. After determining that the candidate R-wave is a valid R-wave, the process further includes: The refractory period is calculated based on the heart rate corresponding to the electrocardiogram signal and the preset maximum heart rate, and the detection of the R wave of the electrocardiogram signal is paused based on the refractory period.

2. The method for detecting the R wave of an electrocardiogram signal as described in claim 1, characterized in that, Before performing first-order difference calculations on each sampling point in the electrocardiogram signal, the method further includes: The electrocardiogram signal is filtered according to a preset second-order IIR notch filter. The transfer function of the second-order IIR notch filter is: ; Wherein, H(z) is the transfer function of the second-order IIR notch filter; The unit delay operator for the second-order IIR notch filter; The coefficients of the numerator polynomial; is the coefficient of the denominator polynomial.

3. The method for detecting the R wave of an electrocardiogram signal as described in claim 1, characterized in that, Also includes: If the first-order difference value of a sampling point in the target ECG signal is not greater than the peak value, or the second-order difference value of a sampling point in the target ECG signal is not positive, then the candidate R wave is determined to be an R wave, and the gain of the ECG signal is adjusted according to the preset gain adjustment rule.

4. A device for detecting the R wave in an electrocardiogram signal, characterized in that, include: ECG signal acquisition module, first-order difference calculation module, second-order difference calculation module, candidate R-wave selection module, and R-wave judgment module; The ECG signal acquisition module is used to acquire the ECG signal of the current lead; The first-order difference calculation module is used to perform first-order difference calculation on each sampling point in the electrocardiogram signal to obtain the first-order difference value corresponding to each sampling point. The second-order difference calculation module is used to perform second-order difference calculation on each of the first-order difference values ​​to obtain the second-order difference value corresponding to each sampling point. The candidate R-wave selection module is used to compare the first-order difference value with a preset first-order difference threshold and the second-order difference value with a preset second-order difference threshold. If the first-order difference value corresponding to the current sampling point is greater than the first-order difference threshold and the second-order difference value is greater than the second-order difference threshold, then the waveform corresponding to the current sampling point is taken as a candidate R-wave. The R-wave determination module is used to take the ECG signal within a preset time period after the current sampling point as the target ECG signal, compare the first-order difference value of each sampling point in the target ECG signal with the peak value of the ECG signal, and determine whether the second-order difference value of each sampling point in the target ECG signal is positive. If the first-order difference value of each sampling point in the target ECG signal is greater than the peak value, and the second-order difference value of each sampling point in the target ECG signal is positive, then the candidate R-wave is determined to be an R-wave. The first-order difference calculation for each sampling point in the electrocardiogram signal is performed using the following formula: Δ1(t) = x(t) - x(t-3ms); Where Δ1(t) is the first-order difference value of the ECG signal at time point t; x(t) is the value of the ECG signal at time point t; t is a continuous time variable; t-3ms is a time offset of 3ms; The second difference is calculated for each of the first-order difference values ​​using the following formula: Δ2(t) = Δ1(t) - Δ1(t-1ms); Where Δ2(t) is the second-order difference value corresponding to each sampling point; t-1ms is the time offset of 1ms; It also includes a valid R-wave determination module, which is used to determine whether all candidate R-waves in all leads are R-waves. If so, the candidate R-wave is determined to be a valid R-wave; otherwise, the candidate R-wave is determined not to be a valid R-wave. It also includes an R-wave processing module, which, after determining that the candidate R-wave is a valid R-wave, calculates the corresponding refractory period duration based on the heart rate corresponding to the ECG signal and the preset maximum heart rate, and pauses the detection of the ECG signal R-wave based on the refractory period duration.

5. An electronic device, characterized in that, The method includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the method for detecting the R wave of an electrocardiogram signal as described in any one of claims 1 to 3.

6. A storage medium, characterized in that, The storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device containing the storage medium to perform the ECG signal R-wave detection method as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Automated detection method of QRS wave groups of electrocardiosignals

    CN107788969A

  • Electrocardiosignal R-wave detection method and system

    CN109009086A