Electrocardiosignal ST segment classification method
By constructing a deep learning network model to extract and classify the ST segments of the ECG signal, the problem of inaccurate classification of ST segments in the prior art is solved, and the accuracy of myocardial ischemia detection is improved.
Patent Information
- Application Number
- CN202311386202.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-24
- Publication Date
- 2025-04-25
AI Technical Summary
The prior art cannot accurately classify the ST segment of the electrocardiogram, resulting in a low accuracy rate of myocardial ischemia detection.
By extracting the ST segment of the ECG signal, a deep learning network model is constructed, including an encoder and a decoder, and the ST segments are characterized by using a convolutional layer, main capsule layer and digital capsule layer.
It realizes the rapid and accurate classification of the ST segment of the ECG signal, improves the accuracy of myocardial ischemia detection, and can quickly judge myocardial ischemia.
Smart Images

Figure CN119867781A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electrocardiogram monitoring, and in particular to a method for classifying ST segments of electrocardiogram signals. Background Art
[0002] Myocardial ischemia (MI) is one of the common cardiovascular diseases, which means that the myocardium cannot support the normal functioning of the heart. With the improvement of people's living standards, the prevalence of myocardial ischemia in my country is currently increasing year by year. It has become a common and frequently-occurring disease among middle-aged and elderly people, and more and more young people are also showing symptoms of myocardial ischemia. Severe myocardial ischemia may also cause myocardial infarction or large-area myocardial necrosis, thereby endangering life safety. Therefore, early diagnosis and prevention are very important for patients with myocardial ischemia. Dynamic electrocardiogram is the most commonly used and most important examination to clarify myocardial ischemia. Hospitals usually use equipment such as Holter monitors to monitor dynamic electrocardiograms. Dynamic electrocardiograms can continuously capture or monitor electrocardiogram signals for several hours, and record the potential changes on the human body surface in the form of dynamic curves. Doctors can provide some diagnostic clues through the electrocardiogram waveform. Each cardiac cycle in the electrocardiogram waveform is composed of waveforms such as P waves, QRS waves and T waves, corresponding to different electrocardiogram activities during the heart's excitation process. Generally, the dynamic electrocardiogram ST segment level changes are analyzed to determine whether myocardial ischemia occurs, which is of great significance for the judgment of asymptomatic myocardial ischemia.
[0003] At present, researchers have established quite accurate analysis methods and algorithms for detecting abnormal R waves in arrhythmias, heart rhythm variability, and atrial fibrillation, but the detection of abnormal ST waves in myocardial ischemia is still at the research level. At present, most myocardial ischemia detection is performed by professionals through computer-assisted ECG signal visual inspection, such as ST segment trend graphs. In recent years, researchers have proposed more and more algorithms for the analysis and diagnosis of myocardial ischemia in the automated detection system of ischemic heart disease, but the existing technology cannot clearly locate the ST segment of the electrocardiogram and cannot accurately classify the ST segment, and the detection accuracy is still very low. Summary of the invention
[0004] In view of the above analysis, an embodiment of the present invention aims to provide an electrocardiogram signal ST segment classification method to solve the problem of inaccurate ST segment classification results.
[0005] On the one hand, an embodiment of the present invention provides a method for classifying ST segments of electrocardiogram signals, comprising the following steps:
[0006] Obtain ECG signals, extract ST segments from the ECG signals to construct a training sample set;
[0007] Constructing a deep learning network model, and training the deep learning network model based on a training sample set to obtain an ST segment classification model;
[0008] The ST segment in the electrocardiogram signal to be detected is extracted and input into the ST segment classification model to obtain the type of each ST segment in the electrocardiogram signal to be detected.
[0009] Based on the further improvement of the above method, the constructed deep learning network model includes an encoder and a decoder, wherein the encoder includes a convolutional layer, a main capsule layer and a digital capsule layer connected in sequence;
[0010] The convolution layer is used to extract local features of the input data;
[0011] The convolutional capsule layer includes a plurality of capsules, which are used to perform feature combination on the local features extracted by the convolutional layer to obtain combined features;
[0012] The digital capsule layer includes a plurality of capsules, each of which maps the input combined features through a weight matrix to obtain an output feature vector; and obtains the ST segment type based on the output feature vector;
[0013] The decoder includes three fully connected layers for decoding and reconstructing the output feature vector.
[0014] Based on the further improvement of the above method, the following formula is used to calculate the loss of the deep learning network model:
[0015] L=αL c +βL d
[0016]
[0017]
[0018] Among them, L c represents the marginal loss, L d represents the reconstruction loss, v k represents the output feature vector of the kth capsule in the digital capsule layer, |v k | indicates v k The model, Represents the preset penalty parameter. If the sample label is the kth category, then T k =1, otherwise, T k = 0, C represents the number of capsules in the digital capsule layer, p ij Represents the element value of the i-th row and j-th column in the model input sample, q ij represents the element value of the i-th row and j-th column of the data reconstructed by the decoder, α and β represent weight coefficients, and n st and m st Represent the width and height of the input sample respectively.
[0019] Based on the further improvement of the above method, the ST segment in the ECG signal is extracted to construct a training sample set, including:
[0020] The ECG signal is detected to obtain the R wave in the ECG signal, and the R wave segment with low confidence is eliminated based on the detection confidence to obtain the preprocessed ECG signal;
[0021] Based on the preprocessed ECG signal, the positions of the S wave and the T wave are determined, and the ST segment ECG signal is extracted. The ST segment ECG signal and the corresponding type constitute the training sample set.
[0022] Based on the further improvement of the above method, the R wave segments with low confidence are eliminated based on the detection confidence to obtain the preprocessed ECG signal, including:
[0023] Taking each R wave in the ECG signal as the current R wave in turn, if the confidence of the current R wave is less than the first threshold, deleting the signal point between the current R wave peak and the previous R wave peak;
[0024] The ECG signal obtained after removing the R wave with low confidence is filtered, the R wave is re-detected on the filtered ECG signal to obtain the R wave position, the corresponding position of the ECG signal before filtering is marked as the R wave, and the pre-processed ECG signal is obtained.
[0025] Based on the further improvement of the above method, the positions of the S wave and the T wave are determined based on the preprocessed ECG signal, and the ST segment ECG signal is extracted, including:
[0026] Perform the following steps for each R wave in order from right to left, traverse all R waves, determine the positions of S waves and T waves, and extract the ST segment ECG signal:
[0027] From the R wave peak to the left, the second maximum slope point is the center of the P wave, and the third maximum slope point is the center of the T wave.
[0028] From the center point of the T wave, traverse to the left and find the first maximum slope point, which is the center point of the S wave;
[0029] The starting point of the T wave is found according to the center point of the T wave, and the signal from the center point of the S wave to the starting point of the T wave is extracted as the ST segment ECG signal.
[0030] Based on the further improvement of the above method, the confidence of the R wave segment is calculated in the following way:
[0031] Performing differential conversion on the ECG signal to obtain an ECG differential signal; constructing a standard R wave differential waveform corresponding to each type of R wave based on the ECG differential signal;
[0032] The confidence of each R wave segment is calculated based on the standard R wave differential waveform corresponding to each type of R wave.
[0033] Based on the further improvement of the above method, the confidence of each R wave segment is calculated based on the standard R wave differential waveform corresponding to each type of R wave, including:
[0034] Perform integral reduction on each type of standard R wave differential waveform to obtain a standard R wave reduction waveform;
[0035] For each type of standard R wave, extract each R wave segment corresponding to the type in the ECG differential signal, perform integral restoration, and use the restored R wave segment as the target R wave;
[0036] Calculate the ratio of each type of standard R wave restoration waveform to the corresponding signal point in each target R wave of the corresponding type to construct a similarity ratio set;
[0037] Calculate the similarity confidence interval of each type based on the set of all similarity ratios corresponding to each type;
[0038] The confidence of each target R wave corresponding to the type is calculated according to the similarity confidence interval of the type.
[0039] Based on the further improvement of the above method, the standard R wave differential waveform corresponding to each type of R wave is constructed based on the ECG differential signal, including:
[0040] For each type of R wave, the central differential waveform of the standard R wave corresponding to the type of R wave is obtained according to the differential mean value of the type of R wave in the ECG differential signal;
[0041] A bidirectional sliding window is used to synchronously slide all such R wave segments, and the boundary differential waveform of the standard R wave corresponding to this type of R wave is obtained according to the differential mean value of the R wave in each sliding window;
[0042] The standard vertebral R wave differential waveform corresponding to this type of R wave is obtained according to the central differential waveform and the boundary differential waveform of the standard R wave corresponding to this type of R wave.
[0043] Based on the further improvement of the above method, a bidirectional sliding window is used to synchronously slide all such R wave segments, and the boundary differential waveform of the standard R wave corresponding to this type of R wave is obtained according to the differential mean value of the R wave in each sliding window, including:
[0044] Determine the left initial position corresponding to the left sliding window and the right initial position corresponding to the right sliding window respectively according to the width of the central differential waveform of the standard R wave;
[0045] Using a left sliding window to slide leftward from the left initial position in all such R wave segments, and determining the left boundary differential waveform of the standard R wave corresponding to the such R wave according to the differential mean of the R wave in each left sliding window;
[0046] A right sliding window is used to slide rightward from the right initial position in all such R wave segments, and the right boundary differential waveform of the standard R wave corresponding to this type of R wave is determined according to the differential mean of the R wave in each right sliding window.
[0047] The present invention constructs training samples by extracting the ST segment of the electrocardiogram signal, and obtains the ST segment classification model by training the deep learning network model, so as to quickly and accurately classify the ST segment. For the electrocardiogram signal to be detected, the ST segment is extracted and input into the classification model to obtain the type of each ST segment. Myocardial ischemia can be quickly judged according to the type of ST segment contained in the electrocardiogram signal.
[0048] In the present invention, the above-mentioned technical solutions can also be combined with each other to achieve more preferred combination solutions. Other features and advantages of the present invention will be described in the subsequent description, and some advantages can become obvious from the description, or can be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained through the contents particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The accompanying drawings are only used for the purpose of illustrating specific embodiments and are not to be considered as limiting the present invention. In the entire drawings, the same reference symbols represent the same components;
[0050] Figure 1 This is a flow chart of a method for classifying ST segments of electrocardiogram signals according to an embodiment of the present invention;
[0051] Figure 2 A schematic diagram of an abnormal ST segment signal waveform according to an embodiment of the present invention;
[0052] Figure 3 Schematic diagram of a normal ST segment signal waveform according to an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0054] A specific embodiment of the present invention discloses a method for classifying ST segments of electrocardiogram signals. Figure 1 As shown, the following steps are included:
[0055] S1, obtain ECG signal, extract ST segment in ECG signal to construct training sample set;
[0056] S2. Construct a deep learning network model, and train the deep learning network model based on a training sample set to obtain an ST segment classification model;
[0057] S3, extracting the ST segment in the electrocardiogram signal to be detected and inputting it into the ST segment classification model to obtain the type of each ST segment in the electrocardiogram signal to be detected.
[0058] During implementation, abnormal ST segments were divided into four types: horizontal depression of the ST segment, upsloping depression of the ST segment, downward elevation of the ST segment, and tombstoning elevation of the ST segment. Figure 2 As shown, Figure 2 (a) is horizontal depression of ST segment, (b) is upward depression of ST segment, (c) is downward elevation of ST segment, and (d) is tombstone elevation of ST segment. The normal ST segment signal waveform is shown in 3. Therefore, there are 5 types of ST segment types.
[0059] The present invention constructs training samples by extracting the ST segment of the electrocardiogram signal, and obtains the ST segment classification model by training the deep learning network model, so as to quickly and accurately classify the ST segment. For the electrocardiogram signal to be detected, the ST segment is extracted and input into the classification model to obtain the type of each ST segment. Myocardial ischemia can be quickly judged according to the type of ST segment contained in the electrocardiogram signal.
[0060] Specifically, the ST segment in the ECG signal is extracted to construct a training sample set, including:
[0061] S11, detecting the ECG signal to obtain an R wave in the ECG signal, and removing R wave segments with low confidence based on the detection confidence to obtain a preprocessed ECG signal;
[0062] S12. Determine the positions of the S wave and the T wave based on the preprocessed ECG signal, extract the ST segment ECG signal, and the ST segment ECG signal and the corresponding type constitute a training sample set.
[0063] During implementation, step S11 may use the Pan&Tomskins algorithm for detection to obtain the R wave of the ECG signal, that is, mark the position of the R wave peak, and classify the R wave by clustering, for example, into 3 categories, and then mark the type corresponding to each R wave.
[0064] The confidence level of the R wave segment is calculated as follows:
[0065] S111, performing differential conversion on the ECG signal to obtain an ECG differential signal; constructing a standard R wave differential waveform corresponding to each type of R wave based on the ECG differential signal;
[0066] S112. Calculate the confidence of each R wave segment based on the standard R wave differential waveform corresponding to each type of R wave.
[0067] For example, the original ECG signal is represented by X = {x0, x1, x2, ..., x NThe first signal point d1 after conversion is calculated by (x1-x0)×f, and the second signal point d2 after conversion is calculated by (x2-x1)×f. And so on, the ECG differential signal D={d1,d2,…,d N}, where N represents the total number of signal points in the ECG signal segment. Since the first signal point x0 in the original ECG signal has no differential value, it is deleted and the original ECG signal is represented by X = {x1, x2, …, x N}. Where f represents the sampling frequency.
[0068] By differentiating the waveform at each point, the dynamic information of all original ECG data is retained, the AC component of the ECG in the low-frequency band is emphasized, the DC component and baseline drift component are weakened, which is conducive to highlighting the ECG characteristics.
[0069] A standard R wave differential waveform corresponding to each type of R wave is constructed based on the ECG differential signal. Specifically, step S111 includes:
[0070] S1111. For each type of R wave, obtain a central differential waveform of a standard R wave corresponding to the type of R wave according to a differential mean value of the type of R wave in the electrocardiographic differential signal;
[0071] S1112, using a bidirectional sliding window to synchronously slide all such R wave segments, and obtaining a boundary differential waveform of a standard R wave corresponding to such R wave according to a differential mean value of the R wave in each sliding window;
[0072] S1113. Obtain a standard R wave differential waveform corresponding to this type of R wave based on the central differential waveform and the boundary differential waveform of the standard R wave corresponding to this type of R wave.
[0073] The construction of the standard R-wave differential waveform includes the construction of the central waveform and the construction of the boundary waveform.
[0074] For each type of R wave, the central differential waveform of the standard R wave corresponding to the type of R wave is obtained according to the differential mean value of the type of R wave in the ECG differential signal, including:
[0075] For each signal point of the central differential waveform of the standard R wave, the differential mean of all sampling points corresponding to the signal point in this type of R wave is calculated as the value of the signal point; and the central differential waveform of the standard R wave is obtained.
[0076] Since the original ECG signal X and the ECG differential signal D are of equal length and have one-to-one correspondence, the R wave marker in the original signal can find the corresponding position in the ECG differential signal.
[0077] For example, to construct the central differential waveform of the standard R wave, it is necessary to first determine the width of the central differential waveform of the standard R wave. According to the beating law of the heart, the R wave is generally greater than 60ms. If the sampling interval is 1ms during implementation, the central waveform width can be set to 60 sampling intervals, with the R wave peak as the center, and the left and right widths are 30 sampling intervals respectively, that is, there are 30 signal points on the left and right.
[0078] For each signal point of the central differential waveform of the standard R wave, the differential mean of all sampling points corresponding to the signal point in this type of R wave is calculated as the value of the signal point in the standard R wave.
[0079] For example, the first signal point on the left side of the center position of the central differential waveform of the normal standard R wave is extracted, and the differential value corresponding to the first sampling point on the left side of each normal R wave mark point in the ECG differential signal is calculated, and the average value is calculated to obtain the value of the first signal point on the left side of the center position of the central differential waveform of the standard R wave. Similarly, after constructing the value of each signal point in the central wave differential shape, the central waveform is obtained, which is expressed as S i ={s i-k ,…,s i-1 ,s i1 ,…,s ik}. Among them, s i-1 is the first signal point on the left side of the center position of the central differential waveform of the i-th type of standard R wave, s i1 is the first signal point to the right of the center position of the central differential waveform of the i-th type of standard R wave, and 2k is the width of the central differential waveform.
[0080] After the central differential waveform is constructed, it is necessary to construct the boundary waveform of the standard R wave differential waveform.
[0081] Specifically, a bidirectional sliding window is used to synchronously slide all such R wave segments, and a boundary differential waveform of a standard R wave corresponding to such R wave is obtained according to the differential mean value of the R wave in each sliding window, including:
[0082] S11121, determining a left initial position corresponding to the left sliding window and a right initial position corresponding to the right sliding window respectively according to the width of the central differential waveform of the standard R wave;
[0083] S11122, using a left sliding window to slide leftward from the left initial position in all such R wave segments, and determining a left boundary differential waveform of a standard R wave corresponding to such R wave according to a differential mean value of the R wave in each left sliding window;
[0084] S11123, using a right sliding window to slide rightward from the right initial position in all such R wave segments, and determining the right boundary differential waveform of the standard R wave corresponding to this type of R wave according to the differential mean of the R wave in each right sliding window.
[0085] First, the initial position of the left sliding window is determined based on half the width of the standard R wave center differential waveform. For example, the width of the center waveform is 60 signal points, that is, 30 signal points on the left and right of the peak. The left initial position is the position of the 31st sampling point on the left side of the R mark point, and the right initial position is the position of the 31st sampling point on the right side of the R mark point.
[0086] The process of determining the left boundary differential waveform and the right boundary differential waveform of the standard R wave is the same, the difference lies in the sliding direction, and the following is explained by taking the construction of the left boundary differential waveform as an example.
[0087] When using a sliding window, you must first determine the window size and sliding step size. During implementation, you can determine the size based on computational efficiency and accuracy. For example, if the sliding window size is determined to be 10 sampling intervals, each sliding window corresponds to 10 sampling points, and the sliding step size is 1 sampling interval, then one sampling point is slid to the left each time.
[0088] Specifically, in step S11122, the left boundary differential waveform of the standard R wave corresponding to the type of R wave is determined in the following manner:
[0089] S111221, taking each left sliding window at the left initial position as the current sliding window; calculating the differential mean of each sampling point in the current sliding window as the value of the signal point corresponding to the left boundary differential waveform of the standard R wave; the mean of each sampling point in the current sliding window constitutes a first set, and the positive and negative signs corresponding to the current sliding window are obtained according to the positive and negative signs of each value in the first set; sliding the current sliding window to the left by the first step length as the current sliding window;
[0090] S111222, calculating the differential mean of each sampling point in the current sliding window as the value of the corresponding signal point in the differential waveform of the left boundary of the standard R wave; the mean of each sampling point in the current sliding window constitutes a first set, and the positive and negative signs corresponding to the current sliding window are obtained according to the positive and negative signs of each value in the first set;
[0091] S111223. If the positive and negative signs corresponding to the current sliding window are different from those corresponding to the previous sliding window, stop sliding the window to obtain the left boundary differential waveform of the standard R wave; otherwise, slide the current sliding window to the left by the first step length as the current sliding window, and return to step S111222.
[0092] For example, the left initial position is the 31st sampling point on the left side of the R wave marker, and the sequence D = {d1, d2, …, d N} at a certain position R d There is an R wave marker (the R marker point may be between two sampling points or at a certain sampling point), and the type is normal. The first sampling point to the left of the marker point is d i , then the left sliding window is initially positioned at the marked point R dThe 31st to 40th sampling points on the left (counting from right to left), the data in the sliding window is d i-30 ~d i-39 .
[0093] Extract the data of the 31st to 40th sampling points on the left side of each normal R wave mark point, and calculate the mean of each sampling point, that is, calculate the mean of the values of the 31st sampling point on the left side of the normal R wave peak as the value of the 31st signal point on the left side of the standard R wave peak, calculate the mean of the values of the 32nd sampling point on the left side of the normal R wave peak as the value of the 32nd signal point on the left side of the standard R wave peak, and so on. These means constitute the first set.
[0094] According to the signs of the means in the first set, the sign corresponding to the current window is determined. If the ratio of the number of values with positive signs in the first set to the total number of values in the first set exceeds the first threshold, the current sliding window corresponds to a positive sign, otherwise the current sliding window corresponds to a negative sign. In implementation, the first threshold can be 2 / 3.
[0095] After obtaining the sign of the first sliding window, slide the current sliding window to the left by the first step as the current sliding window; at this time, the data covered by the sliding window is the data of the 32nd to 41st sampling points on the left side of the R wave mark point, and the mean value at each moment is calculated according to the above process as the data of the 32nd to 41st signal points on the left side of the standard R wave peak (at this time, the 32nd to 40th sampling points have been calculated, so only the mean value of the 41st sampling point needs to be calculated), and the mean values of the 32nd to 41st sampling points constitute a new first set, and the sign corresponding to the current window is determined according to the sign of these means in the new first set. If the sign corresponding to the current sliding window is different from the sign corresponding to the previous sliding window, stop sliding the window, obtain the left boundary waveform of the standard R wave, that is, obtain the value of the 31st to 41st signal points on the left side of the standard R wave, if the sign corresponding to the current sliding window is the same as the sign corresponding to the previous sliding window, slide the current sliding window to the left by the first step as the current sliding window, and return to step S112222.
[0096] The same process is used to obtain the right boundary differential waveform of the standard R wave. It should be noted that at this time, the sliding window starts to slide to the right from the 31st sampling point on the right side of the R wave mark point.
[0097] The center differential waveform, left boundary differential waveform, and right boundary differential waveform of the standard R wave are obtained, that is, the standard R wave differential waveform corresponding to the R wave type is obtained. The constructed standard R wave differential waveform excludes the influence of DC component and baseline drift; only the medium and low frequency AC component is retained, which is the dynamic information of the ECG waveform. It can make detection judgment more accurate.
[0098] After obtaining the standard R wave differential waveform, all ECG R waves of this type are similarly calculated with reference to the standard R wave. Specifically, step S112 calculates the confidence of each R wave segment based on the standard R wave differential waveform corresponding to each type of R wave, including:
[0099] S1121, performing integral reduction on each type of standard R wave differential waveform to obtain a standard R wave reduction waveform;
[0100] S1122, for each type of standard R wave, extract each R wave segment corresponding to the type from the ECG differential signal, perform integral restoration, and use the restored R wave segment as the target R wave;
[0101] S1123, calculating the ratio of the standard R wave restoration waveform of each type to the corresponding signal point in each target R wave of the corresponding type to construct a similarity ratio set;
[0102] S1124, calculating the similarity confidence interval of each type according to all similarity ratio sets corresponding to the type;
[0103] S1123. Calculate the confidence of each target R wave corresponding to the type according to the similarity confidence interval of the type.
[0104] Since the standard R wave is obtained based on the differential waveform, it is necessary to restore it, that is, to convert the standard R wave in the form of integration. The standard R wave differential waveform is represented by S i ={s i-m ,…,s i-1 ,s i1 ,…,s in}, where s i-1 is the first signal point on the left side of the center position of the ith type standard R wave differential waveform, s i1 is the first signal point on the right side of the center position of the i-th standard R-wave differential waveform, s i-m is the left boundary signal point of the i-th standard R-wave differential waveform, s in is the right boundary signal point of the i-th standard R wave differential waveform. The total number of sampling points in the standard R wave differential waveform is m+n.
[0105] Integral restoration is to use the following formula to calculate the corresponding integral restored value for each signal point in the standard R wave differential waveform:
[0106]
[0107] Among them, sr ip represents the value of the pth signal point in the i-th standard R-wave restoration waveform, s iqrepresents the value of the qth signal point in the i-th standard R-wave differential waveform, and r0 represents the preset baseline value. p∈[1,m+n]. During implementation, r0 takes a positive value so that each sr ip The standard R wave restoration waveform is expressed as SR i ={sr i-m ,…,sr i-1 ,sr i1 ,...,sr in For the standard R wave of the i-th type, extract each R wave segment corresponding to the type in the ECG differential signal. That is, find an R wave marker of this type, extract its left m sampling points and right n sampling points to form an R wave segment of this type, and use the same method as above to perform integral reduction to obtain the target waveform, which is expressed as {xr i-m ,…,xr i-1 ,xr i1 ,...,xr in}.
[0108] There are two differences between the standard R wave restoration waveform and the target R wave and the usual ECG wave: they are inverted and the difference in the baseline starting point is removed, thus avoiding the influence of baseline drift.
[0109] Construct the corresponding similarity ratio set as If there are M i-th type R waves, M similarity ratio sets will be constructed.
[0110] The data in the similarity ratio set are the shape ratios of the R waveform. The waveform of the R wave is affected by many random factors, including electrophysiology, muscle movement, external electromagnetic interference, and the characteristics of the sampling circuit itself. These random factors create a ratio set that obeys or approximately obeys a normal distribution.
[0111] Therefore, calculate the mean μ and variance σ of all values in the M similarity ratio sets 2 , with the overall mean as μ and the variance as σ 2 The normal distribution of ECG energy distribution conforms to the half-normal distribution. The corresponding confidence interval is expressed as [μ-zσ,μ+zσ], where z represents the confidence scale corresponding to the confidence level. For example, the corresponding value of 94.5% confidence level is 2.
[0112] For each target R wave, the confidence of each target R wave is obtained according to the ratio of the number of elements in the corresponding similarity ratio set that fall within the confidence interval to the number of elements in the similarity ratio set.
[0113] For example, a target R wave and a standard R wave have the following similarity ratio sets:
[0114] {1.44, 1.22, 1.09, 1.33, 1.15, 1.29, 1.15, 1.27, 1.27, 1.13, 1.16, 1.15, 1.15, 1.19, 1.15, 1.3, 1.41, 1.2, 1.24, 1.22, 1.04, 1.25, 1.21, 1.01, 1.14, 1.25, 1.19, 1.2, 1.38, 1.21, 1.19, 1.09, 1.36, 1.17, 1.35, 1.1, 1.11, 1.1 9, 1.24, 1.29, 1.11, 1.18, 1.09, 1.08, 1.28, 1.36, 1.18, 1.19, 1.21, 1.11, 1.15, 1.27, 1.07, 1.15, 0.92, 1.24, 1.12, 1.24, 1.18, 1.32}; if μ=1.2, σ=0.05, and confidence scale z=2, then the number of ratios in the similarity ratio set that fall within the confidence interval is 45. Therefore, the confidence value of the target R wave is 45 / 60=75%.
[0115] Since the original ECG signal X and the ECG differential signal D are of equal length and correspond one to one, the target R wave and the R wave in the original ECG signal also correspond one to one, and the confidence of the target R wave is the confidence of the corresponding R wave in the original ECG signal.
[0116] After obtaining the confidence of each R wave, the R wave segments with low confidence are eliminated. Specifically, the preprocessed ECG signal is obtained by eliminating the R wave segments with low confidence based on the detection confidence, including:
[0117] S114, taking each R wave in the electrocardiogram signal as the current R wave in turn, and if the confidence of the current R wave is less than a first threshold, deleting the signal point between the current R wave peak and the previous R wave peak;
[0118] S115, filtering the ECG signal obtained after removing the R wave with low confidence, re-detecting the R wave on the filtered ECG signal to obtain the R wave position, marking the corresponding position of the ECG signal before filtering as the R wave, and obtaining the pre-processed ECG signal.
[0119] All signals from each R wave with low confidence in the ECG signal from its marked position to the marked position of the previous R wave are removed, so as to facilitate the subsequent accurate extraction of ST segment signals. The ECG signal after removing the R wave with low confidence is represented as X 1 ={d1,d2,…,d N}.
[0120] During implementation, the undecimated wavelet transform (UWT) is used to filter the ECG signal after removing the R wave with low confidence, so as to remove the high-frequency noise in the signal and facilitate more accurate detection. The filtered ECG signal is detected again to obtain the R wave marker, and the corresponding position of the ECG signal before filtering is marked as the R wave to obtain the pre-processed ECG signal, that is, the obtained R wave marker is placed on the ECG signal X after removing the R wave with low confidence. 1 ={d1,d2,…,d N} corresponding position.
[0121] Step S12 determines the positions of the S wave and the T wave based on the preprocessed ECG signal and extracts the ST segment ECG signal, including:
[0122] S121, perform the following steps for each R wave in order from right to left, traverse all R waves, determine the positions of S waves and T waves, and extract ST segment ECG signals: traverse from the R wave peak to the left to find the second slope maximum point as the P wave center point, and the third slope maximum point as the T wave center point;
[0123] S122, traverse from the center point of the T wave to the left and find the first slope maximum point as the center point of the S wave;
[0124] S123. Find the starting point of the T wave according to the center point of the T wave, and extract the signal from the center point of the S wave to the starting point of the T wave as the ST segment electrocardiogram signal.
[0125] During implementation, first traverse from right to left, that is, from back to front, each calibrated R wave is taken as the current R wave, and the extreme value method is used to determine the position of the P wave in reverse order, that is, from the R wave to the left, find the first slope maximum point as the Q wave, and the second slope maximum point as the center point of the P wave. After the center point of the P wave is verified, continue to look to the left for the next slope maximum point to obtain the center point of the T wave.
[0126] From the center point of the T wave, continue to traverse to the left to find the first slope maximum point, which is the center point of the S wave. From the center point of the T wave, traverse to the left to find the first slope 0 point, which is the starting point of the T wave. During implementation, the signal from the center point of the S wave to the starting point of the T wave can be extracted as the ST segment ECG signal. It is also possible to start from the center point of the S wave and traverse to the right to find the first slope 0 point, which is the end point of the S wave, and extract the signal from the end point of the S wave to the starting point of the T wave as the ST segment ECG signal.
[0127] The ST segment signals and corresponding labels are extracted to form training samples to train the deep learning network model.
[0128] At present, convolutional neural networks (CNNs) are often used in ECG signal analysis based on deep learning methods. However, the pooling operation in CNN that provides local invariance will lose location information. The capsule network uses capsules as the basic unit of the network. The length of its feature vector represents the probability of the instance, and the direction represents the location information. It also uses a dynamic routing algorithm instead of the pooling operation to make up for the shortcomings of CNN. The capsule network has translational equivariance and can better classify ST segment classes. Therefore, the capsule network is used as the deep learning network model.
[0129] Since the capsule network is mainly used to process images, the ST segment ECG signal needs to be converted first. For each ST segment, its signal is one-dimensional, which can be converted into a two-dimensional image through the figure and imwrite functions of Matlab.
[0130] The constructed deep learning network model includes an encoder and a decoder, wherein the encoder includes a convolutional layer, a main capsule layer and a digital capsule layer connected in sequence;
[0131] The convolution layer is used to extract local features of the input data;
[0132] The convolutional capsule layer includes a plurality of capsules, which are used to perform feature combination on the local features extracted by the convolutional layer to obtain combined features;
[0133] The digital capsule layer includes a plurality of capsules, each of which maps the input combined features through a weight matrix to obtain an output feature vector; and obtains the ST segment type based on the output feature vector;
[0134] The decoder includes three fully connected layers for decoding and reconstructing the output feature vector.
[0135] Since the number of ST segment types in the present invention is 5, the digital capsule layer is set with 5 capsules. The type represented by the digital capsule with the longest output feature vector is the type predicted by the model. During implementation, the weight matrix is obtained by the dynamic routing algorithm, and the combined features of the output of the main capsule layer are routed to the digital capsule layer as the input of the digital capsule layer. Each capsule is a small neural network that can be implemented by a standard fully connected layer or convolutional layer.
[0136] The activation function of the first two fully connected layers of the decoder selects the ReLU function, and the last fully connected layer uses the Sigmod function. The decoder uses the correct capsule output feature vector in the digital capsule layer as input to reconstruct an image of the sample source image size. The reconstruction loss function is the distance between the reconstructed image and the input image. The decoder forces the capsule to learn features that are useful for reconstructing the original image. The closer the reconstructed image is to the input image, the better. The correct capsule in the digital capsule layer means that if the sample is of the kth class, then the kth capsule is the correct capsule.
[0137] The loss of the model includes edge loss and reconstruction loss. Specifically, the loss of the deep learning network model is calculated using the following formula:
[0138] L=αL c +βL d
[0139]
[0140]
[0141] Among them, L c represents the marginal loss, L d represents the reconstruction loss, v k represents the output feature vector of the kth capsule in the digital capsule layer, |v k | indicates v k The model, Represents the preset penalty parameter. If the sample label is the kth category, then T k =1, otherwise, T k = 0, C represents the number of capsules in the digital capsule layer, p ij Represents the element value of the i-th row and j-th column in the model input sample, q ij represents the element value of the i-th row and j-th column of the data reconstructed by the decoder, α and β represent weight coefficients, and n st and m st Represent the width and height of the input sample respectively.
[0142] The model parameters are updated by calculating the loss direction propagation until the number of iterations is reached or the loss reaches the preset accuracy requirement, and the ST segment classification model is obtained.
[0143] For extracting the ECG signal to be detected, the ST segment signal can be extracted according to the process of extracting the ST segment in step S1, and each ST segment signal is input into the trained ST classification model to obtain the corresponding ST segment type. According to the types of these ST segments, it can be judged whether there are symptoms of myocardial ischemia.
[0144] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0145] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A method for classifying ST segments of electrocardiogram signals, characterized in that: The following steps are involved: Obtain ECG signals, extract ST segments from the ECG signals to construct a training sample set; Constructing a deep learning network model, and training the deep learning network model based on a training sample set to obtain an ST segment classification model; The ST segment in the electrocardiogram signal to be detected is extracted and input into the ST segment classification model to obtain the type of each ST segment in the electrocardiogram signal to be detected.
2. The method for classifying the ST segment of an electrocardiogram signal according to claim 1, characterized in that: The constructed deep learning network model includes an encoder and a decoder, wherein the encoder includes a convolutional layer, a main capsule layer and a digital capsule layer connected in sequence; The convolution layer is used to extract local features of the input data; The convolutional capsule layer includes a plurality of capsules, which are used to perform feature combination on the local features extracted by the convolutional layer to obtain combined features; The digital capsule layer includes a plurality of capsules, each of which maps the input combined features through a weight matrix to obtain an output feature vector; and obtains the ST segment type based on the output feature vector; The decoder includes three fully connected layers for decoding and reconstructing the output feature vector.
3. The method for classifying the ST segment of an electrocardiogram signal according to claim 1, characterized in that: The loss of the deep learning network model is calculated using the following formula: L=αL c +βL d Among them, L c represents the marginal loss, L d represents the reconstruction loss, v k represents the output feature vector of the kth capsule in the digital capsule layer, |v k | indicates v k The model, Represents the preset penalty parameter. If the sample label is the kth category, then T k =1, otherwise, T k = 0, C represents the number of capsules in the digital capsule layer, p ij Represents the element value of the i-th row and j-th column in the model input sample, q ij represents the element value of the i-th row and j-th column of the data reconstructed by the decoder, α and β represent weight coefficients, and n st and m st Represent the width and height of the input sample respectively.
4. The method for classifying the ST segment of an electrocardiogram signal according to claim 1, characterized in that: Extract the ST segment from the ECG signal to construct a training sample set, including: The ECG signal is detected to obtain the R wave in the ECG signal, and the R wave segment with low confidence is eliminated based on the detection confidence to obtain the preprocessed ECG signal; Based on the preprocessed ECG signal, the positions of the S wave and the T wave are determined, and the ST segment ECG signal is extracted. The ST segment ECG signal and the corresponding type constitute the training sample set.
5. The method for classifying the ST segment of an electrocardiogram signal according to claim 4, characterized in that: Based on the detection confidence, the R wave segments with low confidence are eliminated to obtain the preprocessed ECG signal, including: Taking each R wave in the ECG signal as the current R wave in turn, if the confidence of the current R wave is less than the first threshold, deleting the signal point between the current R wave peak and the previous R wave peak; The ECG signal obtained after removing the R wave with low confidence is filtered, the R wave is re-detected on the filtered ECG signal to obtain the R wave position, the corresponding position of the ECG signal before filtering is marked as the R wave, and the pre-processed ECG signal is obtained.
6. The method for classifying the ST segment of an electrocardiogram signal according to claim 4, characterized in that: Determine the position of the S wave and T wave based on the preprocessed ECG signal and extract the ST segment ECG signal, including: Perform the following steps for each R wave in order from right to left, traverse all R waves, determine the positions of S waves and T waves, and extract the ST segment ECG signal: From the R wave peak to the left, the second maximum slope point is the center of the P wave, and the third maximum slope point is the center of the T wave. From the center point of the T wave, traverse to the left and find the first maximum slope point, which is the center point of the S wave; The starting point of the T wave is found according to the center point of the T wave, and the signal from the center point of the S wave to the starting point of the T wave is extracted as the ST segment ECG signal.
7. The method for classifying the ST segment of an electrocardiogram signal according to claim 4, characterized in that: The confidence level of the R wave segment is calculated as follows: Performing differential conversion on the ECG signal to obtain an ECG differential signal; constructing a standard R wave differential waveform corresponding to each type of R wave based on the ECG differential signal; The confidence of each R wave segment is calculated based on the standard R wave differential waveform corresponding to each type of R wave.
8. The method for classifying the ST segment of an electrocardiogram signal according to claim 7, characterized in that: The confidence of each R wave segment is calculated based on the standard R wave differential waveform corresponding to each type of R wave, including: Perform integral reduction on each type of standard R wave differential waveform to obtain a standard R wave reduction waveform; For each type of standard R wave, extract each R wave segment corresponding to the type in the ECG differential signal, perform integral restoration, and use the restored R wave segment as the target R wave; Calculate the ratio of each type of standard R wave restoration waveform to the corresponding signal point in each target R wave of the corresponding type to construct a similarity ratio set; Calculate the similarity confidence interval of each type based on the set of all similarity ratios corresponding to each type; The confidence of each target R wave corresponding to the type is calculated according to the similarity confidence interval of the type.
9. The method for classifying the ST segment of an electrocardiogram signal according to claim 7, characterized in that: Based on the ECG differential signal, a standard R wave differential waveform corresponding to each type of R wave is constructed, including: For each type of R wave, the central differential waveform of the standard R wave corresponding to the type of R wave is obtained according to the differential mean value of the type of R wave in the ECG differential signal; A bidirectional sliding window is used to synchronously slide all such R wave segments, and the boundary differential waveform of the standard R wave corresponding to this type of R wave is obtained according to the differential mean value of the R wave in each sliding window; The standard vertebral R wave differential waveform corresponding to this type of R wave is obtained according to the central differential waveform and the boundary differential waveform of the standard R wave corresponding to this type of R wave.
10. The method for classifying the ST segment of an electrocardiogram signal according to claim 9, characterized in that: A bidirectional sliding window is used to synchronously slide all such R wave segments, and the boundary differential waveform of the standard R wave corresponding to this type of R wave is obtained according to the differential mean value of the R wave in each sliding window, including: Determine the left initial position corresponding to the left sliding window and the right initial position corresponding to the right sliding window respectively according to the width of the central differential waveform of the standard R wave; Using a left sliding window to slide leftward from the left initial position in all such R wave segments, and determining the left boundary differential waveform of the standard R wave corresponding to the such R wave according to the differential mean of the R wave in each left sliding window; A right sliding window is used to slide rightward from the right initial position in all such R wave segments, and the right boundary differential waveform of the standard R wave corresponding to this type of R wave is determined according to the differential mean of the R wave in each right sliding window.