Multi-task prediction method, device and equipment of electrocardiosignal and storage medium

CN122874007APending Publication Date: 2026-10-09FUWAI HOSPITAL CHINESE ACAD OF MEDICAL SCI & PEKING UNION MEDICAL COLLEGE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611297017.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-25
Publication Date
2026-10-09

AI Technical Summary

Technical Problem

然而,不同来源的心电信号在多个维度上存在显著差异

Benefits of technology

[0008]在本公开的技术方案,采集不同场景下的心电信号,将心电信号进行划分得到预设时间的心电信号;将单导联预设时间的心电信号进行掩码,并输入至编码器中得到对应的信号特征;根据信号特征以及解码器对信号进行重建,得到重建信号;根据信号特征以及预测模块得到信号特征所属的导联;根据重建信号与单导联预设时间的心电信号,以及根据预测的导联与单导联预设时间的心电信号所属导联,对编码器进行训练;根据训练后的编码器确定多导联预设时间的心电信号对应的单导联信号特征,并通过融合模块对单导联信号特征进行融合;将融合后的特征分别输入至多个任务预测头,得到对应的预测结果,并根据预测结果对编码器进行微调,对多个任务预测头进行训练以及对用于特征融合的融合模块进行训练;根据微调结果以及训练结果生成预测模型,以对待测心电信号进行多任务预测,得到预测结果。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122874007A_ABST
    Figure CN122874007A_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a multi-task prediction method and device for electrocardiosignal, equipment and storage medium, including dividing the collected electrocardiosignal under different scenes to obtain a preset time electrocardiosignal; masking the single-lead preset time electrocardiosignal and inputting into an encoder to obtain signal features; reconstructing the signal according to the signal features and the decoder; obtaining the belonging lead according to the signal features and the prediction module; training the encoder according to the reconstructed signal and the single-lead preset time electrocardiosignal, and according to the predicted lead and the belonging lead; determining the single-lead signal features corresponding to the multi-lead preset time electrocardiosignal according to the trained encoder, and performing fusion; inputting the fused features into multiple task prediction heads respectively, and fine-tuning the encoder according to the prediction results, training the multiple task prediction heads and training the fusion module to generate a prediction model for multi-task prediction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of medical data processing, and in particular to a multi-task prediction method, apparatus, device, and storage medium for electrocardiogram signals. Background Technology

[0002] Electrocardiography (ECG) is a crucial tool for clinical diagnosis of heart diseases, widely used in the screening and monitoring of arrhythmias, myocardial ischemia, and other conditions. With the rapid development of wearable devices and telemedicine, ECG acquisition scenarios are becoming increasingly diverse. However, ECG signals from different sources exhibit significant differences across multiple dimensions. Although these signals share commonalities in the electrophysiological nature of the heart, most related intelligent analysis methods still rely heavily on data from specific scenarios or fixed leads for training, lacking universal modeling capabilities across devices and scenarios. This necessitates model re-labeling and retraining in new devices and environments, resulting in high adaptation costs and low deployment efficiency, making it difficult to meet the real-world demand for rapid and reliable ECG analysis. Summary of the Invention

[0003] This application provides a multi-task prediction method, apparatus, device, and storage medium for electrocardiogram signals.

[0004] This application provides a multi-task prediction method for electrocardiogram (ECG) signals, comprising: acquiring ECG signals under different scenarios; dividing the ECG signals into ECG signals of preset time; masking the ECG signals of a single lead at the preset time and inputting them into an encoder to obtain corresponding signal features; reconstructing the signals based on the signal features and a decoder to obtain reconstructed signals; obtaining the lead to which the signal features belong based on the signal features and a prediction module; training the encoder based on the reconstructed signals and the ECG signals of the single lead at the preset time, and based on the predicted leads and the leads to which the ECG signals of the single lead at the preset time belong; determining the single-lead signal features corresponding to the multi-lead ECG signals of the preset time based on the trained encoder, and fusing the single-lead signal features through a fusion module; inputting the fused features into multiple task prediction heads to obtain corresponding prediction results, and fine-tuning the encoder based on the prediction results, training the multiple task prediction heads and the fusion module for feature fusion; generating a prediction model based on the fine-tuning results and the training results to perform multi-task prediction of the ECG signals to be tested, and obtaining prediction results.

[0005] This application provides a multi-task prediction device for electrocardiogram (ECG) signals, comprising: an acquisition module for acquiring ECG signals under different scenarios and dividing the ECG signals into ECG signals of preset time; a masking module for masking the ECG signals of a single lead at the preset time and inputting the mask into an encoder to obtain corresponding signal features; a reconstruction module for reconstructing the signals based on the signal features and a decoder to obtain a reconstructed signal; a first prediction module for obtaining the lead to which the signal features belong based on the signal features and the prediction module; and a training module for training the reconstructed signal and the ECG signals of the single lead at the preset time, and the predicted lead and the single lead... The encoder is trained by connecting the ECG signal to a preset time and training it to the corresponding lead. A determination module is used to determine the single-lead signal features corresponding to the ECG signal at the preset time using the trained encoder, and to fuse these single-lead signal features using a fusion module. A fine-tuning module is used to input the fused features into multiple task prediction heads to obtain corresponding prediction results, and to fine-tune the encoder based on the prediction results, train the multiple task prediction heads, and train the fusion module used for feature fusion. A second prediction module is used to generate a prediction model based on the fine-tuning results and the training results to perform multi-task prediction of the ECG signal under test and obtain prediction results.

[0006] This application provides a device, including: a memory and a processor; the memory is used to store a computer program; the processor is used to execute the computer program for: acquiring electrocardiogram (ECG) signals under different scenarios; dividing the ECG signals into ECG signals of preset time; masking the ECG signals of a single lead at the preset time and inputting them into an encoder to obtain corresponding signal features; reconstructing the signals based on the signal features and a decoder to obtain a reconstructed signal; obtaining the lead to which the signal features belong based on the signal features and a prediction module; and comparing the reconstructed signal with the ECG signals of the single lead at the preset time, and using root... The encoder is trained based on the predicted leads and the leads to which the ECG signal of the single lead at a preset time belongs. The trained encoder determines the single-lead signal features corresponding to the multi-lead ECG signal at a preset time, and these features are fused using a fusion module. The fused features are then input to multiple task prediction heads to obtain corresponding prediction results. The encoder is fine-tuned based on these prediction results, and the multiple task prediction heads and the fusion module used for feature fusion are trained. A prediction model is generated based on the fine-tuning and training results to perform multi-task prediction of the ECG signal under test, yielding the prediction result.

[0007] This application provides a computer-readable storage medium storing a computer program, characterized in that, when the computer program is executed by one or more processors, it causes the one or more processors to implement the steps in the above-described method.

[0008] The technical solution disclosed herein involves collecting electrocardiogram (ECG) signals from different scenarios, dividing the ECG signals into ECG signals of preset time intervals, masking the single-lead ECG signals of preset time intervals, and inputting them into an encoder to obtain corresponding signal features, reconstructing the signals based on the signal features and a decoder to obtain reconstructed signals, determining the leads to which the signal features belong based on the signal features and a prediction module, training the encoder based on the reconstructed signals and the single-lead ECG signals of preset time intervals, and training the encoder based on the predicted leads and the leads to which the single-lead ECG signals of preset time intervals belong, determining the single-lead signal features corresponding to the multi-lead ECG signals of preset time intervals based on the trained encoder, and fusing the single-lead signal features through a fusion module, inputting the fused features into multiple task prediction heads to obtain corresponding prediction results, fine-tuning the encoder based on the prediction results, training the multiple task prediction heads and the fusion module used for feature fusion, and generating a prediction model based on the fine-tuning results and training results to perform multi-task prediction of the ECG signals under test to obtain prediction results.

[0009] This process involves collecting electrocardiogram (ECG) signals from different scenarios and dividing them into ECG signals with preset time intervals. The encoder is then trained based on the reconstructed signal and the ECG signal from a single lead at the preset time interval, as well as the predicted lead and the lead to which the ECG signal belongs. This allows the trained encoder to learn general representations that combine physiological commonality with scenario robustness.

[0010] The encoder, after training, determines the single-lead signal features corresponding to the multi-lead ECG signals at preset times. These single-lead signal features are then fused using a fusion module. The fused features are input into multiple task prediction heads to obtain corresponding prediction results. The encoder is then fine-tuned based on these prediction results, and the multiple task prediction heads and the fusion module used for feature fusion are trained. A prediction model is generated based on the fine-tuning and training results. After learning a general representation, multiple clinical tasks can be performed simultaneously. There is no need to develop separate models for different devices or leads, significantly reducing deployment and maintenance costs and improving model reuse efficiency. Furthermore, by fusing information from multiple scenarios and multiple leads during training, the model exhibits stronger robustness when facing heterogeneous data, effectively supporting early screening, accurate diagnosis, and continuous health management of cardiovascular diseases. Attached Figure Description

[0011] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a flowchart illustrating an exemplary multi-task prediction method for electrocardiogram signals according to this application; Figure 2 This is a schematic diagram of the architecture of a pre-trained model as an exemplary embodiment of this application; Figure 3 This is a schematic diagram of the architecture of a fine-tuning model as an exemplary embodiment of this application; Figure 4 This is a schematic diagram of the structure of a multi-task prediction device for electrocardiogram signals, which is an exemplary embodiment of this application. Figure 5 This is a schematic diagram of the structure of a device that is an exemplary embodiment of this application. Detailed Implementation

[0012] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0013] As mentioned earlier, ECG signals from different sources exhibit significant differences in multiple dimensions. For example, the number of leads varies from single to 18, the acquisition site varies depending on the device type (e.g., chest patch or wristwatch), the recording duration is flexible and can range from seconds to days, and the signal quality is affected by factors such as motion artifacts, poor electrode contact, and environmental interference, resulting in significant fluctuations.

[0014] Current technologies primarily focus on intelligent analysis of ECG signals from single tasks or scenarios. However, intelligent ECG analysis solutions tailored to different ECG acquisition scenarios are relatively scarce. Most related technologies only support intelligent analysis of fixed-lead ECG data and only support single-level analysis. A collaborative framework for simultaneous analysis of local heartbeats and overall abnormalities has not yet been established. Furthermore, a correlation model between local heartbeats and global heart rhythm has not been established, and a decision-making mechanism coupling signal quality and the confidence level of abnormal results is lacking, which significantly limits their application scope.

[0015] This application proposes a multi-task prediction method, device, equipment, and storage medium for electrocardiogram (ECG) signals. Using single-lead signals as the basic processing unit, a unified, lightweight, and scalable deep learning framework is constructed. Through self-supervised pre-training combined with a lead-aware multi-task learning mechanism, the model can learn universal representations with both physiological commonality and scenario robustness on massive amounts of unlabeled, multi-source ECG data. The fine-tuning stage simultaneously optimizes multiple clinical tasks based on adaptive multi-lead feature fusion. This application eliminates the need for separate model development for different devices or leads, significantly reducing deployment and maintenance costs and improving model reuse efficiency. Furthermore, by incorporating contextual information from multiple scenarios and leads during training, the model exhibits stronger robustness when facing heterogeneous data, effectively supporting early screening, accurate diagnosis, and continuous health management of cardiovascular diseases.

[0016] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.

[0017] Figure 1 This is a flowchart illustrating a method for predicting multiple diseases, as an exemplary embodiment of this application. The method 100 provided in this embodiment can be deployed on a server, such as a server, service cluster, or cloud platform. The method 100 includes the following steps: Step 110: Collect ECG signals under different scenarios, and divide the ECG signals to obtain ECG signals for a preset time.

[0018] Step 120: Mask the ECG signal of a single lead for a preset time and input it into the encoder to obtain the corresponding signal characteristics.

[0019] Step 130: Reconstruct the signal based on the signal characteristics and the decoder to obtain the reconstructed signal.

[0020] Step 140: Obtain the lead to which the signal characteristics belong based on the signal characteristics and the prediction module.

[0021] Step 150: Train the encoder based on the reconstructed signal and the ECG signal of the single lead with the preset time, and based on the predicted lead and the ECG signal of the single lead with the preset time.

[0022] Step 160: Determine the single-lead signal features corresponding to the multi-lead ECG signal with a preset time based on the trained encoder, and fuse the single-lead signal features through the fusion module.

[0023] Step 170: Input the fused features into multiple task prediction heads to obtain the corresponding prediction results, fine-tune the encoder based on the prediction results, train the multiple task prediction heads and the fusion module used for feature fusion.

[0024] Step 180: Generate a prediction model based on the fine-tuning results and training results to perform multi-task prediction on the ECG signal to be tested and obtain the prediction results.

[0025] This method 100 is based on self-supervised pre-training of ECG signal mask reconstruction and lead identification, learning the commonalities and differences in cardiac electrical activity from different lead perspectives, as well as signal characteristics under different acquisition scenarios. Furthermore, in the intelligent ECG analysis model, adaptive multi-lead feature fusion and multi-task joint learning are used to achieve multi-task prediction and processing of signals. This allows the model to organically combine local features with global judgments, thereby achieving comprehensive and accurate analysis of ECG signals and providing a reliable basis for clinical auxiliary diagnosis.

[0026] The above steps are explained in detail below: Step 110: Collect ECG signals under different scenarios, and divide the ECG signals to obtain ECG signals for a preset time.

[0027] Among them, different scenarios refer to a variety of clinical and routine data collection scenarios, such as the standard resting scenario and the long-term dynamic monitoring scenario.

[0028] Collect electrocardiogram (ECG) signals under different scenarios, including: collecting multi-lead ECG signals in a resting scenario and multi-lead ECG signals in a preset long-range dynamic scenario, and use the collected ECG signals as training data for training the encoder.

[0029] For example, ECG signals, including but not limited to standard 12-lead and 18-lead resting ECG signals, as well as 12-lead and 3-lead ECG signals acquired during long-term dynamic monitoring, are collected using an ECG monitor or ECG machine. These signals are then used as training data for subsequent pre-training.

[0030] After the electrocardiogram (ECG) device collects data, it sends the collected data to the server and stores it in the corresponding database.

[0031] Specifically, the collected pre-training data can be stored in the server's pre-training database. This database consists of electrocardiogram (ECG) signals from multiple devices and scenarios.

[0032] ECG signals are collected in different scenarios, including: multi-lead ECG signals in resting scenarios, multi-lead ECG signals in preset long-range dynamic scenarios, ECG signals from smart devices, and ECG signals from ECG patches. The collected ECG signals are used as fine-tuning data for encoder fine-tuning, training of multiple task prediction heads, and training of fusion modules for feature fusion.

[0033] For example, ECG signals can be collected via an ECG monitor or electrocardiograph, including but not limited to standard 12-lead and 18-lead resting ECG signals, as well as 12-lead and 3-lead ECG signals acquired during long-term dynamic monitoring. Additionally, ECG signals can be collected via an ECG monitor incorporating preset long-term single-lead signals, ECG signals collected via a smartwatch, and ECG signals collected via ECG patches. These collected data serve as subsequent fine-tuning data.

[0034] The collected data is sent to the server and stored in the corresponding database.

[0035] Specifically, the fine-tuning data collected above can be stored in the fine-tuning database on the server, which integrates labeled signals from multiple devices and multiple scenarios.

[0036] It should be noted that the preset long-range dynamic scenario can be a preset long-range of 7 days, 14 days, or 24 hours.

[0037] The electrocardiogram (ECG) signal is divided into ECG signals for preset times, including: splitting the acquired first ECG signal into first ECG signals for preset times according to the preset time; and splitting the split first ECG signal into first ECG signals for single leads at preset times, based on a single lead. The acquired second ECG signal is then split into second ECG signals for preset times according to the preset time.

[0038] The first ECG signal refers to the signal used as training data. The second ECG signal refers to the signal used as fine-tuning data.

[0039] As mentioned above, all acquired ECG signals underwent standardization. For example, continuous signals exceeding a preset duration of m seconds were segmented into fixed-length segments, each segment lasting m seconds. Simultaneously, each multi-lead signal was broken down into multiple independent single-lead signals, ultimately forming a pre-training dataset composed of numerous single-lead, m-second-long ECG signal segments and their lead information. The signal segment length m can be set manually, typically 10 seconds.

[0040] The aforementioned signals can be segmented non-overlappingly in units of m seconds to form multiple segments. Subsequently, each segment is further divided into independent single-lead signals according to the lead. The preprocessed 10-second single-lead segments constructed in this way, along with their corresponding lead information, i.e., the single-lead segments belong to specific lead types, such as I, II, III, aVR, aVL, aVF, V1-V6, V3R–V5R, V7–V9, etc., together constitute the pre-training data in the multi-scenario ECG pre-training database.

[0041] For the fine-tuning data collected above, as described above, m-second segments are segmented. The original lead structure is preserved at this stage to support multi-lead feature fusion and end-to-end multi-task inference. All fine-tuning segments are meticulously annotated, including signal quality level, waveform position, heartbeat type, and diagnostic type information, providing comprehensive and structured supervision signals for multi-task joint learning.

[0042] All fine-tuned ECG data were segmented into m-second segments. They were also pre-processed, maintaining the original number of leads, and manually labeled with information such as signal quality level (poor, acceptable, excellent), waveform location, heartbeat type, and corresponding diagnostic type.

[0043] The ECG signals collected from multiple devices and scenarios were subjected to unified signal normalization processing to improve the robustness and generalization ability of the model in heterogeneous devices and complex environments. Preprocessing methods include, but are not limited to, outlier suppression, sampling rate alignment, and amplitude normalization.

[0044] Outlier suppression identifies, corrects, or eliminates voltage anomalies that exceed physiological limits, reducing the interference of sudden noise on model training. Sampling rate alignment resamples ECG signals from different devices to a target sampling frequency, ensuring consistency in temporal structure. Amplitude normalization standardizes the signal to eliminate amplitude shifts caused by device, electrode configuration, or individual differences.

[0045] Step 120: Mask the ECG signal of a single lead for a preset time and input it into the encoder to obtain the corresponding signal characteristics.

[0046] Here, the encoder refers to the Transformer encoder. This encoder is included in the pre-trained model. This model refers to a pre-trained model based on self-supervised learning. For example... Figure 2 As shown, the model can include a shared encoder as described above and two parallel downstream task heads. The task head includes a mask signal reconstruction task head and a lead identification task head.

[0047] The model can be input data based on the ECG segments described above, such as a 10-second single-lead ECG segment (Xecg) and its lead index or lead category (Pl). The input data comes from the pre-training database of ECGs across multiple scenarios. Specifically, the ECG segments are masked before being input into the model.

[0048] This method uses m-second single-lead ECG signals and their lead information from different acquisition scenarios as input. A portion of the temporal region is randomly masked within the input sequence, and two objectives are jointly optimized: reconstructing the masked original signal and identifying the lead to which the signal belongs. Through this collaborative training mechanism, the model recovers local waveform details while implicitly learning the physiological commonalities and spatial differences of cardiac electrical activity from different lead perspectives, and adaptively capturing signal characteristics under different devices and monitoring scenarios. This implementation does not rely on manual annotation and is applicable to ECG data with any number of leads and sampling configuration. The obtained single-lead representation has strong generalization and context-aware capabilities, providing a robust initialization foundation for subsequent fine-tuning for diverse clinical tasks, and significantly enhancing the model's adaptability and reliability in complex real-world environments.

[0049] Specifically, the ECG signal of a single lead for a preset time is masked and input into the encoder to obtain the corresponding signal features. This includes: performing a preset number of random masks on the ECG signal; inputting the masked ECG signal into the encoder, and obtaining the corresponding signal features based on the self-attention mechanism and feedforward network in the encoder.

[0050] As mentioned above, the ECG signal Xecg is randomly masked by setting 40% of the data to 0, and then input into... Figure 2 The encoder shown is based on the Transformer architecture. After processing by the encoder's built-in multi-layer self-attention mechanism and feedforward network, the high-dimensional feature Fecg is obtained, as shown below. Figure 2 The signal characteristics shown.

[0051] Step 130: Reconstruct the signal based on the signal characteristics and the decoder to obtain the reconstructed signal.

[0052] Here, the decoder refers to the decoder of MAE. The decoder of MAE can include lightweight transformer blocks, specifically including multi-head self-attention, feedforward networks, residual connections, and layer normalization.

[0053] The aforementioned signal characteristics are processed through two different modules for signal reconstruction and lead identification. For example... Figure 2 As shown, the reconstructed signal is first obtained through the decoder. This enables the model to learn the physiological patterns of electrocardiogram signals and improve its ability to understand signal integrity.

[0054] Step 140: Obtain the lead to which the signal characteristics belong based on the signal characteristics and the prediction module.

[0055] The prediction module, acting as the lead identification module, determines the lead to which the input single-lead ECG signal belongs. Due to differences in lead configurations across different acquisition scenarios, this module uniformly models lead types into 21 mutually exclusive categories. These include the same international standard 12-lead system for both resting 12-lead and long-term 12-lead systems, specifically including limb leads I, II, III, aVR, aVL, aVF, and chest leads V1–V6, totaling 12 categories. It also includes resting 18-lead systems, which, in addition to the standard 12-lead system, add right chest leads V3R–V5R and posterior wall leads V7–V9, adding 6 leads and forming 18 categories. Long-term 3-lead systems, however, do not have a fixed correspondence with the standard 12-lead or 18-lead system and are therefore considered as three independent categories.

[0056] Secondly, the aforementioned high-dimensional features of the signal After lead classification, the lead category to which the signal belongs is predicted. The model is guided to capture the spatial distribution characteristics under different lead perspectives.

[0057] The aforementioned signal reconstruction and lead recognition form a mutually reinforcing closed loop. The reconstruction task drives the model to understand the signal content, while the lead recognition task guides the model to understand the signal source. Together, they propel the encoder to learn robust feature representations that possess both temporal continuity and spatial consistency. This multi-task joint training strategy enables the model to effectively capture the commonalities and differences in ECG data across different acquisition scenarios, even without any ECG abnormality labels or disease diagnostic labels. This significantly improves the feature generalization ability and adaptability to complex real-world data, laying a solid foundation for subsequent fine-tuning tasks.

[0058] Specifically, the lead to which the signal features belong is obtained based on the signal features and the prediction module, including: inputting the signal features into the prediction module, and obtaining the lead category through the multilayer perceptron (MLP) in the prediction module.

[0059] As mentioned above, Figure 2 As shown, the lead recognition module uses a lightweight multilayer perceptron (MLP) to implement a 21-class classification task, and the encoder outputs high-dimensional features. The predicted lead index or lead category is obtained through MLP. This refers to the lead type. This module guides the encoder to learn the spatial feature differences from different lead perspectives during self-supervised pre-training, enhancing the model's adaptability to multi-source ECG data. Specifically, lead index or lead category... Determined by the following formula:

[0060] Step 150: Train the encoder based on the reconstructed signal and the ECG signal of the single lead with the preset time, and based on the predicted lead and the ECG signal of the single lead with the preset time.

[0061] As mentioned earlier, during the pre-training phase, the model's total loss is a weighted average of the masked signal reconstruction loss and the lead classification loss. The reconstruction loss includes the signal loss between the reconstructed signal and the ECG signal from the single lead before the mask at a predetermined time. The lead classification loss includes the category loss between the predicted lead category and the lead category to which the input signal belongs. The loss function is calculated based on these two losses.

[0062] Specifically, the encoder is trained based on the reconstructed signal and the ECG signal of a single lead at a preset time, and based on the predicted lead and the ECG signal of the single lead at a preset time. This includes: training the encoder and the prediction module based on the difference between the reconstructed signal and the ECG signal of the single lead at a preset time and a first loss function, and training the encoder and the prediction module based on the difference between the predicted lead category and the lead category of the ECG signal of the single lead at a preset time and a second loss function.

[0063] As mentioned above, the mean square error (MSE) is used to measure the reconstructed signal. Compared with the original unmasked ECG signal The difference between them is denoted as This loss-driven model learns the temporal structure and physiological patterns of ECG waveforms. Cross-entropy loss is used to calculate the prediction results of the lead classification module. With real lead labels The error between them is denoted as This is to guide the model to capture the spatial characteristics of different leads.

[0064] Specifically, the encoder and prediction module are trained, including: determining the comprehensive loss function based on the weighted sum of the first loss function and the second loss function; and training the encoder and prediction module based on the comprehensive loss function and the difference.

[0065] The overall loss function is determined by the following formula:

[0066]

[0067]

[0068] Where Loss is the overall loss function. For the first loss function, Let be the second loss function, n be the sample size, T be the length of the mask signal, and λ∈[0,1] be an adjustable hyperparameter. For ECG signals with a preset time for a single lead. To reconstruct the signal, For the predicted lead category, The lead category to which the ECG signal with a preset time for a single lead belongs.

[0069] The model is trained using the loss function described above to obtain the trained encoder and prediction module.

[0070] Through the aforementioned multi-task joint optimization strategy, the model can explicitly model lead source information while recovering signal details, thereby learning a general ECG representation that combines temporal continuity and spatial discriminativeness, providing high-quality initialization features for fine-tuning of subsequent downstream tasks.

[0071] Step 160: Determine the single-lead signal features corresponding to the multi-lead ECG signal with a preset time based on the trained encoder, and fuse the single-lead signal features through the fusion module.

[0072] Based on the pre-trained model described above, which extracts deep features from each lead through an encoder, this application employs the following fine-tuning architecture: first, it adaptively fuses the features of multiple leads within the same time window to generate a unified global representation. This fused feature is then fed into a multi-task prediction head, simultaneously completing multiple tasks. This implementation, while preserving the local waveform features of each lead, explicitly models the collaborative relationships between multiple leads, enabling the model to comprehensively judge complex anomalies requiring multi-view support, significantly improving the consistency and reliability of diagnostic results. Thanks to the fusion module's independence from the number and order of leads, this fine-tuning framework can flexibly adapt to any lead data.

[0073] Specifically, the single-lead signal features corresponding to the multi-lead ECG signals at preset times are determined based on the trained encoder, and the single-lead signal features are fused through the fusion module. This includes: inputting the multi-lead ECG signals at preset times into the trained encoder, extracting the signal features corresponding to the preset times of each lead, and fusing the signal features corresponding to the preset times of each lead according to the fusion module.

[0074] As mentioned earlier, the ECG signal for the preset time in a multi-lead ECG can be the ECG signal of the first lead, the ECG signal of the second lead, and the ECG signal of the third lead after division within the multi-lead system. For example... Figure 3 The diagram shows the ECG signals of the first, second, and third leads after division within a three-lead ECG sequence. For example, a 10-second ECG segment.

[0075] The aforementioned fusion module refers to the adaptive multi-lead feature fusion module, which is used to extract robust and discriminative ECG features from any number and any order of lead inputs.

[0076] like Figure 3 As shown, using a 3-lead ECG signal as an example, each 10-second segment of the input ECG signal from each lead is processed by a pre-trained encoder with shared weights to independently extract the high-level semantic features of each lead. , This consists of three high-level semantic features: the first, the second, and the third. Each lead's features are then processed by an adaptive multi-lead feature fusion module to obtain the global fused features. This fusion module and method are compatible with heterogeneous data from various devices and scenarios.

[0077] It should be understood that the encoder mentioned above is the encoder trained in the single-lead ECG pre-training model obtained above. It is extracted separately as the encoder of the ECG fine-tuning model, and ECG signals from a multi-scenario fine-tuning database are used as input. The weights of the encoder are shared by all leads.

[0078] Specifically, the fusion module fuses the signal features corresponding to the preset time of each lead, including: calculating the signal features corresponding to the preset time of each lead according to the self-attention mechanism in the fusion module to determine the context enhancement features of each signal feature; determining the importance of each lead according to the context enhancement features and the learnable vector; determining the weight of each lead according to the importance; and fusing the context enhancement features corresponding to the lead according to the weight to obtain the fused features.

[0079] The adaptive multi-lead feature fusion module uses self-attention to enhance the context of features from each lead, modeling complex dependencies across leads and across time. Subsequently, a learnable global query vector is introduced to perform fine-grained importance evaluation and lead-level adaptive weighting on the enhanced features, generating fused features independent of lead configuration.

[0080] Specifically, the ECG signals of each lead in the multi-lead preset time are used as time terms; the signal features corresponding to the preset time of each lead are calculated according to the self-attention mechanism in the fusion module to determine the context enhancement features of each signal feature, including: calculating multiple time terms corresponding to the ECG signal of the same lead according to the self-attention mechanism to determine the context enhancement features of each signal feature.

[0081] As mentioned earlier, the acquired raw ECG signal is first divided into several consecutive short time segments of a specified length, denoted as tokens. These tokens correspond to preset times. For example, if an ECG signal contains 5000 sampling points, and each 25 points form a token, with these 25 points constituting a preset time, such as 10 seconds, then a total of L=200 tokens are obtained. This transforms the long signal into an ordered sequence of time-based tokens, which is beneficial for fine-grained tasks such as waveform localization and heartbeat classification. Then, features are extracted from the input N-lead ECG signal using a pre-trained encoder, resulting in feature Z. ,in, Let d be the real number field and d be the feature dimension.

[0082] It should be noted that in this embodiment, the division into several segments can be either a preset time overlapping division or a non-overlapping division. For overlapping division, the acquired signal can be segmented in an overlapping manner with a preset time of m seconds as the window length and a preset step size of t seconds as the step size, which is also the token division method.

[0083] To enhance the context awareness of features, the obtained feature Z is input into the self-attention module of the fusion module described above. This allows each token to dynamically pay attention to other tokens, thereby simultaneously capturing temporal evolution patterns and spatial complementarity, significantly improving the discriminative ability of local features. This process is achieved through the following calculation formula:

[0084]

[0085]

[0086] Where Q is the query vector, K is the key vector, and V is the value vector. Let T be the learnable projection matrix, T be the transpose matrix, and A be the attention weight matrix, where the elements in the matrix are... This represents the level of attention that the i-th token has towards the j-th token. This represents the enhanced lead characteristics.

[0087] The final result is context-enhanced features.

[0088] Specifically, the ECG signals of each lead in the multi-lead ECG signal segmented at a preset time are used as time terms. The importance of each lead is determined based on context enhancement features and learnable vectors. This includes: calculating the dot product of the context enhancement features and the learnable vector, where the context enhancement features correspond to the time terms of the same lead; determining the importance of the time terms corresponding to the same lead based on the dot product result; and performing average pooling along the time dimension to determine the importance of the corresponding lead and thus the importance of each lead.

[0089] As described above, after obtaining the context-enhanced feature H, in order to further extract the most valuable information for ECG analysis, this application introduces a learnable global query vector. This vector can dynamically assess the importance of each lead based on the characteristics of the current sample.

[0090] First, calculate the dot product score S of each of the above tokens and the global query vector using the following formula:

[0091] Among them, the dot product score matrix S This score indicates the importance of the nth lead in the l-th time segment, reflecting the correlation between this local ECG segment and the key interpretation patterns learned by the model. The degree of matching is then determined. Subsequently, the score is averaged along the time L dimension to obtain the global importance of each lead. It is determined by the following formula:

[0092] in, In the above dot product score matrix S , Let s be the global importance corresponding to the above.

[0093] That is, the global importance of each lead is determined according to the above method.

[0094] Specifically, the weights of each lead are determined based on importance, and the context enhancement features corresponding to the weighted leads are fused. This includes: normalizing based on importance to determine the weights of the corresponding leads; weighting and summing the context enhancement features corresponding to each lead along the lead dimension according to the weights to obtain the temporal fusion features; and average pooling the temporal fusion features along the time dimension to obtain the global fusion features.

[0095] As described above, softmax normalization is applied to the global importance vector s to obtain the weights used for lead-level fusion, and these weights are then assigned to the leads. Finally, these weights are used to perform a weighted summation of the enhanced features H along the lead dimension to generate the fused temporal features, which are determined by the following formula:

[0096]

[0097] Where w represents the normalization result described above. The fused temporal characteristics.

[0098] The fused temporal features retain the complete token-level temporal structure and can be used for subsequent tasks, such as waveform localization and heartbeat classification.

[0099] Furthermore, the fused feature is average-pooled along the time dimension L to obtain a global representation with fixed dimensions. This is used for subsequent quality grading and diagnostic identification. The global characterization is determined by the following formula. :

[0100] It should be noted that the above fusion module achieves unified modeling from local details to global judgment through a two-stage fusion mechanism, while ensuring that the model is invariant to any number and order of leads, effectively compatible with lead configurations under different devices or acquisition protocols.

[0101] This implementation method, through two-stage fusion, effectively simulates the multi-lead collaborative interpretation logic in clinical electrocardiogram diagnosis under the premise of disordered lead input data, significantly improving the model's generalization ability and diagnostic reliability in real complex scenarios.

[0102] This implementation provides a lead-independent adaptive multi-lead fusion mechanism that enables robust collaborative analysis of heterogeneous inputs. Addressing the issue of variable lead numbers and locations, it dynamically evaluates the discriminative contribution of each lead to the entire signal and performs weighted fusion without relying on prior lead information. This mechanism retains the independent analysis capability of individual leads to handle unknown lead systems, while automatically aggregating complementary information when multiple leads are available, improving the accuracy of localization and diagnosis.

[0103] Step 170: Input the fused features into multiple task prediction heads to obtain the corresponding prediction results, fine-tune the encoder based on the prediction results, train the multiple task prediction heads and the fusion module used for feature fusion.

[0104] Among them, the multiple tasks corresponding to the multiple task prediction heads include the signal quality classification task of ECG signals, the waveform localization task of ECG signals, the heartbeat classification task of ECG signals, and the diagnostic recognition task of ECG signals.

[0105] The fused global representation features are input in parallel to multiple task-specific heads to achieve end-to-end multi-task joint learning.

[0106] like Figure 3 As shown, the aforementioned global representation features are fed into the multi-task prediction head through a multi-lead feature fusion module, simultaneously completing tasks such as signal quality grading, waveform localization, heartbeat classification, and diagnostic identification. This implementation, while preserving the local waveform features of each lead, explicitly models the collaborative relationships between multiple leads, enabling the model to comprehensively judge complex anomalies requiring multi-perspective support, significantly improving the consistency and reliability of diagnostic results. Thanks to the fusion module's independence from the number and order of leads, this fine-tuning framework can flexibly adapt to data from any lead.

[0107] The process includes several key components: signal quality grading (using a three-classifier to determine the quality level of the entire ECG signal, such as poor, acceptable, or good); waveform localization (for accurately identifying the timing boundaries of the P wave, QRS complex, and T wave); heartbeat classification (for fine-grained classification of each detected heartbeat, such as atrial premature beats or ventricular pacing); and diagnostic identification (further subdivided into arrhythmia identification, waveform abnormality detection, and cardiovascular disease diagnosis). Arrhythmia identification includes atrial fibrillation and atrial flutter; waveform abnormality detection includes ST segment elevation and T wave inversion; and cardiovascular disease diagnosis includes myocardial infarction and left ventricular hypertrophy.

[0108] Waveform localization is used to determine the basic structural location of heartbeats, providing temporal boundary constraints for subsequent analysis. Heartbeat classification classifies each heartbeat individually based on this structural result. Diagnostic identification further makes a holistic clinical judgment based on the heartbeat sequence. These three processes form a hierarchical relationship from structural analysis to beat-by-beat analysis to overall diagnosis. Signal quality grading is used to characterize the reliability of the input signal and provides a credibility reference for the overall analysis results. This implementation, based on reusing pre-trained representation capabilities, efficiently supports diverse clinical analysis needs through unified fusion features, balancing model efficiency and functional integrity.

[0109] This implementation constructs a complete and interpretable output, establishing a clinically reliable decision support closed loop, and simultaneously outputting results for quality level, waveform localization, heartbeat classification, and diagnostic identification. The signal quality level directly provides users with objective evidence of data reliability, serving as a credibility threshold to suppress low-quality false positives. Localization information supports retrospective verification, effectively avoiding misleading results caused by noise interference, and significantly improving the model's safety and clinical applicability in real-world, complex environments.

[0110] Specifically, the encoder is fine-tuned based on the prediction results, multiple task prediction heads are trained, and a fusion module for feature fusion is trained. This includes: fine-tuning the encoder based on the prediction results, actual results, and corresponding loss functions for multiple tasks, training multiple task prediction heads, and training a fusion module for feature fusion.

[0111] The signal quality classification task prediction head consists of an MLP composed of multiple fully connected layers, as described above. The MLP is then used for classification. For example, it classifies students into Excellent, Acceptable, and Poor, with the corresponding loss function being cross-entropy.

[0112] The waveform localization branch's prediction head includes a TCN-based temporal feature enhancement module, a ConvTranspose1D-based temporal resolution recovery module, and a 1×1 convolution-based waveform classification prediction module. The waveform classification prediction module can perform four classifications: P-wave, QRS wave, T-wave, and background. This branch first enhances the local temporal information of the encoder output. Then, high-resolution temporal features are recovered, and P-waves, QRS complexes, and T-waves are classified at each time point. Finally, the start and end boundaries of each waveform are determined based on the continuous regional changes of the category. The corresponding loss function includes weighted cross-entropy.

[0113] The specific structure of the prediction head for heartbeat classification includes a fully connected layer. Each token feature is classified into multiple categories after a fully connected layer, including but not limited to atrial premature beats, ventricular pacing, normal, non-cardiac beats, etc., and the corresponding loss function is cross-entropy.

[0114] The specific structure of the prediction head for diagnostic identification tasks includes a fully connected layer, namely... Multi-label classification is performed, including but not limited to the identification of arrhythmias such as atrial fibrillation and atrial flutter, the detection of waveform abnormalities such as ST segment elevation and T wave inversion, and the diagnosis of cardiovascular diseases such as myocardial infarction and left ventricular hypertrophy. The corresponding loss function is BCEWithLogitsLoss.

[0115] Based on the loss functions corresponding to the prediction heads of each task, the joint function is jointly optimized to update or fine-tune the parameters of the encoder, fusion module and each task branch respectively.

[0116] During the fine-tuning phase, the input ECG signal is fed into each task branch after passing through the encoder and fusion module. The output results of each branch are then jointly optimized based on the differences between the output results and the corresponding labels. The parameters of the encoder, fusion module, and each task branch are updated in an end-to-end manner to achieve multi-task collaborative learning.

[0117] Through the collaboration of self-supervised pre-training and multi-task fine-tuning, joint modeling of local waveforms and global semantics is performed to improve model performance and logical consistency. In the pre-training stage, signal reconstruction and lead identification are jointly optimized to learn the physiological commonalities and spatial differences of cardiac electrical activities from the perspective of different leads. In the fine-tuning stage, four tasks including quality grading, waveform localization, heart beat classification and diagnosis recognition are optimized synchronously. Through shared feature representation, waveform localization provides temporal anchor points for classification, and diagnosis recognition reversely constrains the rationality of local analysis, thereby improving accuracy in complex scenarios.

[0118] Step 180: generating a prediction model according to the fine-tuning result and the training result, and performing multi-task prediction on the electrocardiogram signal to be tested to obtain a prediction result.

[0119] Generating a final prediction model based on the foregoing content, which includes the fine-tuned encoder, the trained multi-lead feature fusion module and each corresponding task head.

[0120] The generated prediction model takes an m-second single-lead ECG fragment as the basic processing unit, that is, the ECG signal to be tested. Wherein, zero-padding is performed on signals shorter than m seconds, for over-long signals, sliding segmentation with an m-second window and a t-second step size where t<m is adopted, and prediction results of overlapping regions are fused to ensure temporal consistency. For multi-lead input, features are extracted from each lead after the same preprocessing, and then a lead-independent adaptive multi-lead feature fusion module generates a global representation, and uniformly outputs multi-task results including quality grading, waveform localization, heart beat classification and clinical diagnosis.

[0121] The prediction process does not need to rely on the prior knowledge of lead systems, can seamlessly adapt to various configurations such as 12-lead, 3-lead, and single-lead, and effectively supports robust ECG analysis under heterogeneous devices.

[0122] Specifically, generating a prediction model according to the fine-tuning result and the training result, and performing multi-task prediction on the electrocardiogram signal to be tested to obtain a prediction result includes: acquiring the electrocardiogram signal to be tested, and dividing the electrocardiogram signal to be tested into electrocardiogram signals of preset duration; inputting the divided electrocardiogram signals into the prediction model to obtain prediction results of each task.

[0123] In the inference stage of the aforementioned predictive model, since the model takes a single-lead m-second segment as input, when dealing with data of shorter or longer durations than m seconds, or data containing multiple leads, a unified data alignment and fusion strategy is needed to generate the final analysis results. As mentioned earlier, for single-lead signals, signals shorter than m seconds are padded with zeros at the end to align their length to m seconds. For ultra-long time series signals > m seconds, to fully capture local waveform details and consider contextual information, a sliding window strategy is used. The original signal is segmented with an m-second window length and a t-second step size to generate a series of continuous segments. Each segment is independently input into the fine-tuned model to obtain the predicted probabilities for each task, such as quality grading, waveform localization, heartbeat classification, and diagnostic identification. Subsequently, the prediction results of the overlapping areas on the time axis are probability averaged to smooth boundary effects and improve temporal consistency, ultimately integrating them to obtain a unified analysis result for the entire signal.

[0124] For multi-lead signals, each lead is first preprocessed into a standard m-second segment using the same method as the single-lead signal. If the segment is too long, it is slidably segmented; if it is too short, it is padded with zeros. These segments are then fed into the model to extract high-level features. Subsequently, using a lead-independent adaptive multi-lead feature fusion module, the features of each lead within the same time window are adaptively weighted and fused to generate a more discriminative global representation. Based on this fused feature, the final multi-task prediction result is output.

[0125] This implementation method does not rely on prior knowledge of the lead system and can flexibly adapt to different numbers and types of lead combinations, ensuring the model's generalization ability on heterogeneous device data.

[0126] It should be noted that this application presents a general ECG analysis framework driven by a single lead and centered on multi-level fusion, addressing the adaptability issues across devices, scenarios, and unknown leads. The final prediction model uses a single lead segment as the minimum input, extracting representations through a unified encoder. During inference, data of any number of leads and any length can be adaptively processed through multi-level strategies in both the time and lead dimensions. Even when faced with lead systems not encountered during training, it can still output reliable results stably, achieving the goal of widespread applicability through a single training iteration.

[0127] Furthermore, this application can be applied to resting 12-lead intelligent electrocardiogram (ECG) analysis in hospital settings to assist doctors in interpreting ECGs. Firstly, the raw ECG signal data can be obtained by connecting to the ECG machine's data feedback interface, and then prediction can be performed using the aforementioned method.

[0128] By connecting to a Holter device, ECG signals can be collected in real time during long-term dynamic ECG monitoring, which can help doctors quickly identify and locate abnormalities.

[0129] Daily ECG screening using wearable devices such as smartwatches or ECG patches can be applied to home health monitoring scenarios. After the user wears the device at home, ECG signals are automatically collected. Using the method provided by this invention, users are easily reminded to seek medical attention promptly, promoting early detection and intervention management of diseases.

[0130] like Figure 4 As shown, this application also proposes a multi-task prediction device for electrocardiogram signals, applied to service equipment. The device 400 includes: The acquisition module 410 is used to acquire electrocardiogram (ECG) signals under different scenarios and divide the ECG signals to obtain ECG signals for a preset time.

[0131] The masking module 420 is used to mask the ECG signal of a single lead for a preset time and input it into the encoder to obtain the corresponding signal characteristics.

[0132] The reconstruction module 430 is used to reconstruct the signal based on the signal characteristics and the decoder to obtain the reconstructed signal.

[0133] The first prediction module 440 is used to obtain the lead to which the signal features belong based on the signal features and the prediction module.

[0134] The training module 450 is used to train the encoder based on the reconstructed signal and the ECG signal of the single lead at a preset time, and based on the predicted lead and the lead to which the ECG signal of the single lead at the preset time belongs.

[0135] The determination module 460 is used to determine the single-lead signal features corresponding to the multi-lead ECG signal with a preset time based on the trained encoder, and to fuse the single-lead signal features through the fusion module.

[0136] The fine-tuning module 470 is used to input the fused features into multiple task prediction heads respectively to obtain corresponding prediction results, and to fine-tune the encoder based on the prediction results, train the multiple task prediction heads, and train the fusion module used for feature fusion.

[0137] The second prediction module 480 is used to generate a prediction model based on the fine-tuning results and training results, so as to perform multi-task prediction on the ECG signal to be tested and obtain the prediction results.

[0138] The acquisition module 410 includes an acquisition unit for acquiring multi-lead electrocardiogram (ECG) signals in a resting scenario and multi-lead ECG signals in a preset long-range dynamic scenario, and using the acquired ECG signals as training data for training the encoder; acquiring multi-lead ECG signals in a resting scenario, multi-lead ECG signals in a preset long-range dynamic scenario, ECG signals from a smart device, and ECG signals from an ECG patch, and using the acquired ECG signals as fine-tuning data for fine-tuning the encoder, training the multiple task prediction heads, and training the fusion module for feature fusion.

[0139] In addition, the acquisition module 410 also includes: a splitting unit, used to split the acquired first ECG signal into first ECG signals of preset time according to a preset time; to split the split first ECG signal into first ECG signals of single lead at a preset time based on a single lead, wherein the first ECG signal refers to the signal used as training data; and to split the acquired second ECG signal into second ECG signals of preset time according to a preset time, wherein the second ECG signal refers to the signal used as fine-tuning data.

[0140] Specifically, the masking module 420 includes: a masking unit for performing a preset number of random masks on the electrocardiogram signal; and an input unit for inputting the masked electrocardiogram signal into the encoder and obtaining the corresponding signal features based on the self-attention mechanism and feedforward network in the encoder.

[0141] Specifically, the first prediction module 440 is used to input the signal features into the prediction module and obtain the lead category through the multilayer perceptron (MLP) in the prediction module.

[0142] Specifically, the training module 450 is used to train the encoder and the prediction module based on the difference between the reconstructed signal and the ECG signal of the single lead at a preset time and a first loss function, and based on the difference between the predicted lead category and the lead category of the ECG signal of the single lead at a preset time and a second loss function.

[0143] Specifically, the training module 450 includes: a determination unit, used to determine a comprehensive loss function based on a weighted sum of the first loss function and the second loss function; and a training unit, used to train the encoder and the prediction module based on the comprehensive loss function and the difference.

[0144] The overall loss function is determined by the following formula:

[0145]

[0146]

[0147] Where Loss is the overall loss function. For the first loss function, Let be the second loss function, n be the sample size, T be the length of the mask signal, and λ be an adjustable hyperparameter. For ECG signals with a preset time for a single lead. To reconstruct the signal, For the predicted lead category, The lead category to which the ECG signal with a preset time for a single lead belongs.

[0148] Specifically, the determining module 460 includes: an extraction unit, used to input the ECG signals of multiple leads for a preset time into the trained encoder and extract the signal features corresponding to the preset time of each lead; and a fusion unit, used to fuse the signal features corresponding to the preset time of each lead according to the fusion module.

[0149] Specifically, the fusion unit is used to calculate the signal features corresponding to preset times of each lead according to the self-attention mechanism in the fusion module, and determine the context enhancement features of each signal feature; determine the importance of each lead according to the context enhancement features and the learnable vector; determine the weight of each lead according to the importance, and fuse the context enhancement features corresponding to the lead according to the weight to obtain the fused features.

[0150] Specifically, the ECG signals of each lead in the multi-lead ECG signal with a preset time are used as time terms; specifically, the fusion unit is used to calculate multiple time terms corresponding to the ECG signal of the same lead according to the self-attention mechanism to determine the context enhancement features of each signal feature.

[0151] Specifically, the ECG signals of each lead in the multi-lead ECG signal with a preset time are used as time terms. The fusion unit calculates the dot product of the context-enhanced features and the learnable vector, where the context-enhanced features correspond to the time terms of the same lead. The importance of the time terms corresponding to the same lead is determined based on the dot product result. The importance is then averaged along the time dimension to determine the importance of the corresponding lead, and the importance of each lead is determined.

[0152] Specifically, the fusion unit is used to normalize according to the importance to determine the weight of the corresponding lead; to perform weighted summation of the context enhancement features corresponding to each lead along the lead dimension according to the weight to obtain the temporal fusion features; and to perform average pooling of the temporal fusion features along the time dimension to obtain the global fusion features.

[0153] Among them, the multiple tasks corresponding to the multiple task prediction heads include the signal quality classification task of ECG signals, the waveform localization task of ECG signals, the heartbeat classification task of ECG signals, and the diagnostic recognition task of ECG signals.

[0154] Specifically, the fine-tuning module 470 is used to fine-tune the encoder based on the prediction results, actual results and corresponding loss functions of multiple tasks, to train the prediction heads of the multiple tasks and to train the fusion module for feature fusion.

[0155] Specifically, the second prediction module 480 includes: a division unit, used to acquire the ECG signal to be tested and divide the ECG signal to be tested into ECG signals of a preset time; and a prediction unit, used to input the divided ECG signals into the prediction model to obtain the prediction results of each task.

[0156] This will not be elaborated upon further here; for any content that has not been covered in detail, please refer to the content mentioned above.

[0157] like Figure 5 As shown, this application also proposes a device 500, including: a memory 501 and a processor 502; the memory 501 is used to store a computer program; the processor 502 is used to execute the computer program for: Collect electrocardiogram (ECG) signals under different scenarios, and divide the ECG signals into ECG signals for a preset time. The ECG signal of a single lead for a preset time is masked and input into the encoder to obtain the corresponding signal characteristics; The reconstructed signal is obtained by reconstructing the signal based on the signal characteristics and the decoder. The lead to which the signal characteristics belong is obtained based on the signal characteristics and the prediction module; The encoder is trained based on the reconstructed signal and the ECG signal of the single lead at the preset time, as well as based on the predicted lead and the lead to which the ECG signal of the single lead at the preset time belongs; The single-lead signal features corresponding to the multi-lead ECG signal with a preset time are determined based on the trained encoder, and the single-lead signal features are fused through the fusion module. The fused features are input into multiple task prediction heads to obtain corresponding prediction results. The encoder is then fine-tuned based on the prediction results, and the multiple task prediction heads and the fusion module used for feature fusion are trained. Based on the fine-tuning results and training results, a prediction model is generated to perform multi-task prediction of the ECG signal to be tested and obtain the prediction results.

[0158] This will not be elaborated upon further here; for any content that has not been covered in detail, please refer to the content mentioned above.

[0159] This application also proposes a computer-readable storage medium storing a computer program, which, when executed by one or more processors, causes the one or more processors to implement the steps in method 100. Further details are omitted here; please refer to the foregoing descriptions for any omissions or omissions.

[0160] Furthermore, some processes described in the above embodiments and accompanying drawings include multiple operations appearing in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or they may be executed in parallel. The operation numbers, such as 101, 102, etc., are merely used to distinguish different operations and do not represent any execution order. Additionally, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first" and "second" in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.

[0161] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0162] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of a necessary general-purpose hardware platform, or by a combination of hardware and software. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a computer product. The present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0163] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable multimedia data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable multimedia data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0164] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable multimedia data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0165] These computer program instructions may also be loaded onto a computer or other programmable multimedia data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0166] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0167] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0168] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0169] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A multi-task prediction method for electrocardiogram (ECG) signals, characterized in that, include: Collect electrocardiogram (ECG) signals under different scenarios, and divide the ECG signals into ECG signals for a preset time. The ECG signal of a single lead for a preset time is masked and input into the encoder to obtain the corresponding signal characteristics; The reconstructed signal is obtained by reconstructing the signal based on the signal characteristics and the decoder. The lead to which the signal characteristics belong is obtained based on the signal characteristics and the prediction module; The encoder is trained based on the reconstructed signal and the ECG signal of the single lead at the preset time, as well as based on the predicted lead and the lead to which the ECG signal of the single lead at the preset time belongs; The single-lead signal features corresponding to the multi-lead ECG signal with a preset time are determined based on the trained encoder, and the single-lead signal features are fused through the fusion module. The fused features are input into multiple task prediction heads to obtain corresponding prediction results. The encoder is then fine-tuned based on the prediction results, and the multiple task prediction heads and the fusion module used for feature fusion are trained. Based on the fine-tuning results and training results, a prediction model is generated to perform multi-task prediction of the ECG signal to be tested and obtain the prediction results.

2. The method according to claim 1, characterized in that, The acquisition of electrocardiogram (ECG) signals under different scenarios includes: Collect multi-lead electrocardiogram (ECG) signals in a resting scenario and in a preset long-range dynamic scenario, and use the collected ECG signals as training data for training the encoder. The system collects multi-lead ECG signals in a resting scenario, multi-lead ECG signals in a preset long-range dynamic scenario, ECG signals from smart devices, and ECG signals from ECG patches. The collected ECG signals are used as fine-tuning data for fine-tuning the encoder, training the multiple task prediction heads, and training the fusion module for feature fusion.

3. The method according to claim 1 or 2, characterized in that, The step of dividing the electrocardiogram (ECG) signal into ECG signals of a preset time includes: The first electrocardiogram (ECG) signal collected is split into first ECG signals at preset times according to the preset time. Based on a single lead, the first ECG signal after splitting is divided into a first ECG signal of a single lead at a preset time. The first ECG signal refers to the signal used as training data. The acquired second ECG signal is split into second ECG signals with preset time according to the preset time. The second ECG signal refers to the signal used as fine-tuning data.

4. The method according to claim 1, characterized in that, The process of masking a single-lead ECG signal for a preset time and inputting it into an encoder to obtain the corresponding signal features includes: Apply a preset number of random masks to the electrocardiogram signal; The masked ECG signal is input to the encoder, and the corresponding signal features are obtained based on the self-attention mechanism and feedforward network in the encoder.

5. The method according to claim 1, characterized in that, The step of obtaining the lead to which the signal features belong based on the signal features and the prediction module includes: The signal features are input into the prediction module, and the lead category is obtained through the multilayer perceptron (MLP) in the prediction module.

6. The method according to claim 1, characterized in that, The step of training the encoder based on the reconstructed signal and the ECG signal of the single lead at a preset time, and based on the predicted lead and the lead to which the ECG signal of the single lead at the preset time belongs, includes: The encoder and prediction module are trained based on the difference between the reconstructed signal and the ECG signal of the single lead at the preset time, and a first loss function; and based on the difference between the predicted lead category and the lead category of the ECG signal of the single lead at the preset time, and a second loss function.

7. The method according to claim 6, characterized in that, The training of the encoder and prediction module includes: The comprehensive loss function is determined by a weighted sum of the first loss function and the second loss function; The encoder and prediction module are trained based on the comprehensive loss function and the difference.

8. The method according to claim 7, characterized in that, The comprehensive loss function is determined by the following formula: Where Loss is the overall loss function. For the first loss function, Let be the second loss function, n be the sample size, T be the length of the mask signal, and λ be an adjustable hyperparameter. For ECG signals with a preset time for a single lead. To reconstruct the signal, For the predicted lead category, The lead category to which the ECG signal with a preset time for a single lead belongs.

9. The method according to claim 1, characterized in that, The step of determining the single-lead signal features corresponding to the multi-lead ECG signal at a preset time based on the trained encoder, and fusing the single-lead signal features through a fusion module, includes: The ECG signals of multiple leads at preset times are input into the trained encoder, and the signal features corresponding to each lead at preset times are extracted. The fusion module fuses the signal features corresponding to the preset time of each lead.

10. The method according to claim 9, characterized in that, The step of fusing the signal features corresponding to the preset time of each lead according to the fusion module includes: The signal features corresponding to the preset time of each lead are calculated based on the self-attention mechanism in the fusion module, and the context enhancement features of each signal feature are determined. The importance of each lead is determined based on the context-enhanced features and learnable vectors. The weights of each lead are determined based on the importance, and the context enhancement features corresponding to the leads are fused according to the weights to obtain fused features.

11. The method according to claim 10, characterized in that, The ECG signals of each lead in the multi-lead ECG signal with a preset time are used as time terms. The step of calculating the signal features corresponding to preset times for each lead based on the self-attention mechanism in the fusion module, and determining the context enhancement features of each signal feature, includes: The self-attention mechanism is used to calculate multiple time terms corresponding to the ECG signal in the same lead to determine the context enhancement features of each signal feature.

12. The method according to claim 10, characterized in that, The ECG signals of each lead in the multi-lead ECG signal with a preset time are used as time terms. The step of determining the importance of each lead based on the context-enhanced features and learnable vectors includes: Calculate the dot product of the context-enhanced feature and the learnable vector, wherein the context-enhanced feature corresponds to the temporal terminology of the same lead; The importance of time terms corresponding to the same lead is determined based on the dot product results. The importance is averaged along the time dimension to determine the importance of the corresponding lead, and the importance of each lead is determined.

13. The method according to claim 10, characterized in that, The step of determining the weight of each lead based on the importance, and fusing the context enhancement features corresponding to the leads based on the weights, includes: Normalization is performed based on the importance level to determine the weight of the corresponding lead; Based on the weights, the context enhancement features corresponding to each lead are weighted and summed along the lead dimension to obtain the temporal fusion features; The temporal fusion features are averaged along the time dimension to obtain global fusion features.

14. The method according to claim 1, characterized in that, The multiple tasks corresponding to the multiple task prediction heads include the signal quality classification task of ECG signals, the waveform localization task of ECG signals, the heartbeat classification task of ECG signals, and the diagnostic recognition task of ECG signals.

15. The method according to claim 1, characterized in that, The step of fine-tuning the encoder based on the prediction results, training the multiple task prediction heads, and training the fusion module for feature fusion includes: Based on the prediction results, actual results, and corresponding loss functions for multiple tasks, the encoder is fine-tuned, the prediction heads for the multiple tasks are trained, and the fusion module for feature fusion is trained.

16. The method according to claim 1, characterized in that, The step of generating a prediction model based on the fine-tuning results and training results to perform multi-task prediction of the ECG signal under test and obtain prediction results includes: Acquire the ECG signal to be measured, and divide the ECG signal to be measured into ECG signals of preset time; The segmented electrocardiogram signals are input into the prediction model to obtain the prediction results for each task.

17. A multi-task prediction device for electrocardiogram signals, characterized in that, include: The acquisition module is used to acquire electrocardiogram (ECG) signals under different scenarios and divide the ECG signals into ECG signals for a preset time. The masking module is used to mask the ECG signal of a single lead for a preset time and input it into the encoder to obtain the corresponding signal characteristics; The reconstruction module is used to reconstruct the signal based on the signal characteristics and the decoder to obtain the reconstructed signal; The first prediction module is used to obtain the lead to which the signal features belong based on the signal features and the prediction module. The training module is used to train the encoder based on the reconstructed signal and the ECG signal of the single lead at a preset time, and based on the predicted lead and the lead to which the ECG signal of the single lead at the preset time belongs. The determination module is used to determine the single-lead signal features corresponding to the multi-lead ECG signal at a preset time based on the trained encoder, and to fuse the single-lead signal features through the fusion module. The fine-tuning module is used to input the fused features into multiple task prediction heads respectively to obtain corresponding prediction results, and to fine-tune the encoder based on the prediction results, train the multiple task prediction heads, and train the fusion module used for feature fusion. The second prediction module is used to generate a prediction model based on the fine-tuning results and training results, so as to perform multi-task prediction on the ECG signal to be tested and obtain the prediction results.

18. A device, characterized in that, include: Memory, processor; The memory is used to store computer programs; The processor is configured to execute the computer program for: Collect electrocardiogram (ECG) signals under different scenarios, and divide the ECG signals into ECG signals for a preset time. The ECG signal of a single lead for a preset time is masked and input into the encoder to obtain the corresponding signal characteristics; The reconstructed signal is obtained by reconstructing the signal based on the signal characteristics and the decoder. The lead to which the signal characteristics belong is obtained based on the signal characteristics and the prediction module; The encoder is trained based on the reconstructed signal and the ECG signal of the single lead at the preset time, as well as based on the predicted lead and the lead to which the ECG signal of the single lead at the preset time belongs; The single-lead signal features corresponding to the multi-lead ECG signal with a preset time are determined based on the trained encoder, and the single-lead signal features are fused through the fusion module. The fused features are input into multiple task prediction heads to obtain corresponding prediction results. The encoder is then fine-tuned based on the prediction results, and the multiple task prediction heads and the fusion module used for feature fusion are trained. Based on the fine-tuning results and training results, a prediction model is generated to perform multi-task prediction of the ECG signal to be tested and obtain the prediction results.

19. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by one or more processors, it causes the one or more processors to perform the steps of the method according to claims 1-16.