A pressure recognition method based on electrocardiogram waveform supervision
By employing an ECG waveform-based supervised approach, using Informer encoders and PRT encoding, and combining an attention mechanism, the noise sensitivity and insufficient generalization of existing ECG stress identification methods are addressed, achieving higher stress identification accuracy and individual adaptability.
Patent Information
- Application Number
- CN202410581485.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-11
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2044-05-11
AI Technical Summary
Existing stress recognition methods based on electrocardiogram signals are sensitive to noise, have poor generalization ability, and cannot effectively reflect individual differences, resulting in insufficient generalization performance of the model among different individuals.
We employ a method based on ECG waveform supervision, using an Informer encoder to extract global features of ECG signals. Combined with PRT encoding and an attention mechanism, we obtain the classification results of pressure and keywaves through a pressure classification head and a keywave classification head, respectively, thereby enhancing the model's learning ability and generalization.
It improves the accuracy and generalization of stress identification, better adapts to the ECG signal characteristics of different individuals, and enhances the model's supervision of key waves.
Smart Images

Figure CN118490245B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of signal processing, in particular to a stress recognition method based on electrocardiogram waveform supervision. BACKGROUND
[0002] Stress is an inevitable part of daily life. Moderate stress has a positive stimulating effect, but long-term excessive stress can damage the nervous system, causing mental and neurological diseases. Therefore, it is very important to detect stress state. Many studies have shown that monitoring psychological stress levels by electrocardiogram monitoring of heart rate changes and heart rate variability can be used. In addition, the key information in the electrocardiogram signal is mainly contained in the key waveforms, especially the P wave, QRS complex and T wave, and the T wave alternans increases and the PR interval shortens when the psychological stress is greater. These waveforms play an important role in the electrical activity of stress state characterization.
[0003] In the classification of stress based on electrocardiogram signals, the application of machine learning and deep learning has become common. However, the existing method is only supervised by a single classification loss, and the model is sensitive to the noise of the input signal, resulting in poor generalization. In addition, the existing method uses random mixing of data for cross-validation, which cannot directly reflect the generalization performance of the model for different individuals.
[0004] The present application proposes a stress recognition method based on electrocardiogram waveform supervision, which uses key waves to supervise the model to learn the basic patterns of electrocardiogram signals, and uses PRT coding as supplementary information to enhance the learning ability of the model and improve the effect of key wave supervision. SUMMARY
[0005] The present application provides a stress recognition method based on electrocardiogram waveform supervision, characterized in that the method comprises:
[0006] Step 1, the electrocardiogram signal is cut into multiple electrocardiogram sequences with overlap;
[0007] Step 2, each electrocardiogram sequence is divided into N segments without overlap, and segment coding is performed;
[0008] Step 3, input the coding sequence composed of N segment codes into the Informer encoder, calculate the long-distance dependence and context information between the segment codes using the attention mechanism, and extract the feature vector containing global information representation;
[0009] Step 4, input the feature vector into the stress classification head and the key wave classification head respectively to obtain the stress classification result and the key wave classification result.
[0010] Specifically, in step 1, the public dataset is mainly used as the training and test dataset of the present application. Firstly, the public dataset is resampled to a specific sampling rate f0, and the single-channel electrocardiogram in the dataset is standardized, i.e., the electrocardiogram data distribution is adjusted to zero mean and unit standard deviation, to reduce the influence of device differences and non-uniform standards on classification accuracy. Subsequently, the electrocardiogram is cut into multiple electrocardiogram sequences with a window of T seconds and a sliding step of 10 heartbeats, and each electrocardiogram sequence starts with an R-wave peak and has a sequence length of f0T, where f0 is the sampling frequency of the signal.
[0011] Specifically, in step 2, each electrocardiogram sequence is divided into N segments without overlap, and each segment has a length of L, where NL = f0T. Then the segments are encoded, and the segment encoding includes PRT encoding, position encoding, and input encoding. PRT encoding encodes whether P-wave, R-wave, and T-wave are contained in the segment, and the value of each position [P, R, T] is 0 or 1, indicating the absence or presence of the corresponding peak. Subsequently, using an embedding layer, the PRT encoding is mapped to d model dimensional feature space, and the encoded vector is represented by V k . Position encoding is used to mark the temporal position relationship between segments, and is realized by encoding the position information into a fixed length d model dimensional vector, and the encoded vector is represented by V p . Input encoding is realized using linear mapping, which maps the electrocardiogram segment to d model dimensional feature space, and the input encoded vector is represented by V e . The i-th segment encoding V i is the sum of the above three encodings, i.e., V i = V k + V p + V e . After segment encoding of each electrocardiogram sequence, N d model dimensional encodings can be obtained.
[0012] Specifically, in step 3, the N segment encodings V iThe segment encodings (i = 1,..., N) input into the Informer encoder are used to calculate long-distance dependencies and context information between segment encodings by using an attention mechanism to extract features containing global information representation. The Informer is a sequence-to-sequence generation model, and in the present application, the self-attention mechanism of the Informer is mainly used to calculate long-distance dependencies and context information between segments to obtain features containing global information representation, so the present application only needs to use the encoder of the Informer, and does not use the decoder. The present application uses three layers of Informer. The feature vectors of the lower layer can reflect the local features of the electrocardiogram sequence, and the feature vectors of the deep layer can reflect the abstract global features of the electrocardiogram sequence. There is a distillation mechanism between the two layers of Informer, which can halve the sequence length, so the feature length in the last layer of Informer is one-fourth of the original length, and the feature size is
[0013] Specifically, in step 4, the pressure classification head is composed of two fully connected layers, and the first fully connected layer maps the feature vector obtained in step 3 from d model to 2 dimensions. The features after the first fully connected layer are spliced to obtain , and then the second fully connected layer is used to obtain the binary classification result of the pressure. The key wave classification head is composed of a fully connected layer, which maps the feature map of step 3 from d model to L dimensions, and the features after the fully connected layer are flattened to obtain the classification result of the key wave.
[0014] The present application uses the Informer as the backbone network, adds key wave supervision, so that the model can learn the waveform position and pattern of the electrocardiogram signal, enhances the generalization and pattern recognition ability of the model, uses PRT encoding to give the segment additional information, improves the effectiveness of key wave supervision, and thus improves the accuracy and generalization of pressure recognition. BRIEF DESCRIPTION OF DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of the provided drawings.
[0016] Figure 1 Flow chart of the pressure recognition method based on electrocardiogram waveform supervision;
[0017] Figure 2 Flow chart of segment encoding. DETAILED DESCRIPTION
[0018] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative effort belong to the scope of protection of the present application.
[0019] As shown in Figure 1 , the present application proposes a stress recognition based on electrocardiogram waveform supervision, which can better extract the basic mode and depth information of electrocardiogram data. The present application uses key wave supervision to guide the model to learn the mode of electrocardiogram signal, and uses PRT coding to enhance the learning ability of the model, and improves the effect of key wave supervision.
[0020] S101: The electrocardiogram signal is cut into multiple electrocardiogram sequences with overlap.
[0021] Specifically, the present application mainly uses a public data set as the training and test data set of the present application. First, the public data set is resampled to a specific sampling rate f0, and the single-channel electrocardiogram signal in the data set is standardized, that is, the electrocardiogram signal data distribution is adjusted to zero mean and unit standard deviation, which can reduce the influence of equipment difference and non-uniform standard on classification accuracy. Subsequently, the electrocardiogram signal is cut into multiple electrocardiogram sequences with overlap in a T-second window and a 10-beat step, the beginning of each electrocardiogram sequence is R wave peak, and the sequence length is f0T. Wherein f0 is the sampling frequency of the signal.
[0022] S102: Each electrocardiogram sequence is divided into N segments without overlap, and segment coding is performed.
[0023] Specifically, first, the electrocardiogram sequence is divided into N segments without overlap, and each segment has a length of L, wherein NL=f0T. Then the segment is coded, and the segment coding includes PRT coding, position coding and input coding (as shown in Figure 2 PRT coding is to code whether P wave, R wave and T wave are contained in the segment, and the value of each position [P, R, T] is 0 or 1, indicating that the corresponding wave peak does not exist or exists. Subsequently, using an embedding layer, the PRT coding is mapped to a d model dimensional feature space, and the coded vector is represented by V k . Position coding is used to mark the time sequence position relationship between segments, which is realized by coding the position information into a fixed length d model vector. The specific method is to use a combination of sine and cosine functions, and the position coded vector is represented by V pis represented. The input encoding is implemented using linear mapping, which maps the ECG signal segment to d model dimensional feature space, the input encoded vector is represented by V e . The i-th segment encoding V i is added to the above three encodings, that is, V i = V k + V p + V e . After segment encoding for each ECG sequence, N d model dimensional encodings can be obtained.
[0024] S103: input the encoded segment into the Informer encoder, calculate the long distance dependence and context information between the segments using the attention mechanism, and extract the feature vector containing the global information representation.
[0025] Specifically, the sequence composed of N segment encodings V i (i = 1,...,N) is input into the Informer encoder, the long distance dependence and context information between the segment encodings are calculated using the attention mechanism, and the feature vector containing the global information representation is extracted; specifically, Informer is a sequence-to-sequence generation model, in the present application, the global features of the entire sequence are mainly extracted using the self-attention mechanism of Informer, and the feature vector reflecting the sequence features and structure is obtained. Therefore, the present application only needs to use the encoder of Informer, and does not use the decoder. The present application uses three layers of Informer. The feature vector of the low layer can reflect the local features of the ECG sequence, and the feature vector of the deep layer can reflect the abstract global features of the ECG sequence. There is a distillation mechanism between the two layers of Informer, which can reduce the sequence length by half, so that the feature length in the last layer of Informer is one fourth of the original length, and the feature size is
[0026] S104: input the feature vector into the pressure classification head and the key wave classification head respectively to obtain the pressure classification result and the key wave classification result.
[0027] Specifically, the pressure classification head is composed of two fully connected layers, the first fully connected layer maps the dimension of the feature vector obtained in step 3 from dx odel to 2 dimensions. The features after the first fully connected layer are spliced to obtain dimension, and then the second fully connected layer is used to obtain the binary classification result of the pressure. The key wave classification head is composed of a fully connected layer, which maps the feature map of step 3 from d model to L dimensions, and the features after the fully connected layer are flattened, that is, the classification result of the key wave is obtained.
Claims
1. A stress recognition method based on electrocardiogram waveform supervision, characterized by, The method comprises the following steps: Step 1, the electrocardiosignal is cut into multiple electrocardio sequences with overlap, specifically, the single-channel electrocardio signal in the data set is standardized, that is, the electrocardio signal data distribution is adjusted to zero mean and unit standard deviation; then, with T seconds as the window and 10 heartbeats as the sliding step, the electrocardio signal is cut into multiple electrocardio sequences with overlap, the beginning of each electrocardio sequence is the R wave peak, and the sequence length is f0T, wherein f0 is the sampling frequency of the signal; Step 2, each electrocardio sequence is divided into N segments without overlap, and segment coding is performed, specifically, the electrocardio sequence is divided into N segments without overlap, and the length of each segment is L, wherein NL = f0T; then the segment is coded, and the segment coding includes PRT coding, position coding and input coding; PRT coding can effectively capture the periodic characteristics in the electrocardio sequence, reflecting the timing characteristics of important waveforms in the electrocardio sequence; after segmenting, the N segment codes are input into the Informer encoder, the long-distance dependence and context information between the segment codes are calculated by using the attention mechanism, the feature vectors containing global information representation are extracted, specifically, the global features of the whole sequence are extracted by using the self-attention mechanism of Informer, and the feature vectors reflecting the sequence characteristics and structure are obtained; Step 3, the feature vectors are input into the pressure classification head and the key wave classification head respectively to obtain the pressure classification result and the key wave classification result.
2. The stress recognition method based on electrocardiogram waveform supervision according to claim 1, wherein, In step 1, the public data set is used as the training and test data set of the application; first, the public data set is resampled to a specific sampling frequency f0, the single-channel electrocardio signal in the data set is standardized, that is, the electrocardio signal data distribution is adjusted to zero mean and unit standard deviation, so as to reduce the influence of equipment difference and non-uniform standard on classification accuracy; then, with T seconds as the window and 10 heartbeats as the sliding step, the electrocardio signal is cut into multiple electrocardio sequences with overlap, the beginning of each electrocardio sequence is the R wave peak, and the sequence length is f0T, wherein f0 is the sampling frequency of the signal.
3. The stress recognition method based on electrocardiogram waveform supervision according to claim 1, wherein, In step 2, PRT encoding encodes whether P, R and T waves are contained in the segment, and the value of each position of [P, R, T] is 0 or 1, indicating the absence or presence of the corresponding wave peak, and then using the embedding layer, the PRT encoding is mapped to d model On the V feature space, the encoded vector is represented by V k ; the position encoding is used to mark the time sequence position relationship between segments, and the position information is encoded into a fixed length d model dimensional vector, and the specific method is to use the combination of sine and cosine functions, and the position encoded vector is represented by V p ; the input encoding is implemented using linear mapping, and the electrocardiogram segment is mapped to d model dimensional feature space, and the input encoded vector is represented by V e ; the i-th segment encoding V i is the sum of the above three encodings, that is, V i = V k + V p + V e ; after segment encoding of each electrocardiogram sequence, N d model dimensional encodings can be obtained.
4. The stress recognition method based on electrocardiogram waveform supervision according to claim 1, wherein, In step 2, the present application uses a three-layer Informer; the feature vector of the lower layer reflects the local features of the electrocardio sequence, and the feature vector of the deep layer can reflect the global features of the electrocardio sequence; there is a distillation mechanism between the two layers of Informer, which can reduce the sequence length by half, so that the feature length in the last layer of Informer is one fourth of the original length, and the feature size is 5. The stress recognition method based on electrocardiogram waveform supervision according to claim 1, wherein, In step 3, the pressure classification head is composed of two fully connected layers, the first fully connected layer maps the feature vector obtained in step 2 from d model to 2 dimensions; the features after the first fully connected layer are spliced to obtain dimension, and the second fully connected layer is used to obtain the binary classification result of the pressure; the key wave classification head is composed of a fully connected layer, which maps the feature map in step 2 from d model to L dimensions, and the features after the fully connected layer are flattened to obtain the classification result of the key wave.
6. The stress recognition method based on electrocardiogram waveform supervision according to claim 2, wherein, f0 is 256 Hz, and T is 30 seconds.
7. The stress recognition method based on electrocardiogram waveform supervision according to claim 3, wherein, N takes the value of 256, L takes the value of 30, d model takes the value of 128.
8. The stress recognition method based on electrocardiogram waveform supervision according to claim 5, wherein, The flattened result obtained by the key wave classification head can obtain key wave classification results; the original ECG sequence has NL points, and one point every four points in the original sequence is taken as the true result of the key wave. If a point is in a P wave, a QRS complex or a T wave, it is considered to be a key wave; in the training stage, the leave-one-out validation method is adopted, that is, for the data in the data set, the data of one person is taken as the validation set, and the others are taken as the training set.
Citation Information
Patent Citations
Electrocardiosignal detecting and positioning method based on weak supervised learning
CN116584951A
Unsupervised model vibration anomaly detection method based on sparse self-attention and VAE
CN117633686A