Real-time electrocardiogram R peak detection method and device based on correlation template matching in nuclear magnetic resonance scene

By using sliding window technology, dynamic threshold and correlation template matching methods in the NMR scenario, a personalized comprehensive template is generated, which solves the error and missed detection problems of ECG R peak detection in a high-noise environment, and achieves high-precision and high-reality detection effects.

CN119837541AActive Publication Date: 2025-04-18HANGZHOU RONGNAO TECHNOLOGY CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510348755.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-24
Publication Date
2025-04-18
Estimated Expiration
2045-03-24

AI Technical Summary

Technical Problem

The prior art is prone to false detection and missed detection in the detection of ECG R peak in nuclear magnetic resonance scenarios, and has poor adaptability to dynamically changing ECG signals and insufficient real-time processing capabilities.

Method used

Sliding window technology, dynamic threshold setting, and correlation template matching and merging are used to generate a personalized comprehensive template to conduct real-time ECG R peak detection.

Benefits of technology

It significantly improves the accuracy and real-time performance of ECG R peak detection, reduces calculation complexity, and is suitable for resource-constrained embedded systems, reduces noise interference, and improves detection stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119837541A_ABST
    Figure CN119837541A_ABST
Patent Text Reader

Abstract

The invention discloses a real-time electrocardiograph R peak detection method and device based on correlation template matching in a nuclear magnetic resonance scene, and belongs to the technical field of medical image data processing.The method comprises the steps that a sliding window is adopted for buffering input ECG signals in real time, and continuity and real-time performance of data are ensured; the minimum height threshold value is dynamically calculated to adapt to signal changes under individual differences so as to effectively filter noise and false peaks; according to the method, a plurality of candidate R peak templates are extracted, the correlation among the templates is calculated to merge similar templates to obtain a comprehensive template, and the comprehensive template can reflect real R peak characteristics more accurately, so that the detection reliability is improved. When a new electrocardiosignal sample enters the sliding window, correlation comparison is conducted on the new electrocardiosignal sample and the comprehensive template, if the correlation coefficient exceeds a preset threshold value and meets the minimum requirement of the heart rate interval, it is judged that the new electrocardiosignal sample is an effective R peak, and in the process, the detection accuracy is improved, and the possibility of false detection and missing detection is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of medical image data processing, and in particular relates to a real-time electrocardiogram R peak detection method and device based on correlation template matching in a nuclear magnetic resonance scene. Background Art

[0002] Electrocardiogram (ECG) is a commonly used biomedical signal and is widely used in 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, heart rhythm and heart health. Therefore, accurate and real-time detection of the ECG R-peak is of great significance for early diagnosis of heart disease, sports health monitoring and telemedicine.

[0003] During magnetic resonance imaging (MRI) imaging, ECG signals are subject to strong electromagnetic interference such as gradient magnetic field switching and radio frequency pulses, resulting in a large amount of high-frequency noise and baseline drift in 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 relies on the amplitude and derivative of the ECG signal. The algorithm detects the R peak through a series of filtering, differentiation, integration, and threshold judgment steps. However, when processing ECG signals in a high-noise environment, the Pan-Tompkins algorithm is prone to false detection and missed detection problems, and its adaptability to dynamically changing ECG signals is poor, which limits its application in complex environments, thereby affecting the accuracy and image quality of MRI imaging.

[0004] With the development of wearable devices and mobile health monitoring technology, higher requirements are placed on the real-time performance and computational efficiency of R-peak detection algorithms. Many existing methods have a trade-off between real-time processing capabilities and computational complexity, making it difficult to run efficiently in resource-constrained embedded systems. At the same time, traditional template matching methods often lack sufficient flexibility and robustness when processing ECG signals with large individual differences, which affects the accuracy of detection. Existing pattern matching technologies are usually based on classification tasks of machine learning or deep learning, using a more universal template for training and matching. Although this method improves detection accuracy to a certain extent, it has high computational complexity, poor real-time performance, and high requirements for hardware devices, making it difficult to run 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 strike a balance between real-time performance, accuracy, and computational efficiency. The method should have the ability to adaptively adjust the threshold, effectively filter noise interference, improve the correlation analysis ability of template matching, and adapt to the characteristics of ECG signals of different individuals and dynamic changes. In addition, as ECG monitoring equipment develops towards wearable and intelligent directions, new R-peak detection algorithms should have lower computing resource requirements to adapt to the application environment of embedded systems. Summary of the invention

[0006] In view of the above, the purpose of the present invention is to provide a real-time ECG R-peak detection method and device based on correlation template matching in a nuclear magnetic resonance scene, aiming to solve the technical problems in the prior art that R-peak detection is prone to false detection and missed detection in a high-noise environment such as a nuclear magnetic resonance scene, poor adaptability to dynamic signal changes, and insufficient real-time processing capabilities. The present invention significantly improves the accuracy and real-time performance of ECG R-peak detection by introducing sliding window technology, dynamic threshold setting, and correlation template matching and merging, and is suitable for medical monitoring equipment, wearable health equipment, and other application scenarios that require real-time heart rate monitoring.

[0007] To achieve the above-mentioned purpose of the invention, an embodiment of the present invention provides a real-time ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scene, comprising the following steps: Data buffering: The input ECG signal is buffered in real time using sliding window technology to generate 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 number of samples, the minimum height threshold of each subject is dynamically calculated based on the maximum signal amplitude in the initial ECG signal samples; Template extraction and merging: R peaks with a height greater than the minimum threshold are screened from the sliding window buffer, and signal segments of a predetermined window size are extracted from each R peak position to form multiple R peak templates. The correlation between the pairwise template matches of all R peak templates is calculated, and the signal values ​​of the two R peak templates with a correlation greater 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 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 ECG R peak detected in the current new ECG signal sample and the previous ECG R peak exceeds the minimum RR interval, it is determined that a valid ECG R peak has been detected.

[0008] Preferably, data buffering also includes: when the ECG signal samples in the sliding window buffer are not full, directly adding new ECG signal samples to the sliding window buffer; when it is full, removing the earliest added ECG signal samples and adding new ECG signal samples to ensure the continuity and real-time nature of the data.

[0009] Preferably, the minimum height threshold of each subject is dynamically calculated based on the maximum signal amplitude in the initial ECG signal sample, including: The minimum height threshold of each test subject is determined based on the maximum signal amplitude in the initial ECG signal samples and multiplied by a predetermined proportionality coefficient.

[0010] Preferably, when calculating the correlation between pairwise template matching among all R peak templates, the Pearson correlation coefficient, Spearman rank correlation coefficient, etc. are used.

[0011] Preferably, when calculating the similarity between the current new ECG signal sample added in real time to the sliding window buffer and each comprehensive template in the comprehensive template set, the Pearson correlation coefficient, the Spearman rank correlation coefficient, etc. are used.

[0012] Preferably, when judging the R peak, it also includes: checking whether the signal amplitude of the starting point 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.

[0013] To achieve the above-mentioned purpose of the invention, an embodiment provides a real-time ECG R peak detection device based on correlation template matching in a nuclear magnetic resonance scene, comprising: A data buffer module, which is used to use a sliding window technique to buffer the input ECG signal in real time and generate 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 of each test 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 number of samples; The template extraction and merging module is used to filter out R peaks greater than the minimum height threshold from the sliding window buffer, and extract signal fragments of a predetermined window size before and after each R peak position to form multiple R peak templates, and calculate the correlation between the template matches between all R peak templates, and average the signal values ​​of the 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; The R peak determination module is used to calculate the similarity between the current new ECG signal sample added in real time 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 ECG R peak detected in the current new ECG signal sample and the previous ECG R peak exceeds the minimum RR interval, it is determined that a valid ECG R peak is detected.

[0014] To achieve the above-mentioned purpose of the invention, an embodiment also provides a computing device, including a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, they are used to implement the above-mentioned real-time ECG R peak detection method based on correlation template matching in the nuclear magnetic resonance scenario.

[0015] To achieve the above-mentioned purpose of the invention, an embodiment further provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the above-mentioned real-time ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scenario is implemented.

[0016] To achieve the above-mentioned purpose of the invention, an embodiment further provides a computer product, which includes a computer program. When the computer program is executed by a processor, it implements the above-mentioned real-time ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scenario.

[0017] Compared with the prior art, the present invention has the following beneficial effects: The present invention uses the heartbeat characteristics of the test subject to generate a personalized comprehensive template for R peak detection. In the subsequent real-time matching, only a simple similarity calculation is required, with low computational complexity (O(n)), and 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 the detection, but also reduces the dependence on hardware resources. It is suitable for application scenarios with high requirements for computational efficiency, such as MRI ECG gating systems.

[0018] The pattern matching used in the present invention for ECG R peak recognition can effectively suppress noise interference and accurately recognize ECG R peak by dynamically generating a specific comprehensive template for the test subject. Even in the high noise environment of MRI, the method can still maintain a high detection accuracy and ensure the reliability of ECG gating signals, thus playing a key role in nuclear magnetic resonance imaging. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0020] Figure 1 It is a flow chart of a real-time ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scenario provided by an embodiment; Figure 2 is an example diagram of ECG R peak error detection and correction provided by the embodiment; Figure 3 It is a structural schematic diagram of a real-time ECG R-peak detection device based on correlation template matching in a nuclear magnetic resonance scenario provided in an embodiment. DETAILED DESCRIPTION

[0021] To make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific implementation methods described herein are only used to explain the present invention and do not limit the scope of protection of the present invention.

[0022] The inventive concept of the present invention is: the gradient magnetic field switching and radio frequency pulses in the existing nuclear magnetic resonance environment will introduce a large amount of high-frequency noise and baseline drift. The traditional R peak detection method relies on the amplitude and derivative calculation of the electrocardiogram signal, which is difficult to ensure accuracy in a high noise environment, and the false detection rate and missed detection rate are significantly increased. To solve this technical problem, the embodiment of the present invention provides a real-time electrocardiogram R peak detection scheme based on correlation template matching in a nuclear magnetic resonance scene. Through sliding window technology, dynamic threshold setting and correlation-based template matching, it performs well in a dynamic environment, improves the adaptability and robustness of the algorithm to different electrocardiogram signal changes, realizes high-precision recognition and detection of R peaks, can effectively suppress noise interference, and the false detection rate is less than 5%. At the same time, no complex pre-filtering processing is required, and the trigger delay is less than 20ms, which meets the real-time requirements of MRI electrocardiogram gating. In addition, the algorithm of the present invention has low computational complexity (O(n)), can run efficiently in resource-constrained embedded systems such as microcontrollers, has a CPU occupancy rate of less than 5%, and a memory occupancy of less than 2KB, which 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 magnetic resonance imaging. It can significantly improve the performance and reliability of related equipment, provide a high-precision, low-latency R-peak detection solution for the ECG gating system, effectively reduce imaging artifacts and improve image quality.

[0023] like Figure 1 As shown, the embodiment provides a real-time ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scenario, comprising the following steps: S1, data buffering: The input ECG signal is buffered in real time using the sliding window technique to generate a sliding window buffer containing a predetermined number of ECG signal samples.

[0024] 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 ECG signal samples, wherein the sliding window size is set according to the sampling rate of the ECG signal and the characteristics of the R peak to ensure that sufficient ECG signal cycles are covered. The predetermined number can be adjusted based on different devices. Generally, ten seconds of data can be collected. The obtained sliding layer window buffer is used for the subsequent construction of the comprehensive template. Specifically, when the sliding window buffer is not full, that is, 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 the ECG signal samples in the sliding window buffer are full, the earliest added ECG signal samples are removed and new ECG signal samples are added to ensure the continuity and real-time nature of the data.

[0025] S2, dynamic threshold calculation: when the number of ECG signal samples in the sliding window buffer reaches the initial number of samples, the minimum height threshold of each subject is dynamically calculated based on the maximum signal amplitude in the initial ECG signal samples.

[0026] In an embodiment, when the number of ECG signal samples in the sliding window buffer reaches the initial number of samples, the minimum height threshold of each test subject is dynamically calculated based on the maximum signal amplitude in the initial ECG signal sample. The initial number of samples is used to calculate the dynamic minimum height threshold, which is usually set to cover several ECG cycles. When specifically calculating the minimum height threshold, the minimum height threshold of each test subject is determined based on the maximum signal amplitude in the initial ECG signal sample and multiplied by a predetermined proportional coefficient, so that the signal changes under different individuals and different acquisition conditions can be adapted to effectively filter noise and pseudo peaks. Among them, the predetermined proportional coefficient is 0.85, which is a result obtained by referring to the amplitude of the P wave and R wave of a normal heartbeat and based on a large number of experimental tests and debugging. The P wave of a normal person is between 0.05-0.15 mV and the R wave is between 2.0-2.5 mV. After a lot of subsequent debugging, it was determined that the proportional coefficient was 0.85.

[0027] S3, template extraction and merging: Filter R peaks greater than the minimum height threshold from the sliding window buffer, and extract signal fragments of a predetermined window size before and after each R peak position to form multiple R peak templates, and calculate the correlation between the pairwise template matching of all R peak templates, and average the signal values ​​of the two R peak templates whose correlation is higher than the preset threshold point by point to generate a comprehensive template, and then obtain a comprehensive template set.

[0028] Based on the periodic characteristics of the heartbeat, the embodiment uses correlation (such as the Pearson correlation coefficient) to filter out the template that best matches the patient's own characteristics. The specific process is: first, the R peaks greater than the minimum height threshold are filtered out from the sliding window buffer, and the signal segments of the predetermined window size before and after each R peak position are extracted to form multiple R peak templates and store them in the array. By counting the number of ECG R peaks detected, the diversity and representativeness of the templates are ensured, wherein the predetermined window size is set to a sample point size of 0.2s. This interval is sufficient to contain the heartbeat peak.

[0029] Based on all the extracted R-peak templates, the correlation (such as Pearson correlation coefficient) of pairwise template matching is calculated. For each R-peak template, a group of templates whose matching correlation is higher than the preset threshold is found. The signal values ​​of the two R-peak templates in each group of templates are averaged point by point to generate a comprehensive template, and then a comprehensive template set is obtained. Each comprehensive template can more accurately reflect the real R-peak characteristics and improve the reliability of template matching.

[0030] According to the experimental data optimization, in order to balance the accuracy and false detection rate of detection, based on a large number of experimental comparison results, it is concluded that a threshold that is too high will cause most heartbeat R peak triggering failures. A threshold that is too low may cause false detections. Here, a preset threshold between 0.8-0.95 is more appropriate, preferably 0.85, and will be debugged later according to device differences.

[0031] 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 ECG R peak detected in the current new ECG signal sample and the previous ECG R peak exceeds the minimum RR interval, it is determined that a valid ECG R peak is detected.

[0032] After constructing the comprehensive template, the comprehensive template can be used for real-time R peak detection. Specifically, the current new ECG signal sample added in real time in the sliding window buffer is calculated similarity with each comprehensive template. The similarity here 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 RR interval, then it is determined that a valid ECG R peak is detected.

[0033] The correlation threshold is determined in the same manner as the preset threshold, and is also preferably 0.8-0.95. Here, the correlation threshold can be slightly lower than the preset threshold between templates. Because, in order to make an accurate template, the preset threshold should be as high as possible. When using the template for real-time matching on the signal, the correlation can be slightly reduced to prevent missed detection.

[0034] The minimum RR interval is set according to the physiological heart rate range to avoid false detection due to noise or false peaks. The minimum RR interval is set to 0.3s. The heartbeat interval of a normal person should be above 0.5s. Here, it is set to 0.3s to avoid special cases.

[0035] After detecting a valid ECG R peak, it is also checked whether the signal amplitude of the starting point 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.

[0036] In the above method, a filter (such as low-pass filtering, high-pass filtering or band-pass filtering) can be added before data caching to pre-process the ECG signal to further reduce noise interference. Of course, multi-threading or parallel processing technology can also be used to improve real-time processing capabilities if hardware supports it.

[0037] The real-time ECG R peak detection method based on correlation template matching in the nuclear magnetic resonance scenario provided by the above embodiment improves the strong adaptability to different individuals and dynamic signal changes by dynamically adjusting the threshold and comprehensive template matching, significantly reduces the possibility of false detection and missed detection, and improves the detection accuracy; the real-time processing capability of the algorithm is ensured by the sliding window technology, which is suitable for real-time monitoring needs and enhances the real-time performance of detection; by combining the sliding window technology, dynamic threshold setting and correlation-based template matching and merging, the computational complexity is reduced, and it is suitable for efficient operation in resource-constrained embedded systems, effectively avoiding noise interference, and improving the detection stability in high-noise environments. It realizes high-precision and high-real-time detection of the R peak in the ECG signal, which can be used in wearable health monitoring equipment or medical diagnostic equipment, especially suitable for ECG signal processing 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 heart monitoring equipment. The method of the present invention can also be extended to the feature detection of other biological signals, such as specific waveform detection in electroencephalogram (EEG) signals.

[0038] The real-time ECG R-peak detection method based on correlation template matching in the nuclear magnetic resonance scenario provided in the above embodiment 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. In the pattern matching process, there is no need to pre-filter the original ECG signal, avoiding the phase delay (usually >100ms) introduced by traditional filtering methods. This design greatly reduces the trigger delay, shortens the response time of R-peak detection to less than 20ms, and significantly improves 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 improves the robustness and detection accuracy of the algorithm, and can accurately reflect the individualized R-peak morphology.

[0039] The embodiment also provides an example of using the above-mentioned real-time ECG R peak detection method to perform real-time ECG R peak detection. The example results are as follows: Figure 2 As shown in the figure, the horizontal axis represents the sample points in the time series, and the vertical axis represents the ECG signal amplitude. The edge parts on both sides are ECG signals under non-nuclear magnetic resonance, and the middle part is the ECG signal under nuclear magnetic noise. Figure 2 It can be seen that in the scenario of nuclear magnetic resonance, the algorithm can still accurately locate the R peak position in the face of noise interference.

[0040] like Figure 3 As shown, the embodiment also provides a real-time ECG R peak detection device 30 based on correlation template matching in a nuclear magnetic resonance scenario, 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, wherein the data buffer module 31 is used to use a sliding window technology to buffer the input ECG signal in real time 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 of each test 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 number of samples; the template extraction and merging module 33 is used to extract the minimum height threshold of each test subject from the sliding window R peaks greater than the minimum height threshold are screened in the buffer, and signal segments of a predetermined window size before and after each R peak position are extracted to form multiple R peak templates, and the correlation between the pairwise template matching of all R peak templates is calculated, and the signal values ​​of the two R peak templates with correlation higher than the preset threshold are averaged point by point to generate a comprehensive template, thereby obtaining a comprehensive template set; the R peak determination module 34 is used to calculate the similarity between the current new ECG signal sample added in real time to the sliding window buffer and each comprehensive template in the comprehensive template set, and when the similarity value is greater than the similarity threshold, and the interval between the ECG R peak detected by the current new ECG signal sample and the previous ECG R peak exceeds the minimum RR interval, it is determined that a valid ECG R peak is detected.

[0041] It should be noted that the real-time ECG R-peak detection device based on correlation template matching for nuclear magnetic resonance scenarios provided in the above embodiments should be illustrated by the division of the above-mentioned functional modules when performing real-time ECG R-peak detection. The above-mentioned functions can be assigned to different functional modules as needed, 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 real-time ECG R-peak detection device based on correlation template matching for nuclear magnetic resonance scenarios provided in the above embodiments and the embodiment of the real-time ECG R-peak detection method based on correlation template matching for nuclear magnetic resonance scenarios belong to the same concept. The specific implementation process is detailed in the embodiment of the real-time ECG R-peak detection method based on correlation template matching for nuclear magnetic resonance scenarios, which will not be repeated here.

[0042] Based on the same inventive concept, an embodiment further provides a computing device, including a memory and one or more processors, wherein executable code is stored in the memory, and when the one or more processors execute the executable code, the method is used to implement the above-mentioned real-time ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scene, specifically including the following steps: S1, data buffering: using sliding window technology to buffer the input ECG signal in real time, generating a sliding window buffer containing a predetermined number of ECG signal samples; S2, dynamic threshold calculation: when the number of ECG signal samples in the sliding window buffer reaches the initial number of samples, the minimum height threshold of each subject is dynamically calculated based on the maximum signal amplitude in the initial ECG signal samples; S3, template extraction and merging: R peaks greater than the minimum height threshold are screened from the sliding window buffer, and signal segments of a predetermined window size are extracted from each R peak position to form multiple R peak templates, and the correlation between the pairwise template matching of all R peak templates is calculated, and the signal values ​​of the two R peak templates with correlations higher than the preset threshold are averaged point by point to generate a comprehensive template, thereby obtaining a comprehensive template set; 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 ECG R peak detected in the current new ECG signal sample and the previous ECG R peak exceeds the minimum RR interval, it is determined that a valid ECG R peak is detected.

[0043] The computing device provided in the embodiment, in addition to the processor and memory, also includes hardware required for other services such as internal bus, network interface, memory, etc. at the hardware level. 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 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, but can also be hardware or logic devices.

[0044] Based on the same inventive concept, an embodiment further provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the above-mentioned real-time ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scenario is implemented, which specifically includes the following steps: S1, data buffering: using sliding window technology to buffer the input ECG signal in real time, generating a sliding window buffer containing a predetermined number of ECG signal samples; S2, dynamic threshold calculation: when the number of ECG signal samples in the sliding window buffer reaches the initial number of samples, the minimum height threshold of each subject is dynamically calculated based on the maximum signal amplitude in the initial ECG signal samples; S3, template extraction and merging: R peaks greater than the minimum height threshold are screened from the sliding window buffer, and signal segments of a predetermined window size are extracted from each R peak position to form multiple R peak templates, and the correlation between the pairwise template matching of all R peak templates is calculated, and the signal values ​​of the two R peak templates with correlations higher than the preset threshold are averaged point by point to generate a comprehensive template, thereby obtaining a comprehensive template set; 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 ECG R peak detected in the current new ECG signal sample and the previous ECG R peak exceeds the minimum RR interval, it is determined that a valid ECG R peak is detected.

[0045] In the embodiment, computer-readable media include 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.

[0046] The implementation environment of the real-time ECG R peak detection solution based on correlation template matching in the nuclear magnetic resonance scenario provided in the above embodiment includes: (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).

[0047] (2) Software platform: The method of the present invention can be implemented in a programmable processor using C language or other efficient programming languages, and can be combined with an operating system or a real-time operating system (RTOS) for scheduling and management.

[0048] The application scenarios of the real-time ECG R peak detection solution based on correlation template matching in the nuclear magnetic resonance scenario provided in the above embodiment are as follows: (1) Medical monitoring equipment: such as ECG monitors and portable ECG devices, used for real-time cardiac health monitoring in hospital or home environments.

[0049] (2) Wearable health devices: such as smart watches and fitness trackers, which provide continuous heart rate monitoring and abnormal heart rhythm alerts.

[0050] (4) Telemedicine system: Combined with communication technology, it can realize remote ECG data transmission and monitoring, and support remote medical diagnosis and emergency response.

[0051] The specific implementation methods described above provide a detailed description of 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 intended to limit the present invention. Any modifications, supplements and equivalent substitutions 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 ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scene, characterized in that: The following steps are involved: Data buffering: The input ECG signal is buffered in real time using sliding window technology to generate 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 number of samples, the minimum height threshold of each subject is dynamically calculated based on the maximum signal amplitude in the initial ECG signal samples; Template extraction and merging: R peaks with a height greater than the minimum threshold are screened from the sliding window buffer, and signal segments of a predetermined window size are extracted from each R peak position to form multiple R peak templates. The correlation between the pairwise template matches of all R peak templates is calculated, and the signal values ​​of the two R peak templates with a correlation greater 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 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 ECG R peak detected in the current new ECG signal sample and the previous ECG R peak exceeds the minimum RR interval, it is determined that a valid ECG R peak has been detected.

2. The real-time ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scene according to claim 1, characterized in that: When buffering data, it also includes: when the ECG signal samples in the sliding window buffer are not full, directly adding new ECG signal samples to the sliding window buffer; when it is full, removing the earliest added ECG signal samples and adding new ECG signal samples.

3. The real-time ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scene according to claim 1, characterized in that: The minimum height threshold for each subject is dynamically calculated based on the maximum signal amplitude in the initial ECG signal samples, including: The minimum height threshold of each test subject is determined based on the maximum signal amplitude in the initial ECG signal samples and multiplied by a predetermined proportionality coefficient.

4. The real-time ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scene according to claim 1, characterized in that: When calculating the correlation between pairwise template matching among all R peak templates, Pearson correlation coefficient and Spearman rank correlation coefficient were used.

5. The real-time ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scene according to claim 1, characterized in that: When calculating the similarity between the current new ECG signal sample 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 in a nuclear magnetic resonance scene according to claim 1, characterized in that: When judging the R peak, it also includes: checking whether the signal amplitude of the starting point 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.

7. A real-time ECG R peak detection device based on correlation template matching in a nuclear magnetic resonance scene, characterized in that: include: A data buffer module, which is used to use a sliding window technique to buffer the input ECG signal in real time and generate 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 of each test 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 number of samples; The template extraction and merging module is used to filter out R peaks greater than the minimum height threshold from the sliding window buffer, and extract signal fragments of a predetermined window size before and after each R peak position to form multiple R peak templates, and calculate the correlation between the template matches between all R peak templates, and average the signal values ​​of the 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; The R peak determination module is used to calculate the similarity between the current new ECG signal sample added in real time 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 ECG R peak detected in the current new ECG signal sample and the previous ECG R peak exceeds the minimum RR interval, it is determined that a valid ECG R peak is detected.

8. A computing device comprising a memory and one or more processors, wherein the memory stores executable code, characterized in that: When the one or more processors execute the executable code, they are used to implement the real-time ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scenario as 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, the real-time ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scenario as described in any one of claims 1-6 is implemented.

10. A computer product comprising a computer program, characterized in that When the computer program is executed by a processor, the real-time ECG R peak detection method based on correlation template matching in a nuclear magnetic resonance scenario according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Heart rate acquiring method and electrocardiosignal processing method

    CN103690156A

  • Electrocardiosignal R peak position extraction method and module, monitoring device and storage medium

    CN116269430A

  • Method of using a matched filter for detecting QRS complex from a patient undergoing magnetic resonance imaging

    US20040073124A1

  • R-peak detection apparatus and control method thereof

    US20130165805A1

  • Physiologic Signal Analysis Using Multiple Frequency Bands

    US20190282113A1