An electrophysiological signal-oriented self-supervised representation learning method and system
By employing a self-supervised representation learning method, combining self-supervised learning, vector quantization variational autoencoders, and Transformer encoders, the challenge of cross-device and cross-scenario modeling of ECG signals was solved. This enabled deep semantic feature learning and unified representation of unlabeled data, thereby improving the model's generalization and representation capabilities.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI JIAOTONG UNIV
- Filing Date
- 2026-03-24
- Publication Date
- 2026-06-26
AI Technical Summary
Existing ECG signal representation methods are difficult to achieve unified modeling across devices and scenarios, and rely on specific lead combinations and high-quality labeled data, resulting in poor model generalization ability and serious information loss.
A self-supervised representation learning method is adopted, which combines a self-supervised learning paradigm, a vector quantization variational autoencoder, and a Transformer encoder with sliding window segmentation, waveform discrete coding, sequence coding, and position coding to construct an adaptive pre-training framework to achieve unified representation of multi-channel electrocardiogram signals.
It can learn deep semantic features from massive amounts of unlabeled ECG signals without the need for labeled data, improving the model's generalization ability, fully preserving the waveform morphology and rhythm features of ECG signals, and achieving unified representation of signals across devices and leads.
Smart Images

Figure CN122286149A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electrophysiological signal processing technology, and in particular to a self-supervised representation learning method and system for electrophysiological signals. Background Technology
[0002] Electrocardiogram (ECG) signals are weak bioelectrical signals on the body surface. They not only reflect the spatial coupling of electrical activity between different parts of the heart, but also record the non-stationary changes in cardiac electrical activity over time. This complex physiological characteristic gives ECG signals two inherent features: first, the diversity of characteristic waveforms, including various waveform components such as P waves, QRS complexes, and T waves, each potentially corresponding to specific electrophysiological phenomena; and second, the time-varying nature of rhythm, manifested as quasi-periodic fluctuations and non-stationary changes in heart rate over time. These complex characteristics, intertwined with the specificities of different populations, further exacerbate individual variability in ECG signals, posing a significant challenge to the accurate analysis and characterization of ECG signals.
[0003] With the widespread adoption and development of wearable ECG monitoring devices, clinical ECG signal acquisition presents a diverse landscape, encompassing various lead configurations such as single-lead, three-lead, eight-lead, and twelve-lead configurations. ECG signals from different lead configurations exhibit significant differences in channel count, sampling frequency, and electrode topology, making it difficult to establish a unified representation method for ECG signals across devices and scenarios. Existing automated ECG analysis methods often rely on waveform features defined by specific lead combinations, resulting in the inability to achieve unified modeling of multi-source heterogeneous signals, thus becoming a bottleneck in the field of intelligent ECG analysis.
[0004] Current methods for representing electrocardiogram (ECG) signals mainly fall into two categories: expert feature engineering methods and deep learning methods. Expert feature engineering methods primarily focus on the morphological features of ECG signals and heart rate variability theory, achieving representation by extracting feature points (such as R-wave peak value and ST segment morphology) and statistical features (such as RR interval and heart rate variability indices). However, these traditional methods are limited by complex feature engineering design and poor feature point localization accuracy, leading to significant loss of representational information and sensitivity to noise, resulting in a high misdiagnosis rate in downstream diagnostic tasks. In recent years, deep learning-based representation methods have been widely applied. These methods construct deep neural networks to directly learn task-related feature representations from raw ECG signals. However, existing deep learning methods are often highly coupled with specific diagnostic tasks, and the signal representation effect heavily relies on high-quality labeled data. In practical applications, domain bias exists between different datasets, resulting in poor model generalization ability; simultaneously, the high cost of acquiring labeled data limits the model's potential application on massive amounts of unlabeled data. Furthermore, existing methods often neglect the waveform semantic characteristics and lead topology information of signals during ECG modeling, resulting in representation capabilities limited to specific diagnostic dimensions and making it difficult for models to have the potential ability to predict the risk of systemic diseases. Summary of the Invention
[0005] The purpose of this invention is to address the shortcomings of the existing technology by providing a self-supervised representation learning method and system for electrophysiological signals, establishing a unified representation model for electrocardiogram signals, and providing a lead-adaptive and well-represented foundation for numerous downstream analysis tasks in the field of intelligent electrocardiography.
[0006] On the one hand, a self-supervised representation learning method for electrophysiological signals is provided, including the following steps: S1: Acquire multi-channel electrophysiological signals and perform serialization modeling, converting them into serialized feature representations; S2: Perform a random masking operation on the serialized feature representation, discard some sequence segments, and obtain the visible sequence features; S3: Input the visible sequence features into the representation model based on the Transformer encoder, extract global context features, and obtain the hidden layer representation vector; S4: The hidden layer representation vector and the mask mark are concatenated and input into the decoder to predict the masked original signal segment; S5: Construct a loss function based on the reconstruction error between the original signal segment and the predicted signal segment, build an adaptive pre-training framework based on mask autoencoder and multi-agent task, iteratively optimize the model parameters, and obtain a fully trained self-supervised electrophysiological signal representation model.
[0007] Further, in step S1, acquiring multi-channel electrophysiological signals and performing sequential modeling includes: The signal of each channel is divided into several signal segments by using a sliding window along the time direction; The multi-channel signal segments corresponding to each window are flattened in the channel direction to obtain the electrocardiogram signal block; For each signal block, waveform discrete encoding, sequence encoding, and position encoding are performed separately, and the three are added together to obtain the final serialized feature representation. The calculation formula is expressed as follows: , in, This represents discrete waveform encoding. Indicates sequence encoding, This represents the positional encoding, where the waveform discrete encoding is generated using a vector quantization variational autoencoder (VQ-VAE) model.
[0008] Preferably, the waveform discrete encoding is generated using a vector quantization variational autoencoder (VQ-VAE) model, specifically including: A VQ-VAE model is constructed, consisting of an encoder, a discrete codebook, and a decoder, where the discrete codebook is defined as a learnable embedding space. ,in Represented as a codebook vector, Indicates the size of the embedding space. For the embedded dimension; signal segment Input encoder to obtain latent features Targeting latent features Each set of feature vectors in Using nearest neighbor search from discrete codebooks Obtain the codebook vector that is closest to the set of features, and use the index of that codebook vector. As the codebook index corresponding to the current feature, a new codebook feature is obtained. The process is as follows: , , in, Indicates the first discrete codebook Each codebook vector; Using the decoder from the codebook features Reconstruct the signal segment to obtain the predicted value. ; A total loss function is constructed based on reconstruction loss, codebook alignment loss, and encoder alignment loss, and the model parameters are jointly optimized. The three loss functions are expressed as follows: , , , in, This represents the reconstruction loss based on MSE, used to ensure the overall optimization direction and enable the model to learn the features of the signal segment itself. This represents the codebook alignment loss, used to optimize the embedding space. This gradually aligns the codebook vector with the encoder's feature space, where This indicates the gradient truncation operation; The encoder alignment loss is used to gradually align the encoder output with the embedding space; the sum of the three loss functions is used to obtain the total loss function, which is used to train the waveform coding model. After training, the encoder and discrete codebook are retained for generating discrete waveform codes for signal segments.
[0009] More preferably, the location encoding uses a learnable parameter vector to represent the location information of each signal segment in the time dimension and the lead dimension; The sequence encoding maps the original features of the signal segment to the encoding space through affine transformation.
[0010] Furthermore, in step S3, the representation model based on the Transformer encoder consists of multiple identical stacked layers. Each layer contains a multi-head self-attention sublayer and a feedforward neural network sublayer. Each sublayer employs residual connections and layer normalization. The structural formula is as follows: , in, This represents the sequence features of the input representation model based on the Transformer encoder. Indicates the current sub-layer's response to the input. Transformation operations, Representation layer normalization; The multi-head self-attention mechanism maps the input sequence to queries, keys, and values through multiple sets of learnable parameter matrices, and calculates self-attention features through scaled dot products and SoftMax normalization, as shown in the following formula: , , , in, , and There are three sets of learnable parameter matrices. , and These are the query matrix, key matrix, and value matrix obtained from the mapping, respectively. In a multi-head mechanism, these regions are used to generate the query matrix, key matrix, and value matrix for each attention head. ; The query matrix, key matrix, and value matrix input to the multi-head self-attention mechanism are typically obtained by linear projection as described earlier. , and same, This means performing a normalization operation on each row of the attention score matrix so that the sum of the weights in each row is 1, resulting in the attention weight matrix. is the scaling factor, where The dimension of the key vector; Indicates the first The output features of an attention head For the total number of attention heads, This indicates that the output features of all attention heads are concatenated along the feature dimension. This represents the learnable output projection matrix; This represents the final output of the multi-head self-attention mechanism; The feedforward neural network consists of two fully connected layers and a nonlinear activation function, which is represented as follows: in, The input feature vector or matrix is usually the output of the previous layer. This represents the weight matrix of the first fully connected layer. This represents the bias term of the first fully connected layer. express, This represents the weight matrix of the second fully connected layer. Represents the activation function of the Gaussian error linear unit. This represents the final output of the feedforward neural network.
[0011] Furthermore, in step S4, the decoder adopts a lightweight structure based on a Transformer encoder, which has fewer parameters than the representation model, and is used to generate a complete signal sequence based on the representation of the visible signal and the mask marking.
[0012] Further, in step S5, the loss function is the mean squared error based on block normalization. The formula is expressed as follows: , , in, and These are used to adjust the loss weights for the masked and unmasked regions, respectively. The masking ratio represents the proportion of the number of signal segments that are masked out of the total number of signal segments. proportion, This represents the total number of signal segments. and These represent the original signal segment and the predicted signal segment, respectively. This represents a set of sequence indices representing the masked region; This represents the loss value of a single signal segment. Describing the L2 norm, This represents the z-score normalization operation, which processes the original signal segment and the predicted signal segment, and sets loss weights for the masked region and the non-masked region respectively.
[0013] Furthermore, in step S5, the adaptive pre-training framework includes two stages: The first stage involves training the waveform encoding model by sampling electrocardiogram (ECG) records from the pre-training dataset, segmenting them into ECG segments, and then optimizing the VQ-VAE model. The second stage freezes the waveform encoding model after training and uses it as a component of the serialization model. After serialization transformation of the ECG signal, a masking operation is performed. The representation model is trained using the visible sequence, and the original signal is reconstructed through the decoder to optimize the parameters of the representation model.
[0014] Preferably, the first stage specifically includes: S51: Randomly sample data from the pre-training dataset according to the preset dataset and sample ratios to construct the training dataset, and simultaneously initialize the encoder in the waveform encoding model. Decoder and discrete codebook embedding space; S52: Input ECG signal segments from the training dataset into the encoder. Extract latent features, obtain the codebook vector and its index that are closest to the latent features from the discrete codebook through nearest neighbor search, obtain the codebook features, and input the codebook features into the decoder to reconstruct the signal segment; A total loss function is constructed based on reconstruction loss, codebook alignment loss, and encoder alignment loss, and the parameters of the encoder, decoder, and discrete codebook are iteratively optimized. S53: Repeat step S52 until the preset number of training rounds is reached, and output the trained encoder. The discrete codebook is used as a waveform encoding model to generate the waveform discrete encoding used in the serialization modeling of claim 1.
[0015] Preferably, the second stage specifically includes: S54: Initialize the serialization model, ECG representation model, and decoder, and set the mask markers; S55: Sample ECG signals from the pre-training dataset, convert the ECG signals into serialized feature representations through the serialization model according to the randomly selected lead scene index, and randomly select some segments from the serialized feature representations as mask segments according to the preset mask ratio, with the rest as visible segments; S56: Input the visible segment into the ECG representation model, extract the hidden layer representation vector of the visible segment, concatenate the hidden layer representation vector with the mask marker to form a complete sequence feature, input it into the decoder, and reconstruct the complete predicted signal segment; S57: Construct a loss function based on the reconstruction error between the original signal segment and the predicted signal segment, and update the parameters of the ECG representation model and the decoder using the loss function and a preset learning rate; S58: Repeat steps S55~S57 until the preset training rounds are reached, and output the trained ECG representation model.
[0016] More preferably, in step S55, the ECG signal is converted into a serialized feature representation using the serialization model based on the randomly selected lead scene index, further including: Define a set of lead scenario indexes, where each lead scenario index corresponds to a set of channels; Define the learnable position code for each channel; For the lead scenario of the current sampled ECG signal, the corresponding position code is selected according to the corresponding channel set, and a serialized feature representation containing waveform code, sequence code and position code is generated according to the serialization modeling method described in step S1.
[0017] On the other hand, the present invention provides a self-supervised representation learning system for electrophysiological signals, comprising: The serialization modeling module is used to acquire multi-channel electrophysiological signals and perform serialization modeling on them, converting them into serialized feature representations; The random masking module is used to perform a random masking operation on the serialized feature representation, discarding some sequence segments to obtain visible sequence features; The feature extraction module is used to input the visible sequence features into the representation model based on the Transformer encoder, extract global context features, and obtain the hidden layer representation vector. The signal reconstruction module is used to concatenate the hidden layer representation vector with the mask mark and input it into the decoder to predict the masked original signal segment; The training module is optimized by constructing a loss function based on the reconstruction error between the original signal segment and the predicted signal segment. An adaptive pre-training framework based on mask autoencoder and multi-agent task is constructed, and the model parameters are iteratively optimized to obtain a fully trained self-supervised electrophysiological signal representation model.
[0018] Compared with the prior art, the beneficial effects of the present invention are: (1) This invention uses a self-supervised learning paradigm based on mask modeling to learn deep semantic features from massive unlabeled electrocardiogram signals without relying on labeled data, thus solving the problems of strong dependence on labeled data and poor generalization ability of existing methods. (2) The present invention uses a vector quantization variational autoencoder to discretely encode ECG waveform segments, thus fully preserving the waveform morphology and rhythm characteristics of the ECG signal; (3) The present invention adopts an asymmetric encoder-decoder structure and a block normalized loss function, which forces the encoder to learn more essential semantic representations, while balancing the contribution of different amplitude regions such as QRS groups and P waves to the loss, thereby improving the model's ability to represent the overall waveform morphology. (4) This invention uses an adaptive lead position encoding mechanism in serialization modeling to map ECG signals from multiple scenarios to the same feature space, thereby achieving a unified representation of cross-device and cross-lead configuration signals. Attached Figure Description
[0019] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a flowchart of a self-supervised representation learning method for electrophysiological signals according to the present invention. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0021] The specific embodiments of the present invention will be described below with reference to the accompanying drawings and examples.
[0022] Example 1 Please see Figure 1 The technical solution of the self-supervised representation learning method for electrophysiological signals provided in this embodiment includes the following steps: S1: Acquire multi-channel electrophysiological signals and perform serialization modeling, converting them into serialized feature representations; S2: Perform a random masking operation on the serialized feature representation, discard some sequence segments, and obtain the visible sequence features; S3: Input the visible sequence features into the representation model based on the Transformer encoder, extract global context features, and obtain the hidden layer representation vector; S4: The hidden layer representation vector and the mask mark are concatenated and input into the decoder to predict the masked original signal segment; S5: Construct a loss function based on the reconstruction error between the original signal segment and the predicted signal segment, build an adaptive pre-training framework based on mask autoencoder and multi-agent task, iteratively optimize the model parameters, and obtain a fully trained self-supervised electrophysiological signal representation model.
[0023] First, in step S1, acquiring multi-channel electrophysiological signals and performing sequential modeling includes: The signal of each channel is divided into several signal segments by using a sliding window along the time direction; The multi-channel signal segments corresponding to each window are flattened in the channel direction to obtain the electrocardiogram signal block; For each signal block, waveform discrete encoding, sequence encoding, and position encoding are performed separately, and the three are added together to obtain the final serialized feature representation. The calculation formula is expressed as follows: , in, This represents discrete waveform encoding. Indicates sequence encoding, This represents the positional encoding, where the waveform discrete encoding is generated using a vector quantization variational autoencoder (VQ-VAE) model.
[0024] Specifically, the waveform discrete encoding is generated using a vector quantization variational autoencoder (VQ-VAE) model, including: A VQ-VAE model is constructed, consisting of an encoder, a discrete codebook, and a decoder, where the discrete codebook is defined as a learnable embedding space. ,in Represented as a codebook vector, Indicates the size of the embedding space. For the embedded dimension; signal segment Input encoder to obtain latent features Targeting latent features Each set of feature vectors in Using nearest neighbor search from discrete codebooks Obtain the codebook vector that is closest to the set of features, and use the index of that codebook vector. As the codebook index corresponding to the current feature, a new codebook feature is obtained. The process is as follows: , , in, Indicates the first discrete codebook Each codebook vector; Using the decoder from the codebook features Reconstruct the signal segment to obtain the predicted value. ; A total loss function is constructed based on reconstruction loss, codebook alignment loss, and encoder alignment loss, and the model parameters are jointly optimized. The three loss functions are expressed as follows: , , , in, This represents the reconstruction loss based on MSE, used to ensure the overall optimization direction and enable the model to learn the features of the signal segment itself. This represents the codebook alignment loss, used to optimize the embedding space. This gradually aligns the codebook vector with the encoder's feature space, where This indicates the gradient truncation operation; The encoder alignment loss is used to gradually align the encoder output with the embedding space; the sum of the three loss functions is used to obtain the total loss function, which is used to train the waveform coding model. After training, the encoder and discrete codebook are retained for generating discrete waveform codes for signal segments.
[0025] Meanwhile, the location encoding uses a learnable parameter vector to represent the location information of each signal segment in the time dimension and the lead dimension; The sequence encoding maps the original features of the signal segment to the encoding space through affine transformation.
[0026] Specifically, in this embodiment, for multi-channel electrocardiogram signals... ,in For the number of channels, To determine the signal duration, a serialization model needs to be designed. ,Will Transform into a set of sequences ,in For sequence length, The dimensional features corresponding to each sequence point. Input serialization is very common in the field of natural language processing. Due to the discrete nature of language, techniques such as word2vec[xx] can be used to serialize inputs with a character count of... The statements are converted into a sequence. However, since a single data point in an electrocardiogram (ECG) signal has no practical meaning, the sequence cannot be simply converted into a sequence. The length is equal to This directly converts the signal into a sequence. Therefore, a method for processing multi-channel electrocardiogram signals was designed. Methods for performing serialization modeling. For electrocardiogram (ECG) signals. First, the signal of each channel is divided into a set of signal segments using a window of a specific width along the time direction. ,in This indicates the width of the sliding window, which is then flattened to obtain a set of ECG signal blocks. Finally, both waveform encoding and sequence encoding methods are used to... The sequence can be obtained by mapping. .
[0027] Among them, the waveform segments of the electrocardiogram (ECG) signal are highly semantic, and each of its forms may represent a specific type of electrophysiological phenomenon. Inspired by the vocabulary concept in natural language processing and the highly semantic characteristics of ECG signal waveforms, this strategy uses a vector quantization variable molecular encoder model to discretely encode the waveform segments of the signal to generate highly semantic waveform codes.
[0028] The VQ-VAE model designed for ECG waveform encoding has an overall encoder-discrete codebook-decoder structure. The encoder and decoder employ an asymmetric design and both utilize multi-scale residual modules to enhance their feature extraction capabilities from ECG signals. Specifically, the waveform discrete encoding is generated using a vector quantization variational autoencoder (VQ-VAE) model, as shown in the formula above. New codebook features are then generated. During the process, because of the existence Therefore, the training process involves gradient truncation, requiring separate optimization of loss functions for the codebook and encoder. Thus, a three-part loss function is introduced to optimize the entire model. , and .
[0029] Furthermore, in the serialization modeling, a sequence coding strategy is employed, primarily used to directly map the original information of signal segments to the coding space. Here, we obtain this using affine transformation, i.e. .
[0030] Furthermore, since the Transformer model used in subsequent self-supervised learning loses the relative positional information between segments, it is detrimental to the learning of the agent task. Therefore, this invention provides each signal segment with... A unique location code was designed. It uses a set of learnable parameters to represent Location information in both time and space (leads).
[0031] Finally, combining the three encoding methods mentioned above, we can obtain the electrocardiogram signal. Encoded as a set of sequences .
[0032] After the above sequence is processed in step S2, visible sequence features are obtained and input into the representation model based on the Transformer encoder, as shown in step S3. The representation model based on the Transformer encoder consists of multiple identical stacked layers. Each layer contains a multi-head self-attention sublayer and a feedforward neural network sublayer. Each sublayer uses residual connections and layer normalization. The structural formula is expressed as follows: , in, This represents the sequence features of the input representation model based on the Transformer encoder. Indicates the current sub-layer's response to the input. Transformation operations, Representation layer normalization; The multi-head self-attention mechanism maps the input sequence to queries, keys, and values through multiple sets of learnable parameter matrices, and calculates self-attention features through scaled dot products and SoftMax normalization, as shown in the following formula: , , , in, , and There are three sets of learnable parameter matrices. , and These are the query matrix, key matrix, and value matrix obtained from the mapping, respectively. In a multi-head mechanism, these regions are used to generate the query matrix, key matrix, and value matrix for each attention head. ; The query matrix, key matrix, and value matrix input to the multi-head self-attention mechanism are typically obtained by linear projection as described earlier. , and same, This means performing a normalization operation on each row of the attention score matrix so that the sum of the weights in each row is 1, resulting in the attention weight matrix. is the scaling factor, where The dimension of the key vector; Indicates the first The output features of an attention head For the total number of attention heads, This indicates that the output features of all attention heads are concatenated along the feature dimension. This represents the learnable output projection matrix; This represents the final output of the multi-head self-attention mechanism; The feedforward neural network consists of two fully connected layers and a nonlinear activation function, which is represented as follows: in, The input feature vector or matrix is usually the output of the previous layer. This represents the weight matrix of the first fully connected layer. This represents the bias term of the first fully connected layer. express, This represents the weight matrix of the second fully connected layer. Represents the activation function of the Gaussian error linear unit. This represents the final output of the feedforward neural network.
[0033] In this embodiment, for electrocardiogram signals, after encoding them into sequence features using the sequence model from the previous section, the sequence features can be directly... The data is fed into the Transformer Encoder for global feature learning. Specifically, the Transformer Encoder consists of multiple stacked identical layers, each containing two core sub-layers: 1. A Multi-Head Self-Attention Feed-Forward Network (FFN). Unlike batch normalization commonly used in convolutional neural networks, this invention uses Layer Normalization to mitigate internal covariate bias and stabilize the training process when constructing the ECG representation model. The main difference between layer normalization and batch normalization is that the former normalizes the features of a single sample. Unlike the relatively stable numerical range of images, the numerical fluctuation range of ECG signals is open-space, and population specificity leads to significant variations in the morphological numerical range of the same ECG. Furthermore, the quasi-periodicity of the ECG signal itself makes layer normalization more suitable. Subsequently, the normalized features enter the feed-forward network. This network consists of two fully connected layers and a group of non-linear activation functions. The aforementioned ECG representation model based on the Transformer Encoder combines the characteristics of ECG signals themselves, fully utilizes the global modeling capabilities of self-attention, and ensures stability during large-scale data training based on residual connections and layer normalization. Finally, after the ECG signal passes through the serialization model and the Transformer Encoder layer, the encoded sequence features can be obtained. Linear mapping is then used to flexibly map these features to specific task spaces for different downstream tasks.
[0034] Next, in step S4, the decoder adopts a lightweight structure based on the Transformer encoder, which has fewer parameters than the representation model, and is used to generate a complete signal sequence based on the representation of the visible signal and the mask marking.
[0035] Finally, the agent task is designed. First, the ECG signal is serialized and encoded. Then, the encoded sequence is processed according to the mask ratio. The code is randomly selected and discarded. The remaining code is fed into the encoder to obtain the representation features. Then, the mask features [M] are used to pad the previous mask positions. Finally, the decoder uses the padded features to predict the original ECG signal.
[0036] This invention employs an asymmetric "encoder-decoder" structure. The encoding part uses an electrocardiogram (ECG) representation model, while the decoder uses a similar representation model based on a Transformer Encoder, with relatively few parameters and a lightweight design. In this structure, the encoder processes visible ECG encoded features, and its training aims to better represent the visible signal. The decoder receives the representation of the visible signal and the labeling of the mask blocks, and learns the information of the visible representation and positional information through the Transformer encoder to generate the complete signal. Therefore, the decoder performs a generation task.
[0037] In step S5, for the agent task in the pre-training stage, this invention uses block-normalized mean squared error as the loss function, wherein the loss function is block-normalized mean squared error. The formula is expressed as follows: , , in, and These are used to adjust the loss weights for the masked and unmasked regions, respectively. The masking ratio represents the proportion of the number of signal segments that are masked out of the total number of signal segments. proportion, This represents the total number of signal segments. and These represent the original signal segment and the predicted signal segment, respectively. This represents a set of sequence indices representing the masked region; This represents the loss value of a single signal segment. Describing the L2 norm, This represents the z-score normalization operation, which processes the original signal segment and the predicted signal segment, and sets loss weights for the masked region and the non-masked region respectively.
[0038] Specifically, the loss in the non-masked region allows the encoder to gain a deeper understanding of the relative positional information within the visible block, especially the relationships between leads. Conversely, the loss in the masked region prompts the model to focus more on the relationship between the visible sequence and the masked sequence, thereby improving the representational power of each block. The inclusion of normalization methods is primarily due to the fact that ECG signals can be viewed as sparse event-driven time series, with significant amplitude differences between the QRS region and regions such as the baseline and P wave. MSE comprehensively measures the average difference between two signals, causing the model to focus more on the QRS region while exhibiting certain waveform optimization differences in regions such as the P wave. Therefore, normalization is performed on each signal segment to improve the signal prediction performance.
[0039] Based on all the above, we pre-train the model using the constructed adaptive pre-training framework. This adaptive pre-training framework consists of two stages: The first stage involves training the waveform encoding model by sampling electrocardiogram (ECG) records from the pre-training dataset, segmenting them into ECG segments, and then optimizing the VQ-VAE model. The second stage freezes the waveform encoding model after training and uses it as a component of the serialization model. After serialization transformation of the ECG signal, a masking operation is performed. The representation model is trained using the visible sequence, and the original signal is reconstructed through the decoder to optimize the parameters of the representation model.
[0040] The first stage specifically includes: S51: Randomly sample data from the pre-training dataset according to the preset dataset and sample ratios to construct the training dataset, and simultaneously initialize the encoder in the waveform encoding model. Decoder and discrete codebook embedding space; S52: Input ECG signal segments from the training dataset into the encoder. Extract latent features, obtain the codebook vector and its index that are closest to the latent features from the discrete codebook through nearest neighbor search, obtain the codebook features, and input the codebook features into the decoder to reconstruct the signal segment; A total loss function is constructed based on reconstruction loss, codebook alignment loss, and encoder alignment loss, and the parameters of the encoder, decoder, and discrete codebook are iteratively optimized. S53: Repeat step S52 until the preset number of training rounds is reached, and output the trained encoder. The discrete codebook is used as a waveform encoding model to generate the waveform discrete encoding used in the serialization modeling of claim 1.
[0041] The second stage specifically includes: S54: Initialize the serialization model, ECG representation model, and decoder, and set the mask markers; S55: Sample ECG signals from the pre-training dataset, convert the ECG signals into serialized feature representations through the serialization model according to the randomly selected lead scene index, and randomly select some segments from the serialized feature representations as mask segments according to the preset mask ratio, with the rest as visible segments; S56: Input the visible segment into the ECG representation model, extract the hidden layer representation vector of the visible segment, concatenate the hidden layer representation vector with the mask marker to form a complete sequence feature, input it into the decoder, and reconstruct the complete predicted signal segment; S57: Construct a loss function based on the reconstruction error between the original signal segment and the predicted signal segment, and update the parameters of the ECG representation model and the decoder using the loss function and a preset learning rate; S58: Repeat steps S55~S57 until the preset training rounds are reached, and output the trained ECG representation model.
[0042] In step S55, based on the randomly selected lead scene index, the ECG signal is converted into a serialized feature representation using the serialization model, further including: Define a set of lead scenario indexes, where each lead scenario index corresponds to a set of channels; Define the learnable position code for each channel; For the lead scenario of the current sampled ECG signal, the corresponding position code is selected according to the corresponding channel set, and a serialized feature representation containing waveform code, sequence code and position code is generated according to the serialization modeling method described in step S1.
[0043] Specifically, for the ECG serialization model, the training objective is to encode ECG segments. Therefore, a batch of ECG records is first sampled from the pre-training dataset. For each record, it is divided into ECG segments, and half of the segments are randomly selected and included in the first-stage training set for training. The entire process is described by Algorithm 1 (Table 1). After training, only lines 3 and 4 of Algorithm 1 (Table 1) need to be run to obtain the waveform encoding of the ECG segments.
[0044] Table 1. One-stage training process of the representation model During the second-stage training, the waveform encoding model from the first stage is frozen and added to the serialization model. Then, as shown in Algorithm 2 (Table 2), each ECG signal is serialized and transformed, followed by masking, representation, mask feature completion, decoding, and other operations to finally train the representation model.
[0045] Table 2 Two-stage training process of the representation model It is worth mentioning that this invention employs an adaptive lead training method during training to enhance the model's adaptability across various scenarios. Specifically, a scenario index set is first defined. ,in This indicates the channel number corresponding to the lead scenario. Next, the position code for each channel is defined. ,in This represents the overall location coding features. Subsequently, data is used for specific lead scenarios. During serialization, its serialization features are defined as described in step S1. .
[0046] Furthermore, the electrophysiological signals described in this invention include electrocardiogram (ECG) signals, and the method is applicable to various lead configurations, including single-lead, three-lead, eight-lead, and twelve-lead ECG signals. The trained representation model is adapted to different downstream tasks through linear mapping, including ECG signal classification, rhythm abnormality detection, waveform distortion identification, and systemic disease risk prediction.
[0047] Based on the above methods, this invention provides a self-supervised representation learning system for electrophysiological signals, comprising: The serialization modeling module is used to acquire multi-channel electrophysiological signals and perform serialization modeling on them, converting them into serialized feature representations; The random masking module is used to perform a random masking operation on the serialized feature representation, discarding some sequence segments to obtain visible sequence features; The feature extraction module is used to input the visible sequence features into the representation model based on the Transformer encoder, extract global context features, and obtain the hidden layer representation vector. The signal reconstruction module is used to concatenate the hidden layer representation vector with the mask mark and input it into the decoder to predict the masked original signal segment; The training module is optimized by constructing a loss function based on the reconstruction error between the original signal segment and the predicted signal segment. An adaptive pre-training framework based on mask autoencoder and multi-agent task is constructed, and the model parameters are iteratively optimized to obtain a fully trained self-supervised electrophysiological signal representation model.
[0048] It should be noted that the steps in the self-supervised representation learning method for electrophysiological signals provided in this embodiment can be implemented based on the corresponding modules in the self-supervised representation learning system for electrophysiological signals. Those skilled in the art can refer to the technical solution of the system to implement the steps of the method. That is, the embodiments in the system can be understood as preferred examples of implementing the method, and will not be elaborated here.
[0049] Besides implementing the system and its various devices provided by this invention in purely computer-readable program code, the same functions can be achieved by logically programming the method steps, making the system and its various devices of this invention appear as logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, the system and its various devices provided by this invention can be considered as a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component; alternatively, the devices for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0050] Finally, it should be noted that the above description is only a preferred embodiment of the present invention, and the scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be pointed out that for those skilled in the art, any improvements and modifications made without departing from the principle of the present invention should also be considered within the scope of protection of the present invention.
[0051] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. A self-supervised representation learning method for electrophysiological signals, characterized in that, Includes the following steps: S1: Acquire multi-channel electrophysiological signals and perform serialization modeling, converting them into serialized feature representations; S2: Perform a random masking operation on the serialized feature representation, discard some sequence segments, and obtain the visible sequence features; S3: Input the visible sequence features into the representation model based on the Transformer encoder, extract global context features, and obtain the hidden layer representation vector; S4: The hidden layer representation vector and the mask mark are concatenated and input into the decoder to predict the masked original signal segment; S5: Construct a loss function based on the reconstruction error between the original signal segment and the predicted signal segment, build an adaptive pre-training framework based on mask autoencoder and multi-agent task, iteratively optimize the model parameters, and obtain a fully trained self-supervised electrophysiological signal representation model.
2. The self-supervised representation learning method for electrophysiological signals according to claim 1, characterized in that, In step S1, acquiring multi-channel electrophysiological signals and performing serialization modeling includes: The signal of each channel is divided into several signal segments by using a sliding window along the time direction; The multi-channel signal segments corresponding to each window are flattened in the channel direction to obtain the electrocardiogram signal block; For each signal block, waveform discrete encoding, sequence encoding, and position encoding are performed separately, and the three are added together to obtain the final serialized feature representation. The calculation formula is expressed as follows: , in, This represents discrete waveform encoding. Indicates sequence encoding, This represents the positional encoding, where the waveform discrete encoding is generated using a vector quantization variational autoencoder (VQ-VAE) model.
3. The self-supervised representation learning method for electrophysiological signals according to claim 2, characterized in that, The waveform discrete encoding is generated using a vector quantization variational autoencoder (VQ-VAE) model, specifically including: A VQ-VAE model is constructed, consisting of an encoder, a discrete codebook, and a decoder, where the discrete codebook is defined as a learnable embedding space. ,in Represented as a codebook vector, Indicates the size of the embedding space. For the embedded dimension; signal segment Input encoder to obtain latent features Targeting latent features Each set of feature vectors in Using nearest neighbor search from discrete codebooks Obtain the codebook vector that is closest to the set of features, and use the index of that codebook vector. As the codebook index corresponding to the current feature, a new codebook feature is obtained. The process is as follows: , , in, Indicates the first discrete codebook Each codebook vector; Using the decoder from the codebook features Reconstruct the signal segment to obtain the predicted value. ; A total loss function is constructed based on reconstruction loss, codebook alignment loss, and encoder alignment loss, and the model parameters are jointly optimized. The three loss functions are expressed as follows: , , , in, This represents the reconstruction loss based on MSE, used to ensure the overall optimization direction and enable the model to learn the features of the signal segment itself. This represents the codebook alignment loss, used to optimize the embedding space. This gradually aligns the codebook vector with the encoder's feature space, where This indicates the gradient truncation operation; The encoder alignment loss is used to gradually align the encoder output with the embedding space; the sum of the three loss functions is used to obtain the total loss function, which is used to train the waveform coding model. After training, the encoder and discrete codebook are retained for generating discrete waveform codes for signal segments.
4. The self-supervised representation learning method for electrophysiological signals according to claim 2, characterized in that, The location encoding uses a learnable parameter vector to represent the location information of each signal segment in the time dimension and the lead dimension; The sequence encoding maps the original features of the signal segment to the encoding space through affine transformation.
5. The self-supervised representation learning method for electrophysiological signals according to claim 3, characterized in that, In step S3, the representation model based on the Transformer encoder consists of multiple identical stacked layers. Each layer contains a multi-head self-attention sublayer and a feedforward neural network sublayer. Each sublayer employs residual connections and layer normalization. The structural formula is as follows: , in, This represents the sequence features of the input representation model based on the Transformer encoder. Indicates the current sub-layer's response to the input. Transformation operations, Representation layer normalization; The multi-head self-attention mechanism maps the input sequence to queries, keys, and values through multiple sets of learnable parameter matrices, and calculates self-attention features through scaled dot products and SoftMax normalization, as shown in the following formula: , , , in, , and There are three sets of learnable parameter matrices. , and These are the query matrix, key matrix, and value matrix obtained from the mapping, respectively. In a multi-head mechanism, these regions are used to generate the query matrix, key matrix, and value matrix for each attention head. ; The query matrix, key matrix, and value matrix input to the multi-head self-attention mechanism are typically obtained by linear projection as described earlier. , and same, This means performing a normalization operation on each row of the attention score matrix so that the sum of the weights in each row is 1, resulting in the attention weight matrix. is the scaling factor, where The dimension of the key vector; Indicates the first The output features of each attention head For the total number of attention heads, This indicates that the output features of all attention heads are concatenated along the feature dimension. This represents the learnable output projection matrix; This represents the final output of the multi-head self-attention mechanism; The feedforward neural network consists of two fully connected layers and a nonlinear activation function, which is represented as follows: in, The input feature vector or matrix is usually the output of the previous layer. This represents the weight matrix of the first fully connected layer. This represents the bias term of the first fully connected layer. express, This represents the weight matrix of the second fully connected layer. Represents the activation function of the Gaussian error linear unit. This represents the final output of the feedforward neural network.
6. The self-supervised representation learning method for electrophysiological signals according to claim 1, characterized in that, In step S4, the decoder adopts a lightweight structure based on the Transformer encoder, which has fewer parameters than the representation model, and is used to generate a complete signal sequence based on the representation of the visible signal and the mask marking.
7. The self-supervised representation learning method for electrophysiological signals according to claim 1, characterized in that, In step S5, the loss function is the mean squared error based on block normalization. The formula is expressed as follows: , , in, and These are used to adjust the loss weights for the masked and unmasked regions, respectively. The masking ratio represents the proportion of the number of signal segments that are masked out of the total number of signal segments. proportion, This represents the total number of signal segments. and These represent the original signal segment and the predicted signal segment, respectively. This represents a set of sequence indices representing the masked region; This represents the loss value of a single signal segment. Describing the L2 norm, This represents the z-score normalization operation, which processes the original signal segment and the predicted signal segment, and sets loss weights for the masked region and the non-masked region respectively.
8. The self-supervised representation learning method for electrophysiological signals according to claim 5, characterized in that, In step S5, the adaptive pre-training framework includes two stages: The first stage involves training the waveform encoding model by sampling electrocardiogram (ECG) records from the pre-training dataset, segmenting them into ECG segments, and then optimizing the VQ-VAE model. The second stage freezes the waveform encoding model after training and uses it as a component of the serialization model. After serialization transformation of the ECG signal, a masking operation is performed. The representation model is trained using the visible sequence, and the original signal is reconstructed through the decoder to optimize the parameters of the representation model.
9. The self-supervised representation learning method for electrophysiological signals according to claim 8, characterized in that, The first stage specifically includes: S51: Randomly sample data from the pre-training dataset according to the preset dataset and sample ratios to construct the training dataset, and simultaneously initialize the encoder in the waveform encoding model. Decoder and discrete codebook embedding space; S52: Input ECG signal segments from the training dataset into the encoder. Extract latent features, obtain the codebook vector and its index that are closest to the latent features from the discrete codebook through nearest neighbor search, obtain the codebook features, and input the codebook features into the decoder to reconstruct the signal segment; A total loss function is constructed based on reconstruction loss, codebook alignment loss, and encoder alignment loss, and the parameters of the encoder, decoder, and discrete codebook are iteratively optimized. S53: Repeat step S52 until the preset number of training rounds is reached, and output the trained encoder. The discrete codebook is used as a waveform encoding model to generate the waveform discrete encoding used in the serialization modeling described in claim 1.
10. The self-supervised representation learning method for electrophysiological signals according to claim 9, characterized in that, The second stage specifically includes: S54: Initialize the serialization model, ECG representation model, and decoder, and set the mask markers; S55: Sample ECG signals from the pre-training dataset, convert the ECG signals into serialized feature representations through the serialization model according to the randomly selected lead scene index, and randomly select some segments from the serialized feature representations as mask segments according to the preset mask ratio, with the rest as visible segments; S56: Input the visible segment into the ECG representation model, extract the hidden layer representation vector of the visible segment, concatenate the hidden layer representation vector with the mask marker to form a complete sequence feature, input it into the decoder, and reconstruct the complete predicted signal segment; S57: Construct a loss function based on the reconstruction error between the original signal segment and the predicted signal segment, and update the parameters of the ECG representation model and the decoder using the loss function and a preset learning rate; S58: Repeat steps S55~S57 until the preset training rounds are reached, and output the trained ECG representation model.
11. The self-supervised representation learning method for electrophysiological signals according to claim 10, characterized in that, In step S55, based on the randomly selected lead scene index, the ECG signal is converted into a serialized feature representation using the serialization model, further including: Define a set of lead scenario indexes, where each lead scenario index corresponds to a set of channels; Define the learnable position code for each channel; For the lead scenario of the current sampled ECG signal, the corresponding position code is selected according to the corresponding channel set, and a serialized feature representation containing waveform code, sequence code and position code is generated according to the serialization modeling method described in step S1.
12. A self-supervised representation learning system for electrophysiological signals, characterized in that, include: The serialization modeling module is used to acquire multi-channel electrophysiological signals and perform serialization modeling on them, converting them into serialized feature representations; The random masking module is used to perform a random masking operation on the serialized feature representation, discarding some sequence segments to obtain visible sequence features; The feature extraction module is used to input the visible sequence features into the representation model based on the Transformer encoder, extract global context features, and obtain the hidden layer representation vector. The signal reconstruction module is used to concatenate the hidden layer representation vector with the mask mark and input it into the decoder to predict the masked original signal segment; The training module is optimized by constructing a loss function based on the reconstruction error between the original signal segment and the predicted signal segment. An adaptive pre-training framework based on mask autoencoder and multi-agent task is constructed, and the model parameters are iteratively optimized to obtain a fully trained self-supervised electrophysiological signal representation model.