Electrocardiogram anomaly detection method based on time-frequency enhancement self-supervised contrast learning
By employing a time-frequency in-situ contrast learning mechanism and a feature-level sample data augmentation generator, the problem of selecting positive and negative samples in ECG abnormality detection is solved, improving detection accuracy, capturing multi-angle features of ECG data, and optimizing model performance.
Patent Information
- Application Number
- CN202411760779.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2044-12-03
AI Technical Summary
Existing self-supervised learning methods suffer from reduced accuracy in ECG anomaly detection due to loss of ECG signal features caused by data augmentation transformations, and lack an effective positive and negative sample selection mechanism.
By employing intra- and inter-time-frequency contrastive learning mechanisms, a feature-level sample data enhancement generator is used to design a total loss function to guide model training. Combined with time and frequency encoders, multi-angle features of ECG signals are generated and analyzed to solve the problem of positive and negative sample selection and improve detection accuracy.
It improves the accuracy of ECG abnormality detection, captures the distribution of internal and external abnormalities at different time frequencies in ECG data, enhances feature extraction capabilities, and optimizes model performance.
Smart Images

Figure CN119867771B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of electrocardiogram time series data processing, and relates to an electrocardiogram abnormality detection method based on time-frequency enhancement self-supervised contrast learning. BACKGROUND
[0002] An electrocardiogram (ECG) is an important clinical measurement method for checking various cardiovascular diseases caused by heart electrical activity, such as atrial fibrillation, atrial premature beat, or severe ventricular arrhythmia. With the development of artificial intelligence, neural networks are used for feature extraction and classification of electrocardiogram signals, but these network architectures are usually based on supervised learning and require a large amount of labeled data to train the model. Data labeling is a time-consuming and laborious process, so it is necessary to use self-supervised contrast learning for electrocardiogram abnormality detection to solve the problem of label scarcity.
[0003] In self-supervised deep learning, it is particularly crucial to create a model that can learn robust and distinguishable representations. Typically, time series data enhancement methods are based on transformation enhancement and mask enhancement, such as jittering, flipping, rotation, permutation, time random-masking, and time band-masking. However, these transformations can cause the original electrocardiogram signal to become an abnormal electrocardiogram signal, or even lose the characteristics of the electrocardiogram signal, thereby reducing the accuracy of electrocardiogram abnormality detection. SUMMARY
[0004] The present application provides an electrocardiogram abnormality detection method based on time-frequency enhancement self-supervised contrast learning to solve the technical problem of the influence of existing self-supervised learning data enhancement methods on the accuracy of electrocardiogram abnormality detection. Through time-in and time-out contrast learning mechanisms, a feature-level sample data enhancement generator is designed to solve the problem of positive and negative sample selection in contrast learning and its impact on abnormality detection, thereby improving the accuracy of electrocardiogram abnormality detection.
[0005] To achieve the above-mentioned purpose, the technical scheme adopted by the present application is as follows:
[0006] The present application provides an electrocardiogram abnormality detection method based on time-frequency enhancement self-supervised contrast learning, comprising the following steps:
[0007] S1, obtaining time sample data of an electrocardiogram signal , obtaining frequency sample data by time-frequency conversion;
[0008] S2, inputting the time sample data into a time encoder to obtain a time encoding sequence The frequency sample data is input into a frequency encoder to obtain a frequency encoding sequence ;
[0009] S3, a time-frequency intra-contrast learning convolutional neural network model is established, and the time encoding sequence and the frequency encoding sequence are sampled on the feature space to obtain original sample data , and input into a feature enhancement generator in the time-frequency intra-contrast learning convolutional neural network model to obtain enhanced sample data , the original sample data and the enhanced sample data are used as a positive sample pair to train the time-frequency intra-contrast learning convolutional neural network model;
[0010] S4, a time-frequency inter-contrast learning convolutional neural network model is established, and the time encoding sequence and the frequency encoding sequence are used as a positive sample pair to train the time-frequency inter-contrast learning convolutional neural network model;
[0011] S5, the total loss function is used to guide the convergence of the model, and the trained time-frequency intra-contrast learning convolutional neural network model and the time-frequency inter-contrast learning convolutional neural network model are obtained.
[0012] S6, collect real-time electrocardio signals, and perform electrocardio signal anomaly detection according to the order of steps S1-S5.
[0013] In the technical scheme of the present application, the feature enhancement generator is composed of a feature enhancement encoder and a feature enhancement decoder.
[0014] In the technical scheme of the present application, the total loss function integrates two models to learn the correlation and complementarity between internal features and time-based and frequency-based embeddings, and analyzes from multiple time-frequency angles. The calculation formula of the total loss function is as follows:
[0015] Formula (1),
[0016] Wherein: is the loss function of the time-frequency intra-contrast learning convolutional neural network model, is the loss function of the time-frequency inter-contrast learning convolutional neural network model, is the weighting parameter of each loss function, =0.6.
[0017] In the technical scheme of the present application, the calculation formula of the loss function of the time-frequency intra-contrast learning convolutional neural network model is as follows:
[0018] Formula (2),
[0019] Where: N is the number of positive sample pairs in the input time-frequency contrastive learning convolutional neural network model; Cosine similarity; This is a function representing the distance between samples and the network center of the time-frequency contrastive learning convolutional neural network model. .
[0020] In the above-described technical solution of the present invention, the calculation formula for the loss function of the time-frequency contrastive learning convolutional neural network model is as follows:
[0021] Formula (3),
[0022] in: The positive sample logs of the time-frequency contrastive learning convolutional neural network model; Cosine similarity; This is a function representing the distance between samples and the network center of the time-frequency contrastive learning convolutional neural network model. .
[0023] It is worth noting that, when performing real-time ECG signal abnormality detection, this invention uses the overall abnormality score. To evaluate the percentage of abnormal electrocardiogram signals.
[0024] ,
[0025] in: The abnormal signal score is the output of the time-frequency contrastive learning convolutional neural network model. , ; The abnormal signal score is the output of the time-frequency contrastive learning convolutional neural network model. , .
[0026] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0027] This invention proposes a time-frequency and time-frequency contrastive learning mechanism. The time-frequency contrastive learning network can learn the cross-domain features of ECG signals in the time-frequency space and capture the different time-frequency anomalous distributions of ECG data. The time-frequency contrastive learning network makes the time representation approximate the frequency representation to learn the time-frequency anomalous distributions of ECG data, thus mining the internal features of ECG from both time and frequency depths. Furthermore, a feature-level sample data augmentation generator is designed in the time-frequency contrastive learning model to sample in the sample feature space and generate feature-enhanced samples by analyzing the latent variables of the data from the features. This solves the problem of selecting positive and negative samples in contrastive learning and the impact on anomaly detection. Attached Figure Description
[0028] Figure 1 This is a schematic diagram illustrating the principle of ECG abnormality detection based on time-frequency enhancement self-supervised contrastive learning in this invention.
[0029] Figure 2 The total loss function of this invention guides the trade-off parameters in the model. The results of the sensitivity experiment. Detailed Implementation
[0030] The following embodiments are used to illustrate the present invention, but are not intended to limit the scope of protection of the present invention. Unless otherwise specified, the technical means used in the embodiments are conventional means well known to those skilled in the art. Unless otherwise specified, the test methods in the following embodiments are conventional methods.
[0031] Example 1
[0032] refer to Figure 1 The diagram illustrates the principle of ECG abnormality detection based on time-frequency enhancement and self-supervised contrastive learning, as described in this invention. The time encoder and frequency encoder employ the same architecture, both consisting of four convolutional blocks. Each block contains a Conv1D layer, with the first block using the ReLU activation function. The second and third blocks combine a BatchNormalization layer and the RULR activation function, while the fourth block contains a MaxPool1D layer. Feature enhancement generator. It consists of a feature enhancement encoder and a feature enhancement decoder.
[0033] The ECG abnormality detection method based on time-frequency enhancement and self-supervised contrastive learning in this embodiment includes the following specific steps:
[0034] S1. Acquire time sample data of electrocardiogram signals. Frequency sample data is obtained through time-frequency conversion. ;
[0035] S2, Time sample data The input is fed into the time encoder to obtain the time-coded sequence. Frequency sample data The input is fed into the frequency encoder to obtain the frequency encoded sequence. ;
[0036] S3. Establish a time-frequency intra-contrast learning convolutional neural network model in the time-encoded sequence. and frequency coding sequence Original sample data are obtained by sampling in the feature space. The data is then input into the feature enhancement generator in the time-frequency contrastive learning convolutional neural network model to obtain enhanced sample data. , the original sample data and enhanced sample data training the time-frequency intra-contrast learning convolutional neural network model as positive sample pairs;
[0037] S4, establishing a time-frequency inter-contrast learning convolutional neural network model, and inputting the time encoding sequence and the frequency encoding sequence training the time-frequency inter-contrast learning convolutional neural network model as positive sample pairs;
[0038] S5, using the total loss function shown in formula (1) to guide the model convergence, to obtain the trained time-frequency intra-contrast learning convolutional neural network model and the time-frequency inter-contrast learning convolutional neural network model;
[0039] S6, collecting real-time electrocardio signals, and performing electrocardio signal anomaly detection in the order of steps S1-S5, and calculating the proportion of abnormal signals.
[0040] The data sets used in the experiment comparison are as follows:
[0041] CPSC202: This is a data set specially designed for developing an algorithm for detecting atrial fibrillation (AF) events from dynamic electrocardiogram (ECG) records. The data set contains 32255 2-lead long-term Holter monitoring records, collected from 49 patients with atrial fibrillation and 56 patients without atrial fibrillation, with a sampling rate of 200 Hz. The training set, validation set and test set contain 21960, 4550 and 5745 records respectively.
[0042] PTB-XL: This data set contains 21799 10-second long 12-lead clinical electrocardiogram records, collected from 188869 patients, with a sampling rate of 500 Hz. Each record is annotated by a maximum of two cardiologists, and the categories mainly include: normal electrocardiogram, myocardial infarction, ST / T change, conduction disturbance, cardiac hypertrophy and atrial fibrillation (AF). Among them, atrial fibrillation is classified as an abnormal category, and the others are defined as normal category. The training set, validation set and test set contain 4000, 1757 and 1757 records respectively.
[0043] BUTQDB: This is a data set specially used for electrocardiogram (ECG) quality evaluation. The data set contains 18 long-time single-lead ECG records, with a sampling rate of 1000 Hz. The signal quality is divided into three levels: level 1 represents the best quality, and all key ECG waveforms are clearly visible; level 2 represents an increase in noise level, and detection of important ECG features is unreliable; level 3 represents that QRS complex cannot be reliably detected, making the signal unsuitable for further analysis.
[0044] VFDB: This dataset contains 22 half-hour 2-lead ECG recordings from patients with sustained ventricular tachycardia (VT), ventricular flutter (VFL) and ventricular fibrillation (VF) with a sampling rate of 250 Hz. After pre-processing, the dataset contains 3013 10-second long ECG signals, including 1723 normal signals, 606 noise signals, 523 VT signals, 98 VFL signals and 63 VF signals. To improve the model training effect, the 2-lead data is split into single-lead data to expand the dataset.
[0045] MITBIH: This dataset contains 48 half-hour 2-lead Holter ECG recordings from 47 subjects collected between 1975 and 1979. The recordings include 23 randomly selected from 4000 24-hour recordings at Beth Israel Hospital (60% inpatients and 40% outpatients), and 25 recordings containing less common but clinically important arrhythmias. The data has a sampling rate of 360 Hz and is annotated by multiple ECG experts. After pre-processing, the dataset generates 33,930 10-second long ECG signal records, of which 33,694 are normal / noise signals and 236 are VF or VFL signals. For model training, the 2-lead data is split into single-lead data to expand the dataset.
[0046] CUDB: This dataset contains 35 8-minute ECG recordings from patients with sustained ventricular tachycardia (VT), ventricular flutter (VFL) and ventricular fibrillation (VF) episodes, and is a database dedicated to the study of tachyarrhythmias. Since the detector responds to changes in heart rhythm before ventricular fibrillation, it will show a negative "alarm time" before the onset of VF. The minimum number of non-VF episodes before VF occurs is 61, and the average time of VF episodes is 5 minutes and 47 seconds. After pre-processing, the dataset contains 19,985 ECG signals, including 19,653 normal signals, 19 noise signals, 5 VT signals and 208 VF / VFL signals.
[0047] To compare the weights of the two contrast learning network model loss functions within and between time and frequency in the total loss function, based on the AUC and AP indicators, sensitivity experiments on the trade-off parameters (a, b) were conducted on the six datasets, and the results are shown in Table 2. Figure 2 In summary, when the parameter is too large, the model tends to prioritize mapping normal ECG signals to the center of the hypersphere, while ignoring the task of mapping abnormal ECG signals to the center of the hypersphere. Conversely, when the trade-off parameter is too small, the task of mapping normal ECG signals to the center of the hypersphere cannot be fully optimized. Therefore, during the model training process, it is necessary to adjust and optimize the trade-off parameter to maintain a balance between the two tasks to achieve the best performance, in this embodiment = 0.6.
[0048] To verify the superiority of the electrocardio abnormality detection model of the present application, the test is carried out on the leave-one-out dataset, and the TFCL is evaluated by comparing with other abnormality detection models, contrast learning models and multi-modal contrast learning models, and the results are shown in Table 1.
[0049] Table 1: Comparison results of model test
[0050]
[0051] As can be seen from Table 1, the performance of the detection model proposed in the present application is better than that of other models on all datasets. For example, on the CPSC2021 dataset, the AUC and AP indicators of the model of the present application are improved by 2.8% and 5.67% at most than all the benchmark models; on the MIT BIH dataset, the AUC and AP indicators are improved by 13.92% and 15.74% at most.
[0052] The traditional unsupervised anomaly detection method largely depends on the definition of normal class and abnormal class, and the normal samples may only reflect part of the overall normality, and the self-supervised contrast learning can more comprehensively learn the normality representation by contrasting the normal data from more angles.
[0053] The traditional contrast learning enhancement method such as jitter, replacement and flip will make the original normal electrocardio signal become an abnormal electrocardio signal or even lose the features of physiological signals, that is, the enhanced sample is similar to the abnormal electrocardio sample, at this time the anomaly detection model not only learns the features of the original normal electrocardio signal, but also learns the enhanced abnormal electrocardio features, thereby causing the boundary of the normal data features to become blurred, thereby greatly reducing the performance of electrocardio abnormality detection.
[0054] The self-supervised contrast learning proposed in the present application aims to use a feature extractor to convert the original sample into a slightly different enhanced sample through conversion enhancement, mask enhancement and proximity enhancement to construct a positive sample pair, measure the embedding distance between the original sample and the enhanced sample, so that the feature embedding of the positive sample pair is as close as possible in the sample space, and measure the embedding distance between the original enhancement and the enhancement of another input sample to pull away the negative sample pair, solving the problem of selection of positive and negative samples in contrast learning and the influence on abnormality detection.
[0055] The above-described embodiments are merely preferred embodiments of the present application, merely used to explain the present application, and are not intended to limit the scope of the present application. Those skilled in the art can easily make other embodiments according to the disclosed technical content in the specification through substitution or change, and any changes and improvements made on the principles of the present application should be included in the scope of the patent application of the present application.
Claims
1. A method for electrocardio abnormality detection based on time-frequency enhancement self-supervised contrastive learning, characterized in that, Comprising the following steps: S1, acquiring time sample data of an electrocardio signal , obtaining frequency sample data through time-frequency conversion ; S2, inputting the time sample data to a time encoder to obtain a time encoded sequence , inputting the frequency sample data to a frequency encoder to obtain a frequency encoded sequence ; S3. Establish a time-frequency intra-contrast learning convolutional neural network model in the time-encoded sequence. and frequency coding sequence Original sample data are obtained by sampling in the feature space. The data is then input into the feature enhancement generator in the time-frequency contrastive learning convolutional neural network model to obtain enhanced sample data. , the original sample data and augmented sample data Used as positive sample pairs to train the intra-temporal contrastive learning convolutional neural network model; S4, a time-frequency contrastive learning convolutional neural network model is established, and the time encoding sequence and the frequency encoding sequence The time-frequency contrastive learning convolutional neural network model is trained as a positive sample pair. S5, guiding the model to converge with the total loss function, obtaining the trained time-frequency intra-contrast learning convolutional neural network model and time-frequency inter-contrast learning convolutional neural network model; S6, collecting real-time electrocardio signals, and performing electrocardio signal anomaly detection in the order of steps S1-S5.
2. The electrocardio abnormality detection method according to claim 1, characterized in that, The feature enhancement generator is composed of a feature enhancement encoder and a feature enhancement decoder.
3. The electrocardio abnormality detection method according to claim 1, characterized in that, The calculation formula of the total loss function is as follows: , wherein: is a loss function of the intra-time-frequency contrastive learning convolutional neural network model, is a loss function of the inter-time-frequency contrastive learning convolutional neural network model, is a weighting parameter of each loss function, = 0.
6.
4. The electrocardio abnormality detection method according to claim 1, characterized by, The calculation formula of the loss function of the time-frequency intra-contrast learning convolutional neural network model is as follows: , wherein: N is a number of positive sample pairs of the input intra-time-frequency contrastive learning convolutional neural network model; is a cosine similarity; is a function of the sample and the network center distance of the input intra-time-frequency contrastive learning convolutional neural network model, .
5. The electrocardio abnormality detection method according to claim 1, characterized in that, The calculation formula of the loss function of the time-frequency inter-contrast learning convolutional neural network model is as follows: , wherein: is a number of positive sample pairs for the time-frequency contrastive learning convolutional neural network model; is a cosine similarity; is a function of a sample and a network center distance for inputting the time-frequency contrastive learning convolutional neural network model, .
Citation Information
Patent Citations
Multi-dimensional time sequence anomaly detection method based on time-frequency domain comparative learning and reconstruction
CN118861938A
Method for enhancing audio-visual association by adopting self-supervised curriculum learning
US20220165171A1