A method and system for segmenting electrocardiogram (ECG) signal waveforms based on deep learning
By using deep learning-based sliding window segmentation and weighted averaging technology, combined with encoder and Transformer sub-networks, the problem of low segmentation accuracy of ECG signal waveforms is solved, achieving higher segmentation accuracy and completeness.
Patent Information
- Application Number
- CN202211248162.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-12
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2042-10-12
AI Technical Summary
Existing technologies fail to reasonably utilize the time correlation in ECG signals and the differences between different leads of ECG signals, resulting in low waveform segmentation accuracy.
A deep learning-based ECG signal waveform segmentation method is adopted. The multi-lead original ECG signal is segmented through a sliding window. The deep learning model is used for waveform classification. Weighted averaging is performed at the single-lead and multi-lead levels. The encoder and Transformer sub-network are combined to extract features and correct the waveform segmentation points.
The accuracy of waveform segmentation is significantly improved, especially when the quality of some leads of the ECG signal is poor. By integrating information from other leads to fill in missed detections and correct false detections, the overall segmentation effect is improved.
Smart Images

Figure CN115905969B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of electrocardiogram analysis, and more specifically, relates to a method and system for electrocardiogram signal waveform segmentation based on deep learning. Background Art
[0002] An electrocardiogram (ECG) is a graph of the potential difference of the heart's electrical activity recorded at specific locations on the body. A normal cardiac cycle can be divided into three wave bands: P, QRS, and T. Cardiovascular diseases often manifest abnormalities in the ECG, manifesting as changes in the length, amplitude, or morphology of specific wave bands: P wave absence is one of the key clinical features for detecting atrial fibrillation; detection of the QRS complex (R peak) is often used to extract the RR interval, which is further used to diagnose different arrhythmias; changes in T wave morphology are associated with coronary heart disease, myocardial ischemia, myocardial infarction, and other diseases. Accurate detection of the end of the T wave can help doctors determine changes in the QT interval and is important for predicting malignant ventricular arrhythmias and sudden cardiac death. In summary, accurate automatic waveform segmentation and analysis of ECG signals can assist in the clinical diagnosis of various cardiovascular diseases, improving the efficiency and accuracy of clinical cardiovascular disease diagnosis.
[0003] In recent years, many researchers have developed methods for ECG waveform delineation. Early approaches included digital signal processing and traditional machine learning. Digital signal processing, including differential thresholding, filter-based methods, transform-based methods, and empirical mode decomposition, is primarily used to segment the QRS complex. Traditional machine learning methods include support vector machine (SVM) classifiers and the K-nearest neighbor model. These methods often require specific feature extraction and the setting of complex hyperparameters such as thresholds. The resulting waveform segmentation is inaccurate, exhibiting significant variability across different ECG leads and datasets, and is highly sensitive to noise. In recent years, some ECG signal segmentation methods based on deep learning algorithms have emerged that eliminate the feature extraction step. However, these methods still fail to fully consider the temporal correlation of ECG signals and are developed only for specific ECG leads, neglecting the differences and connections between leads. Consequently, waveform segmentation accuracy remains to be improved. Summary of the Invention
[0004] In response to the above-mentioned defects or improvement needs of the existing technology, the present invention provides a method and system for ECG signal waveform segmentation based on deep learning, which is used to solve the technical problem that the existing technology fails to reasonably utilize the time correlation in ECG signals and the differences between different leads of ECG signals, resulting in low waveform segmentation accuracy.
[0005] In order to achieve the above objectives, in a first aspect, the present invention provides an electrocardiogram signal waveform segmentation method based on deep learning, comprising the following steps:
[0006] S1. Segmenting the original ECG signal of each lead in the multi-lead original ECG signal to be segmented using a sliding window, and preprocessing each obtained signal segment to obtain an ECG signal segment of each lead; wherein the step size of the sliding window is smaller than the length of the sliding window;
[0007] S2. Input each ECG signal segment under each lead into a pre-trained ECG signal waveform classification model to obtain a sampling point granularity-level waveform classification probability of each ECG signal segment under each lead;
[0008] S3. The sampling point granularity-level waveform classification probabilities of each ECG signal segment in each lead are spliced according to the original segmentation order of the ECG signal segments in the lead, and the classification probabilities of the overlapping parts are weighted averaged to obtain the sampling point granularity-level waveform classification probabilities and waveform classification results of the original ECG signal in each lead based on the single lead information. The sampling points where the waveform classification results jump are used as segmentation points to obtain the segmentation points of the original ECG signal in each lead based on the single lead information.
[0009] S4. Performing a weighted average calculation among the leads on the waveform classification probabilities at the sampling point granularity level based on the single-lead information for the original ECG signal in each lead, thereby obtaining the waveform classification probabilities at the sampling point granularity level and the waveform classification results for the original ECG signal in each lead based on the multi-lead information. The sampling points where the waveform classification results change are used as segmentation points, thereby obtaining the segmentation points of the original ECG signal in each lead based on the multi-lead information.
[0010] S5. For each lead of the original ECG signal, determine whether the time difference between each segmentation point based on the single-lead information and its corresponding segmentation point based on the multi-lead information is less than a preset error threshold. If so, use the segmentation point based on the single-lead information as the segmentation point; otherwise, use the corresponding segmentation point based on the multi-lead information as the segmentation point. Finally, obtain the segmentation points of the original ECG signal for each lead.
[0011] Among them, the above-mentioned ECG signal waveform classification model is a deep learning model.
[0012] Further preferably, the waveform classification probability of the original ECG signal in the i-th lead at the t sampling point based on the single lead information is:
[0013]
[0014] Where α is the weight; T and τ are the sliding window sampling length and step size respectively; P(i, j, t) is the waveform classification probability of the j-th ECG signal segment under the i-th lead at sampling point t.
[0015] Further preferably, the waveform classification probability of the original ECG signal in the i-th lead at the t sampling point based on the multi-lead information is:
[0016]
[0017] Among them, β i is the weighted value of the i-th lead; n is the number of leads of the original ECG signal; P a (i, t) is the waveform classification probability of the original ECG signal in the i-th lead at the t sampling point based on the single lead information.
[0018] Further preferably, in step S1, the method of preprocessing the obtained signal segments includes: sequentially performing resampling and standardization processing on the obtained signal segments.
[0019] Further preferably, the waveform classification probability includes the corresponding probabilities when classified into different waveform categories; the waveform categories include: no waveform, P wave, QRS complex wave and T wave.
[0020] Further preferably, the method for obtaining the segmentation points of the original electrocardiogram signal comprises: obtaining the segmentation points of the original electrocardiogram signal by sequentially performing sharpening processing and differential processing on the sampling point granularity level waveform classification probability of the original electrocardiogram signal;
[0021] The sampling point granularity level waveform classification probability of the original ECG signal is the sampling point granularity level waveform classification probability of the original ECG signal based on single-lead information or the sampling point granularity level waveform classification probability of the original ECG signal based on multi-lead information;
[0022] The sharpening process includes: respectively setting the part of the granularity-level waveform classification probability of the original ECG signal sampling point corresponding to the division into different waveform categories, which is greater than or equal to the preset classification probability, to 1, and setting the remaining part to 0, to obtain a binary sequence corresponding to the division of each sampling point in the original ECG signal into different waveform categories, and obtaining a binary sequence when the original ECG signal corresponds to different waveform categories; wherein, in the binary sequence when the original ECG signal corresponds to a certain waveform category, a value of 1 indicates that the waveform classification result of the corresponding sampling point is the waveform category, and a value of 0 indicates that the waveform classification result of the corresponding sampling point is not the waveform category;
[0023] The differential processing includes: performing differential calculation on each binary sequence respectively, taking the sampling point corresponding to the differential value of 1 as the starting point of a segmented waveform, and the sampling point corresponding to the differential value of -1 as the end point of a segmented waveform, and merging them to obtain the segmentation points of the original ECG signal.
[0024] Further preferably, the method for obtaining segmentation points of the original electrocardiogram signal further comprises: waveform completion and elimination processing performed between the sharpening processing and the difference processing;
[0025] Among them, the waveform completion and elimination processing includes: for a binary sequence, when the length of the part with continuous values of 0 is less than a first preset length, the value of this part is set to 1, and waveform completion is performed; when the length of the part with continuous values of 1 is less than a second preset length, the value of this part is set to 0, and waveform elimination is performed.
[0026] Further preferably, the above-mentioned ECG signal waveform classification model includes: an encoder subnetwork, a Transformer subnetwork and a decoder subnetwork; wherein the encoder subnetwork includes multiple cascaded encoders; the encoder includes a cascaded convolutional layer and a pooling layer; the decoder subnetwork includes multiple cascaded decoders; the decoder includes a cascaded deconvolution layer, a channel merging layer, a first SE attention module, a convolutional layer and a second SE attention module; the output ends of the convolutional layers in the multiple cascaded encoders are respectively connected to the input ends of the channel merging layers in the multiple cascaded decoders in a one-to-one correspondence; the output end of the last-level encoder is connected to the input end of the Transformer subnetwork; the output end of the Transformer subnetwork is connected to the input end of the first-level decoder;
[0027] The encoder sub-network is used to gradually extract the implicit features of the ECG signal segments;
[0028] The Transformer sub-network is used to extract ECG timing features from implicit features based on the self-attention mechanism;
[0029] The decoder subnetwork is used to gradually decode implicit features and improve decoding performance based on the attention mechanism of feature dimensions, and finally output the waveform category probability value corresponding to each sampling point.
[0030] Further preferably, the loss function L of the above-mentioned ECG signal waveform classification model is CCE-Boundary for:
[0031] L CCE-Boundary =λ·L cce +(1-λ)·L boundary
[0032]
[0033]
[0034]
[0035]
[0036] Where λ is the weight; M is the number of waveform categories; y kc is the c-th type waveform classification label of the k-th sampling point of the ECG signal segment; pkc is the probability corresponding to the kth sampling point of the ECG signal segment being classified into the cth type of waveform; TP is the total number of segmentation points whose time difference with the true segmentation point is within the preset threshold range when segmenting according to the sampling point granularity-level classification result of the ECG signal segment obtained based on the sampling point granularity-level waveform classification probability of the ECG signal segment; FN is the total number of segmentation points whose time difference with the true segmentation point exceeds the preset threshold when segmenting according to the sampling point granularity-level classification result of the ECG signal segment obtained based on the sampling point granularity-level waveform classification probability of the ECG signal segment; FP is the difference between the total number of segmentation points obtained when segmenting according to the sampling point granularity-level classification result of the ECG signal segment obtained based on the sampling point granularity-level waveform classification probability of the ECG signal segment and the number of true segmentation points.
[0037] In a second aspect, the present invention provides an electrocardiogram signal waveform segmentation system based on deep learning, comprising:
[0038] An ECG signal preprocessing module, configured to execute step S1 of the ECG signal waveform segmentation method provided in the first aspect of the present invention;
[0039] A waveform classification module, configured to execute step S2 of the electrocardiogram signal waveform segmentation method provided in the first aspect of the present invention;
[0040] The ECG signal segmentation module is used to execute steps S3-S5 of the ECG signal waveform segmentation method provided in the first aspect of the present invention.
[0041] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects:
[0042] 1. The present invention provides an ECG signal waveform segmentation method based on deep learning. Since the waveforms on both sides of the ECG signal segments obtained by direct sampling may be incomplete, the present invention uses a sliding window with a sliding step size smaller than the window length to segment the multi-lead original ECG signals to obtain ECG signal segments with fixed-length overlaps. After obtaining the sampling point granularity-level waveform classification probability of each ECG signal segment under each lead based on the ECG signal waveform classification model, the sampling point classification probability of the original ECG signal of the lead is reconstructed from the ECG segments of a single lead by weighted averaging within the lead, and the classification probabilities of the overlapping sampling parts are weighted averaged in this process to ensure the accuracy and completeness of the reconstruction results. In this On this basis, considering that in the original ECG signal of multiple leads, although there are differences in the starting and ending points of the waveforms between different leads, there are connections between the waveform categories, the waveform classification probability at the sampling point granularity level based on the single lead information is weighted averaged between the leads to effectively eliminate waveform classification errors, so that when the quality of some leads of the ECG signal is poor, the information of other leads is integrated to supplement the missed waveforms, eliminate the wrongly detected waveforms and correct the waveform positions; finally, the segmentation points based on multi-lead information are used to correct the segmentation points based on single lead information to obtain the final segmentation points; the present invention rationally utilizes the time correlation in the ECG signal and the connection between different leads of the ECG signal, which greatly improves the accuracy of waveform segmentation.
[0043] 2. The ECG signal waveform segmentation method provided by the present invention performs weighted averaging on the classification probabilities of the overlapping parts of each ECG signal segment when performing intra-lead weighted averaging, and divides the overlapping part into two sub-parts, which are weighted averaged using complementary weight values, thereby giving a greater weight to the non-segment edge part of the overlapping part, thereby avoiding the impact on the overall waveform segmentation effect after splicing when the waveforms at both ends of the segment after ECG signal segmentation are incomplete, resulting in inaccurate waveform segmentation.
[0044] 3. The ECG signal waveform segmentation method provided by the present invention is based on the UNet network structure, in which the multi-level encoder and decoder can effectively extract the multi-scale features of the ECG signal and effectively fuse the high- and low-resolution information of the ECG signal through jump connections. On this basis, the model is further based on the Transformer sub-network to efficiently learn the temporal characteristics of the ECG signal. During the decoding process, the SE attention module is used to further effectively calibrate the interaction between the various feature channels within the model, thereby greatly improving the accuracy of the waveform classification model. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 Flowchart of the ECG signal waveform segmentation method based on deep learning provided in Example 1 of the present invention;
[0046] Figure 2 A schematic diagram of the calculation principle of the intra-lead weighted average provided in Example 1 of the present invention;
[0047] Figure 3 A schematic diagram of the structure of the ECG signal waveform classification model provided in Example 1 of the present invention;
[0048] Figure 4 This is a structural diagram of the deep learning-based ECG signal waveform segmentation system provided in Example 1 of the present invention. DETAILED DESCRIPTION
[0049] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely for the purpose of explaining the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
[0050] Example 1
[0051] This embodiment provides an ECG signal waveform segmentation method based on deep learning, aiming to solve the technical problem of low waveform segmentation accuracy caused by the failure to reasonably utilize the time correlation in ECG signals and the differences between different leads of ECG signals in the existing technology. The present invention can automatically segment the PQRST waveform of single or multi-lead ECG signals of 10 seconds or more.
[0052] like Figure 1 As shown, the ECG signal waveform segmentation method based on deep learning provided in this embodiment includes the following steps:
[0053] S1. Segmenting the original ECG signal of each lead in the multi-lead original ECG signal to be segmented using a sliding window, and preprocessing each obtained signal segment to obtain an ECG signal segment of each lead; wherein the step size of the sliding window is smaller than the length of the sliding window;
[0054] It should be noted that clinically, 24-hour dynamic ECG data of patients are often collected. However, due to limitations of framework, memory, and computing power, deep learning models can only accept data input of a certain length. Therefore, the multi-lead original ECG signals are first processed; first, a sliding window is used to sample the original ECG signal, and an ECG signal segment of a fixed length T (0<τ≤T) is intercepted at each interval τ. In this embodiment, T and τ are 10 seconds and 5 seconds respectively, that is, overlapping sampling is performed. Then the obtained ECG signal segments are preprocessed; in this embodiment, the method for preprocessing each obtained signal segment includes: resampling and standardizing each obtained signal segment in turn. Among them, resampling is: using a cubic spline interpolation algorithm to resample the 10-second ECG signal segment to a specified frequency. In this embodiment, it is resampled to 500Hz (that is, the ECG segment length is 5000 sampling points). Standardization processing is: standardizing the amplitude of the resampled ECG signal segment so that its maximum and minimum values are positive and negative 1, respectively, to enhance the robustness of the system. The formula is as follows:
[0055]
[0056] Where x(i) is the amplitude of the i-th sampling point in the resampled ECG signal segment, x max with x min are the maximum and minimum amplitude values in the ECG signal segment respectively.
[0057] S2. Input each ECG signal segment under each lead into a pre-trained ECG signal waveform classification model to obtain the sampling point granularity-level waveform classification probability of each ECG signal segment under each lead; wherein the above-mentioned ECG signal waveform classification model is a deep learning model; the waveform classification probability includes the probabilities corresponding to different waveform categories; the waveform categories include: no waveform, P wave, QRS complex wave and T wave.
[0058] S3. Weighted averaging within leads: The waveform classification probabilities at the sampling point granularity level of each ECG signal segment in each lead are spliced according to the original segmentation order of the ECG signal segments in that lead, and the classification probabilities of the overlapping parts are weighted averaged to obtain the waveform classification probabilities at the sampling point granularity level and the waveform classification results of the original ECG signal in each lead based on the single lead information. The sampling points where the waveform classification results jump are used as segmentation points to obtain the segmentation points of the original ECG signal in each lead based on the single lead information.
[0059] Specifically, if Figure 2As shown in the figure, since the waveforms on both sides of the sampled ECG signal segment may be incomplete, which will affect the classification accuracy, when reconstructing the classification results of the sampling points of the original ECG signal of a single lead from the ECG segment of the lead, it is necessary to perform a weighted average of the classification probabilities of the overlapping sampling parts; in this embodiment, the waveform classification probability of the original ECG signal under the i-th lead at the t sampling point based on the single lead information is:
[0060]
[0061] Wherein, α is a weight, and its value range in this embodiment is [0.5, 1]; T and τ are the sampling length and step size of the sliding window, respectively; P(i, j, t) is the waveform classification probability of the j-th ECG signal segment under the i-th lead at sampling point t.
[0062] S4. Weighted average between leads: Perform weighted average calculations on the waveform classification probabilities at the sampling point granularity level of the original ECG signal under each lead based on the single-lead information, and obtain the waveform classification probabilities and waveform classification results at the sampling point granularity level of the original ECG signal under each lead based on the multi-lead information. The sampling points where the waveform classification results jump are used as segmentation points, and the segmentation points of the original ECG signal under each lead based on the multi-lead information are obtained.
[0063] Specifically, in multi-lead original ECG signals, although the waveform start and end points vary between leads, there are connections between waveform categories. Weighted averaging of multi-lead results can effectively eliminate some waveform classification errors. When the quality of some leads of the ECG signal is poor, integrating information from other leads can help fill in missed waveforms, eliminate misdetected waveforms, and correct waveform positions, thereby obtaining more accurate results. In this embodiment, the waveform classification probability of the original ECG signal under the i-th lead at sampling point t based on multi-lead information is:
[0064]
[0065] Among them, β i is the weighted value of the i-th lead; in this embodiment, the weighted value of each lead is 0.3; n is the number of leads of the original ECG signal; P a (i, t) is the waveform classification probability of the original ECG signal in the i-th lead at the t sampling point based on the single lead information.
[0066] S5. Correction: For the original ECG signal under each lead, determine whether the time difference between each segmentation point based on the single-lead information and its corresponding segmentation point based on the multi-lead information is less than a preset error threshold (80ms in this embodiment). If so, the segmentation point based on the single-lead information is used as its segmentation point; otherwise, the corresponding segmentation point based on the multi-lead information is used as its segmentation point; finally, the segmentation points of the original ECG signal under each lead are obtained.
[0067] In this embodiment, the segmentation points based on multi-lead information of the original ECG signal under each lead are used as a reference template. If the time difference between the segmentation point based on a single lead information and the corresponding segmentation point in the template is within a preset error threshold, the segmentation point based on the single lead information is retained; otherwise, the corresponding segmentation point in the template is used to correct the segmentation point based on the single lead information.
[0068] In some optional implementations, the method for obtaining the segmentation points of the original ECG signal in step S3 and step S4 includes: obtaining the segmentation points of the original ECG signal by sequentially performing sharpening processing and differential processing on the sampling point granularity-level waveform classification probability of the original ECG signal; wherein the sampling point granularity-level waveform classification probability of the original ECG signal is the sampling point granularity-level waveform classification probability of the original ECG signal based on single-lead information or the sampling point granularity-level waveform classification probability of the original ECG signal based on multi-lead information; specifically:
[0069] The sharpening process includes: for each of the granular-level waveform classification probabilities of the original ECG signal sampling points, the probability corresponding to the classification into different waveform categories is set to 1, and the remaining probability is set to 0. This results in a binary sequence corresponding to the classification of each sampling point in the original ECG signal into different waveform categories, and a binary sequence of the original ECG signal corresponding to different waveform categories. In the binary sequence when the original ECG signal corresponds to a certain waveform category, a value of 1 indicates that the waveform classification result of the corresponding sampling point is that waveform category, and a value of 0 indicates that the waveform classification result of the corresponding sampling point is not that waveform category. After the sharpening process, a binary sequence (0 or 1) corresponding to the four waveform categories corresponding to the original ECG signal sampling points is obtained.
[0070] The differential processing includes: performing differential calculation on each binary sequence respectively, taking the sampling point corresponding to the differential value of 1 as the starting point of a segmented waveform, and the sampling point corresponding to the differential value of -1 as the end point of a segmented waveform, and merging them to obtain the segmentation points of the original ECG signal.
[0071] The single-lead and multi-lead segmentation results of P, QRS and T waves are obtained through the above process.
[0072] Preferably, the above-mentioned method for obtaining the segmentation points of the original electrocardiogram signal further includes: waveform completion and elimination processing performed between the sharpening processing and the differential processing; wherein the waveform completion and elimination processing includes: for a binary sequence, when the length of a portion with continuous values of 0 is less than a first preset length (the value is 40 in this embodiment), the sampling points in the portion and the waveform segments before and after it are considered to belong to the same waveform segment, and the values of the portion are all set to 1, and waveform completion is performed; when the length of a portion with continuous values of 1 is less than a second preset length (the value is 10 in this embodiment), the sampling points in the portion are considered not to belong to a valid waveform segment, and the values of the portion are all set to 0, and waveform elimination is performed.
[0073] Furthermore, in some optional implementations, the ECG signal waveform classification model accepts a single-lead ECG signal segment with a length of 5000 sampling points (10s, 500Hz) as input, and outputs the probability of the waveform category corresponding to each sampling point (including the probabilities corresponding to the four categories of no waveform, P wave, QRS complex wave, and T wave). Specifically, Figure 3 As shown, the above-mentioned ECG signal waveform classification model includes: an encoder subnetwork, a Transformer subnetwork and a decoder subnetwork; wherein the encoder subnetwork includes multiple cascaded encoders; the encoder includes a cascaded convolutional layer and a pooling layer; the decoder subnetwork includes multiple cascaded decoders; the decoder includes a cascaded deconvolution layer, a channel merging layer, a first SE attention module (Squeeze-Excitation module), a convolutional layer and a second SE attention module (Squeeze-Excitation module); the output ends of the convolutional layers in the multiple cascaded encoders are respectively connected to the input ends of the channel merging layers in the multiple cascaded decoders in a one-to-one correspondence; the output end of the last-level encoder is connected to the input end of the Transformer subnetwork; the output end of the Transformer subnetwork is connected to the input end of the first-level decoder;
[0074] The encoder sub-network is used to gradually extract the implicit features of the ECG signal segments;
[0075] The Transformer sub-network is used to extract ECG timing features from implicit features based on the self-attention mechanism;
[0076] The decoder subnetwork is used to gradually decode implicit features and improve decoding performance based on the attention mechanism of feature dimensions, and finally output the waveform category probability value corresponding to each sampling point.
[0077] In order to improve the waveform classification accuracy of the above ECG signal waveform classification model, the loss function of the model adopts the cross entropy loss L cce With the boundary loss L boundary Weighted hybrid loss function L CCE-Boundary, so that the model pays attention to the classification of all sampling points during training while also paying attention to the accuracy of waveform segmentation points; specifically, the loss function of the above ECG signal waveform classification model is:
[0078] L CCE-Boundary =λ·L cce +(1-λ)·L boundary
[0079]
[0080]
[0081]
[0082]
[0083] Wherein, λ is the weight, which is 0.1 in this embodiment; M is the number of waveform categories, which is 4 in this embodiment; y kc is the c-th type waveform classification label of the k-th sampling point of the ECG signal segment; p kc is the probability corresponding to the classification of the kth sampling point of the ECG signal segment into the cth type waveform; TP is the total number of segmentation points whose time difference with the true segmentation point is within a preset threshold (30ms in this embodiment) when the ECG signal segment is segmented according to the sampling point granularity level classification result of the ECG signal segment obtained based on the sampling point granularity level waveform classification probability of the ECG signal segment; FN is the total number of segmentation points whose time difference with the true segmentation point exceeds the preset threshold when the ECG signal segment is segmented according to the sampling point granularity level classification result of the ECG signal segment obtained based on the sampling point granularity level waveform classification probability of the ECG signal segment; FP is the difference between the total number of segmentation points obtained and the true number of segmentation points when the ECG signal segment is segmented according to the sampling point granularity level classification result of the ECG signal segment obtained based on the sampling point granularity level waveform classification probability of the ECG signal segment. Specifically, taking the P wave starting point as an example, if the time difference between the P wave starting point detected by the above ECG signal waveform classification model and the true value is within the threshold th (th is 30ms), then TP is increased by 1. Similarly, if no onset is detected within the threshold th, FN is incremented by 1.
[0084] Based on the above, this embodiment trains the ECG signal waveform classification model for 40 rounds with a training batch size of 64. The Adam optimizer is used, the initial learning rate is set to 0.001, and is adjusted according to the accuracy of the validation set.
[0085] In order to further illustrate the performance of the ECG signal waveform segmentation method based on deep learning provided by the present invention, the present invention conducts an experimental evaluation of ECG segmentation on the Lobachevsky University public dataset. The dataset is collected from real clinical cases, including 200 clinical cases of normal sinus rhythm and various arrhythmias, all of which are 12-lead ECG signals with a length of 10s and a sampling rate of 500Hz. All ECG signals have corresponding waveform segmentation annotations. After the order of the 200 cases is randomly shuffled, the system performance is tested in a 5-fold cross-validation manner, that is, the 200 cases are divided into 5 folds, and 4 folds of data are taken each time and data enhancement is performed, which is used as a dataset for training in the ECG signal waveform classification model provided by the present invention. The remaining 1 fold of data is used as clinical ECG data to be segmented to test the system performance. The average results of the five-fold cross-validation of 12 leads under the ANSI / AAMI-EC57:1998 standard are shown in Table 1. As can be seen from Table 1, the ECG signal waveform segmentation method provided by the present invention has a high accuracy rate for PQRST waveform segmentation of single / multi-lead ECG signals and can meet clinical usage requirements.
[0086] Table 1
[0087]
[0088] Example 2
[0089] A deep learning-based ECG signal waveform segmentation system, such as Figure 4 As shown, including:
[0090] An ECG signal preprocessing module, configured to execute step S1 of the ECG signal waveform segmentation method provided in Example 1 of the present invention;
[0091] A waveform classification module, configured to execute step S2 of the electrocardiogram signal waveform segmentation method provided in Example 1 of the present invention;
[0092] The ECG signal segmentation module is used to execute steps S3-S5 of the ECG signal waveform segmentation method provided in Example 1 of the present invention.
[0093] Preferably, the above-mentioned ECG signal waveform segmentation system also includes: a model training module, which is used to train the ECG signal waveform classification model using the data set, with the ECG signal segments processed by the ECG signal preprocessing module as input, and the actual classification results of the waveform corresponding to each sampling point of each segment as the expected output, and the ECG signal waveform classification model is trained until convergence.
[0094] When the above-mentioned ECG signal waveform segmentation system segments the waveform of the collected ECG signal, the ECG signal to be segmented is first processed by the ECG signal preprocessing module. Specifically, the ECG signal to be segmented is sampled and resampled (resampling) based on the sliding window, and then normalized to obtain input samples suitable for the ECG signal segmentation module. The input samples are then input into the ECG signal segmentation module to obtain waveform classification results at the sampling point level. Finally, the classification results are corrected by the ECG signal segmentation module based on the waveform start and end points of multi-lead weighted averaging.
[0095] The relevant technical solutions are the same as those in Example 1 and will not be described in detail here.
[0096] It will be easily understood by those skilled in the art that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for segmenting an ECG signal waveform based on deep learning, characterized in that: The steps include: S1. Segmenting the original ECG signal of each lead in the multi-lead original ECG signal to be segmented using a sliding window, and preprocessing each obtained signal segment to obtain an ECG signal segment of each lead; wherein the step size of the sliding window is smaller than the length of the sliding window; S2. Input each ECG signal segment under each lead into a pre-trained ECG signal waveform classification model to obtain a sampling point granularity-level waveform classification probability of each ECG signal segment under each lead; S3. The sampling point granularity-level waveform classification probabilities of each ECG signal segment in each lead are spliced according to the original segmentation order of the ECG signal segments in the lead, and the classification probabilities of the overlapping parts are weighted averaged to obtain the sampling point granularity-level waveform classification probabilities and waveform classification results of the original ECG signal in each lead based on the single lead information. The sampling points where the waveform classification results jump are used as segmentation points to obtain the segmentation points of the original ECG signal in each lead based on the single lead information. S4. Performing a weighted average calculation among the leads on the waveform classification probabilities at the sampling point granularity level based on the single-lead information for the original ECG signal in each lead, thereby obtaining the waveform classification probabilities at the sampling point granularity level and the waveform classification results for the original ECG signal in each lead based on the multi-lead information. The sampling points where the waveform classification results change are used as segmentation points, thereby obtaining the segmentation points of the original ECG signal in each lead based on the multi-lead information. S5. For each lead of the original ECG signal, determine whether the time difference between each segmentation point based on the single-lead information and the corresponding segmentation point based on the multi-lead information is less than a preset error threshold. If so, use the segmentation point based on the single-lead information as the segmentation point. Otherwise, the corresponding segmentation point based on the multi-lead information is used as the segmentation point; finally, the segmentation point of the original ECG signal under each lead is obtained; Among them, the electrocardiogram signal waveform classification model is a deep learning model.
2. The electrocardiogram signal waveform segmentation method according to claim 1, characterized in that: No. i The original ECG signal of each lead is based on the single lead information. t The waveform classification probability at the sampling point is: in, is the weight; T and are the sliding window sampling length and step size respectively; For the i The first j ECG signal fragments in t The waveform classification probability at the sampling point.
3. The electrocardiogram signal waveform segmentation method according to claim 1, characterized in that: No. i The original ECG signal under each lead is based on the multi-lead information t The waveform classification probability at the sampling point is: in, For the i The weighted value of each lead; n is the lead number of the original ECG signal; For the i The original ECG signal of each lead is based on the single lead information. t The waveform classification probability at the sampling point.
4. The electrocardiogram signal waveform segmentation method according to claim 1, characterized in that: In step S1, the method of preprocessing each obtained signal segment includes: resampling and standardizing each obtained signal segment in sequence.
5. The electrocardiogram signal waveform segmentation method according to claim 1, characterized in that: The waveform classification probability includes the corresponding probabilities when being classified into different waveform categories; the waveform categories include: no waveform, P wave, QRS complex wave and T wave.
6. The electrocardiogram signal waveform segmentation method according to claim 5, characterized in that: The method for obtaining segmentation points of an original electrocardiogram signal comprises: obtaining segmentation points of the original electrocardiogram signal by sequentially performing sharpening processing and differential processing on the waveform classification probability of the sampling point granularity level of the original electrocardiogram signal; the waveform classification probability of the sampling point granularity level of the original electrocardiogram signal is the waveform classification probability of the sampling point granularity level of the original electrocardiogram signal based on single-lead information or the waveform classification probability of the sampling point granularity level of the original electrocardiogram signal based on multi-lead information; The sharpening process includes: respectively setting the portion of the granularity-level waveform classification probability of the original ECG signal sampling points corresponding to the probabilities of being divided into different waveform categories to 1, and setting the remaining portion to 0, to obtain a binary sequence corresponding to the division of each sampling point in the original ECG signal into different waveform categories, and obtaining a binary sequence of the original ECG signal corresponding to different waveform categories; wherein, in the binary sequence when the original ECG signal corresponds to a certain waveform category, a value of 1 indicates that the waveform classification result of the corresponding sampling point is the waveform category, and a value of 0 indicates that the waveform classification result of the corresponding sampling point is not the waveform category; The differential processing includes: performing differential calculation on each binary sequence respectively, taking the sampling point corresponding to the differential value of 1 as the starting point of a segmented waveform, and the sampling point corresponding to the differential value of -1 as the end point of a segmented waveform, and merging them to obtain the segmentation points of the original ECG signal.
7. The electrocardiogram signal waveform segmentation method according to claim 6, characterized in that: The method for obtaining segmentation points of the original electrocardiogram signal further includes: waveform completion and elimination processing performed between the sharpening processing and the difference processing; Among them, the waveform completion and elimination processing includes: for a binary sequence, when the length of the part with continuous values of 0 is less than a first preset length, the value of this part is set to 1, and waveform completion is performed; when the length of the part with continuous values of 1 is less than a second preset length, the value of this part is set to 0, and waveform elimination is performed.
8. The method for segmenting an electrocardiogram signal waveform according to any one of claims 1 to 7, wherein: The ECG signal waveform classification model includes: an encoder subnetwork, a Transformer subnetwork and a decoder subnetwork; wherein the encoder subnetwork includes multiple cascaded encoders; the encoder includes cascaded convolutional layers and pooling layers; the decoder subnetwork includes multiple cascaded decoders; the decoder includes cascaded deconvolutional layers, channel merging layers, a first SE attention module, a convolutional layer and a second SE attention module; the output ends of the convolutional layers in the multiple cascaded encoders are respectively connected to the input ends of the channel merging layers in the multiple cascaded decoders in a one-to-one correspondence; the output end of the last-level encoder is connected to the input end of the Transformer subnetwork; the output end of the Transformer subnetwork is connected to the input end of the first-level decoder; The encoder sub-network is used to gradually extract implicit features of ECG signal segments; The Transformer sub-network is used to extract ECG time series features from implicit features based on the self-attention mechanism; The decoder subnetwork is used to gradually decode implicit features and improve decoding performance based on the attention mechanism of feature dimensions, and finally output the waveform category probability value corresponding to each sampling point.
9. The method for segmenting an electrocardiogram signal waveform according to claim 8, wherein: The loss function of the ECG signal waveform classification model for: in, is the weight; M is the number of waveform categories; The first segment of the ECG signal k The sampling point c Waveform-like classification labels; The first segment of the ECG signal k The sampling points are divided into c The probability corresponding to the waveform; TP The total number of segmentation points whose time difference with the actual segmentation point is within a preset threshold range when segmenting the ECG signal segment according to the sampling point granularity classification result obtained based on the sampling point granularity waveform classification probability of the ECG signal segment; FN The total number of segmentation points whose time difference with the actual segmentation point exceeds a preset threshold when segmenting the ECG signal segment according to the sampling point granularity classification result obtained based on the sampling point granularity waveform classification probability of the ECG signal segment; FP It is the difference between the total number of segmentation points obtained when segmenting the ECG signal segment according to the sampling point granularity classification result obtained based on the sampling point granularity waveform classification probability of the ECG signal segment and the actual number of segmentation points.
10. A deep learning-based ECG signal waveform segmentation system, characterized in that: The method for segmenting an electrocardiogram signal waveform according to any one of claims 1 to 9 comprises: an ECG signal preprocessing module, configured to segment the original ECG signal of each lead in the segmented multi-lead original ECG signal using a sliding window, and preprocess each obtained signal segment to obtain an ECG signal segment of each lead; wherein the step size of the sliding window is smaller than the length of the sliding window; A waveform classification module is used to input each ECG signal segment under each lead into a pre-trained ECG signal waveform classification model to obtain the sampling point granularity level waveform classification probability of each ECG signal segment under each lead; wherein the ECG signal waveform classification model is a deep learning model; The ECG signal segmentation module is used to classify the waveforms at the sampling point granularity level of each ECG signal segment under each lead, splice the segments according to the original segmentation order of the ECG signal segments under the lead, and perform weighted averaging on the classification probabilities of the overlapping parts to obtain the waveform classification probabilities and waveform classification results at the sampling point granularity level of the original ECG signal under each lead based on the single lead information. The sampling points where the waveform classification results jump are used as segmentation points to obtain the segmentation points of the original ECG signal under each lead based on the single lead information. For the waveform classification probability of the sampling point granularity based on the single-lead information of the original ECG signal under each lead, a weighted average calculation is performed between the leads to obtain the waveform classification probability and waveform classification result of the sampling point granularity based on the multi-lead information of the original ECG signal under each lead. The sampling point where the waveform classification result jumps is used as the segmentation point to obtain the segmentation point of the original ECG signal under each lead based on the multi-lead information; For the original ECG signal under each lead, determine whether the time difference between each segmentation point based on single-lead information and its corresponding segmentation point based on multi-lead information is less than the preset error threshold. If so, the segmentation point based on single-lead information is used as its segmentation point; otherwise, the corresponding segmentation point based on multi-lead information is used as its segmentation point; finally, the segmentation points of the original ECG signal under each lead are obtained.
Citation Information
Patent Citations
Electrocardiosignal classification method and device
CN106725428A
Electrocardiosignal classification method based on sequence labeling and fusing depth features and medical features of leads
CN113855042A