Background
Electrocardiography (ECG or EKG) is a medical technique that records the electrophysiological activity of the heart in units of time, through the thorax, and is captured and recorded by electrodes on the skin. This is a non-invasive way of recording.
The working principle of the electrocardiogram is as follows: when the cardiac muscle cells depolarize each heartbeat, small electrical changes are caused on the skin surface, and the small changes are captured and amplified by the electrocardiogram recording device to draw the electrocardiogram. When the myocardial cells are in a resting state, the potential difference formed by the concentration difference of positive and negative ions exists on the two sides of the myocardial cell membrane, and depolarization is the process that the potential difference of the myocardial cells changes to 0 rapidly and causes the myocardial cells to contract. In one cardiac cycle of a healthy heart, the depolarization waves generated by the sinoatrial node cells are sequentially propagated in the heart, first throughout the atria, and then through the "intrinsic conduction pathways" to the ventricles. If 2 electrodes are placed on either side of the heart, then the slight voltage change between the two electrodes can be recorded during the procedure and displayed on an electrocardiogram or monitor. The electrocardiogram reflects the rhythm of the whole heart beat and weak parts of the heart muscle.
More than 2 electrodes can be placed on the limb, two by two, to make a pair for measurement (e.g. left arm electrode (LA), right arm electrode (RA), left leg electrode (LL) can be combined as LA + RA, LA + LL, RA + LL). The output signal of each electrode pair is referred to as a set of leads. The leads are simply looking at the change in cardiac current from different angles. The kind of electrocardiogram can be distinguished by leads, such as 3-lead electrocardiogram, 5-lead electrocardiogram and 12-lead electrocardiogram, etc. The 12-lead electrocardiogram is the most common clinical one, can record the potential changes of 12 groups of leads on the body surface at the same time, and draws 12 groups of lead signals on the electrocardiogram paper, and is commonly used for disposable electrocardiogram diagnosis. 3-lead and 5-lead electrocardiograms are often used in situations where continuous detection of the heart electrical activity is required through a monitor, such as during surgery or in monitoring when transporting a patient in an ambulance. Depending on the instrument, the results of such continuous monitoring may not be completely recorded at times.
The electrocardiogram is the best method for measuring and diagnosing abnormal heart rhythm, and is used for diagnosing the abnormal rhythm of the heart when the heart conducting tissues are damaged and the change of the heart rhythm caused by imbalance of electrolyte. In the diagnosis of Myocardial Infarction (MI), it can specifically distinguish the region of myocardial infarction. Meanwhile, the electrocardiogram is also the most important examination for diagnosing arrhythmia diseases.
For the electrocardiograph, the diagnosis of an electrocardiogram is not only written with the name of the diagnosis, but also needs to record the parameters of the electrocardiogram, including the heart rate, the PR interval, the QT interval and the like. Relying on manual acquisition by the physician reduces the efficiency of the physician's diagnosis and the physician may have errors in the fine parameter estimation. Therefore, the electrocardio parameters are obtained by an automatic method, so that the working efficiency of doctors is greatly improved, and the accuracy is reduced.
The acquisition of the electrocardio parameters depends on the division of the electrocardio wave bands, and the current wave band division method is mainly a signal processing method. The signal processing method comprises the following steps: amplitude method, slope method, area method, mathematical morphology, wavelet transform, fractal theory, etc. Although these signal processing methods can effectively process electrocardiographic signals, they have poor generalization and are not ideal for waveform processing, which is not common, and has a large waveform variation range.
Disclosure of Invention
The invention aims to solve the technical problems that the wave band segmentation of the central electrical data is actually applied, the subjectivity is strong, the variation degree is large, the influence of the acquisition environment is large, the adaptability of the traditional method is poor, the accuracy rate is to be improved and the like, and provides an electrocardio parameter calculation method based on deep learning. Therefore, the invention adopts the following technical scheme:
an electrocardio parameter calculation method based on deep learning comprises the following steps:
s1, data set construction, namely extracting 12-lead electrocardiogram data with the length of 10 seconds from the existing electrocardiogram data to form an electrocardiogram data set, and carrying out extraction on the electrocardiogram data according to the following steps of 8:2, dividing the proportion into a training set and a testing set, and labeling the extracted electrocardiogram data;
s2, preprocessing the labels, namely generating a 4-channel probability distribution label with the same size as the data by using the labels obtained in the step S1 and the data corresponding to each label, and marking the label as a first label;
s3, standardizing and expanding the data set, namely, scaling the extracted electrocardio data to the same scale, carrying out z-score standardization on each electrocardio data, and expanding the electrocardio data set by adopting a data set amplification mode;
s4, model training, namely establishing a U-Net model based on a one-dimensional convolutional neural network, inputting an electrocardiogram data set into the model, outputting a 4-channel probability distribution label with the same size as each electrocardiogram data set, marking the label as a second label, comparing and calculating the second label with the first label until the model converges, and storing a segmented waveform obtained by the model;
and S5, performing model verification, predicting the wave band to which the point location belongs according to the second label, comparing the predicted wave band with the wave band of the first label, and calculating the corresponding Dice index.
The 12 leads include 6 limb leads and 6 chest leads, the limb leads are aVR, aVF, aVL, VI, VIII and VIII leads, and the chest leads are V1, V2, V3, V4, V5 and V6 leads.
z-score normalization, also called standard deviation normalization, is a method of normalizing data by giving the mean and standard deviation of the raw data. The processed data are in accordance with the standard normal distribution, namely the mean value is 0, the standard deviation is 1, and the conversion function is as follows:
where μ is the mean of all sample data and σ is the standard deviation of all sample data. The z-score normalization method is applicable to cases where the maximum and minimum values of attribute A are unknown, or where there is outlier data that is out of range.
The U-Net network is an image segmentation network based on CNN, and is mainly used for medical image segmentation, and the network is originally proposed to be used for cell wall segmentation, and then has excellent performances in lung nodule detection, blood vessel extraction on fundus retina and the like.
The Dice index is a kind of collective similarity measure index, and is usually used to calculate the similarity of two samples, the value range is 0-1, the segmentation result is preferably 1, and the worst value is 0.
On the basis of the technical scheme, the invention can also adopt the following further technical scheme:
the labeling method in step S1 is to label the electrocardiographic wave band and the point location, where the labeling of the electrocardiographic wave band includes P waves, QRS complexes, and T waves, and the standard of the point location includes a P wave starting point, a QRS complex starting point, a QRS wave end point, a T wave starting point, and a T wave end point.
Wherein, P wave is formed when the sinus sends impulse, QRS wave group is the expression of ventricular depolarization, and T wave is the expression of ventricular repolarization.
The label in step S2 is a label of the annotation point, and if the annotation point belongs to the P wave region, the label is (0,1,0,0), if the annotation point belongs to the QRS complex region, the label is (0,0,1,0), if the annotation point belongs to the T wave region, the label is (0,0,0,1), and if the annotation point belongs to the other regions, the label is (1,0,0, 0).
The expansion method in step S3 is one or more of translation, noise addition, or multiplication of random coefficients, and can be selected appropriately according to the characteristics of the electrocardiographic data.
The step S5 further includes generating a predicted P-wave starting point, a QRS complex ending point, a T-wave starting point, and a T-wave ending point, comparing the 5 point positions with the 5 point positions of the first label, respectively, calculating a distance between the two, and calculating a PR interval, a QRS interval, a QT/QTc interval, and a heart rate according to the predicted 5 point positions.
The RR interval is the starting point of two adjacent QRS complexes, and the time limit is 3-5 grids, namely 0.6-1.0 s; the QT interval is from the beginning of the QRS complex to the end of the T wave, and the time limit is 9-11 lattices, namely 0.36-0.44 s; the QRS interval is from the start of the QRS complex to the end of the QRS complex.
The method comprises the following steps: through the construction of the segmentation network model, the accuracy of prediction is calculated by using the steps in the step S5, and the difference and the correlation between the accuracy of a deep learning mode and the accuracy measured by a professional doctor are analyzed, so that the method provided by the text is finally verified to have a positive effect on improving the calculation of clinical electrocardiogram parameters.
Compared with the prior art, the invention has the following beneficial effects:
1) the segmentation of the deep convolutional neural network is applied to the division of the electrocardiosignals, so that the electrocardio parameters are calculated, and the adaptability and the accuracy of computer-aided diagnosis are improved;
2) the problems of strong subjectivity, inaccuracy and the like of electrocardiogram doctor in measuring the electrocardio parameters are solved.
3) The workload of an electrocardiograph is reduced.
Detailed Description
In order to further understand the present invention, the following specifically describes the deep learning-based method for calculating electrocardiographic parameters according to the present invention with reference to the specific embodiments, but the present invention is not limited thereto, and those skilled in the art can make insubstantial improvements and adjustments under the core guidance of the present invention, and still fall within the scope of the present invention.
First, a large number of electrocardiographic data sets are acquired.
The specific operation steps are as follows: a large amount of 12-lead electrocardiogram data with the sampling frequency of 500Hz are selected from various public data sets and the existing electrocardiogram data of hospitals, and are output as txt files with fixed formats. In particular, some electrocardiosignals with obvious abnormal conditions are selected and added into the data set so as to enhance the generalization of the method. On the basis, the wave bands of the electrocardio data are labeled, and 5 kinds of point positions are labeled in total, wherein the point positions comprise a P wave starting point, a QRS wave group ending point, a T wave starting point and a T wave ending point. All data were divided into training and test sets on an 8:2 scale.
And further, generating a One-hot label according to the marked point.
The specific operation steps are as follows: and generating a Mask with the same size as the data according to the marked points, wherein a P wave region (from a P wave starting point to a QRS wave group starting point) is marked as 1, a QRS wave group region (from a QRS wave group starting point to a QRS wave group ending point) is marked as 2, a T wave region (from a T wave starting point to a T wave ending point) is marked as 3, and other regions are marked as 0. On this basis, an One-hot tag is generated, in which if a certain point belongs to the P-wave region, it is denoted as (1,0,0,0), if it is a QRS complex region, it is denoted as (0,1,0,0), if it is a T-wave region, it is denoted as (0,0,1,0), and if it is another region, it is denoted as (0,0,0, 1).
Further, the electrocardiographic data set is standardized and expanded.
The specific operation steps are as follows: and (3) carrying out z-score standardization on each piece of electrocardio data, and scaling the electrocardio signal intensity to a uniform scale. In the training process, the training set is expanded by means of random translation, noise addition, random coefficient multiplication and the like according to training data, and only standardization operation is performed on the test set in the testing process.
Further, a deep learning segmentation network with a one-dimensional convolutional neural network as a basic module is built, wherein the overall network structure is shown in fig. 1, and the network outputs a 4-channel probability distribution Mask with the same size as the input data.
Further, the segmentation network is trained by using the electrocardiogram data in the training set, and the effect prediction of the test set is carried out.
The specific operation steps are as follows: determining the loss function as the sum of the binary cross entropy loss and the Dice loss. A binary cross entropy loss of L
c- [ ylogf + (1-y) log (1-f)), where y denotes the true label and f denotes the predicted value. A Dice loss of
Wherein X
cIndicates that 1) a prediction tag of the corresponding class, Y
cAnd e is a minimum number, and the denominator is not 0. Set the batch of data input into the split network each time to 16, using an Adam optimizer, with an initial learning rate of 10
-3Setting the upper limit of the cycle iteration times of the whole sample to be 500 times, training the sample once per complete iteration, predicting the effect of the test set, saving the effect after the first complete iteration as the optimal effect, and then comparing and saving the optimal verification effect and saving the model once per complete iteration until the upper limit of the iteration times is reached. In the training process, if the prediction loss of the training set does not decrease for 10 times continuously, the learning rate is adjusted to be half of the last iteration.
Further, electrocardio parameters are calculated according to the output of the model.
The specific operation steps are as follows: and inputting the electrocardiogram data to be predicted into the stored optimal model to obtain a 4-channel prediction label with the same size as the data. Each point location predicts the wave band to which the point location belongs according to the channel with the maximum probability; according to the generated final Mask, a P wave starting point, a QRS wave group ending point, a T wave starting point and a T wave ending point of the data can be obtained; and calculating PR interval, QRS interval, QT/QTc interval and heart rate of the data according to the generated 5 point locations.
Furthermore, in order to verify that the method provided by the inventor is effective and reasonable, the electrocardiogram data obtained during the actual electrocardiogram detection of the patient is collected and input into the stored optimal model, the output prediction result is compared with the analysis result of a professional doctor, and the prediction accuracy is calculated for subsequent improvement.
While the invention has been shown and described with reference to a preferred embodiment, it will be understood by those skilled in the art that various changes in form and detail may be made therein without departing from the scope of the appended claims.