A real-time electrocardiogram R-peak detection method and device based on correlation template matching in the nuclear magnetic resonance scenario
Through sliding window technology and correlation template matching methods, thresholds are dynamically adjusted and personalized templates are generated, which solves the problem of false detection and missed detection of R peak detection in NMR scenarios, and realizes real-time ECG R peak detection with high accuracy and low latency, suitable for wearable and medical devices.
Patent Information
- Application Number
- CN202510348755.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2045-03-24
AI Technical Summary
The existing R peak detection methods are prone to false detection and missed detection in NMR scenarios, and have poor adaptability to dynamic signal changes, insufficient real-time processing capabilities, and are difficult to operate efficiently in embedded systems with resource-constrained resources.
Sliding window technology, dynamic threshold setting and correlation template matching are adopted. By generating a personalized comprehensive template, real-time buffering and template matching of the ECG signal are performed, and thresholds are dynamically adjusted to suppress noise interference and improve detection accuracy and real-time.
In high noise environments, the accuracy and real-time performance of R peak detection are significantly improved, and the calculation complexity is reduced. It is suitable for resource-constrained embedded systems. It is suitable for integration into wearable health devices and medical diagnostic devices to reduce false detection rates and missed detection rates.
Smart Images

Figure CN119837541B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of medical image data processing, and particularly relates to a real-time electrocardiogram R-peak detection method and device based on correlation template matching in a nuclear magnetic resonance scenario. Background Art
[0002] Electrocardiogram (ECG), as a commonly used biomedical signal, is widely applied to the diagnosis and monitoring of heart diseases. The R-peak in the ECG signal represents the rapid depolarization process of the ventricle and is an important indicator for evaluating heart rate, rhythm, and heart health status. Therefore, accurately and real-time detecting the electrocardiogram R-peak is of great significance for applications such as early diagnosis of heart diseases, sports health monitoring, and telemedicine.
[0003] During the nuclear magnetic resonance (MRI) imaging process, the ECG signal will be affected by strong electromagnetic interferences such as gradient magnetic field switching and radio frequency pulses, resulting in a large amount of high-frequency noise and baseline drift being mixed into the signal. Existing R-peak detection methods mainly include threshold-based detection methods, differentiator methods, integration methods, and methods based on template matching and machine learning. Among them, the Pan-Tompkins algorithm is one of the most classic and widely used calculation methods that rely on the amplitude and derivative of the electrocardiogram signal. This algorithm realizes the detection of R-peaks through a series of filtering, differentiation, integration, and threshold judgment steps. However, when dealing with ECG signals in a high-noise environment, the Pan-Tompkins algorithm is prone to problems of false detection and missed detection, and its adaptability to dynamically changing electrocardiogram signals is poor, which limits its application in complex environments and further affects the accuracy of MRI imaging and image quality.
[0004] With the development of wearable devices and mobile health monitoring technologies, higher requirements are put forward for the real-time performance and computational efficiency of the R-peak detection algorithm. Many existing methods have a trade-off between real-time processing capabilities and computational complexity and are difficult to operate efficiently in resource-constrained embedded systems. At the same time, traditional template matching methods often lack sufficient flexibility and robustness when dealing with ECG signals with large individual differences, which affects the detection accuracy. Existing pattern matching technologies usually rely on classification tasks of machine learning or deep learning and use a relatively general template for training and matching. Although this method improves the detection accuracy to a certain extent, its computational complexity is high, real-time performance is poor, and it has high requirements for hardware devices, making it difficult to operate efficiently in resource-constrained embedded systems.
[0005] In view of the above problems, there is an urgent need for an R-peak detection method that can balance real-time performance, accuracy, and computational efficiency. This method should be able to adaptively adjust the threshold, effectively filter out noise interference, improve the correlation analysis ability of template matching, and adapt to the electrocardiogram signal characteristics of different individuals and dynamic changes. In addition, as electrocardiogram monitoring devices develop towards wearable and intelligent directions, new R-peak detection algorithms should have low computational resource requirements to adapt to the application environment of embedded systems. Summary of the Invention
[0006] In view of the above, the object of the present invention is to provide a real-time electrocardiogram R-peak detection method and device based on correlation template matching in a nuclear magnetic resonance scenario, aiming to solve the technical problems in the prior art such as easy false detection and missed detection of R-peak detection in a high-noise environment like the nuclear magnetic resonance scenario, poor adaptability to dynamic signal changes, and insufficient real-time processing ability. The present invention significantly improves the accuracy and real-time performance of electrocardiogram R-peak detection by introducing a sliding window technique, dynamic threshold setting, and correlation template matching and merging, and is applicable to medical monitoring devices, wearable health devices, and other application scenarios that require real-time heart rate monitoring.
[0007] To achieve the above object of the invention, an embodiment of the present invention provides a real-time electrocardiogram R-peak detection method based on correlation template matching in a nuclear magnetic resonance scenario, including the following steps:
[0008] Data buffering: Using a sliding window technique to perform real-time buffering on the input ECG signal to generate a sliding window buffer containing a predetermined number of electrocardiogram signal samples;
[0009] Dynamic threshold calculation: When the number of electrocardiogram signal samples in the sliding window buffer reaches the initial sample number, dynamically calculate the minimum height threshold for each test subject based on the maximum signal amplitude in the initial electrocardiogram signal samples;
[0010] Template extraction and merging: Screen R-peaks greater than the minimum height threshold from the sliding window buffer, extract signal segments of a predetermined window size before and after each R-peak position to form multiple R-peak templates, calculate the correlation of pairwise template matching among all R-peak templates, and take the average of the signal values of two R-peak templates with a correlation higher than the preset threshold point by point to generate a comprehensive template, and then obtain a comprehensive template set;
[0011] R-peak determination: Calculate the similarity between the currently newly added electrocardiogram signal sample in the sliding window buffer and each comprehensive template in the comprehensive template set. When the similarity value is greater than the similarity threshold and the interval between the currently detected electrocardiogram R-peak and the previous electrocardiogram R-peak exceeds the minimum R-R interval, it is determined that an effective electrocardiogram R-peak is detected.
[0012] Preferably, when buffering data, it further includes: when the center electrical signal sample in the sliding window buffer is not full, directly add a new ECG signal sample to the sliding window buffer; when it is full, remove the earliest added ECG signal sample and add a new ECG signal sample to ensure the continuity and real-time nature of the data.
[0013] Preferably, dynamically calculating the minimum height threshold for each subject based on the maximum signal amplitude in the initial ECG signal sample includes:
[0014] Based on the maximum signal amplitude in the initial ECG signal sample and multiplying it by a predetermined proportionality coefficient to determine the minimum height threshold for each subject.
[0015] Preferably, when calculating the correlation of pairwise template matching among all R-peak templates, the Pearson correlation coefficient, Spearman rank correlation coefficient, etc. are used.
[0016] Preferably, when calculating the similarity between the currently newly added ECG signal sample in the sliding window buffer and each composite template in the composite template set, the Pearson correlation coefficient, Spearman rank correlation coefficient, etc. are used.
[0017] Preferably, when determining the R peak, it further includes: checking whether the starting point signal amplitude of the signal segment corresponding to the valid ECG R peak in the sliding window buffer is higher than the minimum height threshold. When it is higher than the minimum height threshold, it is considered that the detected valid ECG R peak is accurate and reliable.
[0018] To achieve the above-mentioned invention purpose, an apparatus for real-time ECG R peak detection based on correlation template matching in a nuclear magnetic resonance scenario provided by an embodiment includes:
[0019] A data buffering module, which is used to perform real-time buffering on the input ECG signal using the sliding window technique to generate a sliding window buffer containing a predetermined number of ECG signal samples;
[0020] A dynamic threshold calculation module, which is used to dynamically calculate the minimum height threshold for each subject based on the maximum signal amplitude in the initial ECG signal sample when the number of ECG signal samples in the sliding window buffer reaches the initial sample number;
[0021] A template extraction and merging module, which is used to screen R peaks greater than the minimum height threshold from the sliding window buffer, extract signal segments of a predetermined window size before and after each R peak position to form multiple R peak templates, calculate the correlation of pairwise template matching among all R peak templates, and take the average of the signal values of two R peak templates with a correlation higher than a preset threshold point by point to generate a composite template, and further obtain a composite template set;
[0022] The R-peak determination module is used to calculate the similarity between the currently added new electrocardiogram (ECG) signal samples in the sliding window buffer and each comprehensive template in the comprehensive template set. When the similarity value is greater than the similarity threshold and the interval between the detected ECG R-peak of the currently added new ECG signal sample and the previous ECG R-peak exceeds the minimum R-R interval, it is determined that a valid ECG R-peak is detected.
[0023] To achieve the above invention purpose, the embodiment also provides a computing device, including a memory and one or more processors. An executable code is stored in the memory. When the one or more processors execute the executable code, it is used to implement the above real-time ECG R-peak detection method based on correlation template matching in the nuclear magnetic resonance (NMR) scenario.
[0024] To achieve the above invention purpose, the embodiment also provides a computer-readable storage medium, on which a program is stored. When the program is executed by a processor, it implements the above real-time ECG R-peak detection method based on correlation template matching in the NMR scenario.
[0025] To achieve the above invention purpose, the embodiment also provides a computer product, which includes a computer program. When the computer program is executed by a processor, it implements the above real-time ECG R-peak detection method based on correlation template matching in the NMR scenario.
[0026] Compared with the prior art, the beneficial effects of the present invention at least include:
[0027] The present invention uses the heartbeat characteristics of the tested person to generate a personalized comprehensive template for R-peak detection. Only simple similarity calculations are required for subsequent real-time matching, with a low computational complexity (O(n)), and it can run in real time on low-power hardware such as microcontrollers. This design not only takes into account the accuracy and real-time performance of detection but also reduces the dependence on hardware resources, and is suitable for application scenarios with high computational efficiency requirements such as the MRI ECG gating system.
[0028] The present invention uses pattern matching for ECG R-peak recognition. By dynamically generating a specific comprehensive template for the tested person, it can effectively suppress noise interference and accurately identify ECG R-peaks. Even in a high-noise MRI environment, this method can still maintain a high detection accuracy rate, ensuring the reliability of the ECG gating signal, and thus playing a key role in nuclear magnetic resonance imaging. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] To more clearly illustrate the technical solutions in the embodiments of the present invention or in the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0030] Figure 1 It is a flowchart of a real-time electrocardiogram R peak detection method based on correlation template matching for the nuclear magnetic resonance scenario provided by the embodiment;
[0031] Figure 2 It is an example diagram for electrocardiogram R peak error detection and correction provided by the embodiment;
[0032] Figure 3 It is a schematic structural diagram of a real-time electrocardiogram R peak detection device based on correlation template matching for the nuclear magnetic resonance scenario provided by the embodiment. Specific Embodiments
[0033] To make the objectives, technical solutions and advantages of the present invention more clearly understood, the following further details the present invention in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and do not limit the protection scope of the present invention.
[0034] The inventive concept of the present invention is as follows: In the existing nuclear magnetic resonance environment, the switching of gradient magnetic fields and radio frequency pulses will introduce a large amount of high-frequency noise and baseline drift. Traditional R peak detection methods rely on the calculation of the amplitude and derivative of electrocardiogram signals, and it is difficult to ensure the accuracy rate in a high-noise environment, and the false detection rate and missed detection rate increase significantly. To solve this technical problem, the embodiments of the present invention provide a real-time electrocardiogram R peak detection solution based on correlation template matching for the nuclear magnetic resonance scenario. Through the sliding window technology, dynamic threshold setting, and correlation-based template matching, it performs excellently in a dynamic environment, improves the adaptability and robustness of the algorithm to different electrocardiogram signal changes, realizes high-precision identification and detection of R peaks, can effectively suppress noise interference, the false detection rate is less than 5%, and at the same time, no complex pre-filtering processing is required, and the trigger delay is less than 20 ms, meeting the real-time requirements of MRI electrocardiogram gating. In addition, the algorithm of the present invention has a low computational complexity (O(n)), can run efficiently in resource-constrained embedded systems such as microcontrollers, the CPU occupancy rate is less than 5%, and the memory occupancy is less than 2 KB, and is suitable for integration into portable medical devices and wearable devices. The technical solution of the present invention has broad application prospects in the fields of heart disease diagnosis, sports health monitoring, telemedicine, and nuclear magnetic resonance imaging, can significantly improve the performance and reliability of related devices, provide a high-precision and low-delay R peak detection solution for the electrocardiogram gating system, effectively reduce imaging artifacts, and improve the image quality.
[0035] As Figure 1 shown, a real-time electrocardiogram R-peak detection method based on correlation template matching for nuclear magnetic resonance scenarios provided by the embodiment includes the following steps:
[0036] S1, data buffering: The input ECG signal is buffered in real time using a sliding window technique to generate a sliding window buffer containing a predetermined number of electrocardiogram signal samples.
[0037] In the embodiment, the input ECG signal is buffered in real time using a sliding window technique to generate a sliding window buffer containing a predetermined number of electrocardiogram signal samples. The size of the sliding window is set according to the sampling rate of the ECG signal and the characteristics of the R peak to ensure that sufficient electrocardiogram signal cycles are covered. The predetermined number can be adjusted based on different devices. Generally, collecting data for ten seconds is sufficient. The obtained sliding window buffer is used for the construction of the subsequent comprehensive template. Specifically, when the sliding window buffer is not full, that is, when the electrocardiogram signal samples in the sliding window buffer are not full, new electrocardiogram signal samples are directly added to the sliding window buffer; when the electrocardiogram signal samples in the sliding window buffer are full, the earliest added electrocardiogram signal samples are removed and new electrocardiogram signal samples are added to ensure the continuity and real-time nature of the data.
[0038] S2, dynamic threshold calculation: When the number of electrocardiogram signal samples in the sliding window buffer reaches the initial sample number, the minimum height threshold for each subject is dynamically calculated based on the maximum signal amplitude in the initial electrocardiogram signal samples.
[0039] In the embodiment, when the number of electrocardiogram signal samples in the sliding window buffer reaches the initial sample number, the minimum height threshold for each subject is dynamically calculated based on the maximum signal amplitude in the initial electrocardiogram signal samples. The initial sample number is used to calculate the dynamic minimum height threshold, which is usually set to cover several electrocardiogram cycles. When specifically calculating the minimum height threshold, it is determined based on the maximum signal amplitude in the initial electrocardiogram signal samples and multiplied by a predetermined proportionality coefficient to adapt to signal variations under different individuals and different acquisition conditions, thereby effectively filtering noise and false peaks. Among them, the predetermined proportionality coefficient is 0.85, which is the result obtained by referring to the amplitudes of the P wave and R wave of normal heartbeats and based on a large number of experimental tests and debugging. The P wave of normal people is between 0.05 - 0.15 mV, and the R wave is between 2.0 - 2.5 mV. After a large number of subsequent debuggings, it is determined that the proportionality coefficient of 0.85 is the best.
[0040] S3, Template extraction and merging: Screen R-peaks greater than the minimum height threshold from the sliding window buffer, extract signal segments of a predetermined window size before and after each R-peak position to form multiple R-peak templates, calculate the correlation of pairwise template matching among all R-peak templates, and take the average of the signal values of two R-peak templates with a correlation higher than the preset threshold point by point to generate a comprehensive template, thereby obtaining a comprehensive template set.
[0041] Based on the periodic characteristics of the heartbeat, the embodiment uses correlation (such as Pearson correlation coefficient) to screen out the template that best matches the patient's own characteristics. The specific process is as follows: First, screen R-peaks greater than the minimum height threshold from the sliding window buffer, extract signal segments of a predetermined window size before and after each R-peak position, form multiple R-peak templates and store them in an array. By counting the number of detected ECG R-peaks, the diversity and representativeness of the templates are ensured. Among them, the predetermined window size can be set to the sample point size of 0.2s. This interval is sufficient to contain the heartbeat spike.
[0042] Based on all the extracted R-peak templates, calculate the correlation (such as Pearson correlation coefficient) of pairwise template matching. For each R-peak template, find a group of templates whose matching correlation is higher than the preset threshold. Take the average of the signal values of the two R-peak templates in each group point by point to generate a comprehensive template, thereby obtaining a comprehensive template set. Each comprehensive template can more accurately reflect the true R-peak characteristics and improve the reliability of template matching.
[0043] According to the optimization of experimental data to balance the detection accuracy and false detection rate, based on the comparison results of a large number of experiments, it is concluded that too high a threshold will lead to the failure of most heartbeat R-peak triggers. Too low a threshold may lead to false detections. Here, a preset threshold between 0.8 - 0.95 is more appropriate, preferably 0.85, and it will be adjusted according to device differences later.
[0044] S4, R-peak determination: For the current new ECG signal sample added in real time to the sliding window buffer, calculate its similarity with each comprehensive template in the comprehensive template set. When the similarity value is greater than the similarity threshold, and the interval between the currently detected ECG R-peak and the previous ECG R-peak exceeds the minimum R-R interval, it is determined that an effective ECG R-peak is detected.
[0045] After constructing the comprehensive template, real-time R-peak detection can be performed using the comprehensive template. Specifically, calculate the similarity between the current new ECG signal sample added in real time to the sliding window buffer and each comprehensive template. Here, the similarity can still use the Pearson correlation coefficient. When the similarity value is greater than the preset similarity threshold, it is considered that the current ECG R-peak is detected, and the interval between the currently detected ECG R-peak and the previous ECG R-peak exceeds the minimum R-R interval, then it is determined that an effective ECG R-peak is detected.
[0046] The determination method of the correlation threshold is the same as that of the above-mentioned preset threshold, and is preferably 0.8 - 0.95. Here, the correlation threshold can be slightly lower than the preset threshold between templates. Because, in order to create an accurate template, the preset threshold should be as high as possible. When using the template to perform real-time matching on the signal, the correlation can be slightly reduced to prevent missed detections.
[0047] For the minimum R - R interval, it is set according to the physiological heart rate range to avoid false detections caused by noise or pseudo - peaks. The minimum R - R interval is set to 0.3 s. The heart - beat interval of normal people should be above 0.5 s, and here it is set to 0.3 s to avoid special situations.
[0048] After detecting an effective ECG R - peak, it is also checked whether the starting - point signal amplitude of the signal segment corresponding to the effective ECG R - peak in the sliding - window buffer is higher than the minimum height threshold. When it is higher than the minimum height threshold, the detected effective ECG R - peak is considered accurate and reliable.
[0049] In the above - mentioned method, a filter (such as low - pass filtering, high - pass filtering, or band - pass filtering) can also be added to pre - process the ECG signal before data caching to further reduce noise interference. Of course, when hardware support is available, multi - threading or parallel - processing technologies can be adopted to improve the real - time processing ability.
[0050] The real - time ECG R - peak detection method based on correlation - template matching for the nuclear magnetic resonance scenario provided by the above - mentioned embodiment improves the strong adaptability to different individuals and dynamic signal changes through dynamic threshold adjustment and comprehensive template matching, significantly reduces the possibility of false detections and missed detections, and improves the detection accuracy; ensures the real - time processing ability of the algorithm through the sliding - window technology, is suitable for real - time monitoring requirements, and enhances the real - time performance of the detection; reduces the computational complexity by combining the sliding - window technology, dynamic threshold setting, and correlation - based template matching and merging, is suitable for efficient operation in resource - constrained embedded systems, effectively avoids noise interference, improves the detection stability in a high - noise environment, realizes high - precision and high - real - time detection of R - peaks in ECG signals, can be used in wearable health - monitoring devices or medical diagnostic devices, especially suitable for processing ECG signals in high - noise environments such as nuclear magnetic resonance (MRI), has a wide range of application prospects, and can significantly improve the performance and reliability of cardiac - monitoring devices. The method of the present invention can also be extended and applied to the feature detection of other biological signals, such as the detection of specific waveforms in electroencephalogram (EEG) signals, etc.
[0051] The real-time ECG R-peak detection method based on correlation template matching for nuclear magnetic resonance (NMR) scenarios provided by the above embodiments has an adaptive threshold adjustment algorithm. The template is dynamically generated based on the heartbeat characteristics of each user and can accurately reflect the individualized R-peak morphology. During the pattern matching process, there is no need to pre-filter the original ECG signal, avoiding the phase delay (usually >100 ms) introduced by traditional filtering methods. This design significantly reduces the trigger delay, shortening the response time of R-peak detection to within 20 ms and significantly improving the real-time performance of the MRI ECG gating system. In addition, the personalized template can adapt to the ECG signal characteristics of different patients, further improving the robustness and detection accuracy of the algorithm and accurately reflecting the individualized R-peak morphology.
[0052] The embodiment also provides an example of using the above real-time ECG R-peak detection method for ECG R-peak detection. The example results are as Figure 2 shown. The abscissa represents the sample points in the time series, and the ordinate represents the amplitude of the ECG signal. The two edge parts on both sides are the ECG signals under non-NMR conditions, and the middle part is the ECG signal under NMR noise. Analyzing Figure 2 it can be obtained that in the NMR scenario, the algorithm can still accurately locate the R-peak position in the face of noise interference.
[0053] As Figure 3 shown, the embodiment also provides a real-time ECG R-peak detection device 30 for NMR scenarios based on correlation template matching, including: a data buffer module 31, a dynamic threshold calculation module 32, a template extraction and merging module 33, and an R-peak determination module 34. Among them, the data buffer module 31 is used to perform real-time buffering on the input ECG signal using the sliding window technique to generate a sliding window buffer containing a predetermined number of ECG signal samples; the dynamic threshold calculation module 32 is used to dynamically calculate the minimum height threshold for each tested person based on the maximum signal amplitude in the initial ECG signal samples when the number of ECG signal samples in the sliding window buffer reaches the initial sample number; the template extraction and merging module 33 is used to screen out the R-peaks greater than the minimum height threshold from the sliding window buffer, extract signal segments of a predetermined window size before and after each R-peak position to form multiple R-peak templates, calculate the correlation of pairwise template matching among all R-peak templates, and take the average of the signal values of two R-peak templates with a correlation higher than the preset threshold point by point to generate a comprehensive template, and then obtain a comprehensive template set; the R-peak determination module 34 is used to calculate the similarity between the currently newly added ECG signal sample in the sliding window buffer and each comprehensive template in the comprehensive template set. When the similarity value is greater than the similarity threshold and the interval between the currently detected ECG R-peak and the previous ECG R-peak exceeds the minimum R-R interval, it is determined that an effective ECG R-peak is detected.
[0054] It should be noted that when the above-described real-time electrocardiogram R-peak detection device based on correlation template matching in the nuclear magnetic resonance scenario performs real-time electrocardiogram R-peak detection, the above-described functional modules should be used as examples for illustration. The above functions can be allocated to different functional modules according to needs, that is, the internal structure of the terminal or server is divided into different functional modules to complete all or part of the functions described above. In addition, the above-described real-time electrocardiogram R-peak detection device based on correlation template matching in the nuclear magnetic resonance scenario and the embodiment of the real-time electrocardiogram R-peak detection method based on correlation template matching in the nuclear magnetic resonance scenario belong to the same inventive concept. For the specific implementation process, please refer to the embodiment of the real-time electrocardiogram R-peak detection method based on correlation template matching in the nuclear magnetic resonance scenario, which will not be elaborated here.
[0055] Based on the same inventive concept, the embodiment also provides a computing device, including a memory and one or more processors. An executable code is stored in the memory. When the one or more processors execute the executable code, it is used to implement the above-described real-time electrocardiogram R-peak detection method based on correlation template matching in the nuclear magnetic resonance scenario, specifically including the following steps:
[0056] S1, data buffering: Use the sliding window technique to perform real-time buffering on the input ECG signal to generate a sliding window buffer containing a predetermined number of electrocardiogram signal samples;
[0057] S2, dynamic threshold calculation: When the number of electrocardiogram signal samples in the sliding window buffer reaches the initial sample number, dynamically calculate the minimum height threshold for each subject based on the maximum signal amplitude in the initial electrocardiogram signal samples;
[0058] S3, template extraction and merging: Screen R-peaks greater than the minimum height threshold from the sliding window buffer, extract signal segments of a predetermined window size before and after each R-peak position to form multiple R-peak templates, calculate the correlation between pairwise template matches in all R-peak templates, and take the average of the signal values of two R-peak templates with a correlation higher than the preset threshold point by point to generate a comprehensive template, and then obtain a comprehensive template set;
[0059] S4, R-peak determination: Calculate the similarity between the currently newly added electrocardiogram signal sample in the sliding window buffer and each comprehensive template in the comprehensive template set. When the similarity value is greater than the similarity threshold, and the interval between the currently detected electrocardiogram R-peak and the previous electrocardiogram R-peak exceeds the minimum R-R interval, it is determined that an effective electrocardiogram R-peak is detected.
[0060] The computing device provided by the embodiment, at the hardware level, in addition to including a processor and a memory, further includes an internal bus, a network interface, a memory, and other hardware required for other services. The memory is a non-volatile memory, and the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the real-time ECG R-peak detection method based on correlation template matching in the nuclear magnetic resonance scenario as described in S1-S4 above. Of course, in addition to the software implementation method, the present invention does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, and can also be hardware or logic devices.
[0061] Based on the same inventive concept, the embodiment also provides a computer-readable storage medium, on which a program is stored. When the program is executed by a processor, it implements the real-time ECG R-peak detection method based on correlation template matching in the nuclear magnetic resonance scenario, specifically including the following steps:
[0062] S1, data buffering: Use a sliding window technique to perform real-time buffering on the input ECG signal to generate a sliding window buffer containing a predetermined number of ECG signal samples;
[0063] S2, dynamic threshold calculation: When the number of ECG signal samples in the sliding window buffer reaches the initial sample number, dynamically calculate the minimum height threshold for each subject based on the maximum signal amplitude in the initial ECG signal samples;
[0064] S3, template extraction and merging: Screen out the R-peaks greater than the minimum height threshold from the sliding window buffer, extract signal segments of a predetermined window size before and after each R-peak position to form multiple R-peak templates, calculate the correlation of pairwise template matching among all R-peak templates, and take the average of the signal values of two R-peak templates with a correlation higher than the preset threshold point by point to generate a comprehensive template, and then obtain a comprehensive template set;
[0065] S4, R-peak determination: Calculate the similarity between the currently newly added ECG signal sample in the sliding window buffer and each comprehensive template in the comprehensive template set. When the similarity value is greater than the similarity threshold, and the interval between the currently detected ECG R-peak and the previous ECG R-peak exceeds the minimum R-R interval, it is determined that an effective ECG R-peak is detected.
[0066] In the embodiment, the computer-readable medium includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data.
[0067] The implementation environment of the real-time ECG R-peak detection scheme based on correlation template matching in the nuclear magnetic resonance scenario provided by the above embodiments includes:
[0068] (1) Hardware platform: The method of the present invention can be implemented in various embedded systems, such as microcontrollers, digital signal processors (DSPs), or programmable logic devices (such as FPGAs).
[0069] (2) Software platform: The method of the present invention can be implemented in a programmable processor through C language or other high-efficiency programming languages, and can be scheduled and managed in combination with an operating system or a real-time operating system (RTOS).
[0070] The application scenarios of the real-time ECG R-peak detection scheme based on correlation template matching in the nuclear magnetic resonance scenario provided by the above embodiments are:
[0071] (1) Medical monitoring devices: Such as electrocardiogram monitors and portable electrocardiogram devices, used for real-time cardiac health monitoring in hospital or home environments.
[0072] (2) Wearable health devices: Such as smart watches and fitness trackers, providing continuous heart rate monitoring and abnormal heart rhythm alerts.
[0073] (4) Telemedicine systems: Combining communication technologies to achieve remote electrocardiogram data transmission and monitoring, supporting remote medical diagnosis and emergency response.
[0074] The above specific implementation manners have detailed the technical solutions and beneficial effects of the present invention. It should be understood that the above is only the most preferred embodiment of the present invention and is not used to limit the present invention. Any modifications, supplements, equivalent replacements, etc. made within the scope of the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A real-time electrocardiogram R-peak detection method based on correlation template matching in the nuclear magnetic resonance scenario, characterized in that, It includes the following steps: Data buffering: The sliding window technique is used to buffer the input ECG signals in real time, generating a sliding window buffer containing a predetermined number of ECG signal samples; Dynamic threshold calculation: When the number of ECG signal samples in the sliding window buffer reaches the initial sample number, the minimum height threshold for each subject is dynamically calculated based on the maximum signal amplitude in the initial ECG signal samples; Template extraction and merging: The R-peaks greater than the minimum height threshold are screened from the sliding window buffer, and signal segments of a predetermined window size before and after each R-peak position are extracted to form multiple R-peak templates. The correlation between pairwise template matches among all R-peak templates is calculated, and the signal values of two R-peak templates with a correlation higher than the preset threshold are averaged point by point to generate a comprehensive template, thereby obtaining a comprehensive template set; R-peak determination: For the current new ECG signal samples added in real time to the sliding window buffer, the similarity between it and each comprehensive template in the comprehensive template set is calculated. When the similarity value is greater than the similarity threshold and the interval between the currently detected ECG R-peak and the previous ECG R-peak exceeds the minimum R-R interval, it is determined that a valid ECG R-peak is detected; Among them, the similarity threshold is slightly lower than the preset threshold.
2. The real-time ECG R-peak detection method based on correlation template matching for nuclear magnetic resonance scenarios according to claim 1, wherein During data buffering, it also includes: When the ECG signal samples in the sliding window buffer are not full, new ECG signal samples are directly added to the sliding window buffer. When it is full, the earliest added ECG signal samples are removed and new ECG signal samples are added.
3. The real-time ECG R-peak detection method based on correlation template matching for nuclear magnetic resonance scenarios according to claim 1, characterized in that, Dynamically calculating the minimum height threshold for each subject based on the maximum signal amplitude in the initial ECG signal samples includes: Based on the maximum signal amplitude in the initial ECG signal samples and multiplying by a predetermined proportionality coefficient to determine the minimum height threshold for each subject.
4. The real-time ECG R-peak detection method based on correlation template matching for nuclear magnetic resonance scenarios according to claim 1, wherein When calculating the correlation between pairwise template matches among all R-peak templates, the Pearson correlation coefficient and the Spearman rank correlation coefficient are used.
5. The real-time electrocardiogram R peak detection method based on correlation template matching for nuclear magnetic resonance scenarios according to claim 1, wherein When calculating the similarity between the current new ECG signal samples added in real time to the sliding window buffer and each comprehensive template in the comprehensive template set, the Pearson correlation coefficient and the Spearman rank correlation coefficient are used.
6. The real-time ECG R peak detection method based on correlation template matching for nuclear magnetic resonance scenarios according to claim 1, characterized in that, During R-peak determination, it also includes: Checking whether the starting point signal amplitude of the signal segment corresponding to the valid ECG R-peak in the sliding window buffer is higher than the minimum height threshold. When it is higher than the minimum height threshold, the detected valid ECG R-peak is considered accurate and reliable.
7. A real-time electrocardiogram R peak detection device based on correlation template matching for nuclear magnetic resonance scenarios, characterized in that, It includes: A data buffering module, which is used to buffer the input ECG signals in real time by using the sliding window technique, generating a sliding window buffer containing a predetermined number of ECG signal samples; A dynamic threshold calculation module, which is used to dynamically calculate the minimum height threshold for each subject based on the maximum signal amplitude in the initial ECG signal samples when the number of ECG signal samples in the sliding window buffer reaches the initial sample number; A template extraction and merging module, which is used to screen out R-peaks greater than the minimum height threshold from the sliding window buffer, extract signal segments of a predetermined window size before and after each R-peak position to form multiple R-peak templates, calculate the correlation between pairwise templates among all R-peak templates, and take the average of the signal values of two R-peak templates with a correlation higher than the preset threshold point by point to generate a comprehensive template, and then obtain a comprehensive template set; An R-peak determination module, which is used to calculate the similarity between the current new electrocardiogram signal sample newly added to the sliding window buffer and each comprehensive template in the comprehensive template set. When the similarity value is greater than the similarity threshold and the interval between the detected electrocardiogram R-peak of the current new electrocardiogram signal sample and the previous electrocardiogram R-peak exceeds the minimum R-R interval, it is determined that a valid electrocardiogram R-peak is detected; Among them, the similarity threshold is slightly lower than the preset threshold.
8. A computing device, comprising a memory and one or more processors, wherein executable code is stored in the memory, characterized in that, When the one or more processors execute the executable code, it is used to implement the real-time electrocardiogram R-peak detection method based on correlation template matching in the nuclear magnetic resonance scenario described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, A program is stored thereon, and when the program is executed by a processor, it implements the real-time electrocardiogram R-peak detection method based on correlation template matching in the nuclear magnetic resonance scenario described in any one of claims 1-6.
10. A computer product, which includes a computer program, characterized in that, When the computer program is executed by a processor, it implements the real-time electrocardiogram R-peak detection method based on correlation template matching in the nuclear magnetic resonance scenario described in any one of claims 1-6.
Citation Information
Patent Citations
Heart rate acquiring method and electrocardiosignal processing method
CN103690156A
R-peak detection apparatus and control method thereof
US20130165805A1