ECG signal classification method based on time-frequency domain fusion and convolutional neural network
By combining wavelet decomposition and fast Fourier transform with a one-dimensional convolutional neural network, time-frequency domain information fusion of electrocardiogram (ECG) signals is achieved, improving the accuracy of ECG signal classification and making it suitable for auxiliary diagnosis of small devices.
Patent Information
- Application Number
- CN202310522195.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-10
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2043-05-10
AI Technical Summary
Existing ECG signal classification methods mainly focus on a single perspective in the time or frequency domain, failing to fully utilize the comprehensive information of ECG signals in the time and frequency domains, resulting in insufficient classification accuracy.
The heart rate cycle is extracted by denoising through wavelet decomposition filtering, locating the R-wave position, obtaining frequency domain information by combining fast Fourier transform, and then inputting the time-frequency domain data into an 11-layer one-dimensional convolutional neural network for classification.
It improves the classification accuracy of single-heartbeat cycle ECG signals, enhances the diagnostic effect of ECG signals, and is suitable for deployment in small devices.
Smart Images

Figure CN116746942B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of signal classification, and particularly relates to an electrocardiosignal classification method based on time-frequency domain fusion and convolutional neural network. BACKGROUND
[0002] In recent years, heart diseases as a kind of cardiovascular diseases (CVD) seriously threaten the life and health of human beings. Early detection of patients with critical arrhythmia symptoms is of great help to the treatment of cardiovascular diseases and the avoidance of more serious consequences. Therefore, the diagnosis, prevention and rescue treatment of heart diseases are important problems in the medical field.
[0003] ECG signal has a more intuitive regularity. It represents the electrical activity of the heart. The signal contains a large amount of biological health information. Through ECG signal diagnosis, it can detect whether the object has ventricular and atrial hypertrophy, myocardial ischemia, arrhythmia and other diseases. At the same time, ECG signal is easier to detect than other bioelectric signals. Therefore, ECG signal has become one of the earliest bio-signals studied and applied in medical clinical. At present, many scholars have carried out research on the recognition of heart health status based on ECG signal. The waves in ECG wave group are named in alphabetical order, respectively P, Q, R, S, T, U. The shape, amplitude and duration of these waves represent different heart state information. Among them, P wave is generated by atrial depolarization. QRS complex is generated by ventricular depolarization. Its amplitude in ECG is often the largest, so it is often used as the reference point of heartbeat cycle positioning. T wave and U wave come from the repolarization of the ventricle. The traditional ECG diagnosis method is for experts to observe the information of wave group in the patient's ECG, and then draw a diagnosis result. When the duration of QRS complex is too long, the patient may have bundle branch block. When ST complex produces abnormal changes, it may indicate that the patient has myocardial infarction or angina and other diseases. But the traditional ECG diagnosis method depends on the professional accomplishment of doctors, and needs a complex feature extraction process. Therefore, more deep learning methods are used for ECG signal classification. Cui et al. used convolutional neural network (CNN) and support vector machine (SVM) to classify ECG signal, and realized the diagnosis of heart health status. Zeng et al. decomposed the ECG signal by variational mode decomposition (VMD) and inputted it into artificial neural network (ANN), realizing the recognition of 5 kinds of heartbeat types. Jikuo et al. proposed a new type of convolutional neural network with non-local convolution block attention module (NCBAM) for single heartbeat cycle ECG signal classification. Subasi et al. used feature selection method based on iterative relief and neighborhood component analysis (NCA) for ECG signal, and finally inputted the features into deep neural network (DNN) to obtain good diagnosis effect. Sinha et al. extracted spectral coherence index (SCI) and phase coherence index (PCI) from 12-lead ECG signal spectrum, and inputted them into the framework of SVM classifier integration for myocardial infarction diagnosis of heart. Amrani M et al. used very deep convolutional neural network (VDCNN) for feature extraction of ECG signal, and through feature fusion, reduced the model calculation amount, and finally classified ECG signal, achieved good effect and generalization ability.
[0004] These studies use various methods to extract feature values from electrocardiogram signals. Finally, the extracted features are classified by a classifier or a neural network to diagnose the heart health status. However, these methods basically start from the time domain or frequency domain performance of the electrocardiogram signal, without considering the information embodied in the time domain and frequency domain of the electrocardiogram signal at the same time, and the classification accuracy is still not high enough. SUMMARY
[0005] The present application provides an electrocardiogram signal classification method based on time-frequency domain fusion and convolutional neural network, which solves the technical problem of how to fuse the performance of a single heartbeat cycle in the time domain and the frequency domain, and comprehensively classifies the electrocardiogram signal.
[0006] To solve the above technical problems, the present application provides an electrocardiogram signal classification method based on time-frequency domain fusion and convolutional neural network, comprising the steps of:
[0007] S1, filtering the entire electrocardiogram signal to filter out noise;
[0008] S2, positioning the R-wave position of the filtered entire electrocardiogram signal, and extracting a plurality of heartbeat cycle signals according to the positioned R-wave position;
[0009] S3, performing fast Fourier transform on each heartbeat cycle signal to obtain its frequency domain information;
[0010] S4, splicing each heartbeat cycle signal with its frequency domain information to obtain a plurality of time-frequency domain splicing data;
[0011] S5, inputting each piece of time-frequency domain splicing data into a convolutional neural network for classification to obtain the corresponding classification result.
[0012] Further, the step S1 specifically comprises the steps of:
[0013] S11, using a multi-order Daubechies wavelet as a wavelet basis for wavelet transform to decompose the entire electrocardiogram signal on N scales, obtaining N low-frequency components and N high-frequency components, N≥3;
[0014] S12, setting the wavelet coefficients of the two high-frequency components with the highest frequency to zero, setting a threshold value , and using soft threshold filtering to set the wavelet coefficients of other high-frequency components less than the threshold value to zero;
[0015] S13, reconstructing the low-frequency component with the lowest frequency and the high-frequency component processed in step S12 to obtain the entire electrocardiogram signal filtered to remove noise.
[0016] Further, in the step S12, the threshold value is calculated as follows:
[0017] ,
[0018] wherein D is the processed wavelet coefficient, C is the signal length, indicates taking the median.
[0019] Further, the step S2 specifically comprises the steps of:
[0020] S21, using a db2 wavelet base to perform three-scale decomposition on the filtered whole ECG signal;
[0021] S22, performing wavelet reconstruction on the high-frequency component of the third scale to obtain a reconstructed signal f(n);
[0022] S23, locating the R-wave position in the reconstructed signal f(n);
[0023] S24, according to the result of R-wave position locating, extracting each R-wave position and the previous n-1 and the following 2n data, a total of 3n data, in the filtered whole ECG signal as a heartbeat cycle signal to be identified, thereby extracting multiple heartbeat cycle signals.
[0024] Further, the step S23 specifically comprises the steps of:
[0025] S231, locating the maximum value generated by the QRS complex in the reconstructed signal f(n), and setting the position of the maximum value as point A;
[0026] S232, sliding a window of size J on the reconstructed signal f(n) with a sliding step S;
[0027] S233, judging whether there are still three windows, if not, continue to judge, if yes, proceed to the next step;
[0028] S234, obtaining the data of the next window, and finding the maximum value and the minimum value in the data, if the difference between the maximum value and the minimum value is greater than a threshold value, proceed to the next step, otherwise return to step S233;
[0029] S235, finding the value that is most different from the signal mean value in the left and right K intervals of the position of point A in the next window, and setting the position of the value as point B1, and setting B2 as the position of the previous B1 point;
[0030] S236, calculating the distance between B1 point and B2 point, if the distance is greater than a distance threshold value L, recording the B1 point as the R-wave position, otherwise proceed to the next step;
[0031] S237, determine whether the difference between the signal value of B1 point and the signal average value of its interval is greater than the signal value of B2 point, if yes, replace B2 with B1 position, if not, discard the position and return to step S233.
[0032] Further, the step S3 specifically comprises the steps of:
[0033] S31, using fast Fourier transform to perform fast Fourier transform on each heartbeat period signal with a frequency of sampling frequency F, to obtain frequency domain information of the heartbeat period signal;
[0034] S32, the first half of the frequency domain information is reserved to participate in splicing.
[0035] Further, in the step S5, the convolutional neural network is constructed as an 11-layer architecture, the first layer is an input layer composed of a plurality of input nodes; the second layer is a one-dimensional convolutional layer composed of a 4-channel 21x1 convolutional kernel, the convolutional kernel moving step is 1, and the padding mode is same; the third layer is a maximum pooling layer, the pooling range is 2x1, and the moving step is 2; the fourth layer is a one-dimensional convolutional layer composed of a 16-channel 23x1 convolutional kernel, the convolutional kernel moving step is 1, and the padding mode is same; the fifth layer is a maximum pooling layer, the pooling range is 2x1, and the moving step is 2; the sixth layer is a one-dimensional convolutional layer composed of a 32-channel 25x1 convolutional kernel, the convolutional kernel moving step is 1, and the padding mode is same; the seventh layer is an average pooling layer, the pooling range is 2x1, and the moving step is 2; the eighth layer is a one-dimensional convolutional layer composed of a 64-channel 27x1 convolutional kernel, the convolutional kernel moving step is 1, and the padding mode is same; the ninth layer is a Flatten layer, which splices the convolutional results of the last layer into a 3840x1 feature vector; the tenth layer is a fully connected layer composed of 128 fully connected neurons, and the activation function of the neuron is relu; the eleventh layer is an output layer, and the function therein is softmax.
[0036] Further, the loss function used in the process of training the convolutional neural network is cross entropy.
[0037] Further, the 102nd and 104th data in the MIT-BIH arrhythmia database are discarded, the R-wave peak position of each heartbeat in the remaining 46 data is labeled, and 99188 heartbeat period signals are obtained, and 70% of the heartbeat period signals are used for training the convolutional neural network, and the remaining 30% are used for testing.
[0038] Further, the convolutional neural network has five classification labels, which are normal heartbeat, atrial premature beat, ventricular premature beat, left bundle branch block and right bundle branch block.
[0039] The application provides a method for classifying electrocardiosignal based on time-frequency domain fusion and convolutional neural network, first, the electrocardiosignal is filtered through wavelet decomposition, second, a single heartbeat cycle is extracted through the R wave position of each heartbeat cycle, the extracted heartbeat signal is subjected to fast Fourier transform to obtain frequency domain information, the time domain signal and the frequency domain signal are spliced and input into a one-dimensional convolutional neural network (1D-CNN) for fusion and feature extraction, and finally the feature matrix is input into a fully connected neural network for classification.
[0040] The method for classifying electrocardiosignal based on time-frequency domain fusion and convolutional neural network has three main contributions.
[0041] 1. The CNN fuses the performance of a single heartbeat cycle in the time domain and the frequency domain, comprehensively classifies the electrocardiosignal, improves the classification accuracy of the single heartbeat cycle electrocardiosignal, and makes it exceed the latest method.
[0042] 2. A novel heartbeat cycle positioning method is proposed, which can simultaneously calibrate the R wave peak position of normal electrocardiosignal and pathological electrocardiosignal, so that each heartbeat cycle in the electrocardiosignal can be better segmented, thereby improving the accuracy of subsequent classification.
[0043] 3. The fast Fourier transform is introduced to extract the frequency domain signal of the heartbeat cycle, and the frequency domain signal is fused with the time domain signal to fully utilize the time-frequency domain features of the signal, which helps to improve the accuracy of subsequent classification.
[0044] 4. In order to make the model smaller and classify the electrocardiosignal under the condition of limited hardware resources, a shallow layer CNN is used, and a large receptive field and a small step convolution filter are used, which improves the quality of feature extraction in the shallow network, and the model is very suitable for deployment in small devices, which provides a way for the miniaturization of the electrocardiosignal auxiliary diagnosis device. BRIEF DESCRIPTION OF DRAWINGS
[0045] Figure 1 It is a wavelet decomposition diagram of N scale provided by the embodiment of the application;
[0046] Figure 2 It is a waveform diagram of electrocardiosignal provided by the embodiment of the application;
[0047] Figure 3 It is a wavelet third scale decomposition reconstruction diagram provided by the embodiment of the application;
[0048] Figure 4 It is an R wave positioning algorithm flowchart provided by the embodiment of the application;
[0049] Figure 5is a convolutional neural network model structure diagram provided by an embodiment of the present application;
[0050] Figure 6 is a filter effect diagram provided by an embodiment of the present application, wherein (A) is before filtering, and (B) is after filtering;
[0051] Figure 7 is an R wave positioning effect provided by an embodiment of the present application, wherein (A) is before positioning, and (B) is after positioning;
[0052] Figure 8 is a heartbeat cycle spectrum diagram provided by an embodiment of the present application;
[0053] Figure 9 is a change diagram of loss and accuracy provided by an embodiment of the present application. DETAILED DESCRIPTION
[0054] The embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments are given only for the purpose of illustration and should not be understood as limiting the present application. The accompanying drawings are used for reference and illustration only and do not constitute a limitation on the scope of patent protection of the present application, because many changes can be made to the present application without departing from the spirit and scope thereof.
[0055] Electrocardiogram (ECG) signals are often used to diagnose heart conditions. However, most existing electrocardiogram diagnosis methods only use time domain information of electrocardiogram signals, ignoring frequency domain information. This results in some obvious disease information in the frequency domain being ignored. To solve this problem, an embodiment proposes a method of fusing time domain and frequency domain information in electrocardiogram signals through a convolutional neural network (CNN). First, the electrocardiogram signal is filtered. Second, each heartbeat cycle in the electrocardiogram signal is segmented through R wave positioning. Next, the frequency domain information of the heartbeat cycle is extracted through fast Fourier transform (FFT). Finally, the time domain information and the frequency domain information are spliced and input into a neural network for classification. This method realizes the diagnosis of five states of the heart, with an identification accuracy of 99.43%.
[0056] Traditional heart disease diagnosis through electrocardiogram signals requires a large amount of electrocardiogram monitoring data and doctors with high business level. If electrocardiogram signals can be automatically classified, medical resources can be saved and efficiency can be improved. Currently, many scholars have conducted research on the automatic classification of electrocardiogram signals. Such research mainly includes two contents: feature extraction of electrocardiogram signals and result classification.
[0057] Feature extraction of ECG signal is to extract the key information of heart activity in ECG signal, so that ECG signal can be represented in a lower dimension. With this information, the diagnosis of ECG signal can obtain higher accuracy with less information. Traditional feature extraction methods are pattern recognition methods, including wavelet transform, frequency analysis, principal component analysis (PCA), independent component analysis (ICA), etc. In recent years, with the development of artificial intelligence technology, a large number of deep learning methods have been used for feature information extraction of ECG signal. The main methods include CNN, multilayer perceptron, recurrent neural network (RNN), deep belief network (DBN), long short-term memory network (LSTM), gated recurrent unit (GRU) and bidirectional recurrent neural network (BRNN) etc.
[0058] In the ECG signal classification stage, various classifiers are mainly used for classification, such as conditional random field (CRF), support vector machine, dynamic Bayesian network (DBN), neural network and decision tree (DT) etc. In recent years, deep learning methods are becoming more and more popular, and there are multiple authoritative ECG signal data sets on the Internet. This makes a large number of scholars and research teams try to build various neural network models to solve the automatic classification problem of ECG signal.
[0059] The electrocardiosignal is a time series signal, and its essence is a voltage signal changing with time. In the past, the traditional electrocardio classification in the hospital is to judge by the electrocardiogram drawn by the doctor observing the time series electrocardio signal. The basis of the judgment is whether the electrocardiogram drawn by the electrocardio signal is the typical shape of the healthy electrocardiogram. If there is a significant deviation between the shape and the healthy electrocardiogram, it is considered that the electrocardio signal has a lesion. However, many frequency domain features in medicine are related to certain diseases. When arrhythmia occurs, the QRS complex will change significantly, resulting in abnormal changes in high-frequency components. As can be seen, the frequency domain features of the electrocardio signal also contain part of the information of the lesion, and this part of the information may be difficult to observe in the time domain. Therefore, the extraction of the frequency domain information of the electrocardio signal is of great help to find the lesion information that is difficult to observe in the time domain. Among the methods of extracting the frequency domain features of the electrocardio signal, the most famous are the fast Fourier transform (FFT) and the wavelet transform (WT). The fast Fourier transform changes the time series signal into the distribution of each frequency in the frequency domain through an infinite long trigonometric function base. The content after the transformation represents the maximum amplitude of the signal at each frequency, but it cannot determine the time of the generation of the frequency signal. The wavelet transform uses a finite length wavelet base, and the corresponding frequency and time can be obtained by controlling the scale and translation of the wavelet. The time-frequency spectrum of the signal can be obtained. The frequency spectrum contains the distribution of each frequency on the time axis. In addition to extracting the time-frequency domain information of the signal, the wavelet transform can also be used for R-wave positioning of the electrocardio signal. In this example, the wavelet transform is used to filter the original electrocardio signal and locate the R-wave. The fast Fourier transform is used to extract the frequency domain information of the electrocardio signal.
[0060] The convolutional neural network (CNN) is a deep learning algorithm, which is generally used for feature extraction of information. It is widely used in image processing. The CNN generally consists of three elements: convolution layer, pooling layer and fully connected layer. Each layer obtains input from the previous layer and outputs the processed result to the next layer. The convolution layer and the pooling layer in the network are generally combined to complete feature extraction and data dimension reduction. After multiple convolutions and poolings, a feature matrix is obtained. After inputting the feature matrix into the fully connected layer, the final result can be obtained. Through training, the parameters in the network are constantly optimized, and finally the error between the prediction result of the network and the label is as small as possible.
[0061] Specifically, the electrocardio signal classification method based on time-frequency domain fusion and convolutional neural network provided by the application comprises the following steps:
[0062] S1, filtering the whole electrocardio signal by wavelet transform to filter out noise;
[0063] S2, positioning the R-wave position of the whole electrocardio signal after filtering, and extracting a plurality of heartbeat period signals according to the positioned R-wave position;
[0064] S3, performing fast Fourier transform on each heartbeat cycle signal to obtain frequency domain information thereof;
[0065] S4, splicing each heartbeat cycle signal with the frequency domain information thereof to obtain a plurality of time-frequency domain splicing data;
[0066] S5, inputting each piece of time-frequency domain splicing data into a convolutional neural network for classification to obtain a corresponding classification result.
[0067] In this example, the frequency domain information of the electrocardiogram signal is extracted, the time domain information and the frequency domain information of the electrocardiogram signal are fused through the convolutional neural network, and finally the classification of the electrocardiogram signal is completed. In actual application, the real-time collected electrocardiogram signal does not need to be calibrated for the position of the R wave peak. Therefore, after collecting the human electrocardiogram signal, the R wave positioning is performed first. Then, each complete heartbeat cycle is input into the model for diagnosis through the positioning information. Therefore, the key parts are the signal preprocessing (step S1), R wave position positioning (step S2), frequency domain information extraction (step S3), and electrocardiogram diagnosis model building (convolutional neural network in step S5).
[0068] (1) Signal preprocessing
[0069] The electrocardiogram signal itself is a relatively weak signal, and its frequency and amplitude are low. Such characteristics make the electrocardiogram signal very susceptible to various noises during collection. For example, during collection, the change in electrode position caused by the sliding of the patch electrode on the human body and the movement caused by the human body's own breathing. Both of these will cause a certain baseline drift of the electrocardiogram signal, causing the regularity of the electrocardiogram signal to change over time. This change rule is very similar to a low-frequency sinusoidal function. The involuntary tremor of the human body's own muscles will also affect the electrocardiogram signal. This interference is called electromyographic interference, which is often high-frequency and irregular. The power supply environment of the collection device will cause electromagnetic interference to the device, which is a kind of interference that is difficult to avoid. Electromyographic interference and electromagnetic interference often mask some small but key information-containing waveforms in the electrocardiogram signal.
[0070] The electrocardiogram signal is mixed with high-frequency low-amplitude noise. These noises mask some waveforms with small amplitudes in the electrocardiogram signal. Such noise interference will have a greater impact on subsequent R wave positioning and frequency domain analysis, and will also affect the final classification accuracy of the model. Therefore, before the subsequent work is carried out, the original electrocardiogram signal needs to be filtered.
[0071] Since noise and signal are mixed together, but they differ significantly in the frequency domain, multi-scale wavelet decomposition can be used to extract information from different frequencies within the signal. Furthermore, wavelet transform considers both time and frequency domain information simultaneously, making it highly suitable for processing non-stationary electrocardiogram (ECG) signals. The mathematical expression for the continuous wavelet transform (CWT) is shown in equation (3-1):
[0072] (3-1)
[0073] In the formula, It is the result after wavelet transform. It is a signal that has undergone wavelet transform. It is time. It is the wavelet mother function. It is the wavelet scale. The wavelet's scale is the shift amount. However, in CWT, both the wavelet scale and the shift amount change continuously. Performing continuous wavelet transforms on ECG signals results in excessive redundant information. This negatively impacts ECG signal denoising and reconstruction. Discrete wavelet transform is more suitable for processing ECG signals.
[0074] Discrete wavelet transform requires scaling the wavelet. With translation Perform a discrete transformation to make , , The discrete wavelet transform is calculated using the following equation (3-2):
[0075] (3-2)
[0076] It is the result after discrete wavelet transform, if For a discrete signal, the result of wavelet transform is given by formula (3-3):
[0077] (3-3)
[0078] Where A[ ] is The low-frequency component obtained by wavelet transform decomposition, D[ ] is the high-frequency component obtained by decomposition.
[0079] When using wavelet transform to decompose a signal, only the low-frequency components of the signal are decomposed, and wavelet decomposition has excellent performance when decomposing the low-frequency part.
[0080] This example uses wavelet basis to decompose the signal into N scales. The process is as follows: Figure 1 As shown. Reference Figure 1, step S1 specifically comprises the steps of:
[0081] S11, using multi-order Daubechies wavelet as the wavelet basis of wavelet transform to decompose the whole ECG signal on N scales, obtaining N low-frequency components and N high-frequency components, N≥3;
[0082] S12, setting the wavelet coefficients of the two high-frequency components with the highest frequency to zero, setting a threshold using soft threshold filtering to set the wavelet coefficients less than the threshold in other high-frequency components to zero;
[0083] S13, signal reconstruction is performed on the low-frequency component with the lowest frequency and the high-frequency component processed in step S12, obtaining the whole ECG signal filtered of noise.
[0084] In step S12, the threshold is calculated as follows:
[0085] (3-4)
[0086] wherein D is the wavelet coefficient after processing, C is the signal length, indicates taking the median.
[0087] (2) R wave positioning
[0088] The classification of the ECG signal in this example is based on each independent heartbeat cycle. Each QRS fluctuation on the ECG represents a heartbeat, and the peak of the R wave fluctuation can be used to locate a heartbeat, as shown in Figure 2 . Before classifying the ECG signal, the R wave position in the ECG signal needs to be located to segment each independent heartbeat cycle.
[0089] The rising slope and the falling slope of the R wave are both larger than the slopes of other waveforms. The traditional R wave recognition method uses this characteristic to recognize the first-order differential data of the ECG signal by setting a threshold, but this method only has accurate recognition for typical healthy ECG signals, but the accuracy of this method decreases significantly for pathological signals. This is because the slope of the R wave in some pathological signals will decrease, and many wave peaks with a slope greater than the R wave will be generated in other places.
[0090] The research finds that the energy of QRS wave is mainly concentrated on the third scale after wavelet transform of the electrocardio signal, and the transform of R wave on the scale produces a pair of modulus maximum, i.e. a positive maximum value-negative minimum value pair, and the value time of R wave peak corresponds to the zero-crossing point between the maximum value and the minimum value on the scale. Meanwhile, the characteristic of QRS wave position of the pathological signal after wavelet transform on the scale is similar to that of the typical healthy electrocardio signal, and most of the interference of the pathological waveform is filtered. The method has good performance for segmenting the heartbeat period of the pathological signal.
[0091] The example uses db2 wavelet base to decompose the electrocardio signal on three scales. Then the high-frequency component D3 of the third scale is used for reconstruction to obtain fd3. The subsequent R wave positioning is performed through fd3. The process is as shown in Figure 3 .
[0092] However, it is found through experiments that the R wave peak point is not necessarily strictly the zero-crossing point of the maximum value and the minimum value on the scale, and there is often a certain deviation. The example positions the maximum value generated by the QRS complex in fd3 through the form of sliding window and threshold setting. The position of the maximum value is set as point A. The interval width is set as 2K. The value that is most different from the signal mean value in the interval around the position of point A in the electrocardio signal f(n) is found, and the value is set as 1. The value of 2 is set as the value of the previous 1, and the position of the value is set as B1 point. The position of B2 is set as the position of the previous B1 point. The reason for finding the value that is most different from the signal mean value instead of the maximum value is that the R wave is downward in some pathological signals, and at this time, the trough instead of the peak should be found. The corresponding point can be found in both cases through the finding of the absolute value. The distance between the position of the current positioning and the previous position is calculated considering the time difference between two heartbeats. When the distance is greater than L, the point that is more different from the signal mean value in the electrocardio signal is taken, and otherwise, it is considered as a new heartbeat. The algorithm flow is as shown in Figure 4 .
[0093] Referring to Figure 3 , Figure 4 and the above analysis process, step S2 specifically includes the following steps:
[0094] S21, using db2 wavelet base to decompose the filtered electrocardio signal on three scales;
[0095] S22, performing wavelet reconstruction on the high-frequency component of the third scale to obtain the reconstructed signal f(n);
[0096] S23, positioning the R wave position in the reconstructed signal f(n);
[0097] S24, according to the result of positioning of the R wave position, each R wave position in the filtered whole ECG signal is extracted as a heartbeat cycle signal to be recognized together with the previous n-1 and the following 2n data, totally 3n data, thereby extracting multiple heartbeat cycle signals.
[0098] The step S23 specifically comprises the steps of:
[0099] S231, the maximum value generated by the QRS complex in the reconstructed signal f(n) is positioned, and the position of the maximum value is set as point A;
[0100] S232, a window with a size of J is used to slide on the reconstructed signal f(n) with a sliding step S;
[0101] S233, it is judged whether there are three windows, if not, continue to judge, if yes, the next step is entered;
[0102] S234, the data of the next window is obtained, and the maximum value and the minimum value in the data are found, if the difference between the maximum value and the minimum value is greater than a threshold value, the next step is entered, otherwise, it is returned to step S233;
[0103] S235, the value with the largest difference from the signal average in the left and right K intervals of the position of point A in the next window is found, the position of the value is set as point B1, and B2 is set as the position of the previous B1 point;
[0104] S236, the distance between B1 point and B2 point is calculated, if the distance is greater than a distance threshold value L, the B1 point is recorded as the R wave position, otherwise, the next step is entered;
[0105] S237, it is judged whether the difference between the signal value of B1 point and the signal average of its interval is greater than the signal value of B2 point, if yes, B1 position is used to replace B2, if not, the position is discarded and returned to step S233.
[0106] (3) Frequency domain information extraction
[0107] Because some cardiovascular lesions are difficult to be identified in the time domain representation of the ECG signal, but can be easily found in the high frequency part in the frequency domain. Therefore, the frequency domain information of the ECG signal is extracted and spliced with the time sequence signal, and then sent into a one-dimensional convolution network for recognition and classification, so as to improve the recognition accuracy.
[0108] According to the result of R wave positioning, the R wave position and the previous n-1 and the following 2n data, a total of 3n data are extracted as a heartbeat period signal to be identified. The fast Fourier transform of the signal is performed using fast Fourier transform with a frequency of the sampling frequency F to obtain the frequency domain information of the heartbeat signal. Since the converted frequency spectrum is generally center-symmetric, only the first half is taken to obtain the maximum amplitude of each frequency from 0Hz to F / 2Hz.
[0109] (4) ECG diagnosis model building
[0110] With the development of artificial intelligence technology, more and more scholars use deep learning technology for feature recognition of ECG signals. In deep learning technology, CNN is good at extracting local spatial features with translation invariance. 1D-CNN has good feature extraction effect on one-dimensional sequential data. This makes 1D-CNN very suitable for feature extraction of ECG signals.
[0111] The convolutional neural network generally has the functions of feature extraction and classification. After the data is input through the input layer, the feature extraction is performed through the convolution layer and the pooling layer, and finally the classification result is output using the fully connected neural network. The training process of the network model is to update the values in the convolution kernel of the convolution layer and the weights in the neurons of the hidden layer of the fully connected neural network to obtain a model with high classification accuracy.
[0112] The one-dimensional convolutional neural network model of the present example is composed of an input layer, four convolutional layers, three pooling layers, a Flatten layer, a fully connected layer and an output layer. A wider receptive field can make the features more integrated and global, and at the same time optimize the feature extraction effect of 1D-CNN. Therefore, a wider receptive field is set in the 1D-CNN in the present example. The model input is 300 time series ECG signal data and 180 corresponding frequency domain information data combined into 480 data, and finally the classification result is output. The model structure is shown in Figure 5 .
[0113] The first layer of the model is an input layer (Input) composed of 480 input nodes. The second layer is a one-dimensional convolution layer (Conv1D) composed of a 4-channel 21x1 convolution kernel, with a convolution kernel moving step of 1 and a padding method of same to maintain the data dimension after convolution. The third layer is a maximum pooling layer (MaxPooling) with a pooling range of 2x1 and a moving step of 2. The fourth layer is a one-dimensional convolution layer (Conv1D) composed of a 16-channel 23x1 convolution kernel, with a convolution kernel moving step of 1 and a padding method of same. The fifth layer is a maximum pooling layer (MaxPooling) with a pooling range of 2x1 and a moving step of 2. The sixth layer is a one-dimensional convolution layer (Conv1D) composed of a 32-channel 25x1 convolution kernel, with a convolution kernel moving step of 1 and a padding method of same. The seventh layer is an average pooling layer (AveragePooling) with a pooling range of 2x1 and a moving step of 2. The eighth layer is a one-dimensional convolution layer (Conv1D) composed of a 64-channel 27x1 convolution kernel, with a convolution kernel moving step of 1 and a padding method of same. The ninth layer is a Flatten layer that concatenates the convolution results of the previous layer into a 3840x1 feature vector. The tenth layer is a fully connected layer (Dense) composed of 128 fully connected neurons, with the neuron activation function being relu. The eleventh layer is an output layer (Output) with a softmax function that can output 5 results. The model properties are shown in Table 1.
[0114] Table 1 Model structure
[0115]
[0116] The time complexity of performing FFT on the electrocardio signal is The calculation complexity of the convolution layer is where is the length of the feature vector output by the i-th convolution kernel. is the length of the i-th convolution kernel. is the number of channels of the i-th convolution. The calculation complexity of the fully connected layer is The time complexity of the algorithm is .
[0117] Experiments and analysis are performed as follows.
[0118] The experimental hardware platform is a notebook computer with an Intel Core i7-4720HQ 2.60GHz CPU, 16GB of RAM, and a NVIDIA GeForce GTX 980M GPU. The experiment in this example is performed using the TensorFlow deep learning tool in a Python3.6 environment on a Windows 8.1 operating system.
[0119] This example uses five types of electrocardiogram data in the MIT-BIH arrhythmia dataset for model training to achieve classification of the five types of heartbeats by the model. The five types of heartbeats are normal heartbeat, atrial premature beat, ventricular premature beat, left bundle branch block, and right bundle branch block, as shown in Table 2 below.
[0120] Table 2. Recognized categories
[0121]
[0122] The database comes from the Harvard-MIT Division of Health Sciences and Technology Biomedical Engineering Center. It contains 48 pieces of electrocardiogram signal data of about 30 minutes, and in the annotation file of each piece of data, the peak position of the R wave and the diagnostic category of each heartbeat cycle are labeled by a cardiologist. In the model training and recognition stage, the heartbeats can be located according to the peak position of the heartbeat R wave, and a complete heartbeat cycle can be read according to the position to input the model.
[0123] The experiment first filters the electrocardiogram signal provided by the data set. The fifth-order Daubechies wavelet (db5) is used as the wavelet basis for wavelet transform to decompose the electrocardiogram signal at 9 scales. After decomposition, the high-frequency components are mainly distributed in D1 and D2 high-frequency components, which are set to zero to filter out this part of high-frequency noise. Soft threshold filtering operation is performed on other high-frequency components D3 to D9. Finally, the processed each classification is reconstructed to complete the filtering of the electrocardiogram signal. The effect is shown in Figure 6 Figure 6 , where (A) is the electrocardiogram signal before filtering, and (B) is the electrocardiogram signal after filtering.
[0124] In the process of model training, the labeled data in the MIT-BIH arrhythmia dataset is used to directly obtain the position information of the R wave peak in the electrocardiogram signal, and each heartbeat cycle of the electrocardiogram signal is segmented through the position information. However, in actual application, the R wave position of the electrocardiogram signal is not labeled, so before using the model of this research to classify the electrocardiogram signal, the R wave position in the electrocardiogram signal needs to be located to segment each independent heartbeat cycle.
[0125] The R-wave positioning experiment uses the positioning algorithm described above, wherein the sliding window size J is set to 80, the sliding step S is set to 30, the threshold of the difference between the maximum value and the minimum value of the reconstructed signal window is set to 0.15, the one-sided interval width K is set to 20, and the distance L is set to 50. Since the MIT-BIH arrhythmia data set has a small deviation in the R-wave peak position annotation, when comparing the positioning results with the annotation results, as long as the difference between the two positions is not more than 3, it is considered that the point positioning is accurate. The accuracy of this method on normal electrocardio signals is extremely high, and the accuracy of R-wave positioning on the 100th data set of the MIT-BIH arrhythmia data set reached 99.64%, and the R-wave positioning accuracy of the 108th data set of the lesion reached 87.75%. Although the positioning effect of the lesion data needs to be improved, compared with the positioning accuracy by the first-order difference threshold, it has been greatly improved. The R-wave positioning effect is shown in Figure 7 , wherein (A) is the R-wave positioning effect of the normal electrocardio signal, and (B) is the R-wave positioning effect of the lesion signal.
[0126] The R-wave peak position of the electrocardio signal is marked with a black dot, and it can be seen that the positioning effect of this method on the R-wave peak position of various electrocardio signals is good.
[0127] Since the sampling frequency of the data set used in this experiment is 360Hz, the sampling length n is set to 100. According to the R-wave positioning result, the R-wave position and the previous 99 and the next 200 data, a total of 300 data, are extracted as a heartbeat cycle signal to be recognized. The fast Fourier transform of the signal is performed with a frequency of 360Hz, and the amplitude distribution of the signal in the 0Hz to 180Hz frequency band is obtained, as shown in Figure 8 .
[0128] In the MIT-BIH arrhythmia database, there are a total of 48 records. In order to maintain the consistency of the lead, MLII lead is usually used in the study. The 102nd and 104th do not have MLII lead data, so these two data are discarded, and only 46 data are used. The R-wave peak position of each heartbeat in the record is annotated by an expert, and each heartbeat can be positioned according to the R-wave peak position. Among the 46 data, there are a total of 99188 heartbeat cycles. The 99188 electrocardio signals are divided, and 70% of the heartbeat cycles are used for model training, and the remaining 30% are used for model testing.
[0129] After completing the frequency domain information extraction of the electrocardio signal, it is spliced with the electrocardio time domain signal to form a data with a length of 480 for inputting into the diagnosis model for recognition. The epochs of the model trained in this experiment is 30, and the loss function used is cross entropy, and its mathematical expression is shown in the following formula 4-1.
[0130] (4-1)
[0131] wherein denotes the true class of sample, if the class of sample i is equal to c takes 1, otherwise takes 0, denotes the probability that sample i belongs to class c, N denotes the total number of samples, and c=1,2,3,4,5 respectively denotes five heartbeat state types of normal heartbeat (N), atrial premature beat (A), ventricular premature beat (V), left bundle branch block (L) and right bundle branch block (R).
[0132] Figure 9 The changes of loss and accuracy during the training process are shown. It can be seen that the accuracy of the five diagnoses of the electrocardiosignal by the method reaches 99.43%, which indicates that the electrocardiogram diagnosis model has high reliability. In the following Table 3, the method is compared with some electrocardiosignal classification methods in the past five years, and the method using time-frequency domain fusion and 1D-CNN reaches a higher accuracy.
[0133] Table 3 Comparison of various methods
[0134]
[0135] In summary, the electrocardiosignal classification method based on time-frequency domain fusion and convolutional neural network provided by the embodiment of the application has three main contributions:
[0136] 1. The performance of a single heartbeat cycle in the time domain and the frequency domain is fused by CNN, the electrocardiosignal is classified comprehensively, the classification accuracy of the single heartbeat cycle electrocardiosignal is improved (the accuracy reaches 99.43% on the MIT-BIH arrhythmia data set), and it is higher than the latest method;
[0137] 2. A novel heartbeat cycle positioning method is proposed, which can simultaneously calibrate the R wave peak position of normal electrocardiosignal and pathological electrocardiosignal, which makes each heartbeat cycle in the electrocardiosignal be well segmented, thereby improving the accuracy of subsequent classification;
[0138] 3. The fast Fourier transform is introduced to extract the frequency domain signal of the heartbeat cycle, and the frequency domain signal is fused with the time domain signal to fully utilize the time-frequency domain features of the signal, which is helpful to improve the accuracy of subsequent classification;
[0139] 4、In order to make the volume of the model smaller and classify the ECG signal under the condition of limited hardware resources, a shallow CNN is used, and a convolution filter with a large receptive field and a small step is adopted, which improves the quality of feature extraction under the shallow network. The model is very suitable for being deployed to small devices, which provides a thought for the miniaturization of the ECG auxiliary diagnosis device.
[0140] The above embodiments are the preferred embodiments of the present application, but the embodiments of the present application are not limited to the above embodiments, and any changes, modifications, substitutions, combinations, simplifications made without departing from the spirit and principles of the present application should be equivalent replacement methods, and are all included in the protection scope of the present application.
Claims
1. A method for electrocardiogram signal classification based on time-frequency domain fusion and convolutional neural network, characterized in that, The method comprises the steps of: S1, filtering the whole ECG signal to filter out noise; S2, positioning the R-wave position of the filtered whole ECG signal, and extracting a plurality of heartbeat cycle signals according to the positioned R-wave position; The step S2 specifically comprises the steps of: S21, using a db2 wavelet base to decompose the filtered whole ECG signal at three scales; S22, wavelet reconstruction is performed on the high-frequency component of the third scale to obtain a reconstructed signal f(n); S23, the R-wave position is positioned in the reconstructed signal f(n); S24, according to the positioning result of the R-wave position, each R-wave position and the previous n-1 and the next 2n data, a total of 3n data in the filtered whole ECG signal are extracted as a heartbeat cycle signal to be identified, thereby extracting a plurality of heartbeat cycle signals; The step S23 specifically comprises the steps of: S231, positioning the maximum value generated by the QRS complex in the reconstructed signal f(n), and setting the position of the maximum value as point A; S232, a window with a size of J is used to slide on the reconstructed signal f(n) with a sliding step S; S233, it is judged whether there are three windows, if not, continue to judge, if yes, go to the next step; S234, the data of the next window are obtained, and the maximum value and the minimum value in the data are found, if the difference between the maximum value and the minimum value is greater than a threshold value, go to the next step, otherwise return to step S233; S235, find the value that is most different from the signal average in the left and right K intervals of the position of point A in the next window, set the position of the value as B1 point, and set B2 as the position of the previous B1 point; S236, calculate the distance between B1 point and B2 point, if the distance is greater than a distance threshold value L, record the B1 point as the R-wave position, otherwise go to the next step; S237, judge whether the difference between the signal value of B1 point and the signal average of its interval is greater than the signal value of B2 point, if yes, replace B2 with B1, if not, discard the position and return to step S233; S3, performing fast Fourier transform on each heartbeat cycle signal to obtain its frequency domain information; S4, splicing each heartbeat cycle signal with its frequency domain information to obtain a plurality of time-frequency domain splicing data; S5, inputting each time-frequency domain splicing data into a one-dimensional convolutional neural network for classification to obtain a corresponding classification result. 2.The ECG signal classification method based on time-frequency domain fusion and convolutional neural network according to claim 1, characterized in that, The step S1 specifically comprises the steps of: S11, using a multi-order Daubechies wavelet as a wavelet base for wavelet transform to decompose the whole ECG signal at N scales, obtaining N low-frequency components and N high-frequency components, N≥3; S12, set the wavelet coefficients of the two high frequency components with the highest frequencies to zero, set a threshold and set the wavelet coefficients of other high frequency components less than the threshold to zero in a manner using soft threshold filtering. S13, reconstructing the low-frequency component with the lowest frequency and the high-frequency component processed by step S12 to obtain the whole ECG signal filtered out of noise. 3.The ECG signal classification method based on time-frequency domain fusion and convolutional neural network according to claim 2, characterized in that, In the step S12, the threshold value is calculated as follows: , where D is the processed wavelet coefficients, C is the signal length, denotes the median. 4.The ECG signal classification method based on time-frequency domain fusion and convolutional neural network according to claim 1, characterized in that, The step S3 specifically comprises the steps of: S31, using fast Fourier transform to perform fast Fourier transform on each heartbeat cycle signal at a frequency of a sampling frequency F to obtain the frequency domain information of the heartbeat cycle signal; S32, retaining the first half of the frequency domain information to participate in splicing. 5.The ECG signal classification method based on time-frequency domain fusion and convolutional neural network according to claim 1, characterized in that, In the step S5, the input layer of the first layer of the one-dimensional convolutional neural network is composed of multiple input nodes; the one-dimensional convolutional layer of the second layer is composed of a 4-channel 21x1 convolutional kernel, the convolutional kernel moving step is 1, and the padding mode is same; the maximum pooling layer of the third layer, the pooling range is 2x1, and the moving step is 2; the one-dimensional convolutional layer of the fourth layer is composed of a 16-channel 23x1 convolutional kernel, the convolutional kernel moving step is 1, and the padding mode is same; the maximum pooling layer of the fifth layer, the pooling range is 2x1, and the moving step is 2; the one-dimensional convolutional layer of the sixth layer is composed of a 32-channel 25x1 convolutional kernel, the convolutional kernel moving step is 1, and the padding mode is same; the average pooling layer of the seventh layer, the pooling range is 2x1, and the moving step is 2; the one-dimensional convolutional layer of the eighth layer is composed of a 64-channel 27x1 convolutional kernel, the convolutional kernel moving step is 1, and the padding mode is same; the ninth layer is a Flatten layer, which splices the convolutional results of the previous layer into a 3840x1 feature vector; the tenth layer is a fully connected layer composed of 128 fully connected neurons, and the activation function of the neurons is relu; the output layer of the eleventh layer, wherein the function is softmax.
6. The electrocardiosignal classification method based on time-frequency domain fusion and convolutional neural network according to claim 5, characterized in that: The loss function used in the process of training the convolutional neural network is cross entropy.
7. The electrocardiosignal classification method based on time-frequency domain fusion and convolutional neural network according to claim 5, characterized in that: In the MIT-BIH arrhythmia database, data No. 102 and No. 104 are discarded, the R-wave peak position of each heartbeat in the remaining 46 data is labeled, and 99188 heartbeat period signals are extracted, of which 70% are used for training the convolutional neural network, and the remaining 30% are used for testing. 8.The ECG signal classification method based on time-frequency domain fusion and convolutional neural network according to claim 5, characterized in that: The convolutional neural network has five classification labels, which are normal heartbeat, atrial premature beat, ventricular premature beat, left bundle branch block and right bundle branch block.
Citation Information
Patent Citations
Detection method of electrocardiosignal R characteristic waves
CN103156599A
Electrocardiosignal type recognition method and device
CN112426160A