A method and system for constructing a universal electrocardiogram base large model framework

By building a general electrocardiogram base big model framework, the problem that the existing unsupervised pre-trained large model cannot effectively process electrocardiogram data is solved, and the effect of reducing data labeling costs and improving model generalization is achieved.

CN119003993BActive Publication Date: 2025-02-28DIGITAL HEALTH CHINA TECHNOLOGIES CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411456386.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-18
Publication Date
2025-02-28
Estimated Expiration
2044-10-18

AI Technical Summary

Technical Problem

The existing unsupervised pre-trained large models cannot effectively extract the information in the ECG data, cannot be directly applied to the processing of ECG data, and rely on a large number of labeled ECG signal data, and the labeling process is time-consuming and labor-intensive.

Method used

A general electrocardiogram base big model framework construction method is proposed, including obtaining the original ECG signal for data augmentation, obtaining discrete representations through the VQ-VAE model, building a mask electrocardiogram modeling task to train the ECG encoder, obtain the electrocardiogram base big model, and fine-tuning it through downstream tasks.

Benefits of technology

It realizes the effective application of unsupervised pre-trained large models in the field of ECG, reduces data labeling costs, improves the generalization and applicability of the model, and can be widely used in a variety of ECG analysis tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for constructing a universal ECG base large model framework. This scheme proposes an enhanced VQ-VAE model. The improved enhanced VQ-VAE model can be applied to ECG signals of different lengths, different noise levels and multiple lead conditions. A masked ECG modeling model is proposed. This model is a self-supervised pre-training framework for 1D ECG signals. Most of the existing mask modeling is developed based on language or images and cannot be directly used for ECG tasks. This scheme designs reasonable mask modeling ECG block parameters and the embedding layer dimension of the ECG encoder for ECG signals. By constructing the above-mentioned ECG self-supervised pre-training task, the data annotation cost can be effectively reduced. In addition, the model does not depend on specific tasks. It is a universal ECG framework that is widely applicable to different ECG tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of large ECG models, and in particular relates to a method and system for constructing a universal large ECG base model framework. Background Art

[0002] Existing electrocardiogram (ECG) analysis models are mostly based on traditional deep learning architectures, such as multi-scale CNN, LSTM, Transformer, etc. based on supervised learning. The training of these models relies on a large amount of labeled ECG signal data and is only applicable to specific ECG tasks. Labeling a large number of ECG signals relies on professional physicians, and the labeling process is time-consuming and labor-intensive. It is difficult to obtain clinical ECG sample labels, which limits the development of artificial intelligence in the ECG field. In contrast, unsupervised pre-trained large models do not rely on data labels and can be widely applied to a variety of ECG analysis tasks.

[0003] Unsupervised pre-trained large models can be roughly classified into the following two ideas: One is based on the idea of ​​contrastive learning, generating enhanced data, and constraining the distance between positive and negative samples during training to achieve model training, such as SimCLR, DINO, etc. The other is a method based on mask modeling, which achieves training tasks by restoring masked data, such as Bert, Beit and other models. However, the above models are designed for language or images, and fail to fully consider the lead characteristics of ECG signals, so they cannot effectively extract information from ECG data. This results in the inability of existing unsupervised pre-trained large models to be directly applied to process ECG data. Summary of the invention

[0004] In view of the above-mentioned deficiencies in the prior art, the present application provides a method and system for constructing a universal ECG base large model framework.

[0005] In the first aspect, the present application proposes a method for constructing a universal ECG base large model framework, comprising the following steps:

[0006] The original ECG signal is obtained as the model input and data enhancement is performed based on three enhancement strategies to obtain the overall enhanced data;

[0007] By performing data reconstruction training on the entire enhanced data to enhance the VQ-VAE model, parameters of a word segmenter and a codebook are obtained, thereby obtaining a discrete representation of the original ECG signal;

[0008] Constructing a masked ECG modeling task according to a discrete representation of the original ECG signal, training an ECG encoder according to the masked ECG modeling task, and obtaining a large ECG base model;

[0009] The downstream tasks are called to fine-tune the ECG base model, and ECG signal data is collected to verify the fine-tuned ECG model to ensure the integrity of the framework.

[0010] In some embodiments, the method of obtaining the original ECG signal as a model input and performing data enhancement training based on three enhancement strategies to obtain all enhanced data includes:

[0011] A one-dimensional ECG signal with a time length of 10 seconds and lead data of 12 is obtained as the original ECG signal, and the original ECG signal is used as the model input, denoted as , the input size is ,in Indicates the number of samples, 4096 indicates the data length, and 12 indicates lead data;

[0012] Each sample of the original ECG signal is enhanced by three data enhancement strategies: random cropping, adding noise, and lead occlusion, to obtain the corresponding enhanced data. ;

[0013] Among them, random cropping includes:

[0014] The original ECG signal is truncated into an ECG signal with a time length of not less than 2 seconds;

[0015] Performing zeroing processing on the ECG signal of the remaining time length in the original ECG signal;

[0016] Adding noise includes:

[0017] Adding Gaussian white noise to the original ECG signal, wherein the Gaussian white noise has a magnitude of 0-24 dB;

[0018] Lead occlusion includes:

[0019] Splitting the lead data of the original ECG signal into a single lead data and a three-lead data, wherein the single lead data refers to lead I or lead II, and the three-lead data refers to leads I, II, and III;

[0020] The enhanced data and model input Merge to get all enhanced data .

[0021] In some embodiments, the enhancing the VQ-VAE model by performing data reconstruction training on the entire enhanced data to obtain parameters of a word segmenter and a codebook, and then obtaining a discrete representation of the original ECG signal, includes:

[0022] The enhanced data is then Compress to intermediate representation , and vector quantize the intermediate representation;

[0023] The distance between each intermediate representation after vector quantization and the codebook is calculated, and the index of the vector with the smallest distance in the codebook is calculated to form a discrete representation corresponding to the model input .

[0024] In some embodiments, the method further includes adding a sample internal distance loss based on the loss function in the enhanced VQ-VAE model:

[0025]

[0026] Among them, the final quantized representation is obtained by looking up the table from the codebook according to the index , which is decoded by the decoder as the output generated by the enhanced VQ-VAE model , Represents the mean square error, which is used to measure the reconstructed data The difference between the whole augmented data, sg represents the stop gradient, α and β represent hyperparameters, is an intermediate representation of the original data, is the intermediate representation of the augmented data, represents the codebook vector, and DIS represents the cosine distance.

[0027] In some embodiments, the step of constructing a masked ECG modeling task based on a discrete representation of the original ECG signal, training an ECG encoder based on the masked ECG modeling task, and obtaining a large ECG base model includes:

[0028] Constructing an ECG block and an ECG discrete tag, wherein the ECG block construction includes: dividing a one-dimensional ECG signal with a data length of 4096 into 64 ECG segments, wherein the data length of each ECG segment is 64, wherein the ECG discrete tag is obtained by the pre-trained word segmenter and is represented by 64 discrete numbers, wherein each ECG block and each ECG discrete tag correspond to each other;

[0029] Construct a mask ECG modeling task based on the ECG blocks and ECG discrete markers:

[0030] Flatten the ECG block to obtain a block embedding with a dimension of 768, replace the masked ECG block with the mask embedding, generate a position encoding for each ECG block with the same dimension as the block embedding, add the block embedding and the position encoding to form the input of the ECG encoder, encode the input through the ECG encoder, and predict the discrete tags corresponding to the masked ECG block through the MLP;

[0031] The large model of the ECG base is obtained by completing the mask ECG modeling task.

[0032] In some embodiments, the calling of downstream tasks fine-tunes the ECG base model, collects ECG signal data to verify the fine-tuned ECG model, and ensures the integrity of the framework, including setting time length judgment:

[0033] Filter out any lead ECG signal data with a time length greater than 2 seconds;

[0034] The ECG signal data with a time length less than 10 seconds after screening are padded with zeros to be filled into 10-second segments, and the padded ECG signal data are converted into 4096 data points through a resampling operation;

[0035] The ECG signal data with a time length greater than 10 seconds after filtering are segmented and truncated, and ECG signal recognition is performed once every 10 seconds and the results are returned.

[0036] In some embodiments, the calling of downstream tasks fine-tunes the ECG base model, collects ECG signal data to verify the fine-tuned ECG model, and ensures the integrity of the framework, including setting lead discrimination:

[0037] For single-lead or three-lead ECG signal data: set the missing leads to zero and then feed them into the model;

[0038] For the standard eight-lead data, the missing leads are supplemented through linear operations and then fed into the model;

[0039] Among them, it is mainly to complete the data of the four leads of III, aVR, aVL and aVF. The specific calculation formula is:

[0040] Lead III = lead II - lead I;

[0041] aVR lead = -(lead I + lead II) / 2;

[0042] aVL lead = lead I - lead II / 2;

[0043] aVF lead = lead II - lead I / 2.

[0044] The second aspect itself proposes a general ECG base large model framework construction system, including a model pre-training module, a data reconstruction module, an ECG base large model construction module and a fine-tuning setting module;

[0045] The model pre-training module is used to obtain the original ECG signal as the model input and perform data enhancement training based on three enhancement strategies to obtain all enhanced data;

[0046] The data reconstruction module is used to enhance the VQ-VAE model by performing data reconstruction training on the entire enhanced data, obtain parameters of the word segmenter and the codebook, and then obtain a discrete representation of the original ECG signal;

[0047] The ECG base large model construction module is used to construct a mask ECG modeling task according to the discrete representation of the original ECG signal, and train the ECG encoder according to the mask ECG modeling task to obtain the ECG base large model;

[0048] The fine-tuning setting module is used to call downstream tasks to fine-tune the ECG base large model, collect ECG signal data to perform model verification on the fine-tuned ECG large model, and ensure the integrity of the framework.

[0049] In a third aspect, the present application proposes an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0050] In a fourth aspect, the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0051] Beneficial effects of the present invention:

[0052] 1. Enhanced VQVAE is proposed, which is an improvement based on the VQVAE model. This improvement is mainly to solve the generalization problem of the ECG model. The improved enhanced VQVAE model can be applied to ECG signals of different lengths, different noise levels and multiple lead conditions (single lead, three leads, standard eight leads and standard twelve leads).

[0053] 2. A masked ECG modeling model is proposed, which is a self-supervised pre-training framework for 1D ECG signals. Most existing mask modeling is based on language or images and cannot be directly used for ECG tasks. This solution designs reasonable mask modeling ECG block parameters and the embedding layer dimension of the ECG encoder for ECG signals. By constructing the above ECG self-supervised pre-training task, the data annotation cost can be effectively reduced. The model does not depend on specific tasks and is a general ECG framework that is widely applicable to different ECG tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 It is the overall flow chart of the present invention.

[0055] Figure 2 Schematic diagram of the enhanced VQ-VAE model.

[0056] Figure 3 Schematic diagram for pre-training the ECG encoder.

[0057] Figure 4 Fine-tune the flow chart for the ECG pedestal model.

[0058] Figure 5 It is a system principle diagram of the present invention. DETAILED DESCRIPTION

[0059] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments described herein; on the contrary, these embodiments are provided to enable a more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.

[0060] In the first aspect, the present application proposes a method for constructing a universal ECG base large model framework, comprising the following steps:

[0061] S100: Obtain the original ECG signal as the model input and perform data enhancement training based on three enhancement strategies to obtain all enhanced data;

[0062] In some embodiments, the method of obtaining the original ECG signal as a model input and performing data enhancement training based on three enhancement strategies to obtain all enhanced data includes:

[0063] A one-dimensional ECG signal with a time length of 10 seconds and lead data of 12 is obtained as the original ECG signal, and the original ECG signal is used as the model input, denoted as , the input size is ,in Indicates the number of samples, 4096 indicates the data length, and 12 indicates lead data;

[0064] Each sample of the original ECG signal is enhanced by three data enhancement strategies: random cropping, adding noise, and lead occlusion, to obtain the corresponding enhanced data. ;

[0065] Among them, random cropping includes:

[0066] The original ECG signal is truncated into an ECG signal with a time length of not less than 2 seconds;

[0067] Performing zeroing processing on the ECG signal of the remaining time length in the original ECG signal;

[0068] Adding noise includes:

[0069] Adding Gaussian white noise to the original ECG signal, wherein the Gaussian white noise has a magnitude of 0-24 dB;

[0070] Lead occlusion includes:

[0071] Splitting the lead data of the original ECG signal into a single lead data and a three-lead data, wherein the single lead data refers to lead I or lead II, and the three-lead data refers to leads I, II, and III;

[0072] The enhanced data and model input Merge to get all enhanced data .

[0073] For example, for lead masking: the original data is 12 leads, and now three-lead data is to be generated, the data of leads I, II, and III remain unchanged, and the data of the other 9 leads are set to 0;

[0074] For example, for random cropping, the input time length is 10 seconds. Each time point corresponds to the value of the ECG signal at that moment. Random length truncation means truncating the 10-second ECG signal to a random time length. This random length is greater than 2 seconds and can be 3 seconds. At this time, only the values ​​of the ECG signal of these three seconds are retained, and the values ​​of the remaining seven seconds are set to 0.

[0075] Data augmentation helps improve the generalization of the model for various time lengths, noise interference, and various lead combinations. The principle of enhancing VQVAE is as follows Figure 2 shown.

[0076] S200: Enhance the VQ-VAE model by performing data reconstruction training on the entire enhanced data to obtain parameters of a word segmenter and a codebook, thereby obtaining a discrete representation of the original ECG signal;

[0077] In some embodiments, the enhancing the VQ-VAE model by performing data reconstruction training on the entire enhanced data to obtain parameters of a word segmenter and a codebook, and then obtaining a discrete representation of the original ECG signal, includes:

[0078] The enhanced data is then Compress to intermediate representation , and vector quantize the intermediate representation;

[0079] The distance between each intermediate representation after vector quantization and the codebook is calculated, and the index of the vector with the smallest distance in the codebook is calculated to form a discrete representation corresponding to the model input .

[0080] In some embodiments, the method further includes adding a sample internal distance loss based on the loss function in the enhanced VQ-VAE model:

[0081]

[0082] Among them, the final quantized representation is obtained by looking up the table from the codebook according to the index , which is used as the output generated by the enhanced VQ-VAE model, Represents the mean square error, which is used to measure The difference between the whole augmented data, sg represents the stop gradient, α and β represent hyperparameters, is an intermediate representation of the original data, is the intermediate representation of the augmented data, represents the codebook vector, and DIS represents the cosine distance.

[0083] Furthermore, in the decoding process, the final quantized representation is obtained by looking up the table in the Codebook according to the index. Finally, The input decoder generates the final output The word segmenter consists of three layers of one-dimensional convolution with kernel sizes of 3, 3, and 5 and a stride of 2. An average pooling layer with a stride of 2 is set after each convolution layer. The decoder consists of three layers of one-dimensional deconvolution with kernel sizes of 5, 3, and 3 and a stride of 2. An upsampling layer with a scale of 2 is set after each deconvolution layer. In order to weaken the impact of ECG length change, noise pollution and lead missing on the model, an internal sample distance loss is added on the basis of the VQVAE loss function to shorten the distance between different enhanced data features of the same sample.

[0084] S300: constructing a masked ECG modeling task according to the discrete representation of the original ECG signal, training an ECG encoder according to the masked ECG modeling task, and obtaining a large ECG base model;

[0085] In some embodiments, the step of constructing a masked ECG modeling task based on a discrete representation of the original ECG signal, training an ECG encoder based on the masked ECG modeling task, and obtaining a large ECG base model includes:

[0086] Constructing an ECG block and an ECG discrete tag, wherein the ECG block construction includes: dividing a one-dimensional ECG signal with a data length of 4096 into 64 ECG segments, wherein the data length of each ECG segment is 64, wherein the ECG discrete tag is obtained by the pre-trained word segmenter and is represented by 64 discrete numbers, wherein each ECG block and each ECG discrete tag correspond to each other;

[0087] Construct a mask ECG modeling task based on the ECG blocks and ECG discrete markers:

[0088] Flatten the ECG block to obtain a block embedding with a dimension of 768, replace the masked ECG block with the mask embedding, generate a position encoding for each ECG block with the same dimension as the block embedding, add the block embedding and the position encoding to form the input of the ECG encoder, encode the input through the ECG encoder, and predict the discrete tags corresponding to the masked ECG block through the MLP;

[0089] The large model of the ECG base is obtained by completing the mask ECG modeling task.

[0090] The ECG encoder uses a one-dimensional visual Transformer model, but with some minor changes: the size of its block is not 16x16 in two dimensions, but 64 in one dimension. Through the above pre-training process, a general ECG base model can be obtained. The schematic diagram of the ECG encoder pre-training is shown in the figure. Figure 3 shown.

[0091] S400: Calling downstream tasks to fine-tune the ECG base large model, collecting ECG signal data to perform model verification on the fine-tuned ECG large model to ensure framework integrity.

[0092] In some embodiments, the calling of downstream tasks fine-tunes the ECG base model, collects ECG signal data to verify the fine-tuned ECG model, and ensures the integrity of the framework, including setting time length judgment:

[0093] Filter out any lead ECG signal data with a time length greater than 2 seconds;

[0094] The ECG signal data with a time length less than 10 seconds after screening are padded with zeros to be filled into 10-second segments, and the padded ECG signal data are converted into 4096 data points through a resampling operation;

[0095] The ECG signal data with a time length greater than 10 seconds after filtering are segmented and truncated, and ECG signal recognition is performed once every 10 seconds and the results are returned.

[0096] In some embodiments, the calling of downstream tasks fine-tunes the ECG base model, collects ECG signal data to verify the fine-tuned ECG model, and ensures the integrity of the framework, including setting lead discrimination:

[0097] For single-lead or three-lead ECG signal data: set the missing leads to zero and then feed them into the model;

[0098] For the standard eight-lead data, the missing leads are supplemented through linear operations and then fed into the model;

[0099] Among them, it is mainly to complete the data of the four leads of III, aVR, aVL and aVF. The specific calculation formula is:

[0100] Lead III = lead II - lead I;

[0101] aVR lead = -(lead I + lead II) / 2;

[0102] aVL lead = lead I - lead II / 2;

[0103] aVF lead = lead II - lead I / 2.

[0104] Among them, the fine-tuning process of the ECG base model only uses the trained ECG encoder part, plus the downstream task head to implement multiple downstream tasks. There is no need to use the word segmenter and mask modeling steps. The fine-tuning process is as follows Figure 4 shown.

[0105] Specifically, the fine-tuning dataset is divided into blocks according to the time window: the one-dimensional ECG with a length of 4096 is divided into 64 ECG segments, each segment is 64 long, forming an ECG block perspective. Then the ECG block is flattened to obtain a block embedding with a dimension size of 768, and the block embedding and position embedding are added to form the input of the ECG encoder, which is then sent to the encoder to obtain ECG features. Finally, the model is trained through specific downstream tasks and their labels (such as classification tasks, where the downstream task head can use a fully connected layer, and the label is the classification result).

[0106] Among them, data with a time length of less than 2 seconds does not meet the model requirements, so it is necessary to set the time length discrimination for screening, and fill the data with zeros for less than 10 seconds to form a 10-second segment. For data longer than 10 seconds, it is segmented and truncated, and ECG recognition is performed once every 10 seconds as a unit and the result is returned. For example: the time length of the filtered data is 3 seconds in total, then 7 seconds of zeros are added to form a 10-second segment, so there are 5000 data points, and then resampled into 4096 data points;

[0107] If the filtered time length is 32 seconds in total, it will be executed once for 0-10 seconds, once for 10-20 seconds, once for 20-30 seconds, and the last 2 seconds will be discarded.

[0108] The second aspect itself is to propose a universal ECG base large model framework construction system, such as Figure 5 As shown, it includes a model pre-training module, a data reconstruction module, an ECG base large model building module and a fine-tuning setting module;

[0109] The model pre-training module is used to obtain the original ECG signal as the model input and perform data enhancement training based on three enhancement strategies to obtain all enhanced data;

[0110] The data reconstruction module is used to enhance the VQ-VAE model by performing data reconstruction training on the entire enhanced data, obtain parameters of the word segmenter and the codebook, and then obtain a discrete representation of the original ECG signal;

[0111] The ECG base large model construction module is used to construct a mask ECG modeling task according to the discrete representation of the original ECG signal, and train the ECG encoder according to the mask ECG modeling task to obtain the ECG base large model;

[0112] The fine-tuning setting module is used to call downstream tasks to fine-tune the ECG base large model, collect ECG signal data to perform model verification on the fine-tuned ECG large model, and ensure the integrity of the framework.

[0113] In a third aspect, the present application proposes an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0114] In a fourth aspect, the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0115] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0116] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0117] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this disclosure.

[0118] In the embodiments provided in the present disclosure, it should be understood that the disclosed apparatus / computer equipment and methods can be implemented in other ways. For example, the apparatus / computer equipment embodiments described above are merely schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation. Multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection of the apparatus or unit, which may be electrical, mechanical or other forms.

[0119] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0120] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0121] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present disclosure implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.

[0122] The above are only preferred implementations of the present invention. It should be pointed out that a number of modifications and improved technical solutions made by those skilled in the art without departing from the technical solution should also be deemed to fall within the scope of protection required by the claims.

Claims

1. A method for constructing a universal ECG base large model framework, characterized by: The following steps are involved: The original ECG signal is obtained as the model input and data enhancement is performed based on three enhancement strategies to obtain the overall enhanced data; The VQ-VAE model is enhanced by performing data reconstruction training on the entire enhanced data to obtain parameters of a word segmenter and a codebook, thereby obtaining a discrete representation of the original ECG signal, including: Through the word segmentation, all enhanced data Compress to intermediate representation , and vector quantize the intermediate representation; perform distance calculation between each intermediate representation after vector quantization and the codebook, calculate the index of the vector with the smallest distance in the codebook, and form a discrete representation corresponding to the model input ; It also includes adding the sample internal distance loss based on the loss function in the enhanced VQ-VAE model: Among them, the final quantized representation is obtained by looking up the table from the codebook according to the index , which is used as the output generated by the enhanced VQ-VAE model, Represents the mean square error, which is used to measure The difference between the whole augmented data, sg represents the stop gradient, α and β represent hyperparameters, is an intermediate representation of the original data, is the intermediate representation of the augmented data, represents the codebook vector, DIS represents the cosine distance; A masked ECG modeling task is constructed according to the discrete representation of the original ECG signal. The ECG encoder is trained according to the masked ECG modeling task to obtain a large ECG base model, including constructing ECG blocks and ECG discrete tags. The ECG block construction includes: dividing a one-dimensional ECG signal with a data length of 4096 into 64 ECG segments, each ECG segment has a data length of 64, and the ECG discrete tags are obtained by the pre-trained word segmenter, represented by 64 discrete numbers, and each ECG block and each ECG discrete tag correspond to each other; constructing a masked ECG modeling task according to the ECG blocks and ECG discrete tags: Flatten the ECG block to obtain a block embedding with a dimension of 768, replace the masked ECG block with the mask embedding, generate a position encoding for each ECG block, the dimension of which is the same as the block embedding, add the block embedding and the position encoding to form the input of the ECG encoder, encode the input through the ECG encoder, and predict the discrete tags corresponding to the masked ECG block through MLP; obtain the ECG base large model by completing the masked ECG modeling task; The downstream tasks are called to fine-tune the ECG base model, and ECG signal data is collected to verify the fine-tuned ECG model to ensure the integrity of the framework.

2. The method according to claim 1, characterized in that: The original ECG signal is obtained as the model input and data enhancement training is performed based on three enhancement strategies to obtain all enhanced data, including: A one-dimensional ECG signal with a time length of 10 seconds and lead data of 12 is obtained as the original ECG signal, and the original ECG signal is used as the model input, denoted as , the input size is ,in Indicates the number of samples, 4096 indicates the data length, and 12 indicates lead data; Each sample of the original ECG signal is enhanced by three data enhancement strategies: random cropping, adding noise, and lead occlusion, to obtain the corresponding enhanced data. ; Among them, random cropping includes: The original ECG signal is truncated into an ECG signal with a time length of not less than 2 seconds; Performing zeroing processing on the ECG signal of the remaining time length in the original ECG signal; Adding noise includes: Adding Gaussian white noise to the original ECG signal, wherein the Gaussian white noise has a magnitude of 0-24 dB; Lead occlusion includes: Splitting the lead data of the original ECG signal into a single lead data and a three-lead data, wherein the single lead data refers to lead I or lead II, and the three-lead data refers to leads I, II, and III; The enhanced data and model input Merge to get all enhanced data .

3. The method according to claim 2, characterized in that: The downstream task is called to fine-tune the ECG base model, collect ECG signal data to verify the fine-tuned ECG model, and ensure the integrity of the framework, including setting the time length judgment: Filter out any lead ECG signal data with a time length greater than 2 seconds; The ECG signal data with a time length less than 10 seconds after screening are padded with zeros to be filled into 10-second segments, and the padded ECG signal data are converted into 4096 data points through a resampling operation; The ECG signal data with a time length greater than 10 seconds after filtering are segmented and truncated, and ECG signal recognition is performed once every 10 seconds and the results are returned.

4. The method according to claim 3, characterized in that: The downstream task is called to fine-tune the ECG base model, collect ECG signal data to verify the fine-tuned ECG model, and ensure the integrity of the framework, including setting lead discrimination: For single-lead or three-lead ECG signal data: set the missing leads to zero and then feed them into the model; For the standard eight-lead data, the missing leads are supplemented through linear operations and then fed into the model; Among them, it is mainly to complete the data of the four leads of III, aVR, aVL and aVF. The specific calculation formula is: Lead III = lead II - lead I; aVR lead = -(lead I + lead II) / 2; aVL lead = lead I - lead II / 2; aVF lead = lead II - lead I / 2.

5. A universal ECG base large model framework construction system, characterized by: It includes model pre-training module, data reconstruction module, ECG base large model building module and fine-tuning setting module; The model pre-training module is used to obtain the original ECG signal as the model input and perform data enhancement training based on three enhancement strategies to obtain all enhanced data; The data reconstruction module is used to enhance the VQ-VAE model by performing data reconstruction training on the entire enhanced data, obtain the parameters of the word segmenter and the codebook, and then obtain the discrete representation of the original ECG signal, and transform the entire enhanced data into Compress to intermediate representation , and vector quantize the intermediate representation; perform distance calculation between each intermediate representation after vector quantization and the codebook, calculate the index of the vector with the smallest distance in the codebook, and form a discrete representation corresponding to the model input ; It also includes adding the sample internal distance loss based on the loss function in the enhanced VQ-VAE model: Among them, the final quantized representation is obtained by looking up the table from the codebook according to the index , which is used as the output generated by the enhanced VQ-VAE model, Represents the mean square error, which is used to measure The difference between the whole augmented data, sg represents the stop gradient, α and β represent hyperparameters, is an intermediate representation of the original data, is the intermediate representation of the augmented data, represents the codebook vector, DIS represents the cosine distance; The ECG base large model construction module is used to construct a mask ECG modeling task according to the discrete representation of the original ECG signal, train the ECG encoder according to the mask ECG modeling task, and obtain the ECG base large model, including constructing ECG blocks and ECG discrete tags. The ECG block construction includes: dividing a one-dimensional ECG signal with a data length of 4096 into 64 ECG segments, each ECG segment has a data length of 64, and the ECG discrete tags are obtained by the pre-trained word segmenter, represented by 64 discrete numbers, and each ECG block and each ECG discrete tag correspond to each other; constructing a mask ECG modeling task according to the ECG block and the ECG discrete tag: Flatten the ECG block to obtain a block embedding with a dimension of 768, replace the masked ECG block with the mask embedding, generate a position encoding for each ECG block, the dimension of which is the same as the block embedding, add the block embedding and the position encoding to form the input of the ECG encoder, encode the input through the ECG encoder, and predict the discrete tags corresponding to the masked ECG block through MLP; obtain the ECG base large model by completing the masked ECG modeling task; The fine-tuning setting module is used to call downstream tasks to fine-tune the ECG base large model, collect ECG signal data to perform model verification on the fine-tuned ECG large model, and ensure the integrity of the framework.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Electrocardiogram anomaly detection method based on VQ-VAE2 and deep neural network method

    CN113171106A

  • Method, device and equipment for training electroencephalogram signal analysis model and storage medium

    CN116955983A