Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The application will be further described in detail with reference to the drawings and detailed description below in order to make the objects, features and advantages of the application more comprehensible.
As shown in FIG. 1, an embodiment of the present application provides an ECG signal classification system comprising the following modules.
And the data preprocessing module is used for carrying out filtering processing on the ECG signal and reconstructing a clean signal.
And the feature extraction module is used for carrying out multi-scale feature extraction on the pure signals, determining heart rate variability features of a time domain, a frequency domain and a nonlinear domain, and generating multidimensional physiological feature vectors suitable for deep neural network model input according to the heart rate variability features.
The model learning optimization module is used for guiding the deep neural network model to learn the distinguishing characteristic expression with distinguishing capability by contrasting and learning the multidimensional physiological characteristic vector in the model learning stage, establishing a space class center based on a class center limiting mechanism in the model optimization stage, and optimizing the deep neural network model, wherein the multidimensional physiological characteristic vector comprises a positive sample and a negative sample.
The confidence interval decision module is used for calculating the minimum class center distance from the ECG signal to be detected to all the space class centers, constructing a confidence interval, classifying the ECG signal to be detected according to the minimum class center distance and the confidence interval, and determining the ECG signal type, wherein the ECG signal type comprises a known class and an unknown class.
In an exemplary embodiment, the data preprocessing module specifically includes the following units.
The wavelet decomposition unit is used for carrying out multi-layer wavelet decomposition on the ECG signal by utilizing a wavelet filter and decomposing the ECG signal into an approximation coefficient and a detail coefficient, wherein the approximation coefficient reflects the low-frequency trend of the ECG signal, and the detail coefficient reflects the high-frequency change of the ECG signal.
And the reconstruction unit is used for reconstructing the pure signal from the highest layer to the bottommost layer according to the approximate coefficient and the detail coefficient.
In practice, the data preprocessing module decomposes the ECG signal using a wavelet filter.
At each decomposition level, the ECG signal is decomposed into approximation coefficients for low frequencies and detail coefficients for high frequencies. The approximation coefficients reflect the low frequency trend portion of the signal and the detail coefficients reflect the high frequency change portion of the signal.
The decomposed approximation coefficients and detail coefficients are processed, such as thresholding, to remove noise. By setting the appropriate threshold, the main features of the ECG signal can be preserved while suppressing noise. And performing inverse transformation on the processed coefficients to reconstruct the pure signal.
The main steps of the method comprise the following steps.
First for an input ECG signalPerforming j-layer wavelet decomposition, and approximating coefficient of j-th layerAnd detail coefficientThe following is provided.
Wherein the approximation coefficientsRepresenting the low frequency components of the ECG signal, preserving the morphology of the signal body, detail coefficientsRepresenting the high frequency content of the ECG signal, including noise and detail; a low-pass filter corresponding to a scale function used in the j-th layer wavelet decomposition for extracting an approximate (low-frequency) component of the signal, wherein n is uniformly defined as an index of discrete time; The filter is a high-pass filter corresponding to a wavelet function used in the j-th layer wavelet decomposition and is used for extracting detail (high frequency) components of signals, and j is a wavelet decomposition layer number index.
The reconstruction of the signal is followed:
Wherein, the In the reverse wavelet reconstruction process, the approximation coefficient and the detail coefficient of the j layer are combined to reconstruct the lower layer signal step by step, and k is the discrete time index or the position index of the filter coefficient and is used to represent the position of the filter or the signal in the rolling and reconstruction process.
Iterative reconstruction is gradually carried out from the j-th layer of the highest layer to the 0-th layer of the lowest layer, and finally pure signals are obtained;For a clean signal of layer 0, i.e. a denoised ECG signal,Is the final output signal obtained by layer-by-layer reverse reconstruction from the highest layer.
In an exemplary embodiment, the feature extraction module specifically includes the following units.
And the positioning unit is used for positioning the R wave crest of the pure signal by adopting a peak detection algorithm.
And the multiscale extraction unit is used for multiscale extracting heart rate variability characteristics of a time domain, a frequency domain and a nonlinear domain of the clean signal according to the original waveform of the clean signal and the sequence of RR intervals based on the R wave peak.
And the processing unit is used for carrying out normalization or standardization processing on the heart rate variability characteristics to determine the processed heart rate variability characteristics, wherein the RR interval is the time interval between adjacent R wave peaks on an electrocardiogram.
And the multidimensional physiological feature vector generation unit is used for generating multidimensional physiological feature vectors suitable for the deep neural network model input according to the processed heart rate variability features.
In practical application, the feature extraction module firstly adopts a Pan-Tompkins peak detection algorithm to position an R wave crest for pure signals, then extracts HRV features of a time domain, a frequency domain and a nonlinear domain in a multi-scale mode based on an RR interval sequence and an original waveform, and finally performs normalization or standardization processing on the obtained HRV feature vectors to generate D-vitamin feature vectors suitable for deep neural network model input.
R peak detection is carried out on the preprocessed electrocardiographic waveform, a dual-threshold QRS wave detection algorithm with Pan-Tompkins self-adaptability is used for R peak positioning of ECG signals, and subsequent HRV feature extraction can be carried out through accurate identification of the R peak position.
HRV time domain features (MeanNN, SDNN, RMSSD, NN and pNN 50), frequency domain features (very low frequency VLF, low frequency power LF, high frequency power HF and LF/HF) and nonlinear features (ApEn, sampEn, poincar e SD1/SD 2) are extracted from the RR interval sequence and the original waveform, a D vitamin feature vector X d∈RD is constructed, the D vitamin feature vector X d is an HRV feature vector, R D is a D-dimensional real space, the extracted D vitamin feature vector X d is a D-dimensional real value vector, and the D-dimensional real space R D belongs to the mathematical Euclidean space.
In an exemplary embodiment, the model learning optimization module specifically includes the following elements.
And the standardized processing unit is used for carrying out standardized processing on the multidimensional physiological characteristic vector and determining the processed characteristic vector.
The contrast learning unit is used for carrying out contrast learning on the processed feature vectors in a model learning stage to construct a contrast relation between positive samples and negative samples, wherein the positive samples are heart rate variability characteristics of similar heart rate arrhythmias, the heart rate variability characteristics of the similar heart rate arrhythmias comprise low-HF characteristics and high-LF/HF characteristics of atrial fibrillation patients, and the negative samples are difficult samples similar to the characteristics of the processed feature vectors but different in diagnosis conclusion.
And the guiding unit is used for guiding the deep neural network model to learn the distinguishing characteristic expression with distinguishing capability according to the comparison relation, and determining the learned deep neural network model.
The space class center determining unit is used for introducing a class center limiting mechanism in a model optimizing stage, and taking heart rate variability characteristic mean value vectors of various arrhythmias as space class centers.
The core loss function determining unit is used for calculating Euclidean distance between each sample and the center of the corresponding space class, minimizing Euclidean distance between all samples and the corresponding space class, compressing intra-class distribution, and determining a core loss function of a model optimizing stage, wherein the samples are the processed feature vectors.
And the optimizing unit is used for optimizing the deep neural network model according to the core loss function.
In practical application, the D-vitamin feature vector X d is subjected to standardization processing, so that scaling of the original data in equal proportion is realized.
Wherein, the In order to process the feature vector after the processing,For the s-th eigenvalue in the original eigenvectorIs the mean value of the two values,And s is the index of the original feature vector, which is the standard deviation.
The method solves the problem of different metrics by converting the original data into data bounded by a specific range by using the mean value and standard deviation of the variable value, thereby eliminating the influence of dimension and magnitude, and changing the weight of the variable in analysis. The training method is suitable for being input into a deep neural network model (model for short), and the training efficiency and stability of the model are improved.
The model learning optimization module is divided into two stages of model learning and optimization, in the model learning stage, HRV features are used for contrast learning, the main body of learning is a positive sample and a negative sample, the positive sample is HRV features (such as low HF features and high LF/HF features of atrial fibrillation patients) of similar arrhythmia, and the negative sample is a sample similar to the features of the original sample but different in diagnosis conclusion, namely a difficult sample. By constructing the comparison relation, the model is guided to learn the distinguishing characteristic expression with distinguishing capability.
In the model optimization stage, in order to make the HRV features of the same class more tightly gathered in the model and the different classes more separated, a class center limiting mechanism is introduced, namely, the HRV feature mean vector of various arrhythmias is used as a class center, and the Euclidean distance between the sample embedding and the corresponding class center is minimized, so that the model compresses the feature distribution in the class while keeping the degree of distinction between the classes, and the generalization capability of the model in unknown type sample recognition is enhanced.
Wherein, the construction of the difficult sample is firstly to locate the diagnosis key feature, and the diagnosis key feature of the D vitamin feature vector X d is defined asWhere t is the diagnostic key feature index. For example atrial fibrillation, which is characterized by lower HF and higher LF/HF characteristics than normal electrocardiograms。
Then applying a large disturbance to the diagnostic key features, for each of whichThe transformation is performed according to category reversal or enhancement trends.
Wherein, the For the transformed original value, beta is the scaling factor controlling the disturbance amplitude, typically taken3。
The model learning and optimizing overall framework first trains an initialization model based on a deep neural network modelThe multi-layer two-way long-short-term memory network (Bi-LSTM) is mixed with a one-dimensional convolutional neural network (1D-CNN), wherein the number of channels with each layer of hidden units 128,1D-CNN of the Bi-LSTM is 64, and the core width is 3.
Then constructing a loss function of positive and negative sample contrast learning,
Where j= {1,2,3,..b } is the set of lot indices, B is the total number of lot indices,={Y m=yc represents a set of positive samples, m is an index number, y m represents a type, y c is a class label of a c-th class sample, and y m=yc is the same type;{ Y m≠yc represents the set of negative samples, q is the sample index in the negative sample set; Is the multidimensional physiological characteristic vector of the m-th sample, ∈RD;Feature vector for the p-th positive sample; B is the index of the positive or negative sample, all positive and negative samples are traversed, p is the index of the positive sample, all positive sample samples are traversed; for vector inner product calculation, the similarity between the representations is measured; the sharpness of the similarity distribution is controlled for the temperature parameter.
Then, a model optimization stage is carried out, a class center limiting mechanism is introduced, and taking the class c as an example, all training samples of the class c are mapped and then expressed as {Definitions ofThe representation vectors extracted in the model for the HRV features of the arrhythmia samples are averaged for the spatial limiting center point of the class, i.e. the spatial class center of class C, where C is the total number of known classes, i.e. the number of all known classes.
Wherein, the Is training data of class c.
Then, the Euclidean distance between each sample and the center of the corresponding class is calculated, wherein the Euclidean distance is the straight line distance between two points in the feature space, namelyAnd (3) withEuclidean distance of (2)The definition is as follows.
=
Wherein D is the dimension of the HRV feature vector,An e-th dimension eigenvalue that is the c-th sample; and e is a feature dimension index, which is the e-th dimension coordinate value of the c-th class center point.
Compressing intra-class distribution by minimizing Euclidean distance of all samples from their corresponding class centers, core loss function at model optimization stage,
Wherein, the For the regularization coefficient(s),All the learnable network parameters for the feature extractor. By minimizing the objective function, the same type of samples can be intensively distributed near the center of the type, the distinguishing capability of the model on different arrhythmia is enhanced, and the identification robustness on unknown types is improved.
The model learning optimization module learns the center vector of each arrhythmia class at the end of the deep network through contrast learning (positive and negative sample contrast) and class center limiting mechanism, and minimizes the loss function between the same class sample and the class centerThereby compressing intra-class distribution and expanding inter-class differences in the feature space.
In one exemplary embodiment, the deep neural network model is composed of a mixture of layers of two-way long and short term memory networks and one-dimensional convolutional neural networks.
In an exemplary embodiment, the confidence interval decision module specifically includes the following modules.
And the estimation unit is used for calculating the minimum class center distance from the ECG signal to be detected to all the space class centers and estimating the sample variance of the ECG signal to be detected.
And the confidence interval construction unit is used for constructing a confidence interval according to the sample variance and the super-parameters of the optimized deep neural network model.
And the judging unit is used for judging whether the minimum class center distance exceeds the confidence interval.
And the unknown class determining unit is used for determining that the ECG signal to be detected is of an unknown class when the output result of the judging unit is yes.
And the known class determining unit is used for determining that the ECG signal to be detected is of a known class when the output result of the judging unit is NO, and determining the accurate known type of the ECG signal to be detected by utilizing the statistical analysis information.
In practical application, after model learning and model optimization are completed, the confidence interval decision module is responsible for mapping the embedded representation of each test sample onto a "known class" or an "unknown class", and specifically includes the following three steps.
First of all using the aforementioned class center and euclidean distance,Namely, calculating the Euclidean distance standard, and calculating the Euclidean distance set from each sample in the class to the center。
Wherein, the For a certain sample in class c to the center of the class space classIs a euclidean distance of (c).
Estimating its sample varianceThe following is provided.
Wherein, the For a certain sample in class c to the center of the class space classIs a mean value of euclidean distances of (c).
And judging the distance between the test samples, and extracting an embedded representation z from any one test sample x through a model. Calculating the minimum distance embedded in all known class centers。
Where C is the total number of known categories, i.e., the number of all known categories.
Finally, setting decision criterion of confidence interval and setting super parameterGenerally takeCorresponding to a multiple threshold of approximately 95% confidence interval.
If the distance between the test sample and the nearest class center exceeds the confidence interval of the distance distribution.
Namely:。
Wherein, the The confidence interval is used for measuring whether the distance between a test sample and the center of the nearest class belongs to the normal (training) distance distribution range of the class or not in the system, and if the distance exceeds the normal (training) distance distribution range, the test sample is judged to be an unknown class; class index (class number of nearest class center) to minimize test sample distance.
If not, the method judges that the class is unknown, otherwise, the method belongs to the nearest known class, and the overall analysis logic is as follows.
The confidence interval decision module can not only ensure the accurate classification of the known class samples by using the statistical distribution information, but also safely identify the samples as 'unknown' types, namely, unknown classes, when the samples deviate from any class center significantly, and provide reliable prompts for subsequent clinical rechecking.
The confidence interval decision module is based on the loss function from each sample in the training set to the center thereofAnd (3) the distance distribution, the mean value and the variance are calculated, a multiple sigma threshold is set to form a confidence interval, if the nearest center of the test sample exceeds the threshold, the test sample is judged to be an unknown class, otherwise, the test sample is classified into a corresponding known class, and smooth connection from closed set classification to open set detection is realized.
As shown in FIG. 2, the present application provides a method of ECG signal classification, comprising the following steps.
And S1, filtering the ECG signal based on the data preprocessing module to reconstruct a clean signal.
And S2, based on a feature extraction module, carrying out multi-scale feature extraction on the pure signals, determining heart rate variability features of a time domain, a frequency domain and a nonlinear domain, and generating multidimensional physiological feature vectors suitable for deep neural network model input according to the heart rate variability features.
And S3, based on a model learning optimization module, in a model learning stage, the multi-dimensional physiological feature vector is used for guiding the deep neural network model to learn the distinguishing feature expression with distinguishing capability through comparison learning, in a model optimization stage, a space class center is established based on a class center limiting mechanism, and the deep neural network model is optimized, wherein the multi-dimensional physiological feature vector comprises a positive sample and a negative sample.
And S4, calculating the minimum class center distance from the ECG signal to be measured to all space class centers based on a confidence interval decision module, constructing a confidence interval, classifying the ECG signal to be measured according to the minimum class center distance and the confidence interval, and determining the ECG signal type, wherein the ECG signal type comprises a known class and an unknown class.
The method has the advantages of comprehensively capturing time domain, frequency domain and nonlinear characteristics of the electrocardiosignal and improving characteristic representation capability.
The data support that the feature discrimination is improved by about 12% compared with a single model by combining 128-dimensional Bi-LSTM and 64-channel 1D-CNN (comparative experiment is not shown).
The application covers time domain, frequency domain, nonlinearity and morphological multi-view features, adopts a Bi-LSTM+1D-CNN deep neural network model, and extends unknown class detection through a confidence interval.
In an exemplary embodiment, a computer device is provided, comprising a memory and a processor, the memory having stored therein a computer program, the processor performing the steps of the method embodiments described above when the computer program is executed. The computer device may be a server or a terminal. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used for storing data to be processed. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement an ECG signal classification method.
In an exemplary embodiment, a computer device is provided, comprising a memory and a processor, the memory having stored therein a computer program, the processor performing the steps of the method embodiments described above when the computer program is executed.
In an exemplary embodiment, a computer-readable storage medium is provided, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method embodiments described above.
In an exemplary embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by hardware associated with computer program instructions, where the computer program may be stored on a non-transitory computer readable storage medium, which when executed may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magneto-resistive random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (PHASE CHANGE Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic RandomAccess Memory, DRAM), etc.
The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The principles and embodiments of the present application have been described herein with reference to specific examples, which are intended to facilitate an understanding of the principles and concepts of the application and are to be varied in scope and detail by persons of ordinary skill in the art based on the teachings herein. In view of the foregoing, this description should not be construed as limiting the application.