Small sample chronic pressure detection method based on Siamese network
Through Siamese network and Gram angle field technology, EEG and ECG signals are converted into GAF images, and feature extraction is combined with attention mechanism and ResNet, which solves the problems of scarcity of data sets and small sample learning in chronic psychological stress detection, and effectively detects under small sample data, improving the accuracy and applicability of the detection.
Patent Information
- Application Number
- CN202510044450.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-11
- Publication Date
- 2025-05-09
AI Technical Summary
When using physiological signals such as EEG and ECG to detect chronic psychological stress, data sets are scarce and small sample learning applications are less, making it difficult to effectively detect chronic psychological stress.
The Siamese network combined with Gram Angle Field (GAF) technology is used to convert EEG and ECG signals into GAF images, and feature extraction is used by the attention mechanism and ResNet to realize the detection of chronic psychological stress in small samples.
Through Siamese network and GAF technology, chronic psychological stress can be effectively detected under small sample data, improve the accuracy and applicability of the detection, and provide more possibilities for the field of mental health.
Smart Images

Figure CN119964830A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of life stress detection, and specifically to a small sample deep learning method for detecting chronic psychological stress in the human body using physiological signals such as EEG and ECG. Background Art
[0002] As the stress of modern life continues to increase, mental health issues have become more prominent. Deep learning technology has attracted widespread attention in the use of physiological signals such as EEG (electroencephalogram) and ECG (electrocardiogram) for psychological stress detection. However, the current research status shows that it mainly focuses on acute stress research based on stimulation, while chronic stress research is relatively rare, and there is also a problem of scarce data sets.
[0003] In addition, few-shot learning is not widely used in the field of psychological stress detection. Psychological stress detection usually requires a large amount of data to build an accurate model, but in reality, much data may be difficult to obtain, which makes few-shot learning crucial. However, only a few studies have attempted to apply few-shot learning in this field, highlighting the potential value of this method.
[0004] Another important technique is the method of converting time series signals into Gramian Angular Field (GAF). This technique converts time series signals into image matrices, which are convenient for deep learning models to process. In psychological stress detection, converting EEG and ECG signals into GAF can provide more information and help the model better capture potential features and patterns.
[0005] In the field of small sample learning, especially in psychological stress detection, the necessity is prominent. Because chronic psychological stress is usually not easy to simulate, and the sample data is relatively limited, the traditional large sample learning method may not be applicable enough. The technology of few-shot learning and time series signal conversion to GAF can better adapt to small sample data, improve the accuracy and applicability of psychological stress detection, and provide more possibilities in the field of mental health. Summary of the invention
[0006] The present invention introduces small sample deep learning into the prediction of chronic psychological stress based on Siamese network, so that chronic stress detection can be applied to various groups at a lower cost.
[0007] The technical solution provided by the present invention is as follows:
[0008] A small sample chronic psychological stress detection method comprises the following steps:
[0009] 1) Use wearable devices to collect physiological data such as EEG and ECG from some members of the designated group, and obtain the true value of the sample based on the psychological stress questionnaire and cortisol to construct a local small sample data set;
[0010] 2) Perform data preprocessing on the public dataset and the local small sample dataset. Use the Gram angular field to convert the time series data of physiological signals into GAF images, and extract samples with different labels from the local dataset to form a support set, which will be used as a reference for the final prediction.
[0011] 3) The public dataset converted into images and the local small sample dataset are combined into two categories: positive samples and negative samples according to the labels. The processed public dataset is used as the input of the model to preliminarily train the neural network to calculate the similarity between different samples. The model includes two parts: using the attention mechanism to extract image features and using the Siamese network to perform similarity analysis on the features.
[0012] 4) The processed local small sample data set is then input into the pre-trained model to fine-tune its parameters so that it can identify the category of chronic stress based on distinguishing acute stress, and can also make it more adaptable to the psychological stress characteristics of specific groups.
[0013] 5) Finally, the sample to be tested and the samples in the support set are used as the fine-tuned model to obtain the similarity with each sample in the support set, and finally the category is divided into the category with the highest similarity, thus completing the detection of the psychological pressure of the sample to be tested.
[0014] The technical effects of the present invention are:
[0015] The psychological stress detection method proposed in the present invention is a method for detecting chronic psychological stress in small samples based on Siamese networks. It combines psychological stress detection with a small sample image classification method of computer vision to form a framework for detecting chronic psychological stress in small samples. The use of channel attention allows the neural network to effectively focus on more relevant electrodes in physiological signals. The use of spatial attention makes full use of the time-dependent characteristics of GAF for the main diagonal, ensuring the effectiveness of the features. The present invention allows traditional time series signals such as EEG and ECG to be applied to few-shot learning, which is popular in the field of computer vision, so that the neural network learns how to distinguish physiological signal samples with different labels. Therefore, even in different groups, when encountering sample types that do not exist in the training set, the neural network can reliably find its own category from the Support set. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 This is the structural diagram of the small sample deep learning model framework proposed in this invention; it includes the complete process of preprocessing of public data sets and local data sets, model training, model prediction, etc.
[0017] Figure 2 Schematic diagram of the feature extraction process of the present invention; including GAF image generation of EEG and ECG, use of channel attention and spatial attention, and feature extraction using a ResNet network.
[0018] Figure 3 It is a schematic diagram of the training process of the Siamese network of the present invention; including the input and output of the model. DETAILED DESCRIPTION
[0019] The present invention will be further described below by way of embodiments in conjunction with the accompanying drawings, but the scope of the present invention is not limited in any way.
[0020] The present invention provides a small sample chronic stress detection method based on Siamese network. Through the present invention, a chronic psychological stress detection deep learning model can obtain reliable output in a small sample training environment, and the traditional EEG and ECG time series signals are converted into GAF images through the Gram angle field, so as to be suitable for few-shot learning in the field of computer vision.
[0021] Step 1: If Figure 2 As shown, the time series signals such as EEG and ECG are scaled to the interval [-1, 1] or [0, 1], and then the scaled time series is converted to the polar coordinate system, the angle represents the value, the radius represents the timestamp, and finally the elements of the Gramian matrix are defined as the sum or difference of the angle cosine at two moments to obtain the GASF or GADF image. The specific process is:
[0022] Given n signal samples of physiological signal X = {x1, x2, ..., x n}, we rescale X so that all values fall in the interval [-1,1] or [0,1]:
[0023]
[0024] or
[0025]
[0026] Therefore, we can express the rescaled time series in polar coordinates by encoding the value as the cosine of the angle and the timestamp as the radius with the following equation
[0027]
[0028] In the above equation, t i is the timestamp, and N is a constant factor used to normalize the span of the polar coordinate system. This polar-based representation is a novel way to understand time series. Over time, the corresponding values will be distorted on an expanding circle at different corners, like water ripples. The encoding mapping of the equation has two important properties. First, it is bijective, because cos(φ) is monotonic when φ∈[0,π]. Given a time series, the proposed mapping produces a unique result in the polar coordinate system with a unique inverse mapping. Second, unlike Cartesian coordinates, polar coordinates preserve absolute time relationships. Rescaled data in different intervals have different angular bounds. [0,1] corresponds to The cosine function in the interval [-1,1], while the cosine values in the interval [-1,1] fall into the angular bounds [0,π]. They provide different granularity of information in the Gramian Angular Field for classification tasks, and the Gramian Angular Difference Field (GADF) of the rescaled data in the range [0,1] has an accurate inverse mapping. This actually lays the foundation for filling missing values in time series by restoring images. After converting the rescaled time series to a polar coordinate system, the angular perspective can be exploited by considering the trigonometric sum or difference between each point to identify temporal correlations in different time intervals. The Gramian Summation Angular Field (GASF) and Gramian Difference AngularField (GADF) are defined as follows:
[0029]
[0030] I is a unit row vector [1,1,...,1]. After conversion to the polar coordinate system, the time series at each time step is considered as a one-dimensional metric space. By defining the inner product and In fact, two types of Gramian Angular Fields (GAFs) are generated, which are actually quasi-Gramian matrices
[0031] Step 2: Convert the public dataset and local dataset into multi-channel GAF images respectively, and divide the dataset into positive sample group and negative sample group according to label matching, such as Figure 1As shown. By setting group label 1 for groups with the same label and group label 2 for groups with different labels, the neural network can learn to distinguish the differences between samples in the data set. Since the classification task is not a traditional visual image, we need to introduce an attention mechanism in the feature extraction process to make the neural network more suitable for feature extraction of GAF images. The specific process is as follows Figure 2 shown.
[0032] 1) The GAF images converted from different physiological signals are composed into multi-channel images and input into the neural network.
[0033] 2) Set up a channel attention module to calculate the weights of each channel of the input signal. Given an intermediate feature map F∈R C×H×W As input, the process through the channel attention model can be summarized as the equation:
[0034]
[0035] The channel attention map is generated by exploiting the channel relationship between features. Since each channel of the feature map is regarded as a feature detector, channel attention focuses on determining "what" is meaningful given the input image. In order to efficiently calculate channel attention, the spatial dimension of the input feature map is compressed. In order to aggregate spatial information, features of average pooling and maximum pooling are used at the same time. First, the spatial information of the feature map is summarized by using average pooling and maximum pooling operations, generating two different spatial context descriptors: and These two descriptors are then passed to a shared network to generate our channel attention map The shared network consists of a multilayer perceptron (MLP) with one hidden layer. To reduce parameter overhead, the size of the hidden layer activation is set to where r represents the reduction ratio. After applying the shared network to each descriptor, we merge the output feature vectors using element-wise summation. In short, the channel attention is calculated as follows:
[0036]
[0037] Here, σ represents the Sigmoid function, and It is worth noting that the weights W0 and W1 of the MLP are shared for both inputs, and the ReLU activation function follows W0.
[0038] 3) Set up the spatial attention module. Due to the particularity of GAF in spatial features, the main diagonal retains the time dependence of the original EEG and ECG time series signals. Spatial attention can effectively extract relevant features. The feature F processed by the channel attention module ′ As input, the process can be expressed as:
[0039] We introduce prior knowledge to manually set weights so that features on the main diagonal are emphasized more during feature extraction. This is different from channel attention and spatial attention because it explicitly directs attention to a specific region. To compute this prior knowledge guided spatial attention, we perform the following steps:
[0040] First, we define a set of weight matrices W, where We then use these manually set weights with the feature map F ′ Perform a dot multiplication operation to generate a weighted feature map F ″ ,in
[0041] This approach allows us to selectively focus on features on the main diagonal, thereby better adapting to prior knowledge. The process can be expressed as:
[0042]
[0043] 4) The weighted feature F obtained by the attention module ″ Input into ResNet18 for feature extraction to obtain the final feature vector.
[0044] Step 3: Train the Siamese network, such as Figure 3 As shown in the figure, the feature vectors extracted from the positive sample group and the negative sample group are input into the Siamese network to obtain the features h1 and h2. Then the absolute value z = |h1-h2| is subtracted, and then the value is obtained between [0,1] through the fully connected layer and the activation function Sigmoid. Then the Loss is calculated with the label target. The Loss is used to perform gradient update of the fully connected layer and ResNet parameters.
[0045] The same applies when target is 0.
[0046] Step 4: Test the new sample, such as Figure 1 As shown in the figure, the sample to be detected and each sample in the support set are input into the neural network respectively to obtain the similarity between the sample to be detected and each sample in the support set. The samples with the same label take the average value, and the samples with different labels take the max value to obtain the category of the sample to be detected.
[0047] At this point, the deep learning framework for small-sample chronic stress detection based on the Siamese network has been completed. The ResNet18 used in the attention module and feature extraction can be flexibly replaced to achieve more accurate detection results.
[0048] It should be noted that the purpose of publishing the embodiments is to help further understand the present invention, but those skilled in the art can understand that various substitutions and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. Therefore, the present invention should not be limited to the contents disclosed in the embodiments, and the scope of protection claimed by the present invention shall be subject to the scope defined in the claims.
Claims
1. A small sample chronic stress detection method based on Siamese network, characterized in that: The method comprises the following steps: 1) Use wearable devices to collect physiological data such as EEG and ECG from some members of the designated group, and obtain the true value of the sample based on the psychological stress questionnaire and cortisol to construct a local small sample data set; 2) Data preprocessing is performed on the public dataset and the local small sample dataset. The time series data of physiological signals are converted into GAF images by using the Gram angular field. Samples with different labels are extracted from the local dataset to form a Supportset, which is used as a reference for the final prediction. 3) The public dataset converted into images and the local small sample dataset are combined into two categories: positive samples and negative samples according to the labels. The processed public dataset is used as the input of the model to preliminarily train the neural network to calculate the similarity between different samples. The model includes two parts: using the attention mechanism and ResNet18 network to extract image features and using the Siamese network to perform similarity analysis on the features. 4) Input the processed local small sample data set into the pre-trained model and fine-tune its parameters so that it can distinguish the categories of chronic stress based on the distinction of acute stress, and can also make it more adaptable to the psychological stress characteristics of specific groups; 5) Finally, the sample to be tested and the samples in the support set are used as the fine-tuned model to obtain the similarity with each sample in the support set, and finally the category is divided into the category with the highest similarity, thus completing the detection of the psychological pressure of the sample to be tested.
2. The small sample chronic psychological stress detection method according to claim 1, characterized in that: The local small sample dataset and the public dataset described in step 1) may include data such as physiological signals, psychological stress questionnaires, and cortisol.
3. The small sample chronic psychological stress detection method according to claim 1, characterized in that: The attention module described in step 3) includes: 1) Set up a channel attention module to calculate the weights of each channel of the input signal; 2) Set up a spatial attention module to emphasize the features on the main diagonal more during feature extraction.
4. The small sample chronic psychological stress detection method according to claim 1, characterized in that: The ResNet18 network described in step 3) can be replaced by a neural network model with similar feature extraction capabilities.
5. The small sample chronic psychological stress detection method according to claim 1, characterized in that: The neural network model described in step 4) can adapt to the psychological stress characteristics of different groups.