Electrocardiogram classification method and device

By combining high-dimensional convolutional layers and fully connected layers, along with Transformer layers and multi-scale convolutional layers, the problem of signal coupling in ECG classification is solved, achieving automated feature extraction and accurate ECG classification.

CN120895261APending Publication Date: 2025-11-04SHENYANG NEUSOFT INTELLIGENT MEDICAL TECH RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510992714.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-17
Publication Date
2025-11-04

AI Technical Summary

Technical Problem

Existing ECG classification methods rely on manual feature extraction, resulting in low classification accuracy and an inability to effectively decouple signal coupling.

Method used

An automated feature extraction method is adopted, which maps the original features to a high-dimensional subspace through high-dimensional convolutional layers and generates a label set by combining fully connected layers. Features are extracted and fused using Transformer layers and multi-scale convolutional layers, and the model is trained using a triple loss function.

Benefits of technology

It achieves automated feature extraction, effectively decouples signal coupling, and improves the accuracy and generalization ability of ECG classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120895261A_ABST
    Figure CN120895261A_ABST
Patent Text Reader

Abstract

The invention discloses an electrocardiogram classification method and device, and relates to the technical field of signal processing. The method is applied to a pre-trained electrocardio classification model, and comprises the following steps: carrying out feature extraction on an electrocardio signal to obtain an original feature; mapping the original features to a high-dimensional subspace through a high-dimensional convolutional layer to obtain high-dimensional features; based on the high-dimensional features, a label set corresponding to the electrocardiosignals is generated through a full-connection layer. According to the embodiment of the invention, automatic feature extraction can be realized, and the high-dimensional convolutional layer expands the features from an original signal space to a high-dimensional subspace through nonlinear mapping, so that key information is reserved, the problem of signal coupling is solved through dimension expansion and nonlinear transformation, signal coupling can be effectively decoupled, and the accuracy of signal coupling is improved. Therefore, the electrocardio classification accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of signal processing technology, and in particular to an electrocardiogram (ECG) classification method and apparatus. Background Technology

[0002] An electrocardiogram (ECG) is a bioelectrical signal curve that records the changes in the heart's electrical activity over time. By capturing the conduction path, rhythm, and waveform characteristics of the heart's electrical signals, it provides crucial information for assessing cardiac function and diagnosing cardiovascular diseases such as arrhythmias, myocardial ischemia, and myocardial infarction. Accurate ECG classification can help doctors pinpoint the type of lesion, significantly improving diagnostic efficiency and accuracy.

[0003] Currently, ECG classification methods are mainly divided into two categories: one is traditional manual analysis, which involves manually identifying the waveform features of ECG signals and combining them with clinical experience to achieve ECG classification; the other is a combination of manual feature extraction and shallow machine learning models to achieve ECG / ECG signal classification.

[0004] Therefore, current ECG classification methods rely on manual feature extraction and cannot effectively decouple signal coupling, resulting in low ECG classification accuracy. Summary of the Invention

[0005] To address the aforementioned issues, this application provides an electrocardiogram (ECG) classification method and apparatus that automates feature extraction and effectively decouples signal coupling, thereby improving the accuracy of ECG classification.

[0006] The embodiments of this application disclose the following technical solutions:

[0007] In a first aspect, embodiments of this application provide an electrocardiogram (ECG) classification method applied to a pre-trained ECG classification model, the method comprising:

[0008] Feature extraction is performed on the electrocardiogram signal to obtain the original features;

[0009] The original features are mapped to a high-dimensional subspace through a high-dimensional convolutional layer to obtain high-dimensional features;

[0010] Based on the high-dimensional features, a tag set corresponding to the electrocardiogram (ECG) signal is generated through a fully connected layer; wherein, the tag set includes: the ECG type corresponding to the ECG signal.

[0011] In one possible implementation, the step of mapping the original features to a high-dimensional subspace through a high-dimensional convolutional layer to obtain high-dimensional features includes:

[0012] The original features are input into a high-dimensional convolutional layer so that the high-dimensional convolutional layer can map the original features to a high-dimensional subspace through nonlinear transformation to obtain high-dimensional features; wherein, the number of channels of the original features is the number of input channels of the high-dimensional convolutional layer, the number of channels of the high-dimensional features is the number of output channels of the high-dimensional convolutional layer, and the number of output channels of the high-dimensional convolutional layer is greater than the number of input channels.

[0013] In one possible implementation, the feature extraction of the electrocardiogram signal to obtain the original features includes:

[0014] The electrocardiogram signal is processed using the self-attention mechanism of the Transformer layer to obtain the first feature;

[0015] By using multi-scale convolutional layers, feature extraction is performed on the first feature to obtain multiple second features; wherein, the multi-scale convolutional layers include multiple convolutional layers in parallel, and the kernel sizes of the multiple convolutional layers are different, and the multiple second features are: second features corresponding to the multiple convolutional layers respectively;

[0016] The multiple second features are fused to obtain the original features.

[0017] In one possible implementation, the first feature is extracted using a multi-scale convolutional layer to obtain multiple second features, including:

[0018] The first feature is divided into multiple first sub-features along the channel dimension; wherein, the multiple first sub-features are: the first sub-features corresponding to the multiple convolutional layers respectively;

[0019] By using the multiple convolutional layers included in the multi-scale convolutional layer, feature extraction is performed on the multiple first sub-features one by one to obtain multiple second features.

[0020] In one possible implementation, the feature fusion of the plurality of second features to obtain the original features includes:

[0021] The multiple second features are concatenated to obtain the concatenated features;

[0022] The spliced ​​features are then subjected to flattening, linear transformation, and reshaping operations in sequence to obtain the original features.

[0023] In one possible implementation, generating a tag set corresponding to the electrocardiogram signal through a fully connected layer based on the high-dimensional features includes:

[0024] Based on the high-dimensional features, a multi-label classification result corresponding to the electrocardiogram signal is generated through a fully connected layer; wherein, the multi-label classification result includes: a probability distribution corresponding to each preset electrocardiogram type;

[0025] Based on the multi-label classification results, a set of labels corresponding to the electrocardiogram signal is determined.

[0026] In one possible implementation, the electrocardiogram (ECG) signal includes: voltage values ​​at each time point; the high-dimensional features include: high-dimensional feature vectors of the ECG signal at each time point; and the generation of multi-label classification results corresponding to the ECG signal through a fully connected layer based on the high-dimensional features includes:

[0027] A linear transformation is performed on the high-dimensional features to obtain the original score for each time point for each preset ECG type;

[0028] By using the sigmoid activation function, based on the original score of each time point for each preset ECG type, the probability distribution of each time point for each preset ECG type is obtained, so as to obtain the multi-label classification result corresponding to the ECG signal.

[0029] In one possible implementation, the training process of the ECG classification model includes:

[0030] Anchor samples, positive samples, and negative samples are dynamically selected from the training set to construct training triples; wherein, the positive samples are ECG signals with the same ECG type as the anchor samples, and the negative samples are ECG signals with a different ECG type than the anchor samples.

[0031] The ECG classification model is trained based on the triplet loss function corresponding to the training triplet.

[0032] In one possible implementation, the negative sample is a semi-hard negative sample, and the distance between the semi-hard negative sample and the anchor sample is greater than the distance between the positive sample and the anchor sample, but less than the sum of the distance between the positive sample and the anchor sample and a preset boundary value.

[0033] Secondly, embodiments of this application provide an electrocardiogram (ECG) classification device, including:

[0034] The feature extraction module is used to extract features from electrocardiogram signals to obtain the original features;

[0035] The high-dimensional mapping module is used to map the original features to a high-dimensional subspace through a high-dimensional convolutional layer to obtain high-dimensional features;

[0036] The tag generation module is used to generate a tag set corresponding to the electrocardiogram (ECG) signal through a fully connected layer based on the high-dimensional features; wherein the tag set includes: the ECG type corresponding to the ECG signal.

[0037] Compared with existing technologies, this application has the following advantages: it can realize automated feature extraction, and the high-dimensional convolutional layer expands the features from the original signal space to a high-dimensional subspace through nonlinear mapping, which not only preserves key information, but also solves the signal coupling problem through dimensional expansion and nonlinear transformation, effectively decoupling signal coupling and thus improving the accuracy of ECG classification. Attached Figure Description

[0038] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0039] Figure 1 A flowchart illustrating an electrocardiogram (ECG) classification method provided in this application embodiment;

[0040] Figure 2 A schematic diagram illustrating a process for obtaining original features, provided as an embodiment of this application;

[0041] Figure 3 A schematic diagram illustrating a process for generating a tag set corresponding to an electrocardiogram signal, provided in an embodiment of this application;

[0042] Figure 4 This is a schematic diagram of the structure of an electrocardiogram classification model provided in an embodiment of this application;

[0043] Figure 5 A structural example diagram of an electrocardiogram classification model provided in this application embodiment;

[0044] Figure 6 This is a schematic diagram of the structure of an electrocardiogram (ECG) classification device provided in an embodiment of this application. Detailed Implementation

[0045] As described above, the common ECG classification methods in current technology are mainly divided into two categories. One is traditional manual analysis, which involves doctors manually identifying ECG waveform features (such as P waves, QRS complexes, T wave morphology, etc.) and classifying them based on clinical experience. In traditional manual analysis, there is a high degree of subjectivity (low consistency in interpretation among different doctors), low efficiency, and significant influence from the doctor's professional level.

[0046] In current technology, another approach combines manual feature extraction with shallow machine learning models to classify electrocardiograms (ECGs). Shallow machine learning models refer to models with simple structures, few hidden layers, and few points. These models directly model the relationship between the input and output domains through explicit feature engineering and statistical methods, without the need for complex hierarchical feature extraction. Common shallow machine learning models include linear regression, logistic regression, support vector machines, decision trees, and random forests. Specifically, due to the simple structure of shallow machine learning models, their expressive power is limited, making it difficult to automatically learn complex feature representations from raw data. Therefore, manual feature extraction is still necessary. Consequently, current ECG classification methods rely on manual feature extraction, resulting in low accuracy and comprehensiveness. Furthermore, different diseases present signal coupling problems in their ECGs; features of different ECG types (such as arrhythmias and myocardial ischemia) overlap and become entangled in the original ECG signal space. This makes it difficult for current shallow machine learning models to accurately distinguish boundaries and effectively decouple signal coupling, leading to low ECG classification accuracy.

[0047] This application provides an electrocardiogram (ECG) classification method, comprising: extracting features from ECG signals to obtain original features; mapping the original features to a high-dimensional subspace through a high-dimensional convolutional layer to obtain high-dimensional features; and generating a set of labels corresponding to the ECG signals through a fully connected layer based on the high-dimensional features. In this embodiment, automated feature extraction is achieved, and the high-dimensional convolutional layer extends the features from the original signal space to a high-dimensional subspace through nonlinear mapping. This preserves key information and solves the signal coupling problem through dimensional expansion and nonlinear transformation, effectively decoupling signal coupling and thus improving the accuracy of ECG classification.

[0048] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.

[0049] Example 1:

[0050] The following is combined Figures 1-5 This application provides a detailed description of an electrocardiogram (ECG) classification method. The ECG classification method provided in this application is applied to a pre-trained ECG classification model.

[0051] like Figure 1 As shown in the embodiments of this application, an electrocardiogram (ECG) classification method includes the following steps:

[0052] S101. Extract features from the electrocardiogram signal to obtain the original features.

[0053] Among them, the electrocardiogram (ECG) signal is a time-series signal that records the voltage value or potential difference of the heart's electrical activity over time. The ECG signal is formed by capturing the weak electric field generated on the body surface by the heart's electrophysiological processes (such as the depolarization and repolarization of myocardial cells), forming an electrical signal curve with a specific waveform and periodicity.

[0054] In one possible implementation, the electrocardiogram (ECG) signal includes voltage values ​​at each time point to record the voltage values ​​or potential differences that change with cardiac electrical activity over time. For example, the ECG signal is plotted on a time axis, recording multiple time points and their corresponding voltage values ​​(vertical axis) to form a continuous waveform, thus recording the dynamic process of cardiac electrical activity.

[0055] In one possible implementation, the electrocardiogram (ECG) signal is obtained by preprocessing the raw ECG data. For example, the raw ECG data undergoes heartbeat truncation and noise reduction to obtain the ECG signal.

[0056] To make it easier to understand, the following will be combined with... Figure 2 This paper details the specific process of obtaining the original features in the embodiments of this application.

[0057] S201. The electrocardiogram signal is processed through the self-attention mechanism of the Transformer layer to obtain the first feature.

[0058] Among them, Transformer is a deep learning model architecture based on the self-attention mechanism. The self-attention mechanism refers to allowing the model to dynamically pay attention to all other elements when processing each element in a sequence, thereby capturing global contextual relationships.

[0059] The first feature is essentially a feature matrix.

[0060] Specifically, the electrocardiogram (ECG) signal is input into the Transformer layer, allowing the Transformer layer to extract and generate the first feature using its self-attention mechanism. For example, since the ECG signal is a time-series data, the time-series data is input into the Transformer layer. The Transformer layer, utilizing its self-attention mechanism, can automatically learn the importance weights between different parts of the ECG signal and dynamically adjust the contribution of each part to the final feature representation. That is, for each time point in the ECG signal, the Transformer layer can evaluate the dependency between that time point and all other time points. The Transformer layer adaptively aggregates feature information from different locations to obtain the first feature.

[0061] To make it easier to understand, the following example illustrates the process by which the Transformer layer obtains the first feature.

[0062] Assuming the electrocardiogram (ECG) signal is a one-dimensional time series of length T, meaning the ECG signal includes T time points and the corresponding voltage values ​​at those T time points, it can also be represented as a (1, T) matrix, where T is a positive integer.

[0063] The Transformer layer first embeds the voltage value at each time point of the electrocardiogram signal into a d-dimensional vector space, obtaining the corresponding input matrix X∈R. T×d , which is a matrix of T rows and d columns, where d is the feature dimension pre-set for the Transformer layer. Here, d is a positive integer.

[0064] For an input matrix X, the Transformer layer uses a self-attention mechanism to calculate the correlation between each time point and other time points using three learnable weight matrices.

[0065] First, the query (Q) matrix, key (K) matrix, and value (V) matrix are calculated using three learnable weight matrices. The Q matrix represents the query requirement of the current time point (position) for other time points (positions) in the sequence, the K matrix represents the identifiers of other time points (positions) in the sequence, used to match the query, and the V matrix represents the actual content of other time points (positions) in the sequence, used to generate the final output.

[0066] Specifically, the query matrix Q = XW Q ∈R T×d Key matrix K = XW K ∈R T×d Value matrix V = XW V ∈R T×d Among them, three learnable weight matrices WQ W K W V ∈R d×d .

[0067] Then, attention scores are calculated using the Q-matrix (vector) and the K-matrix (vector) to measure the similarity between the Q-matrix and the K-matrix. Specifically, the attention scores are calculated as: Scores = QK T ∈R T×T Each element has Scores i,j This represents the similarity between the query vector at time point i (location) and the key vector at time point j (location).

[0068] Subsequently, the attention scores are normalized using the Softmax function to obtain the attention weight matrix. Specifically, the attention weight matrix A = Softmax(Scores) ∈ R. T×T .

[0069] Finally, by weighting the value matrix V with the weight matrix A, we obtain the output feature matrix Z = AV ∈ R of the Transformer layer. T×d .

[0070] In one possible implementation, the output feature matrix of the Transformer layer is the first feature.

[0071] In one possible implementation, the Transformer layer uses multi-head attention, which involves parallelizing multiple self-attention sub-layers to obtain the outputs (feature matrices) of each sub-layer, and then concatenating or weighting these outputs to obtain the first feature. Through multi-head attention, the Transformer layer can simultaneously focus on local details (such as steep changes in waveforms) and global trends (such as overall heart rate patterns), achieving adaptive aggregation of feature information at different scales and locations to obtain the first feature.

[0072] S202. Through multi-scale convolutional layers, feature extraction is performed on the first feature to obtain multiple second features.

[0073] Multi-scale convolutional layers consist of multiple convolutional layers operating in parallel, each with a different kernel size. A convolutional kernel is essentially a learnable weight matrix used to extract local features from the input features / data. The kernel moves across the input features / data via a sliding window, focusing on only a local region (receptive field) at a time, and the same kernel shares weight parameters across different locations within the input features / data.

[0074] Among them, multiple second features are: second features corresponding to multiple convolutional layers respectively. For example, if a multi-scale convolutional layer includes four parallel convolutional layers, namely Conv1, Conv2, Conv3 and Conv4, then four second features are obtained. The four second features are: the second feature corresponding to Conv1, the second feature corresponding to Conv2, the second feature corresponding to Conv3, and the second feature corresponding to Conv4.

[0075] In this embodiment, the kernel sizes of multiple convolutional layers are different, thus each convolutional layer corresponds to a receptive field of different scales. This allows for the extraction of fine-grained ECG signals at multiple scales, from local to global, thereby capturing both local details and global trends in the ECG signal. This avoids focusing only on features at a single scale and ignoring the cross-scale information contained in the ECG signal. Furthermore, the parallel use of multiple convolutional layers with different kernel sizes effectively enhances the accuracy and richness of feature representation.

[0076] In one possible implementation, the first feature is divided into multiple first sub-features along the channel dimension; through multiple convolutional layers included in the multi-scale convolutional layer, the multiple first sub-features are extracted one by one to obtain multiple second features.

[0077] Among them, the multiple first sub-features are: the first sub-features corresponding to the multiple convolutional layers respectively.

[0078] Among them, the channel dimension is a key dimension of the data tensor, corresponding to the depth of the features; the channel dimension represents the feature data at each location (i.e., time point).

[0079] Specifically, the first feature obtained / output by the Transformer layer is a (T, d) feature matrix, where d is the number of output channels pre-set for the Transformer layer. Assuming the multi-scale convolutional layer includes N convolutional layers with different kernel sizes, the first feature is divided into N first sub-features along the channel dimension. Each first sub-feature is a (T, d / N) feature matrix. The input channels of the multiple convolutional layers in the multi-scale convolutional layer are d / N, and the output channels are also d / N. The number of output channels of a convolutional layer is actually the number of convolutional kernels it includes. Through the N convolutional layers with different kernel sizes in the multi-scale convolutional layer, feature extraction is performed on each of the N first sub-features to obtain N second features, each of which is a (T, d / N) feature matrix.

[0080] For ease of understanding, the following example describes how the second feature is obtained in an embodiment of this application.

[0081] Assume the multi-scale convolutional layer consists of four convolutional layers with different kernel sizes: 3×1, 5×1, 7×1, and 11×1, respectively. Each of the four convolutional layers has 16 input and 16 output channels. The padding of all four convolutional layers is set to 1 to ensure that the number of time steps after convolution remains constant, and the stride of all four convolutional layers is set to 1 to ensure that the kernel slides one time step at a time.

[0082] Taking a feature matrix with the first feature being (100, 64) as an example, the first feature (100, 64) is divided into four first sub-features (100, 16), and the four first sub-features are fed one-to-one into four convolutional layers with different kernel sizes. The four convolutional layers output four second features (100, 16) respectively.

[0083] S203. Perform feature fusion on multiple second features to obtain the original features.

[0084] Multi-scale convolutional layers output multiple secondary features, i.e., features at multiple different scales. These features (such as local detail features and global trend features) are then fused, allowing them to complement and enhance each other, resulting in a more comprehensive and robust feature representation—the original feature. Specifically, features at different scales can complement each other, avoiding the limitations of single-scale features; by fusing features at multiple different scales, the ECG classification model can better handle noise or abnormalities in the input ECG signal; furthermore, the fused original feature is more comprehensive and can capture more discriminative information.

[0085] In one possible implementation, multiple second features are concatenated to obtain concatenated features; the concatenated features are then flattened, linearly transformed, and reshaped sequentially to obtain the original features.

[0086] The flatten operation refers to converting a multidimensional tensor into a one-dimensional vector. For example, flattening the feature matrix (A, B) into a one-dimensional vector (1, A×B). The flatten operation compresses multidimensional features into one dimension, eliminating the spatial or temporal dimensions of the features, simplifying the feature structure, and reducing the number of parameters in subsequent operations.

[0087] Linear transformation refers to applying a linear mapping to input data (features) through matrix multiplication, such as Y = WX + b, where Y is the transformed feature, X is the input feature (usually a one-dimensional vector feature), W is the weight matrix, and b is the bias vector. Linear transformation operations adjust the dimensionality of features, extract linear combination features, or introduce learnable parameters.

[0088] The reshape operation refers to adjusting the shape of a tensor without changing the total number of elements. For example, reshaping a one-dimensional vector (A×B) into a two-dimensional matrix (A, B).

[0089] For example, given N feature matrices with second features of (T, d / N), concatenate the N second features to obtain a concatenated feature (T, d). Flatten the concatenated feature to obtain a one-dimensional feature vector (T×d). Perform a linear transformation on the one-dimensional feature vector (T×d) to generate a new feature representation (1, K), where K is the target dimension of the linear transformation. Reshape the new feature representation (1, K) into a feature matrix (K / D1, D1) of a specific shape, which serves as the original feature. Here, D1 is the number of input channels of the high-dimensional convolutional layer.

[0090] The above combination Figure 2 This application details how to extract features from electrocardiogram (ECG) signals to obtain the original features in its embodiments. The following section continues with further examples. Figure 1 This application introduces an electrocardiogram (ECG) classification method provided by an embodiment.

[0091] S102. Through high-dimensional convolutional layers, the original features are mapped to a high-dimensional subspace to obtain high-dimensional features.

[0092] In this context, a high-dimensional convolutional layer has fewer input channels than its output channels; that is, a high-dimensional convolutional layer is a convolutional layer where the number of input channels is less than the number of output channels. Generally, the number of input channels in a high-dimensional convolutional layer is much smaller than the number of output channels. For example, a high-dimensional convolutional layer is a Conv(D1, D2) layer where D1 < D2.

[0093] In this context, the number of input and output channels of the high-dimensional convolutional layer is pre-defined. The number of channels in the original feature is the number of input channels for the high-dimensional convolutional layer, and the corresponding number of channels in the high-dimensional feature is the number of output channels for the high-dimensional convolutional layer. Specifically, the number of channels in the original feature obtained after passing through the Transformer layer, multi-scale convolutional layer, and fusion (splicing, flattening, linear transformation, and reshaping) satisfies the number of input channels for the high-dimensional convolutional layer.

[0094] Specifically, the original features are input into a high-dimensional convolutional layer so that the high-dimensional convolutional layer can use its convolutional kernel to locally perceive the original features. A nonlinear transformation is introduced through an activation function (such as the ReLU activation function) to map the original features from the original ECG signal space to a high-dimensional subspace, that is, from low dimension (number of input channels) to high dimension (number of output channels), forming high-dimensional features.

[0095] In this embodiment, in the original ECG signal space, ECG signals of different types may have overlapping and entangled feature distributions due to morphological similarity or noise interference, leading to ECG signal coupling. High-dimensional convolutional layers map the original features to a high-dimensional subspace, that is, through nonlinear mapping, the original features are extended to a higher dimension. This makes the originally overlapping features easier to classify in the high-dimensional subspace, thereby increasing the inter-class distance and reducing the intra-class variance, effectively decoupling the ECG signal coupling, and enabling the high-dimensional features to provide more accurate and robust evidence. Furthermore, during the high-dimensional subspace mapping process in the high-dimensional convolutional layers, the nonlinear transformation of the activation function allows the ECG classification model to adapt to the diversity of ECG signals under different acquisition devices and individual differences, enhancing generalization ability.

[0096] S103. Based on high-dimensional features, a set of labels corresponding to electrocardiogram signals is generated through a fully connected layer.

[0097] The tag set includes the ECG type corresponding to the ECG signal. Specifically, an ECG signal may involve one or more ECG types, therefore the tag set includes one or more ECG types.

[0098] A fully connected layer (FC) is a component in a neural network. Each neuron in a fully connected layer is connected to all neurons in the previous layer. The tight connection structure of a fully connected layer allows it to integrate local features from the previous layer and achieve regression or classification tasks through a combination of linear transformations and nonlinear activation functions.

[0099] To make it easier to understand, the following will be combined with... Figure 3 This paper details how a tag set corresponding to an electrocardiogram (ECG) signal is generated in the embodiments of this application.

[0100] S301. Based on high-dimensional features, multi-label classification results corresponding to electrocardiogram signals are generated through a fully connected layer.

[0101] The multi-label classification results include: probability distributions corresponding to each preset ECG type, and these probability distributions are calculated independently. For example, if three preset ECG types are set, the multi-label classification results include: probability distributions corresponding to each of the three preset ECG types, such as P1 = 0.6, P2 = 0.7, and P3 = 0.3.

[0102] In one possible implementation, the electrocardiogram (ECG) signal includes the voltage value at each time point, and the high-dimensional feature includes the high-dimensional feature vector of the ECG signal at each time point. For example, if the ECG signal is a time-series signal with T time points, including the voltage values ​​at each of the T time points, then the high-dimensional feature is (T, D2), which includes the high-dimensional feature vector of the T time points.

[0103] Furthermore, a fully connected layer is used to perform a linear transformation on the high-dimensional features to obtain the original score for each preset ECG type at each time point. Then, using the sigmoid activation function, based on the original score for each preset ECG type at each time point, the probability distribution for each preset ECG type at each time point is obtained, thus yielding the multi-label classification result corresponding to the ECG signal. The sigmoid activation function is used to calculate the score for each preset ECG type independently, without the need for normalization.

[0104] To make it easier to understand, the following example, using formulas (1) and (2), illustrates how a fully connected layer obtains the probability distribution for each preset ECG type at each time point.

[0105] Assume the high-dimensional feature is X∈R T×D2 The number of preset ECG types is E, meaning the goal is to obtain the probability distributions corresponding to each of the E preset ECG types.

[0106] The fully connected layer obtains the raw score for each preset ECG type at each time point through formula (1).

[0107] Z = XW + b (1)

[0109] Where Z is the raw score for each preset ECG type at each time point, Z∈R T×E Each element z in Z i,c Represents the raw score at time point i for the preset ECG type c; W is the weight matrix, W∈R D2×E This is used to map the D2-dimensional features at each time point to E preset ECG types. b is a bias vector, b∈R E .

[0110] The fully connected layer uses the sigmoid activation function to obtain the probability distribution of each time point for each preset ECG type based on the original score Z. The sigmoid activation function can independently calculate the probability for each preset ECG type at each time point, as shown in formula (2).

[0111]

[0112] Among them, z i,c This represents the raw score at time point i for the preset ECG type c. P∈RT×E Each row in P represents the probability distribution of the corresponding time point for each preset ECG type. Therefore, P represents the probability distribution of T time points for E preset ECG types.

[0113] S302. Based on the multi-label classification results, determine the label set corresponding to the electrocardiogram signal.

[0114] In one possible implementation, based on the multi-label classification results corresponding to the ECG signal (i.e., including obtaining the probability distribution of each time point for each preset ECG type), the preset ECG types with a probability distribution greater than a preset probability threshold at each time point are marked as 1, and the rest are marked as 0, and the binary representation of the predicted type corresponding to each time point is output; according to the binary representation of the preset type corresponding to each time point, the label set corresponding to the ECG signal is obtained.

[0115] For example, assume the obtained probability distribution With a preset probability threshold of 0.7, the binary representation of the prediction type for each time point is as follows: The resulting tag set corresponding to the ECG signal includes: the first preset ECG type and the second preset ECG type.

[0116] The above combination Figures 1-3 This paper details an electrocardiogram (ECG) classification method provided by an embodiment of this application. The following section combines... Figure 4 and Figure 5 This application provides a detailed description of an electrocardiogram (ECG) classification model and its training method, based on embodiments of the present application.

[0117] like Figure 4 As shown in the embodiment of this application, an electrocardiogram (ECG) classification model includes: a feature extraction layer 410, a high-dimensional convolutional layer 420, and a fully connected layer 430. Specifically, the feature extraction layer 410 includes: a Transformer layer 411, a multi-scale convolutional layer 412, and a feature fusion layer 413; the multi-scale convolutional layer 412 includes multiple convolutional layers with different kernel sizes.

[0118] Specifically, the electrocardiogram (ECG) signal is input into the ECG classification model. The feature extraction layer 410 extracts features from the ECG signal to obtain the original features, which are then transmitted to the high-dimensional convolutional layer 420. The high-dimensional convolutional layer 420 maps the original features to a high-dimensional subspace to obtain high-dimensional features, which are then transmitted to the fully connected layer 430. Based on the high-dimensional features, the fully connected layer 430 generates a set of labels corresponding to the ECG signal.

[0119] To make it easier to understand, the following will be combined with... Figure 5 The electrocardiogram (ECG) classification model shown is an example of an ECG classification method provided in this application.

[0120] like Figure 5 As shown, the ECG classification model includes: a Transformer layer with 64 output channels; a multi-scale convolutional layer consisting of four convolutional layers with kernels of 3×1, 5×1, 7×1, and 11×1, and each of the four convolutional layers having 16 input and output channels, namely Conv(16)3×1, Conv(16)5×1, Conv(16)7×1, and Conv(16)11×1; a feature fusion layer with 8 output channels; a high-dimensional convolutional layer with 8 input channels and 256 output channels, namely Conv(8, 256); and a fully connected layer that maps high-dimensional features to subspaces corresponding to 26 preset ECG types, i.e., the number of preset ECG types is 26.

[0121] Specifically, the ECG signal input to the Transformer layer is a time-series signal, assuming it's an ECG signal of (1, 100). The Transformer layer outputs the first feature (i.e., R) of (100, 64). 100×64 The first feature is divided into four (100, 16) sub-features along the channel dimension, and these sub-features are fed into the four convolutional layers of the multi-scale convolutional layer. The four convolutional layers output four (100, 16) second features. The feature fusion layer converts the four second features into original (100, 8) features. The high-dimensional convolutional layer maps the original (100, 8) features to a high-dimensional subspace, resulting in high-dimensional (100, 256) features. The fully connected layer performs a linear transformation and a sigmoid activation function on the high-dimensional features to obtain the multi-label classification result, i.e., R. 100×26 That is, the probability distribution of 26 preset ECG types corresponding to 100 time points; based on the multi-label classification results, a label set corresponding to the ECG signal is generated.

[0122] In this embodiment, the training process of the ECG classification model includes: dynamically selecting anchor samples, positive samples, and negative samples from the training set to construct training triplets; and training the ECG classification model based on the triplet loss function corresponding to the training triplets. That is, the ECG classification model is trained using the triplet loss function to make features of the same category as close as possible, and features of different categories as far apart as possible.

[0123] The triplet loss function is a type of loss function in contrastive learning, used to optimize feature representations using triples (anchor samples, positive samples, and negative samples).

[0124] In this system, an anchor sample is randomly selected from the training set as the anchor sample; a positive sample is an ECG signal with the same ECG type as the anchor sample; and a negative sample is an ECG signal with a different ECG type than the anchor sample. For example, the intersection of the label set corresponding to the anchor sample and the label set corresponding to the positive sample is not empty; the intersection of the label set corresponding to the anchor sample and the label set corresponding to the negative sample is empty.

[0125] To facilitate understanding, the triplet loss function will be introduced below in conjunction with formula (3).

[0126] Loss=max(0,d(A,P)-d(A,N)+margin) (4)

[0127] Where Loss is the triplet loss function, d(A, P) is the distance between the anchor sample and the positive sample (in the feature space) (usually using Euclidean or cosine distance), and d(A, N) is the distance between the anchor sample and the negative sample (in the feature space); margin is a preset boundary value, a hyperparameter representing the minimum distance difference that should be maintained between positive and negative samples. The triplet loss function is not zero only when d(A, P) + margin ≥ d(A, N), i.e., there is a loss; otherwise, the triplet loss function is zero.

[0128] In one possible implementation, the negative samples are semi-hard negative samples; the distance between the semi-hard negative sample and the anchor sample is greater than the distance between the positive sample and the anchor sample, and less than the sum of the distance between the positive sample and the anchor sample and the preset boundary value. That is, d(A, P) < d(A, N) < d(A, P) + margin, and the corresponding triplet loss function is also called the triplet semi-hard loss function.

[0129] Specifically, semi-hard negative samples are selected through semi-hard negative mining. If simple samples are used, d(A, N) > d(A, P) + margin, the triplet loss function is 0, which is of no help to training. If hard samples are used, d(A, N) < d(A, P), resulting in the maximum loss, but training is unstable and prone to overfitting. Therefore, semi-hard samples are used, i.e., semi-hard negative samples are selected, choosing negative samples where d(A, P) < d(A, N) < d(A, P) + margin, thereby training the ECG classification model based on the triplet semi-hard loss function.

[0130] By using a triplet loss function, the ECG classification model learns a feature space where similar samples (positive samples) are closer together, and dissimilar samples (negative samples) are farther apart. Furthermore, based on semi-difficult sample mining, semi-difficult triples are obtained for training, avoiding being overwhelmed by a large number of simple samples during training. This focuses on samples "close to the boundary," improving the discriminative ability of the ECG classification model and reducing the number of invalid samples, thus saving training resources. Because training emphasizes the learning of semi-difficult samples, the generalization ability of the ECG classification model is enhanced.

[0131] This application provides an electrocardiogram (ECG) classification method, comprising: extracting features from ECG signals to obtain original features; mapping the original features to a high-dimensional subspace through a high-dimensional convolutional layer to obtain high-dimensional features; and generating a label set corresponding to the ECG signals through a fully connected layer based on the high-dimensional features. This application enables automated feature extraction, and the high-dimensional convolutional layer extends features from the original signal space to a high-dimensional subspace through nonlinear mapping. This preserves key information and solves the signal coupling problem through dimensional expansion and nonlinear transformation, effectively decoupling signal coupling and thus improving the accuracy of ECG classification.

[0132] Furthermore, the first feature is obtained by adaptively aggregating feature information at different scales and locations through the Transformer layer. Then, the first feature is extracted through a multi-scale convolutional layer to obtain multiple second features. This enables fine-grained extraction of ECG signals at multiple scales from local to global, thereby capturing local details and global trends in ECG signals. This avoids focusing only on features at a single scale and ignoring the cross-scale information contained in ECG signals. The second features at multiple scales are then fused to obtain the original feature. This enables the fusion of features at multiple different scales (such as local detail features and global trend features), allowing features at different scales to complement and enhance each other, resulting in a more comprehensive and robust feature representation.

[0133] Example 2:

[0134] The following is combined Figure 6 This application provides a detailed description of an electrocardiogram (ECG) classification device according to its embodiments.

[0135] like Figure 6 As shown in the embodiment of this application, an electrocardiogram (ECG) classification device includes the following modules:

[0136] The feature extraction module 601 is used to extract features from the electrocardiogram signal to obtain the original features;

[0137] The high-dimensional mapping module 602 is used to map the original features to a high-dimensional subspace through a high-dimensional convolutional layer to obtain high-dimensional features;

[0138] The tag generation module 603 is used to generate a tag set corresponding to the electrocardiogram (ECG) signal based on high-dimensional features through a fully connected layer; wherein the tag set includes: the ECG type corresponding to the ECG signal.

[0139] In one possible implementation, the high-dimensional mapping module 602 is specifically used to input the original features into the high-dimensional convolutional layer, so that the high-dimensional convolutional layer can map the original features to a high-dimensional subspace through nonlinear transformation to obtain high-dimensional features; wherein, the number of channels of the original features is the number of input channels of the high-dimensional convolutional layer, the number of channels of the high-dimensional features is the number of output channels of the high-dimensional convolutional layer, and the number of output channels of the high-dimensional convolutional layer is greater than the number of input channels.

[0140] In one possible implementation, the feature extraction module 601 includes: a self-attention module, a multi-scale convolution module, and a feature fusion module;

[0141] The self-attention module is used to process ECG signals through the self-attention mechanism of the Transformer layer to obtain the first feature;

[0142] The multi-scale convolution module is used to extract features from the first feature through multi-scale convolutional layers to obtain multiple second features. The multi-scale convolutional layers include multiple convolutional layers in parallel, and the kernel sizes of the multiple convolutional layers are different. The multiple second features are the second features corresponding to the multiple convolutional layers respectively.

[0143] The feature fusion module is used to fuse multiple second features to obtain the original features.

[0144] In one possible implementation, the multi-scale convolution module is specifically used to divide the first feature into multiple first sub-features along the channel dimension; through the multiple convolution layers included in the multi-scale convolution layer, the multiple first sub-features are extracted one by one to obtain multiple second features.

[0145] In one possible implementation, the feature fusion module is specifically used to perform a splicing operation on multiple second features to obtain spliced ​​features; the spliced ​​features are then subjected to flattening, linear transformation, and reshaping operations in sequence to obtain the original features.

[0146] In one possible implementation, the label generation module 603 is specifically used to generate multi-label classification results corresponding to the electrocardiogram (ECG) signal through a fully connected layer based on high-dimensional features; wherein, the multi-label classification results include: probability distributions corresponding to each preset ECG type; and based on the multi-label classification results, a set of labels corresponding to the ECG signal is determined.

[0147] In one possible implementation, the label generation module 603 is specifically used to perform a linear transformation on the high-dimensional features to obtain the original score for each preset ECG type at each time point; and to obtain the probability distribution for each preset ECG type at each time point based on the original score for each preset ECG type at each time point through the sigmoid activation function, so as to obtain the multi-label classification result corresponding to the ECG signal.

[0148] In one possible implementation, the ECG classification device further includes: a model training model for dynamically selecting anchor samples, positive samples, and negative samples in the training set to construct training triplets; and training the ECG classification model based on the triplet loss function corresponding to the training triplets.

[0149] This application provides an electrocardiogram (ECG) classification device, including: a feature extraction module 601 for extracting features from ECG signals to obtain original features; a high-dimensional mapping module 602 for mapping the original features to a high-dimensional subspace through a high-dimensional convolutional layer to obtain high-dimensional features; and a label generation module 603 for generating a set of labels corresponding to the ECG signals based on the high-dimensional features through a fully connected layer. This application enables automated feature extraction, and the high-dimensional convolutional layer extends features from the original signal space to a high-dimensional subspace through nonlinear mapping. This preserves key information and solves the signal coupling problem through dimensional expansion and nonlinear transformation, effectively decoupling signal coupling and thus improving the accuracy of ECG classification.

[0150] Furthermore, the first feature is obtained by adaptively aggregating feature information at different scales and locations through the Transformer layer. Then, the first feature is extracted through a multi-scale convolutional layer to obtain multiple second features. This enables fine-grained extraction of ECG signals at multiple scales from local to global, thereby capturing local details and global trends in ECG signals. This avoids focusing only on features at a single scale and ignoring the cross-scale information contained in ECG signals. The second features at multiple scales are then fused to obtain the original feature. This enables the fusion of features at multiple different scales (such as local detail features and global trend features), allowing features at different scales to complement and enhance each other, resulting in a more comprehensive and robust feature representation.

[0151] It should be noted that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiments. The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate. The components indicated 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 solution according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0152] The above description is merely one specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. An electrocardiogram (ECG) classification method, characterized in that, The method, applied to a pre-trained electrocardiogram (ECG) classification model, includes: Feature extraction is performed on the electrocardiogram signal to obtain the original features; The original features are mapped to a high-dimensional subspace through a high-dimensional convolutional layer to obtain high-dimensional features; Based on the high-dimensional features, a tag set corresponding to the electrocardiogram (ECG) signal is generated through a fully connected layer; wherein, the tag set includes: the ECG type corresponding to the ECG signal.

2. The method according to claim 1, characterized in that, The process of mapping the original features to a high-dimensional subspace through a high-dimensional convolutional layer to obtain high-dimensional features includes: The original features are input into a high-dimensional convolutional layer so that the high-dimensional convolutional layer can map the original features to a high-dimensional subspace through nonlinear transformation to obtain high-dimensional features; wherein, the number of channels of the original features is the number of input channels of the high-dimensional convolutional layer, the number of channels of the high-dimensional features is the number of output channels of the high-dimensional convolutional layer, and the number of output channels of the high-dimensional convolutional layer is greater than the number of input channels.

3. The method according to claim 1, characterized in that, The process of extracting features from the electrocardiogram signal to obtain the original features includes: The electrocardiogram signal is processed using the self-attention mechanism of the Transformer layer to obtain the first feature; By using multi-scale convolutional layers, feature extraction is performed on the first feature to obtain multiple second features; wherein, the multi-scale convolutional layers include multiple convolutional layers in parallel, and the kernel sizes of the multiple convolutional layers are different, and the multiple second features are: second features corresponding to the multiple convolutional layers respectively; The multiple second features are fused to obtain the original features.

4. The method according to claim 3, characterized in that, The first feature is extracted using a multi-scale convolutional layer to obtain multiple second features, including: The first feature is divided into multiple first sub-features along the channel dimension; wherein, the multiple first sub-features are: the first sub-features corresponding to the multiple convolutional layers respectively; By using the multiple convolutional layers included in the multi-scale convolutional layer, feature extraction is performed on the multiple first sub-features one by one to obtain multiple second features.

5. The method according to claim 3, characterized in that, The feature fusion of the plurality of second features to obtain the original features includes: The multiple second features are concatenated to obtain the concatenated features; The spliced ​​features are then subjected to flattening, linear transformation, and reshaping operations in sequence to obtain the original features.

6. The method according to claim 1, characterized in that, The step of generating a tag set corresponding to the electrocardiogram signal through a fully connected layer based on the high-dimensional features includes: Based on the high-dimensional features, a multi-label classification result corresponding to the electrocardiogram signal is generated through a fully connected layer; wherein, the multi-label classification result includes: a probability distribution corresponding to each preset electrocardiogram type; Based on the multi-label classification results, a set of labels corresponding to the electrocardiogram signal is determined.

7. The method according to claim 6, characterized in that, The electrocardiogram (ECG) signal includes: voltage values ​​corresponding to each time point; the high-dimensional features include: high-dimensional feature vectors of the ECG signal at each time point; and the generation of multi-label classification results corresponding to the ECG signal through a fully connected layer based on the high-dimensional features includes: A linear transformation is performed on the high-dimensional features to obtain the original score for each time point for each preset ECG type; By using the sigmoid activation function, based on the original score of each time point for each preset ECG type, the probability distribution of each time point for each preset ECG type is obtained, so as to obtain the multi-label classification result corresponding to the ECG signal.

8. The method according to claim 1, characterized in that, The training process of the ECG classification model includes: Anchor samples, positive samples, and negative samples are dynamically selected from the training set to construct training triples; wherein, the positive samples are ECG signals with the same ECG type as the anchor samples, and the negative samples are ECG signals with a different ECG type than the anchor samples. The ECG classification model is trained based on the triplet loss function corresponding to the training triplet.

9. The method according to claim 8, characterized in that, The negative sample is a semi-difficult negative sample. The distance between the semi-difficult negative sample and the anchor sample is greater than the distance between the positive sample and the anchor sample, and less than the sum of the distance between the positive sample and the anchor sample and the preset boundary value.

10. An electrocardiogram (ECG) classification device, characterized in that, include: The feature extraction module is used to extract features from electrocardiogram signals to obtain the original features; The high-dimensional mapping module is used to map the original features to a high-dimensional subspace through a high-dimensional convolutional layer to obtain high-dimensional features; The tag generation module is used to generate a tag set corresponding to the electrocardiogram (ECG) signal through a fully connected layer based on the high-dimensional features; wherein the tag set includes: the ECG type corresponding to the ECG signal.