Modeling and training method, device and medium for twelve-lead electrocardiogram signal
By constructing ECG signals as a two-dimensional grid and employing hierarchical windowed self-attention computation, the problems of lead structure information collapse and insufficient cross-lead feature fusion were solved, achieving stable and efficient twelve-lead ECG signal modeling, and improving the model's multi-scale feature expression and clinical application effect.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HENAN ACADEMY OF MEDICAL SCIENCES
- Filing Date
- 2026-03-18
- Publication Date
- 2026-06-30
AI Technical Summary
Existing deep learning modeling of 12-lead ECG signals suffers from problems such as easy collapse of lead structure information, insufficient fusion of cross-lead features, and easy introduction of false connections in time boundary processing.
The ECG signal is constructed as a two-dimensional grid input, and a hierarchical windowed self-attention computation is adopted. The downsampling operation is restricted in the lead axis direction and downsampling is performed only in the time axis direction. An occlusion strategy is introduced during the model training stage, and the encoding and reconstruction are performed through a windowed self-attention network.
It effectively avoids the dimensional collapse of the lead axis, improves the sufficiency of cross-lead feature fusion and model stability, enhances the multi-scale modeling ability and clinical interpretability of ECG signals, and improves the generalization ability of the model.
Smart Images

Figure CN122296905A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of medical decision support and deep learning technology, and in particular to a method, device and medium for modeling and training twelve-lead electrocardiogram signals. Background Technology
[0002] Electrocardiography (ECG) records the voltage-time curve of the heart's electrical activity using electrodes on the body surface. It is a commonly used clinical examination method to assist in the diagnosis of arrhythmias and structural heart disease. However, traditional manual interpretation relies on clinical experience, which has problems such as high workload, strong subjectivity, and easy to miss hidden abnormalities. Therefore, using deep learning to achieve automatic classification and auxiliary diagnosis of ECGs has become an important research direction.
[0003] In existing deep learning modeling methods for 12-lead ECG signals, the fusion and feature extraction of multi-lead information face numerous challenges. On the one hand, current techniques typically flatten multi-lead ECG signals into a one-dimensional long sequence or employ a post-fusion approach involving lead attention weighting, independent processing of multiple branches, and subsequent splicing. This not only significantly increases computational overhead and leads, making it easy to confuse time and lead semantics, but also makes it difficult to effectively extract joint pattern information across leads within the same local time segment. On the other hand, in existing hierarchical network structures, repeated downsampling of input features in the spatial dimension can easily lead to rapid reduction or even collapse of the originally small-dimensional lead axes, resulting in irreversible loss of cross-lead structural information. Furthermore, when applying windowed attention mechanisms, improper handling of temporal boundaries can easily introduce non-physical cross-boundary pseudo-connections. Simultaneously, in the pre-training stage of unlabeled data, traditional random discrete occlusion can easily lead the model to recover speculatively through simple nearest-neighbor interpolation, failing to force the model to deeply learn cardiac cycle patterns and cross-lead consistency features.
[0004] Currently, there is a lack of a good technology that can effectively solve the above problems.
[0005] The information disclosed in this background section is intended only to enhance the understanding of the overall background of the invention and should not be construed as an admission or in any way implying that the information constitutes prior art known to those skilled in the art. Summary of the Invention
[0006] To address the shortcomings of existing technologies, the present invention aims to provide a modeling and training method, device, and medium for 12-lead electrocardiogram (ECG) signals, thereby solving technical problems in traditional models such as the easy collapse of lead structure information during downsampling, insufficient fusion of translead features, and the easy introduction of spurious connections in time boundary processing. The technical solution of the present invention is as follows:
[0007] On one hand, the present invention provides a modeling method for 12-lead electrocardiogram (ECG) signals. The modeling method includes: acquiring 12-lead ECG signals and constructing the ECG signals as a two-dimensional grid input consisting of lead axes and time axes; performing two-dimensional block embedding processing on the two-dimensional grid input to generate corresponding embedded feature grids; performing hierarchical windowed self-attention computation on the embedded feature grids, wherein the two-dimensional window of the attention computation is set to cover all lead dimensions in the lead axis direction, and window shifting operations are performed only along the time axis direction between adjacent attention layers; performing hierarchical downsampling on the embedded feature grids to obtain multi-scale feature grids, wherein the number of downsampling operations in the lead axis direction is limited, and after reaching the number of downsampling operations, subsequent downsampling operations are performed only along the time axis direction; extracting global representations based on the finally obtained multi-scale feature grids and outputting corresponding prediction results.
[0008] Optionally, constructing the ECG signal as a two-dimensional grid input consisting of lead axes and time axes includes: when there are missing leads in the twelve-lead ECG signal, setting the waveform corresponding to the missing lead to a preset fill value and generating a missing lead identifier; the missing lead identifier is used to perform attention suppression on the missing lead block in the windowed self-attention calculation.
[0009] Optionally, performing two-dimensional block embedding processing on the two-dimensional mesh input includes: using block size The circuit is divided into blocks on the lead axis and time axis, where... When the length of the time axis cannot be... During division, the two-dimensional grid input is filled along the time axis; the step of performing a window shift operation only along the time axis between adjacent attention layers includes: the shift amount of the window shift operation is... ,in The time axis width of the two-dimensional window is defined, and a boundary mask is generated to suppress feature pairs that cross the window boundary after shifting from participating in the self-attention calculation.
[0010] Optionally, the subsequent downsampling operation is performed only along the time axis direction, including: employing merging rules. Two adjacent feature blocks along the time axis are merged, and a linear mapping is performed on the merged features to obtain a downsampled time axis feature grid; the merging rule This indicates that the merging factor in the lead axis direction is 1 and the merging factor in the time axis direction is 2.
[0011] Optionally, before performing the hierarchical windowed self-attention calculation, the modeling method further includes: obtaining tabular features corresponding to the twelve-lead ECG signal; and generating channel-level scaling parameters based on the tabular features. With offset parameter For the channel features of the embedded feature grid Perform conditional modulation; the conditional modulation satisfies:
[0012]
[0013] in This indicates element-wise multiplication.
[0014] On the other hand, the present invention also provides a training method for modeling 12-lead electrocardiogram signals. The training method includes: acquiring training samples and generating corresponding embedded feature grids; selecting continuous intervals along the time axis on the embedded feature grids and performing occlusion operations on the regions within the continuous intervals that cover all blocks along the lead axis; inputting the unoccluded blocks into a preset windowed self-attention network for encoding, and reconstructing the occluded blocks based on the encoded features; updating the model parameters using the error between the reconstruction result and the target representation as a loss function, and using the windowed self-attention network as an encoding network for downstream tasks after training is completed.
[0015] Optionally, the step of selecting a continuous interval to perform the occlusion operation includes: the time span of the continuous interval is 0.3 seconds to 1.0 seconds, and the proportion of the occluded blocks in each training sample to the total number of blocks in the embedded feature grid is 30% to 70%.
[0016] Optionally, the target representation is an occluded block embedded in the embedded feature grid, or a feature vector after the embedded vector has been processed by at least one layer of windowed self-attention network, and the target representation is not the original ECG sampling point sequence.
[0017] On the other hand, the present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the computer program, when executed by the processor, implements the modeling method or the training method.
[0018] On the other hand, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the modeling method or the training method described above.
[0019] The beneficial effects of this invention are as follows:
[0020] This invention effectively avoids the irreversible spatial dimension collapse caused by conventional pooling mechanisms when processing small-dimensional features by strictly limiting the number of downsampling operations along the lead axis during the hierarchical downsampling stage, and then performing downsampling only along the time axis after reaching the limit. This asymmetric restricted downsampling strategy allows the original spatial structure information of the twelve leads to be persistently retained in the deep network, greatly improving the stability of multi-scale modeling and the clinical interpretability of translead feature expression.
[0021] Meanwhile, this invention constructs the ECG signal as a two-dimensional feature grid and, when setting the two-dimensional window for attention calculation, ensures that it covers all lead dimensions along the lead axis. This native two-dimensional structured design enables the model to directly and synchronously acquire the correlation information of all leads within each local time segment, accurately capturing the joint patterns of consistency and difference across leads, and significantly improving the sufficiency of multi-lead feature fusion.
[0022] Furthermore, this invention employs a window shifting operation performed only along the time axis, significantly reducing the massive computational and memory overhead of traditional global attention mechanisms. Simultaneously, in conjunction with a boundary masking mechanism to suppress cross-window boundary feature pairs, it completely eliminates the loopback or padding false connections that shifting operations easily introduce at time boundaries, ensuring the physical rationality of time-series feature interactions.
[0023] Finally, during the model training phase, this invention introduces an occlusion strategy that selects continuous intervals along the time axis and covers all blocks along the lead axis. This mechanism breaks through the limitations of traditional random discrete occlusion, forcing the network to delve deeper into the global rhythmic patterns of the cardiac cycle and the strongly coupled electrophysiological characteristics across leads when local shortcut information is unavailable. This provides highly representative underlying weights for downstream fine-tuning, significantly enhancing the model's generalization ability when faced with complex data distribution variations. Attached Figure Description
[0024] Figure 1 This is a flowchart illustrating a modeling method for twelve-lead electrocardiogram signals provided in an embodiment of the present invention.
[0025] Figure 2 This is a flowchart illustrating a training method for modeling twelve-lead electrocardiogram signals provided in an embodiment of the present invention.
[0026] Figure 3 This is a complete execution flowchart of the twelve-lead electrocardiogram signal modeling method of the present invention. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only for explaining the invention and are not intended to limit the invention; that is, the described embodiments are merely some embodiments of the invention, and not all embodiments. The components of the embodiments of the invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0028] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0029] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0030] As mentioned earlier, existing deep learning modeling methods for 12-lead ECG signals face numerous challenges in the fusion and feature extraction of multi-lead information. On one hand, current techniques typically flatten multi-lead ECG signals into a one-dimensional long sequence or employ a post-fusion approach involving lead attention weighting, independent processing of multiple branches, and subsequent splicing. This not only significantly increases computational overhead and leads to confusion between temporal and lead semantics but also makes it difficult to effectively extract joint pattern information across leads within the same local time segment. On the other hand, in existing hierarchical network structures, repeated downsampling of input features in the spatial dimension can easily lead to rapid reduction or even collapse of the originally smaller lead axes, resulting in irreversible loss of cross-lead structural information. Furthermore, when applying windowed attention mechanisms, improper handling of temporal boundaries can easily introduce non-physical cross-boundary pseudo-connections.
[0031] To solve the above problems, the present invention solves them in the following way:
[0032] Example 1
[0033] like Figure 1 or Figure 3 As shown, Embodiment 1 of the present invention provides a modeling method for 12-lead electrocardiogram signals, which can be executed by a terminal device, server, or related data processing system. The steps are as follows:
[0034] S100. Acquire twelve-lead electrocardiogram (ECG) signals and construct the ECG signals as a two-dimensional grid input consisting of lead axes and time axes.
[0035] Specifically, the twelve-lead electrocardiogram waveform data of the tested subject are acquired. ,in The data shape is , Corresponding to twelve leads, This represents the number of time sampling points. Subsequently, the... Constructing data into shape as Two-dimensional grid input .
[0036] Through this construction method, the model can clearly and natively distinguish between the lead axis and the time axis at the data representation and feature processing levels, fundamentally avoiding the lead and time semantic confusion caused by flattening the signal into a one-dimensional sequence.
[0037] In actual clinical data acquisition, considering the potential signal loss caused by factors such as electrode detachment or poor contact, the above-mentioned grid-based construction process also has a corresponding fault-tolerance mechanism:
[0038] S110. When there are missing leads in the twelve-lead ECG signal, the waveform corresponding to the missing lead is set to a preset fill value, and a missing lead identifier is generated.
[0039] Before entering the feature mapping network, this step uniformly covers the missing parts with preset padding values (such as zero values) and simultaneously generates missing lead identifiers for the corresponding dimensions. As an additional input, it marks the location of invalid data.
[0040] Furthermore, to eliminate the noise interference caused by the above-mentioned padding operation to subsequent network feature extraction, the specific mechanism of the missing lead identifier is as follows:
[0041] S111, The missing lead identifier is used to perform attention suppression on the missing lead block in the windowed self-attention calculation.
[0042] Specifically, during the attention interaction within the network or the final global representation extraction stage, this identifier is used to directly apply a negative infinite bias or assign zero weight to the missing lead blocks, ensuring that hardware-level missingness does not distort the overall prediction results.
[0043] After completing the gridded construction and preprocessing of the input signal, this embodiment performs feature mapping on the input data:
[0044] S200. Perform two-dimensional block embedding processing on the two-dimensional mesh input to generate the corresponding embedded feature mesh.
[0045] Each slice in the grid is processed by linear mapping or multilayer perceptron (MLP) to map it from the original waveform segment into a fixed-dimensional feature vector, thereby forming a lead axis height of... The time axis width is Structured embedded feature grid .
[0046] Specifically, the above two-dimensional block embedding process achieves boundary alignment through the following logic:
[0047] S210, based on block size The circuit is divided into blocks on the lead axis and time axis, where... When the length of the time axis cannot be... During division, the two-dimensional grid input is filled in the time axis direction.
[0048] In addition to using the conventional zero-padding to meet the stride divisibility condition, in practical applications, mirror padding, boundary repetition padding, or direct clipping can also be used to achieve normalization of the feature grid dimensions.
[0049] To ensure the model can accurately capture fine-grained features of the cardiac cycle, the specific physical parameters of the aforementioned time axis block size are limited as follows:
[0050] S211, the block size Corresponding to a time span of 0.05 seconds to 0.20 seconds, and based on the ECG signal sampling rate, the time span is converted into the number of sampling points to determine the... .
[0051] In addition to the interaction of ECG waveform data itself, in order to fully integrate the patient's individual prior knowledge, this embodiment also includes the following clinical feature fusion process before entering the core self-attention calculation:
[0052] S220. Obtain the tabulated features corresponding to the twelve-lead ECG signals; generate channel-level scaling parameters based on the tabulated features. With offset parameter For the channel features of the embedded feature grid Perform conditional modulation.
[0053] This step takes the patient's age, gender, and other medical history as tabular input, and generates modulation parameters through networks such as multilayer perceptrons. The ECG characteristics are then adaptively calibrated without disrupting the existing two-dimensional grid structure.
[0054] Specifically, the above conditional modulation process satisfies the following mathematical operation logic:
[0055] S221, The conditional modulation satisfies: ,in This indicates element-wise multiplication.
[0056] in, and The dimension is consistent with the number of channels of the embedded feature grid, and it is broadcast in the direction of the lead axis and the time axis, so that individual features can be effectively reused by each layer of the model.
[0057] After successfully constructing and modulating the embedded feature grid, the network enters the core spatiotemporal feature extraction stage:
[0058] S300, Perform hierarchical windowed self-attention computation on the embedded feature grid, wherein the two-dimensional window for attention computation is set to cover all lead dimensions in the lead axis direction, and window shifting operation is performed only along the time axis direction between adjacent attention layers.
[0059] This step will embed the feature mesh according to the window size. The algorithm is divided into multiple two-dimensional windows, and self-attention is calculated only within each two-dimensional window. The key is setting the window height. It is always equal to the global height of the embedded feature mesh in the lead axis direction. This full-lead coverage design allows the model to directly and synchronously acquire the correlation information of all leads within each local time segment.
[0060] To enable the flow and interaction of information between different local time windows, the specific settings of the above shifting mechanism are as follows:
[0061] S310, the shift amount of the window shift operation is ,in The time axis width of the two-dimensional window is defined, and a boundary mask is generated to suppress feature pairs that cross the window boundary after shifting from participating in the self-attention calculation.
[0062] To ensure the physical validity of the temporal feature interactions after the shift, the boundary mask described above functions as follows:
[0063] S311, The boundary mask is used to suppress the participation of block pairs located in different windows in the self-attention calculation within the same window after shifting; the boundary mask is implemented by setting the attention weights of block pairs in different windows to zero or negative infinity.
[0064] This masking mechanism completely eliminates the false connections that are easily introduced by shift operations at the boundaries of time series, thus avoiding unreasonable attention interactions in non-adjacent time periods.
[0065] Furthermore, the time span parameter of the aforementioned attention window is designed as follows:
[0066] S312, the window width Corresponding to a time span of 0.20 seconds to 2.00 seconds, and based on the ECG signal sampling rate and block size. This is converted to the number of blocks and columns contained in the window along the time axis.
[0067] As the network depth increases, in order to extract multi-scale features while avoiding the collapse and loss of lead-dimensional information, this embodiment implements an asymmetric downsampling strategy:
[0068] S400. Perform hierarchical downsampling on the embedded feature grid to obtain a multi-scale feature grid, wherein the number of downsampling operations for the lead axis direction is limited, and after the number of downsampling operations is reached, subsequent downsampling operations are only performed along the time axis direction.
[0069] Specifically, the aforementioned restricted downsampling strategy for the lead axis direction can be implemented through one of the following two equivalent paths:
[0070] S410. The downsampling operation for the lead axis direction is performed at most once, and is implemented in any of the following ways: setting in the two-dimensional block embedding process This completes one reduction in lead axis direction resolution, and the lead axis direction will no longer be downsampled in subsequent layered downsampling.
[0071] Alternatively, set in the two-dimensional block embedding process In the first layer of downsampling, a double downsampling is performed on the lead axis direction, and then no further downsampling is performed on the lead axis direction.
[0072] This mechanism effectively prevents the rapid dimensional reduction and structural disappearance of the lead axes (only 12 dimensions) in deep networks, which is easily caused by conventional symmetric pooling.
[0073] After satisfying the above lead axis constraints, the model only performs dimensional compression on the time axis:
[0074] S420. The subsequent downsampling operation is performed only along the time axis, including: using merging rules. Two adjacent feature blocks along the time axis are merged, and a linear mapping is performed on the merged features to obtain the downsampled time axis feature grid.
[0075] To clarify the merging multiple of the above rules, it is specifically defined as follows:
[0076] S421, the merging rule This indicates that the merging factor in the lead axis direction is 1 and the merging factor in the time axis direction is 2.
[0077] After multi-layered, multi-scale feature extraction, the network finally enters the task prediction stage:
[0078] S500: Extract global representations based on the finally obtained multi-scale feature grid and output the corresponding prediction results.
[0079] Specifically, in order to aggregate feature vectors for classification tasks from a multi-scale feature grid:
[0080] S510. Calculate the mean values of the finally obtained multi-scale feature grid in the direction of the lead axis and the time axis respectively to obtain the global representation.
[0081] Finally, the aforementioned global representation is used to perform specific downstream clinical auxiliary diagnostic tasks:
[0082] S520. Output risk scores or probability values for multiple tasks based on the global representation, wherein the multiple tasks include at least two structural cardiac abnormality-related tasks.
[0083] Because structured multi-lead features contain rich and consistent pathological information, output heads (such as multi-branch fully connected layers) can accurately identify hidden arrhythmias and structural heart lesions based on this global representation.
[0084] Example 2
[0085] Based on the same general inventive concept, Embodiment 2 of the present invention also provides a training method for modeling twelve-lead electrocardiogram signals. For example... Figure 2 As shown, this training method mainly includes the following steps:
[0086] S101. Obtain training samples and generate corresponding embedded feature grids.
[0087] Specifically, a training sample containing twelve-lead ECG signal waveform data is obtained, and following steps S100 to S200 as described in Example 1, a two-dimensional mesh construction and two-dimensional block embedding process are sequentially performed on the training sample to obtain a lead axis height of... Embedded feature grid.
[0088] S102. On the embedded feature grid, select a continuous interval along the time axis and perform a masking operation on the area within the continuous interval that covers the entire block in the direction of the lead axis.
[0089] Furthermore, a starting column index is selected in the time axis direction of the embedded feature grid. and the number of columns to be obscured For column intervals All blocks along the inner and lead axes are subjected to full-column occlusion, resulting in the geometry of the occluded area being as follows: .
[0090] S1021, the time span of the continuous interval is 0.3 seconds to 1.0 seconds, and the proportion of the occluded blocks in each training sample to the total number of blocks of the embedded feature grid is 30% to 70%.
[0091] Specifically, the time span is denoted as Based on the sampling rate of the electrocardiogram signal With block size The time span is converted into the number of occluded blocks. ,in In addition, the number of occlusion regions for each training sample is set to 1 or 2.
[0092] S1022, The occlusion operation is achieved by replacing the occluded block with a preset mask vector or a preset fill value, and recording the occlusion position.
[0093] After completing the local occlusion of the embedded feature mesh, feature encoding and reconstruction are performed:
[0094] S103. Input the unoccluded blocks into a preset windowed self-attention network for encoding, and reconstruct the occluded blocks based on the encoded features.
[0095] Specifically, the unoccluded blocks and the previously recorded occlusion positions are input into a windowed self-attention network, and global context encoding features are obtained through network encoding. Subsequently, the reconstruction head connected to the windowed self-attention network outputs the reconstruction results of the occluded blocks based on the encoding features.
[0096] S1031, the target representation is an occluded block embedded vector in the embedded feature grid, or a feature vector after the embedded vector has been processed by at least one layer of windowed self-attention network, and the target representation is not the original ECG sampling point sequence.
[0097] S104. The model parameters are updated using the error between the reconstruction result and the target representation as the loss function, and the windowed self-attention network is used as the encoding network for downstream tasks after training is completed.
[0098] Finally, the reconstruction error between the reconstruction result and the target representation is calculated, and this reconstruction error is used as the loss function to update the model parameters through the backpropagation algorithm. After pre-training, the reconstruction head is discarded, and the trained windowed self-attention network is used as the backbone encoding network to perform fine-tuning of the downstream supervision task described in Example 1.
[0099] Example 3
[0100] Based on the same general inventive concept, Embodiment 3 of the present invention also provides an electronic device.
[0101] An electronic device includes a memory and a processor. The memory stores a computer program, which, when executed by the processor, implements the modeling method described in Embodiment 1 or the training method described in Embodiment 2.
[0102] Specifically, the electronic device can be a built-in computing module of a clinically deployed electrocardiograph, a medical workstation, a cloud-based diagnostic server, or a processing terminal for a smart wearable device. The processor can be a central processing unit (CPU), a graphics processing unit (GPU), an application-specific integrated circuit (ASIC), or a microprocessor containing a deep learning acceleration engine. The memory stores the computer instruction set and related weight parameters for implementing the aforementioned two-dimensional gridded hierarchical shift window attention algorithm. By calling the program in memory, the processor can automatically perform high-dimensional, multi-scale joint feature extraction or model pre-training on the acquired 12-lead electrocardiogram signals, outputting an accurate cardiac abnormality risk score.
[0103] Example 4
[0104] Based on the same general inventive concept, Embodiment 4 of the present invention provides a computer-readable storage medium for carrying the above-described algorithm program. A computer program is stored thereon, and when executed by a processor, the computer program implements the modeling method described in Embodiment 1, or the training method described in Embodiment 2.
[0105] Specifically, the computer-readable storage medium includes, but is not limited to, various non-volatile media capable of persistently or temporarily storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks. Medical institutions or research and development companies can quickly deploy the twelve-lead electrocardiogram signal processing system described in this invention on a corresponding computing platform by reading the instruction sequences in this medium, thereby significantly improving the automation level and interpretation accuracy of auxiliary diagnosis and treatment.
[0106] It should be understood that, in the embodiments of the present invention, "B corresponding to A" means that B is associated with A, and B can be determined based on A. However, it should also be understood that determining B based on A does not mean that B is determined solely based on A; B can also be determined based on A and / or other information.
[0107] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0108] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0109] In the embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the couplings or direct couplings or communication connections shown or discussed may be indirect couplings or communication connections through some interfaces, apparatuses, or units, or they may be electrical, mechanical, or other forms of connection.
[0110] 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 units can be selected to achieve the purpose of the embodiments of the present invention, depending on actual needs.
[0111] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0112] From the above description of the embodiments, those skilled in the art will clearly understand that the present invention can be implemented in hardware, firmware, or a combination thereof. When implemented in software, the above-described functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transmission of a computer program from one place to another. Storage media can be any available medium accessible to a computer. For example, but not limited to, computer-readable media can include RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible to a computer. Furthermore, any connection can suitably be considered a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of the medium. As used in this invention, disk and disc include compressed optical discs (CDs), laser discs, optical discs, digital versatile discs (DVDs), floppy disks, and Blu-ray discs, wherein disks typically magnetically copy data, while discs optically copy data using lasers. The combinations described above should also be included within the scope of protection for computer-readable media.
[0113] In summary, the above description is merely a preferred embodiment of the technical solution of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A modeling method for 12-lead electrocardiogram signals, characterized in that, The modeling method includes: Acquire twelve-lead electrocardiogram (ECG) signals and construct the ECG signals as a two-dimensional grid input consisting of lead axes and time axes; Perform two-dimensional block embedding processing on the two-dimensional mesh input to generate the corresponding embedded feature mesh; Hierarchical windowed self-attention computation is performed on the embedded feature grid, wherein the two-dimensional window for attention computation is set to cover all lead dimensions in the lead axis direction, and window shifting operations are performed only along the time axis direction between adjacent attention layers; Hierarchical downsampling is performed on the embedded feature grid to obtain a multi-scale feature grid, wherein the number of downsampling operations for the lead axis direction is limited, and after the number of downsampling operations is reached, subsequent downsampling operations are only performed along the time axis direction; Global representations are extracted based on the finally obtained multi-scale feature grid, and corresponding prediction results are output.
2. The modeling method according to claim 1, characterized in that, The step of constructing the ECG signal as a two-dimensional grid input consisting of lead axes and time axes includes: when there are missing leads in the twelve-lead ECG signal, setting the waveform corresponding to the missing lead to a preset fill value and generating a missing lead identifier; the missing lead identifier is used to perform attention suppression on the missing lead block in the windowed self-attention calculation.
3. The modeling method according to claim 1, characterized in that, The step of performing two-dimensional block embedding processing on the two-dimensional grid input includes: By block size The circuit is divided into blocks on the lead axis and time axis, where... When the length of the time axis cannot be... During integer division, the two-dimensional grid input is filled in the time axis direction; The step of performing window shifting operations between adjacent attention layers only along the time axis direction includes: The shift amount of the window shift operation is ,in The time axis width of the two-dimensional window is defined, and a boundary mask is generated to suppress feature pairs that cross the window boundary after shifting from participating in the self-attention calculation.
4. The modeling method according to claim 1, characterized in that, The subsequent downsampling operation is performed only along the time axis direction, including: Merge rules Two adjacent feature blocks along the time axis are merged, and a linear mapping is performed on the merged features to obtain the downsampled time axis feature grid. The merging rules This indicates that the merging factor in the lead axis direction is 1 and the merging factor in the time axis direction is 2.
5. The modeling method according to claim 1, characterized in that, Prior to performing the hierarchical windowed self-attention computation, the modeling method further includes: Obtain the tabular features corresponding to the twelve-lead electrocardiogram signals; Generate channel-level scaling parameters based on the tabular features. With offset parameter For the channel features of the embedded feature grid Perform conditional modulation; The conditional modulation satisfies: in This indicates element-wise multiplication.
6. A training method for modeling 12-lead electrocardiogram signals, characterized in that, The training method includes: Obtain training samples and generate corresponding embedding feature grids; On the embedded feature grid, a continuous interval is selected along the time axis, and a masking operation is performed on the area within the continuous interval that covers the entire block in the direction of the lead axis. Unoccluded blocks are input into a pre-defined windowed self-attention network for encoding, and occluded blocks are reconstructed based on the encoded features; The model parameters are updated using the error between the reconstruction result and the target representation as the loss function, and the windowed self-attention network is used as the encoding network for downstream tasks after training is completed.
7. The training method according to claim 6, characterized in that, The step of selecting a continuous interval to perform the occlusion operation includes: The time span of the continuous interval is from 0.3 seconds to 1.0 seconds, and the proportion of occluded blocks in each training sample to all blocks of the embedded feature grid is from 30% to 70%.
8. The training method according to claim 6, characterized in that, The target representation is either an occluded block embedded in the embedded feature grid, or a feature vector after the embedded vector has been processed by at least one layer of windowed self-attention network. The target representation is not the original ECG sampling point sequence.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the computer program is executed by the processor, it implements the modeling method according to any one of claims 1 to 5, or the training method according to any one of claims 6 to 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the modeling method according to any one of claims 1 to 5, or the training method according to any one of claims 6 to 8.