An automatic sleep staging method based on electroencephalogram signal analysis

By introducing a multiplicative exponential decay term, the influence of long-term sleep EEG signals on decision-making in the next period is reduced, solving the problem of low staged efficiency in existing technologies and improving the accuracy and performance of automatic sleep staged sleep.

CN116548984BActive Publication Date: 2025-12-19SOUTH CHINA UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310585045.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-23
Publication Date
2025-12-19
Estimated Expiration
2043-05-23

AI Technical Summary

Technical Problem

In existing technologies, automatic staging methods using neural networks during sleep cannot effectively solve the staging problem in long-term sleep states, especially in terms of how to reduce the impact of long periods of time, which leads to low staging efficiency, affects the decision-making of the next period, and results in inaccurate staging efficiency. These are technical problems that existing technologies have failed to effectively solve.

Method used

By introducing a multiplicative exponential decay term, the influence of staging results from other EEG signals that are too far in the past on the current classification decision is reduced. The multiplicative exponential decay term also reduces the influence of long-term sleep EEG signals on the decision of the next period, thereby improving the accuracy of automatic staging.

Benefits of technology

It effectively reduces the impact of long-term sleep EEG signals on decision-making in the next period, improves the accuracy of automatic sleep staging, improves the correlation score calculation formula, maintains the correlation between highly correlated EEG data, and improves the model performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116548984B_ABST
    Figure CN116548984B_ABST
Patent Text Reader

Abstract

A sleep automatic staging method based on electroencephalogram signal analysis, comprising: acquiring EEG electroencephalogram signals of multiple samples as training data, the training step comprising: extracting time domain features and frequency domain features; performing time sequence processing on each sample according to the time domain features and the frequency domain features, extracting context information, obtaining a time sequence feature vector corresponding to each sample, and constituting a sample sequence; calculating the multiplicative exponential decay weight between the sample features at different time steps in the sequence according to the context information in the time sequence feature vector, combining the attention mechanism to calculate the feature correlation between the samples at different times, and weighting to obtain optimized features; performing classification prediction to obtain a first prediction result; calculating a first loss function L1 according to the prediction result and performing iteration to obtain model parameters; the present application introduces a multiplicative exponential decay term to reduce the influence of the staging results of the electroencephalogram signals too long time ago on the current classification decision, thereby improving the precision of the sleep automatic staging.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electroencephalogram (EEG) signal analysis technology, and more specifically to an automatic sleep staging method based on EEG signal analysis. Background Technology

[0002] Brain activity during sleep is not static, but rather exhibits a series of actively regulated, periodic changes. During this time, various physiological functions of the body, such as sensory, motor, and autonomic nervous systems, undergo varying degrees of regular activity. Therefore, segmenting the sleep process according to the characteristics of brain electrical activity is crucial for sleep medicine.

[0003] According to international sleep medicine standards, during human sleep, different sleep periods can be divided into five normal categories—WAKE, REM, N1, N2, and N3—using physiological information. Current technologies, based on this standard, employ neural networks to automatically identify and stage sleep characteristics, aiming to improve stageing efficiency and explore different methods to enhance the accuracy of automatic stagening. However, because sleep stages vary in length, excessively long stages can negatively impact the stage selection for the next stage.

[0004] Therefore, how to reduce the impact of long-term sleep EEG signals on decision-making in the next period in order to improve the accuracy of automatic staging is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] In view of this, the present invention provides an automatic sleep staging method based on EEG signal analysis, which introduces a multiplicative exponential decay term to reduce the influence of staging results from other EEG signals that are too far in the past on the current classification decision, thereby improving the accuracy of automatic sleep staging.

[0006] To achieve the above objectives, the present invention adopts the following technical solution:

[0007] An automatic sleep staging method based on electroencephalogram (EEG) signal analysis includes the following steps:

[0008] Multiple samples of EEG brain signals are acquired as training data to train a pre-constructed neural network model, and sleep stages are performed using the trained neural network model; the neural network model includes a first neural network model.

[0009] The training steps for the first neural network model include:

[0010] Extract time-domain features and frequency features from each sample in the training data;

[0011] Based on the time domain and frequency domain features, each sample is processed in time series to extract context information and obtain the time series feature vector corresponding to each sample, thus forming a sample sequence.

[0012] According to the context information in the timing feature vector, a multiplicative exponential decay weight between sample features at different time steps in the sequence is calculated, the correlation degree between features of different samples at different times is calculated by combining the attention mechanism, and the optimized features are obtained by weighting.

[0013] The optimized features are classified and predicted to obtain a first prediction result; a first loss function L1 is calculated according to the prediction result and is iterated to obtain model parameters.

[0014] Further, the first loss function L1 is calculated according to the first prediction result, specifically:

[0015] The weight of each class result sample is calculated according to the prediction result:

[0016] The loss function is calculated according to the weight:

[0017] L1=WCE(y,c)=-w c Σy·logp c

[0018] Where y is the label of the current sample, p c is the probability that the network judges the sample to be class c, w c represents the weight of class c in the training set, and WCE(·) is the class weighted cross-entropy function.

[0019] Further, the training step of the first neural network model further includes:

[0020] According to the first prediction result, a prediction label sequence is generated;

[0021] According to the consistency of each sample prediction label in the prediction label sequence within a preset time width, label conversion is performed to obtain a new label sequence;

[0022] According to the new label sequence and the first prediction result, a loss function is calculated, and re-prediction is performed to obtain a second prediction result;

[0023] According to the second prediction result, a second loss function L2 is calculated and iterated to update the model parameters of the first neural network model.

[0024] Further, the neural network model further includes a second neural network model; the training step of the first neural network model includes: combined with the second neural network model, joint training is performed, specifically:

[0025] A trainable random embedding of the same number as the number of sample categories is initialized;

[0026] The label in the first prediction result is multiplied by the random embedding label to obtain a label embedding-based feature vector;

[0027] The feature vector based on label embedding is input into a pre-built second neural network model to obtain features, and a third prediction result is obtained through prediction; the third loss function L3 is calculated based on the third prediction result to update the model parameters of the second neural network model, thereby realizing the training of the second neural network model;

[0028] The sequence distance is calculated based on the third prediction result and the sample label, and the final loss function is calculated based on the sequence distance. The model parameters of the first neural network model and the second neural network model are updated through backpropagation.

[0029] Further, the sequence distance is calculated based on the third prediction result and the sample labels, and the final loss function is calculated based on the sequence distance. The steps include:

[0030] Based on the third prediction result, the category with the largest predicted value is used as the sleep stage result of the EEG data corresponding to the current time step, and the predicted sequence is obtained by sorting the sequence.

[0031] The sample label categories are sorted sequentially to obtain the label sequence;

[0032] According to the predicted sequence and label sequence Calculate the cost matrix:

[0033]

[0034] Where δ(·,·) is a differentiable cost function, using the Euclidean distance function.

[0035] Predicted sequence x i and label sequence y j Minimum distance:

[0036]

[0037] Where r i,j To predict sequence x i and label sequence y j The minimum distance, min γ It is a differentiable minimum function:

[0038]

[0039] Where a i γ is a manually set parameter used to find the elements in the set containing the minimum value.

[0040] The distance r between the calculated predicted sequence and the label sequence n,n The final loss function, Loss, is obtained by adding it to the overall loss function:

[0041] Loss1=w1·L1+w2·L2+w3·L3+w4·r n,n

[0042] wherein w1, w2, w3, w4 are weight coefficients, specifically, w1, w2 are 0.3, w3, w4 are 0.7.

[0043] Further, according to the context information in the time sequence feature vector, the attention mechanism is used to calculate the feature correlation between different time samples, and the steps include:

[0044] setting the first model parameter and calculating the similarity of the electroencephalogram data at different time steps in the sequence;

[0045] calculating the context-aware distance metric between sample features at different time steps in the sequence based on the time step length according to the similarity;

[0046] setting the second model parameter and calculating the multiplicative exponential decay weight between sample features at different time steps in the sequence according to the context-aware distance metric;

[0047] calculating the attention weight between sample features at different time steps in the sequence, and generating optimized features.

[0048] Further, the first model parameter is set and the similarity of the electroencephalogram data at different time steps in the sequence is calculated, specifically:

[0049] The model parameter is three trainable matrices;

[0050] For each sample feature, the time sequence feature vector is multiplied by the three trainable matrices to obtain the query vector, the key value vector and the value vector;

[0051] calculating the similarity of the electroencephalogram data at different time steps in the sequence:

[0052]

[0053] wherein γ t,t′ is the similarity between the sample feature at the tth time step and the sample feature at the t'th time step in the sequence, t and t' represent the time position of the sample in the sequence; is the transpose of the query feature matrix of the sample feature at the tth time step, k t′ is the key feature matrix of the sample feature at the t'th time step; D k is the dimension of the key matrix. τ' is a time step greater than 1 and less than t, k τ′ is the key feature matrix of the sample feature at the τ'th time step; exp(·) is the exponential function with the natural constant e as the base.

[0054] Further, the second model parameter is set and the multiplicative exponential decay weight between the sample features at different time steps in the sequence is calculated according to the context-aware distance metric, specifically:

[0055] The second model parameter is a trainable decay rate parameter;

[0056]

[0057] Where s t,τ is the multiplicative exponential decay weight between the sample feature at the t-th time step and the sample feature at the τ-th time step, θ is a learnable decay rate parameter, t and τ represent the time positions of the samples in the sequence, d(t, τ) is the context-aware distance metric between the sample feature at the t-th time step and the sample feature at the τ-th time step, is the transpose of the query feature matrix of the sample feature at the t-th time step, k τ is the key feature matrix of the sample feature at the τ-th time step. D k is the dimension of the key matrix. exp(·) is the exponential function with the natural constant e as the base.

[0058] Further, the time domain features and frequency features are extracted from each sample in the training data, specifically:

[0059] A multi-scale convolution feature extraction module constructed by a CNN is used to extract the original electroencephalogram features;

[0060] The feature extraction module is composed of two parts, one is a small-scale convolution network for extracting time information, and the other is a large-scale convolution network for extracting frequency information;

[0061] Each CNN part is composed of four consecutive one-dimensional convolution layers;

[0062] Each convolution layer sequentially performs one-dimensional convolution, normalization and RELU activation function of the corresponding convolution kernel.

[0063] The beneficial effects of the present application are:

[0064] According to the above technical solution, compared with the prior art, the present application provides a sleep automatic staging method based on electroencephalogram signal analysis, which introduces a multiplicative exponential decay term in the correlation score calculation to reduce the influence of the staging results of the electroencephalogram signal at other too long times on the current classification decision; the correlation score calculation formula is improved, the correlation evolution process between the two time step corresponding electroencephalogram data is used to maintain the correlation between the high correlation electroencephalogram data, and the automatic sleep staging task is effectively completed. The sequence information module is designed, the sequence correlation information is added in the training process of the automatic sleep staging method, and the performance of the model is improved. BRIEF DESCRIPTION OF DRAWINGS

[0065] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description only constitute a part of the embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort on the basis of the provided drawings.

[0066] Figure 1 A schematic diagram of a sleep automatic staging method based on electroencephalogram signal analysis provided by the present application;

[0067] Figure 2 A schematic diagram of a network structure for feature extraction of the present application;

[0068] Figure 3 A schematic diagram of a method for feature optimization in the present application;

[0069] Figure 4 A schematic diagram of a sequence tag generation method in an embodiment of the present application;

[0070] Figure 5 A schematic diagram of a sleep automatic staging system based on electroencephalogram signal analysis provided by an embodiment of the present application. DETAILED DESCRIPTION

[0071] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments only constitute a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort fall within the scope of the present application.

[0072] Embodiment 1

[0073] As Figures 1-4 The embodiment of the present application discloses a sleep automatic staging method based on electroencephalogram signal analysis, comprising the following steps:

[0074] EEG electroencephalogram signals of a plurality of samples are obtained as training data, a pre-constructed neural network model is trained, and sleep staging is performed through the trained neural network model; the neural network model comprises a first neural network model; wherein the training data has a time sequence label.

[0075] The first neural network model training step comprises:

[0076] S1: Extract time domain features and frequency features from each sample in the training data; the extracted time domain and frequency domain features are used as information substitutes for the original electroencephalogram.

[0077] In an embodiment, the time domain features and the frequency domain features are extracted in the following manner:

[0078] As shown in FIG. 2, a multi-scale convolution feature extraction module constructed by a CNN is used to extract the original EEG features. Figure 2

[0079] The feature extraction module is composed of two parts, one is a small-scale convolution network for extracting time information, and the other is a large-scale convolution network for extracting frequency information.

[0080] Each CNN part is composed of four consecutive one-dimensional convolution layers.

[0081] Each convolution layer sequentially performs one-dimensional convolution, normalization and RELU activation function of the corresponding convolution kernel.

[0082] S2: Each sample is arranged according to the time sequence label, and each sample represents a time step to obtain a sample sequence; the time domain features and the frequency domain features are used to process each sample in time sequence, extract the context information in the sample sequence, and obtain the time sequence feature vector corresponding to each sample,

[0083] Specifically, the EEG data of each sample in the sample sequence is processed by using a bidirectional recurrent neural network Bi-RNN structure. In sleep staging, the sleep staging result at a certain time may be affected by the EEG signal at an earlier time. Bi-RNN obtains context information from each EEG signal sample in the sample sequence by simultaneously running forward and backward propagation, performs feature processing, and obtains a time sequence feature vector.

[0084] S3: According to the time sequence feature vector corresponding to each sample, the sample features at different time steps in the forward and reverse calculation sequence, i.e., the multiplicative exponential decay weight between the time sequence feature vectors, are calculated, the feature correlation between different time samples is calculated by using an attention mechanism, and the optimized features are obtained by weighting.

[0085] S4: The optimized features are classified and predicted to obtain a first prediction result; a first loss function L1 is calculated according to the prediction result and is iterated to obtain model parameters.

[0086] In an embodiment, the first loss function L1 is calculated according to the first prediction result, and the calculation is specifically as follows:

[0087] The weights of the samples of each type are calculated according to the prediction result:

[0088] The loss function is calculated according to the weights:

[0089]

[0090] ​where y is the label of the current sample, p c is the probability of the network judging the sample as class c, w c represents the weight of class c in the training set, and WCE(·) is a class-weighted cross-entropy function.

[0091] In another embodiment, the training step of the first neural network model further comprises:

[0092] S5: generating a predicted label sequence according to the first prediction result; specifically, converting the sleep period labels in the first prediction result into class labels that can be recognized by a machine.

[0093] S6: performing label conversion according to the consistency of each sample prediction label in the predicted label sequence within a preset time width, to obtain a new label sequence.

[0094] Specifically, when generating the sequence label, first set a time width k, for each class label in the sequence, find whether the previous and subsequent k labels are the same as it, calculate the number of same labels, and replace the prediction label with the number; traverse each sample to generate a new label sequence.

[0095] S7: calculating a second loss function L2 according to the new label sequence and the optimized features, performing re-prediction to obtain a second prediction result; the number of prediction classes of the second prediction result is the same as the number of classes of the sequence label obtained by converting the class labels.

[0096] The first neural network model parameters are updated through the loss function L2 to realize the training of the first neural network model. Specifically:

[0097] L2 = CrossEntropy(p seq , y seq )

[0098] where p seq is the second prediction result, y seq is the sequence label obtained by converting the sample class labels, and CrossEntropy(·) is a cross-entropy function. This loss function updates the CNN model in S1, the Bi-RNN in S2, and the bidirectional evolutionary distance attention mechanism module in S3.

[0099] In this embodiment, the neural network model further comprises a second neural network model; the training step of the first neural network model comprises: jointly training in combination with the second neural network model, specifically:

[0100] initializing a number of trainable random embeddings equal to the number of sample classes, and the dimension of the embedding is 512;

[0101] The first prediction result is multiplied by the random label embedding, and a feature vector based on the label embedding is obtained;

[0102] Specifically, the feature vector based on the label embedding is input into a second neural network model constructed in advance for feature optimization, and a third prediction result is obtained through prediction; a third loss function L3 is calculated according to the third prediction result, and the model parameters of the second neural network model and the first neural network are updated, so as to realize the training of the first neural network model and the second neural network model; wherein the network structure of the second neural network model is the same as that of the part of the first neural network model for feature optimization, and both adopt a bidirectional evolutionary distance attention mechanism.

[0103] Specifically, the class weight is calculated according to the number of samples in the training set:

[0104]

[0105] Where N is the number of all samples in the data set, n c is the number of samples of class c in the data set, and K is the number of classes in the data set.

[0106] The loss function L3 is:

[0107]

[0108] Where y is the label of the current sample, is the probability that the model predicts the sample to be class c based on the label embedding, w c represents the weight of class c in the training set, and WCB(·) is a class weighted cross-entropy function

[0109] According to the third prediction result and the sample label, a sequence distance is calculated, and a final loss function is calculated according to the sequence distance, and the model parameters of the first neural network model and the second neural network model are updated through back propagation.

[0110] In this embodiment, according to the third prediction result and the sample label, a sequence distance is calculated, and a final loss function is calculated according to the sequence distance, and the model parameters of the first neural network model and the second neural network model are updated through back propagation.

[0111] According to the third prediction result, the class with the maximum prediction value is used as the staging result of the electroencephalogram sample corresponding to the current time step in the sequence, and a prediction sequence is obtained according to the sequence order;

[0112] The sample label classes are sorted according to the sequence to obtain a label sequence;

[0113] According to the prediction sequence and the label sequence a cost matrix is calculated:

[0114]

[0115] where δ(·,·) is a differentiable cost function using the Euclidean distance function.

[0116] predicted sequence x i and label sequence y j

[0117]

[0118] where r i,j is the minimum distance between predicted sequence x i and label sequence y j min γ is a differentiable minimum function:

[0119]

[0120] where a i is an element in the set for finding the minimum value, and γ is a manually set parameter

[0121] The calculated distance r n,n between the predicted sequence and the label sequence is added to the overall loss function to obtain the final loss function Loss:

[0122] Loss=w1·L1+w2·L2+w3 · L3 + w4·r n,n

[0123] where w1, w2 are 0.3, and w3, w4 are 0.7.

[0124] In another embodiment, according to the context information in the time sequence feature vector, the attention mechanism is used to calculate the feature correlation between samples at different times, and the steps include:

[0125] setting the first model parameters and calculating the similarity of the electroencephalogram data at different time steps in the sequence;

[0126] calculating the context-aware distance metric between sample features at different time steps in the sequence based on the time step length according to the similarity;

[0127] setting the second model parameters and calculating the multiplicative exponential decay weight between sample features at different time steps in the sequence according to the context-aware distance metric;

[0128] calculating the attention weight between sample features at different time steps in the sequence, and generating optimized features.

[0129] ​In the embodiment, the first model parameters are set and the similarity of the electroencephalogram data at different time steps in the sequence is calculated, specifically:

[0130] The model parameters are three trainable matrices;

[0131] For each sample feature, the time series feature vector is multiplied by the three trainable matrices to obtain the query vector, the key vector and the value vector;

[0132] The similarity of the electroencephalogram data at different time steps in the sequence is calculated:

[0133]

[0134] wherein γ t,t′ is the similarity between the sample feature at the tth time step and the sample feature at the t'th time step in the sequence, t and t' represent the time position of the sample in the sequence; is the transpose of the query feature matrix of the sample feature at the tth time step, k t′ is the key feature matrix of the sample feature at the t'th time step; D k is the dimension of the key matrix. τ' is a time step greater than 1 and less than t, k τ′ is the key feature matrix of the sample feature at the τ'th time step; exp(·) is the exponential function with the natural constant e as the base.

[0135] According to the similarity, the context-aware distance measure between the sample features at different time steps in the sequence based on the time step length is calculated:

[0136]

[0137] wherein d(t, τ) is the context-aware distance measure between the sample feature at the tth time step and the sample feature at the τth time step, t and τ represent the time position of the sample in the sequence, |t-τ| is the absolute value difference of the position of the sample feature at the tth time step and the sample feature at the τth time step in the sequence, γ t,t′ is the similarity between the sample feature at the tth time step and the sample feature at the t'th time step in the sequence.

[0138] In the embodiment, the second model parameters are set and the multiplicative exponential decay weight between the sample features at different time steps in the sequence is calculated according to the context-aware distance measure, specifically:

[0139] The second model parameters are trainable decay rate parameters;

[0140]

[0141] wherein s t,τis a multiplicative exponential decay weight between the sample feature at the t-th time step and the sample feature at the t-th time step, is a learnable decay rate parameter, t and t represent the time positions of the samples in the sequence, and d(t, t) is a context-aware distance metric between the sample feature at the t-th time step and the sample feature at the t-th time step, is the transpose of the query feature matrix of the sample feature at the t-th time step, k τ is the key feature matrix of the sample feature at the t-th time step. D k is the dimension of the key matrix. exp(·) is an exponential function with the natural constant e as the base.

[0142] The attention weight between the sample features at different time steps in the sequence is calculated as follows:

[0143]

[0144] where t, t, and t' represent the time positions of the samples in the sequence, and t,τ is the attention weight between the sample feature at the t-th time step and the sample feature at the t-th time step.

[0145] 6) Calculate the new features of the sample features in the sequence based on the attention weights:

[0146] x t_new = a t,1 x v1+ a t,2 x v2+ … + a t,i x vn i i = 1, 2, …, n, where x t_new is the new attention-based feature of the t-th sample in the sequence, v i is the value feature vector obtained by the i-th sample feature in the sequence, n is the length of the sequence, and a t,i is the attention weight between the sample feature at the t-th time step and the sample feature at the i-th time step.

[0147] Embodiment 2

[0148] The neural network model of the sleep automatic staging method based on electroencephalogram signal analysis is provided in the embodiments of the present application;

[0149] The model includes the first neural network in Embodiment 1, wherein,

[0150] The first neural network includes:

[0151] A multi-scale convolutional layer is used to extract multi-scale features, including time domain features and frequency domain features; specifically, the multi-scale convolutional layer is composed of two parts, one is a small-scale convolutional network for extracting time information, and the other is a large-scale convolutional network for extracting frequency information; each CNN part is composed of four consecutive one-dimensional convolutional layers, and each convolutional layer sequentially performs one-dimensional convolution, normalization and RELU activation function of a corresponding convolution kernel;

[0152] A Bi-RNN network layer is used to obtain a feature with continuous time sequence information for each electroencephalogram signal sample in the sequence by simultaneously running forward and backward propagation, to form a time sequence feature vector corresponding to each sample, and to form a sample sequence; the Bi-RNN network layer is helpful to solve the long-term dependency problem;

[0153] A first bidirectional evolutionary distance attention network layer is used to calculate a multiplicative exponential decay weight between sample features at different time steps in the sequence according to context information in the time sequence feature vector, to calculate a feature correlation degree between samples at different times by using an attention mechanism, to perform weighting, and to output first optimized features.

[0154] A first classifier is used to perform prediction classification according to the first optimized features, and to output a first prediction result.

[0155] Embodiment 3

[0156] The embodiment of the present application provides a neural network model training method, which can be used to train the neural network model in Embodiment 2.

[0157] In the training process, the training data is input into the first neural network to obtain a first prediction result; a first loss function L1 is calculated according to the first prediction result and is iterated to obtain model parameters.

[0158] In another embodiment, after the labels are adjusted, a second prediction result is obtained by re-prediction, a second loss function L2 is calculated according to the second prediction result and is iterated to update the model parameters of the first neural network model. Wherein, the specific steps of adjusting the labels are: generating a predicted label sequence according to the first prediction result; performing label conversion according to the consistency of each sample predicted label in the predicted label sequence within a preset time width to obtain a new label sequence.

[0159] In this embodiment, the second loss function and the first loss function can be weighted and summed to obtain a total loss function, and the model parameters are adjusted according to the total loss function for training.

[0160] In another embodiment, the second neural network in Embodiment 1 is used for auxiliary training.

[0161] The second neural network comprises:

[0162] a second bidirectional evolutionary distance attention network layer, configured to obtain a first prediction result of embedding a random label and obtain second optimized features;

[0163] a second classifier, configured to perform a prediction classification according to the second optimized features and output a prediction result.

[0164] an auxiliary training process:

[0165] initializing a same number of trainable random embeddings as the number of sample categories;

[0166] multiplying the labels in the first prediction result with the random embedding labels to obtain a feature vector based on label embedding;

[0167] inputting the feature vector based on label embedding into a second neural network model constructed in advance to obtain features, and obtaining a third prediction result through prediction; calculating a third loss function L3 according to the third prediction result, updating model parameters of the second neural network model, and realizing training of the second neural network model;

[0168] calculating a sequence distance according to the third prediction result and sample labels, and calculating a final loss function according to the sequence distance, updating model parameters of the first neural network model and the second neural network model through back propagation.

[0169] Embodiment 4

[0170] As Figure 5 embodiments of the present application provide a sleep automatic staging system based on electroencephalogram signal analysis, comprising a data import module, a model training module and a model prediction module.

[0171] The data import module is configured to load multiple sets of electroencephalogram data and pre-process the data.

[0172] The model training module extracts time domain and frequency domain features from samples using a feature extraction module as information substitutes of original electroencephalogram, captures context information and long-term dependencies in sample sequences using a time sequence processing module, extracts correlations of electroencephalogram data features at different time steps in the sequence using a bidirectional evolutionary distance attention mechanism module, generates feature vectors with attention, and a sequence information module is configured to extract information of sleep staging results of electroencephalogram data at each time step in the sequence, and finally obtain an optimal automatic sleep staging model.

[0173] The model prediction module is configured to perform an automatic sleep staging task according to electroencephalogram images recorded during an overnight sleep process of a subject, and provide statistical data such as proportion of each period and duration. The specific steps are as follows:

[0174] 1) Load the electroencephalogram data using the data loading module in the data import module, process the electroencephalogram data using the data preprocessing module, and divide the electroencephalogram data according to 30s as a time step and a sequence of 10 time steps of electroencephalogram data;

[0175] 2) The electroencephalogram data processed in step 1) is input into the optimal automatic sleep staging model trained by the automatic sleep staging training module, and automatic sleep staging is performed;

[0176] 3) The staging results obtained by performing the automatic sleep staging task on the electroencephalogram image recorded during the whole night sleep of the subject obtained in step 2) are sorted to obtain diagnostic indicators such as whole night sleep time, proportion of each period, and duration of each period

[0177] In an embodiment, the data import module comprises:

[0178] The data loading submodule is used to load the electroencephalogram data of real-time sleep and the electroencephalogram data for model training.

[0179] The data preprocessing submodule is used to preprocess the loaded electroencephalogram data. For the problems of noise, artifacts, sample imbalance, etc. existing in the original electroencephalogram data, the noise in the original electroencephalogram data is removed by filtering, and the individual specificity is eliminated by standardization, and the electroencephalogram data not belonging to the sleep process such as large movement period is removed.

[0180] In an embodiment, the model training module comprises:

[0181] The feature extraction submodule is used to maximize the extraction of time domain and frequency domain features in the classification task. A multi-scale convolution feature extraction module constructed by CNN is used to extract the original electroencephalogram features. The module consists of two parts, one is a small-scale convolution network that extracts time information, and the other is a large-scale convolution network that extracts frequency information. Each CNN part consists of four consecutive one-dimensional convolution layers. Each convolution layer performs three operations in turn: one-dimensional convolution of the corresponding convolution kernel, normalization, and RELU activation function. This module can maximize the extraction of time domain and frequency domain features in the classification task, as an information substitute for the original electroencephalogram, reducing information loss. In addition, compared with other feature extraction structures, such structure design has better interpretability.

[0182] The time series processing submodule is used to process the continuous time series of electroencephalogram data, and also helps the method to more accurately capture the context information and long-term dependencies in the sequence, to obtain the electroencephalogram data at multiple time steps, thereby improving the accuracy and robustness of the staging. Specifically, a Bi-RNN structure is used as the time series processing module.

[0183] The feature optimization submodule adopts a bidirectional evolutionary distance attention mechanism module, which is used to extract the correlation of the features of the electroencephalogram data at different time steps in the sequence and generate a feature vector with attention.

[0184] The classifier submodule is used for classification according to the features.

[0185] The sequence information submodule is used for processing the label according to the sequence information and training.

[0186] In the embodiment, the sequence information submodule includes:

[0187] The sequence label unit is used for converting the class label in the sample, observing the position of the sample label in the sequence, obtaining the consistency of the sample label and the previous and subsequent labels within a certain time step, finally converting the consistency information into another class label as a new label for a new classification task, re-predicting, and training the model through a loss function.

[0188] The label embedding unit trains the label embedding through an attention mechanism, so that a unique embedding vector can be obtained for each label, which has both the inherent features of the label and the mutual information with other labels. The model is trained according to the embedded label.

[0189] The sequence distance module is used for comparing the distance between two sequences, aligning the two sequences, obtaining sequence information from the overall perspective of the sequence, calculating the total loss function according to the distance between the two sequences, and training the model.

[0190] The embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and the related parts can be referred to the method part.

[0191] The above description of the disclosed embodiments enables a person skilled in the art to implement or use the present application. Various modifications to the embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A sleep automatic staging method based on electroencephalogram signal analysis, characterized in that, The method comprises the following steps: Obtaining EEG brain signals of a plurality of samples as training data, training a pre-constructed neural network model, and performing sleep staging through the trained neural network model; the neural network model comprises a first neural network model; The first neural network model training step comprises: Arranging in time sequence, each sample representing a time step, to obtain a sample sequence; Extracting time domain features and frequency domain features from each sample in the training data; Performing time sequence processing on each sample according to the time domain features and the frequency domain features, extracting context information in the sample sequence, and obtaining a time sequence feature vector corresponding to each sample; Setting first model parameters and calculating the similarity of the EEG data at different time steps in the sequence; wherein γ t,t′ is a similarity between the sample feature at the t-th time step and the sample feature at the t'-th time step in the sequence, t and t' represent the time position of the sample in the sequence; is the transpose of the query feature matrix of the sample feature at the t-th time step, k t′ is the key feature matrix of the sample feature at the t'-th time step; D k is the dimension of the key matrix, τ' is a time step greater than 1 and less than t, k τ′ is the key feature matrix of the sample feature at the τ'-th time step; exp(·) is an exponential function with the natural constant e as the base. Calculating the context-aware distance metric between the sample features at different time steps in the sequence based on the time step length according to the similarity; Setting second model parameters and calculating the multiplicative exponential decay weight between the sample features at different time steps in the sequence according to the context-aware distance metric; where s t,τ is a multiplicative exponential decay weight between the sample feature at the t-th time step and the sample feature at the τ-th time step, θ is a learnable decay rate parameter, t and τ represent the time positions of the samples in the sequence, d(t, τ) is a context-aware distance measure between the sample feature at the t-th time step and the sample feature at the τ-th time step, is the transpose of the query feature matrix of the sample feature at the t-th time step, k τ is the key feature matrix of the sample feature at the τ-th time step, D k is the dimension of the key matrix, exp(·) is the exponential function with the natural constant e as the base; Calculating the attention weight between the sample features at different time steps in the sequence and generating optimized features. Classifying the optimized features to obtain a first prediction result; calculating a first loss function L1 according to the first prediction result and iterating to obtain model parameters.

2. The method for automatic sleep staging based on electroencephalogram signal analysis according to claim 1, characterized in that, The first loss function L1 is calculated according to the first prediction result, specifically: Calculating the weight of each type of result sample according to the prediction result: Calculating the loss function according to the weight: where y is the label of the current sample, p c is the probability that the network judges the sample to be of class c, w c denotes the weight of class c in the training set, and WCE(·) is the class-weighted cross-entropy function.

3. The method of claim 1, wherein the method comprises: The first neural network model training step further comprises: Generating a predicted label sequence according to the first prediction result; Converting labels according to the consistency of each sample label in the predicted label sequence within a preset time width to obtain a new label sequence; Re-predicting according to the loss function calculated based on the new label sequence and the first prediction result to obtain a second prediction result; Calculating a second loss function L2 according to the second prediction result and iterating to update the model parameters of the first neural network model.

4. The method of claim 1, wherein the method comprises: The neural network model further comprises a second neural network model; the first neural network model training step comprises joint training combined with the second neural network model, specifically: Initializing a same number of trainable random embeddings as the number of sample categories to obtain label embedding vectors; Multiplying the labels in the first prediction result with the generated label embedding vectors to obtain label embedding-based feature vectors; Inputting the label embedding-based feature vectors into the pre-constructed second neural network model for feature optimization, and obtaining a third prediction result through prediction; calculating a third loss function L3 according to the third prediction result to update the model parameters of the second neural network model, thereby training the second neural network model; Calculating sequence distance according to the third prediction result and the sample labels, and calculating a final loss function according to the sequence distance, and updating the model parameters of the first neural network model and the second neural network model through back propagation.

5. The method for automatic sleep staging based on electroencephalogram signal analysis according to claim 4, characterized in that, The step of calculating the sequence distance according to the third prediction result and the sample labels, and calculating the final loss function according to the sequence distance, comprises: According to the third prediction result, a class with the maximum prediction value is used as a brain electrical sample staging result corresponding to a current time step, and a prediction sequence is obtained according to sequence ordering; The sample label categories are sorted according to the sequence to obtain a label sequence; According to the predicted sequence and the tag sequence Computing the cost matrix: Where δ(·,·) is a differentiable cost function, and a Euclidean distance function is used; Predicted sequence x i and tag sequence y j Minimum distance: where r i,j is the minimum distance of the predicted sequence x i and the label sequence y j min γ is a differentiable minimum function: where a i is the element in the set for finding the minimum value, and γ is a manually set parameter The distance r between the calculated predicted sequence and the labeled sequence is n,n The final loss function Loss is obtained by adding the overall loss function Loss = w1-L1 + w2-L2 + w3-L3 + w4-r n,n Where w1, w2, w3, and w4 are weight coefficients.

6. The method for automatic sleep staging based on electroencephalogram signal analysis according to claim 1, characterized in that, The time domain features and frequency features are extracted from each sample in the training data, specifically: A multi-scale convolution feature extraction module constructed by a CNN is used to extract original brain electrical features; The feature extraction module is composed of two parts, one is a small-scale convolution network for extracting time information, and the other is a large-scale convolution network for extracting frequency information; Each CNN part is composed of four consecutive one-dimensional convolution layers; Each convolution layer sequentially performs one-dimensional convolution, normalization, and a RELU activation function of a corresponding convolution kernel.