Electroencephalogram automatic sleep staging method based on residual network and multi-level attention

By using an automatic sleep staging method based on EEG signals with residual networks and multi-level attention, we have solved the problems of gradient descent, spatial information neglect and class imbalance in existing technologies, and achieved higher sleep staging accuracy and model performance.

CN119385505BActive Publication Date: 2025-11-25CHONGQING UNIV OF POSTS & TELECOMM
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411437319.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-15
Publication Date
2025-11-25
Estimated Expiration
2044-10-15

AI Technical Summary

Technical Problem

Existing deep learning models suffer from problems such as gradient descent, single-channel attention ignoring spatial information, loss of long-term sequence information, and class imbalance in sleep staging tasks, resulting in insufficient accuracy in sleep staging.

Method used

An automatic sleep staging method based on EEG signals using residual networks and multi-level attention is adopted. By constructing a feature extraction module, a temporal feature learning module, and a classification layer, the model is trained using gradient descent. Combined with a style recalibration module, a spatial attention module, and a gated recurrent network, a self-attention mechanism and a weighted cross-entropy loss function are added to optimize the model parameters.

Benefits of technology

It improved the accuracy of sleep staging, enhanced the model's ability to capture EEG signal features, alleviated the class imbalance problem, and improved the overall performance of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119385505B_ABST
    Figure CN119385505B_ABST
Patent Text Reader

Abstract

The present application relates to a kind of electroencephalogram automatic sleep staging method based on residual network and multilevel attention, belong to sleep monitoring technical field, comprising the following steps: S1: sleep data set is built and data is preprocessed;S2: the single-channel electroencephalogram automatic sleep staging network model based on deep learning is built;S3: the model is trained using gradient descent method;S4: using the sleep staging model with optimal parameters realizes the sleep staging of single-channel electroencephalogram signal.The present application uses different size convolution kernel to realize the feature extraction of multiple scales, uses the recalibration module based on style pooling to combine spatial attention module to more comprehensive extraction signal feature, using the gated recurrent network of fusion self-attention mechanism captures time sequence information and highlights important sequence, finally improves sleep staging accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of sleep monitoring technology and relates to an automatic sleep staging method based on residual networks and multi-level attention EEG signals. Background Technology

[0002] Sleep is crucial for human health, playing a vital role in maintaining optimal cognitive and emotional function in daily life. As more and more people face sleep problems, accurately assessing sleep quality to ensure timely medical intervention becomes essential. Sleep staging is a primary task in sleep research; segmenting sleep states using various physiological signals is an effective method for objectively evaluating sleep quality.

[0003] In clinical practice, polysomnography (PSG) is commonly used to analyze patients' sleep patterns and is widely regarded as the gold standard for sleep staging. It records various electrophysiological signals, including electroencephalograms (EEG), electromyograms (EOG), electromyograms (EMG), and electrocardiograms (ECG). Sleep experts stage sleep based on the characteristics of 30-second sleep data. The American Academy of Sleep Medicine (AASM) divides sleep into five stages: wakefulness (W), N1, N2, N3, and rapid eye movement (REM) (Berry et al., 2017). However, manual sleep staging is not only time-consuming and laborious, but the results are also easily influenced by expert subjectivity. Therefore, the use of automated sleep staging technology is crucial.

[0004] Many studies use machine learning algorithms for sleep staging, typically involving feature engineering to extract relevant features in the time domain, frequency domain, and time-frequency domain. Classifiers such as random forests, support vector machines, and decision trees are then used to classify the extracted sleep features. This process requires domain knowledge and may lead to information loss. Furthermore, the large number of feature types available presents a challenge in feature selection.

[0005] In recent years, deep learning methods have achieved good results in automatic sleep staging tasks, with models demonstrating accuracy comparable to sleep experts. Convolutional neural networks (CNNs) are used to extract time-frequency features of sleep signals, while recurrent neural networks (RNNs), improved long short-term memory (LSTM) networks, and gated recurrent unit networks (GRUs) are used to learn the temporal dependencies and switching rules between sleep stages. These methods do not rely on expert experience, which can reduce the workload of clinicians. Although various deep learning models have been applied to sleep staging tasks, some problems still exist: increasing network depth to fully extract sleep features can lead to gradient descent; single-channel attention ignores the contribution of spatial information in the same channel to the model's classification performance; GRU networks can use their gating mechanism to alleviate the problem of information loss in long sequences, but they cannot highlight important information in long sequences, which weakens the network's ability to learn sleep stage transition rules. Summary of the Invention

[0006] In view of this, the purpose of this invention is to provide an automatic sleep staging method for EEG signals based on residual networks and multi-level attention, in order to fully extract relevant features of sleep EEG and better learn staging rules, thereby improving the accuracy of sleep staging of EEG signals.

[0007] To achieve the above objectives, the present invention provides the following technical solution:

[0008] An automatic sleep staging method based on residual networks and multi-level attention using EEG signals includes the following steps:

[0009] S1: Construct a sleep dataset and preprocess the data;

[0010] S2: Construct a single-channel EEG-based automatic sleep staging network model based on deep learning;

[0011] S3: Train the model using gradient descent;

[0012] S4: Implement sleep staging of single-channel EEG signals using a sleep staging model with optimal parameters.

[0013] Furthermore, step S1 specifically includes the following steps:

[0014] S11: Acquire polysomnography signals with sleep tags and extract raw EEG signals from them;

[0015] S12: The original EEG signals are cropped, and irrelevant data that do not belong to the five sleep stages, such as the MOVEMENT and UNKNOW stages, are removed according to the sleep tags; only the waking period data of 30 minutes before and after sleep is retained for each sleep data;

[0016] S13: Select a single-channel EEG signal for slice processing.

[0017] Furthermore, the deep learning-based single-channel EEG automatic sleep staging network model includes a feature extraction module, a temporal feature learning module, and a classification layer;

[0018] The feature extraction module is used to extract feature parameters;

[0019] The temporal feature learning module first uses a forward gated recurrent network to learn contextual information, then adds a self-attention mechanism to highlight important sequence features, and finally uses a reverse gated recurrent network to learn contextual information from two directions.

[0020] The classification layer uses global average pooling to reduce network parameters, and a fully connected layer maps the output to the five categories of the sleep stage.

[0021] Furthermore, the feature extraction module includes an initial convolutional layer, a feature recalibration module, and a pooling layer; the input first passes through the initial convolutional block, then alternately passes through two RCSA blocks and a max pooling layer, and after the third RCSA block, a global average pooling layer is used to reduce the network parameters, and finally a random dropout layer is used to prevent the model from overfitting.

[0022] Furthermore, the initial convolutional layer consists of two one-dimensional convolutional layers, each followed by a BN normalization layer and a ReLU nonlinear activation function layer;

[0023] The Feature Recalibration Module (RCSA) is based on the residual channel attention module and uses a style-based recalibration module (SRM) to replace the excitation-squeeze network to implement the channel attention function, and then adds a spatial attention module.

[0024] The style-based recalibration module extracts style information from each channel of the feature map through style pooling, including the channel's mean and standard deviation; given the input feature map... Obtaining style characteristics Then, the recalibration weights for each channel are estimated through channel-independent style integration to obtain the weights. Finally, the weights are multiplied by the initial input through a broadcast mechanism to reweight the feature channels.

[0025] The spatial attention module is the spatial attention module in the Convolutional Block Attention Module (CBAM). First, average pooling and max pooling are applied along the channel direction of each feature point and stacked by concatenation. Then, a standard convolutional layer is used for connection and convolution. Next, the sigmoid activation function is used to obtain a two-dimensional spatial attention map, that is, to obtain the weight value of each feature point of the input feature map. Finally, the weights are multiplied and weighted channel by channel onto the input feature layer.

[0026] Furthermore, the time step of the gated recurrent network (GRU) is t, and the network includes a reset gate r. t And update the gate zt, This represents a candidate hidden layer, updating the currently retained information, expressed as follows:

[0027] r t =σ(Wr x t +U r h t-1 )

[0028] z t =σ(W z x t +U z h t-1 )

[0029]

[0030] In the formula, W r W z ,W,U z U and H represent the weight matrices of the GRU, respectively. t-1 x represents the information from the previous time step t-1. t Let represent the input vector at time step t, and σ be the Sigmoid function.

[0031] Furthermore, in step S3, the loss function of the single-channel EEG automatic sleep staging network model is:

[0032]

[0033] In the formula y i and These represent the actual label and predicted label for each category, respectively; C represents the number of categories; w i This represents the weight coefficient assigned to each class;

[0034] The sleep staging network model is trained using gradient descent, and the model parameters are optimized by minimizing the loss function until the loss function converges, thereby obtaining the optimal sleep staging network model and parameters.

[0035] Furthermore, in step S4, after the input data passes through the fully connected layer in the classification layer, a 5-dimensional vector is obtained. Then, the Softmax function is applied to this vector to obtain the probabilities of the five sleep stages, ultimately yielding the staging result. The Softmax function is as follows:

[0036]

[0037] Where x i Let be the output value of the i-th node, C be the number of classification labels for the sample, and e be the exponential function.

[0038] The beneficial effects of this invention are as follows:

[0039] (1) This invention improves upon the residual channel attention network by using a style-based recalibration module to replace the squeezing and excitation module, which can fully explore the various style information of the channel; and adds a spatial attention mechanism to enhance the model's ability to capture and focus on important EEG waveforms in the feature map, thereby improving the model performance.

[0040] (2) In the initial convolutional module of feature extraction, the present invention uses wide kernel convolution to obtain a larger receptive field, and then uses smaller convolutional kernels to achieve multi-scale feature extraction.

[0041] (3) This invention uses a gated recurrent network to capture contextual information. Compared with long short-term memory networks, it has fewer parameters and faster speed. Furthermore, by incorporating a self-attention mechanism and an inverse gated recurrent network, it can capture temporal information more comprehensively and highlight important sequences.

[0042] (4) The present invention uses a weighted cross-entropy loss function, which can alleviate the problem of class imbalance in the five categories of sleep data and improve the accuracy of sleep staging.

[0043] Other advantages, objectives, and features of the invention will be set forth in part in the description which follows, and in part will be apparent to those skilled in the art from the following examination, or may be learned from practice of the invention. The objectives and other advantages of the invention can be realized and obtained through the following description. Attached Figure Description

[0044] To make the objectives, technical solutions, and advantages of the present invention clearer, the preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings, wherein:

[0045] Figure 1 This is a flowchart of the method of the present invention;

[0046] Figure 2 This is an overall framework diagram of the automatic sleep staging model of the present invention;

[0047] Figure 3 This is an overall framework diagram of the feature extraction module of the present invention;

[0048] Figure 4 This is a network structure diagram of the RCSA module in the feature extraction module of this invention;

[0049] Figure 5 This is a diagram of the SRM network structure in the feature extraction module of this invention;

[0050] Figure 6 This is a diagram of the gated loop network structure of the present invention;

[0051] Figure 7 This is the temporal information learning network of the present invention. Detailed Implementation

[0052] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Unless otherwise specified, the following embodiments and features can be combined with each other.

[0053] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.

[0054] In the following description, numerous details are explored to provide a more thorough explanation of embodiments of the invention. However, it will be apparent to those skilled in the art that embodiments of the invention may be practiced without these specific details. In other embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring embodiments of the invention.

[0055] This invention provides an automatic sleep staging method for EEG signals based on residual networks and multi-level attention. The automatic sleep staging model employs a sequence-to-sequence framework, utilizing convolutional networks to extract multi-level features from the signal and a GRU network to capture sequence features. The convolutional networks apply kernels of different sizes to extract feature information from EEG signals of different frequencies. The RCSA module addresses gradient degradation while recalibrating channel features and enhancing spatial feature extraction. In the temporal information learning network, a self-attention mechanism is added after the GRU to emphasize important sequence features, and an inverse GRU is added to capture sleep features from two directions. Finally, a weighted cross-entropy loss function is used to alleviate class imbalance and improve network performance. The overall flowchart is shown below. Figure 1 As shown, specifically, it includes the following steps:

[0056] Step 1: Obtain polysomnography signals tagged with sleep and extract sleep EEG signals. The raw EEG dataset is cropped, removing irrelevant data such as "movement" and "unknowing" that do not belong to the five sleep stages. To increase focus on sleep stages, only 30 minutes of wakefulness data before and after sleep are retained for each sleep dataset. This prevents excessive wakefulness data from negatively impacting the model's recognition of other stages. Finally, a single-channel EEG signal is sliced ​​for easier input into the neural network model. The publicly available dataset used in this example is Sleep-EDF-20, which contains 39 full nights of sleep data from 20 subjects, using EEG data from the Fpz-Cz channels. The experiment employs K-fold cross-validation, dividing the dataset into K parts: K-1 parts as the training set and the remaining part as the validation set. This is repeated K times (each time with a different validation set), and the average of the K iterations is taken as the final result.

[0057] Step 2: Build a deep learning automatic sleep staging network model framework, including: a feature extraction module, a temporal feature learning module, and a classification layer, such as... Figure 2 As shown.

[0058] The feature extraction module includes an initial convolutional layer, a feature recalibration module, and pooling layers, such as... Figure 3 As shown.

[0059] The initial convolutional layer consists of two one-dimensional convolutional layers, each followed by a BN normalization layer and a ReLU non-linear activation function layer. In this example, the first convolutional layer has 1 input channel, 128 output channels, a kernel size of 128×1, a stride of S=2, and padding of 3. The second convolutional layer has 32 output channels, a kernel size of 15×1, a stride of S=1, and padding of 7.

[0060] The Feature Recalibration Module (RCSA) is an improvement upon the Residual Channel Attention Module: it uses a Style-based Recalibration Module (SRM) instead of the excitation-squeeze network to implement channel attention, and adds a spatial attention module after it, such as... Figure 4-5As shown. In the main branch, the channel count first passes through two one-dimensional convolutions, then an SRM module for channel recalibration, and finally a spatial attention module to enhance the capture of waveform features. A one-dimensional convolution is used in the shortcut connection to match the number of input and output channels. It is worth noting that only the first convolution in the main branch and the convolutions in the branches change the number of channels during computation; other convolutions do not change the number of channels. The style-based recalibration module and the spatial attention module used are described below:

[0061] Style-based recalibration module: First, style information, including the channel mean and standard deviation, is extracted from each channel of the feature map through style pooling. Given an input feature map... Style characteristics can be obtained Then, by estimating the recalibration weights for each channel through channel-independent style integration, the weights can be obtained. By multiplying the weights by the initial input through a broadcast mechanism, the channels of the features can be reweighted. By incorporating the relative importance of each style into the feature map, SRM effectively enhances the representational power of CNN.

[0062] The spatial attention module used is the spatial attention module in the Convolutional Block Attention Module (CBAM). First, average pooling and max pooling (both pooling are applied to the channels of the input feature layer) are applied along the channel direction of each feature point, and then they are stacked by concatenation. Then, a standard convolutional layer (a convolution with 1 channel) is used for connection and convolution (the number of channels is adjusted). Then, the sigmoid activation function is used to obtain a two-dimensional spatial attention map, which obtains the weight value (between 0 and 1) of each feature point of the input feature map. Finally, the weights are multiplied and applied to the input feature layer channel by channel.

[0063] The overall framework of the feature extraction module is as follows: Figure 3As shown, the input first passes through an initial convolutional block, then alternately through two RCSA blocks and a max-pooling layer. After the third RCSA block, a global average pooling layer is used to reduce network parameters, and finally, a random dropout layer is used to prevent overfitting. In this example, the first RCSA block has 32 input channels and 64 output channels, using a 3×1 kernel, a stride of S=1, and padding of 1. The second RCSA block has 64 input channels and 128 output channels, using a 5×1 kernel, a stride of S=1, and padding of 2. The third RCSA block has 128 input channels and 128 output channels, using a 7×1 kernel, a stride of S=1, and padding of 3. The two max-pooling layers use a 4×1 kernel with a stride of S=4. The dropout rate of the final random dropout layer is 0.5.

[0064] A temporal feature learning module is constructed, which includes a gated recurrent network and a self-attention module. The gated recurrent network is used to learn contextual information, while the self-attention module is added to highlight important information in the sequence.

[0065] Figure 6 This describes the internal structure of a GRU cell with time step t. and These represent matrix multiplication and matrix addition operations, respectively. GRU has a reset gate (r... t ) and update gate (z t The update gate determines which information should be discarded and which should be added, while the reset gate determines how much of the network's previous state should be written to capture short-term memory. This represents a candidate hidden layer, updating the currently retained information, expressed as follows:

[0066] r t =σ(W r x t +U r h t-1 )

[0067] z t =σ(W z x t +U z h t-1 )

[0068]

[0069] In the formula, W r W z ,W,U z U and H represent the weight matrices of the GRU, respectively. t-1x represents the information from the previous time step t-1. t Let represent the input vector at time step t, and σ be the Sigmoid function.

[0070] The temporal information learning network designed in this invention is as follows: Figure 7 First, a forward-gated recurrent network is used to learn contextual information. Then, a self-attention mechanism is added to highlight important sequence features. Finally, a reverse-gated recurrent network is used to learn contextual information from two directions, thereby enhancing the model's expressive power.

[0071] The classification layer consists of a global average pooling layer and a fully connected layer. Global average pooling further reduces the number of network parameters, while the fully connected layer maps the output to the five categories of the sleep phase.

[0072] Step 3: Construct the loss function Loss of the automatic sleep staging network using the following formula:

[0073]

[0074] In the formula, y i and These represent the actual label and predicted label for each category, respectively; C represents the number of categories; w i This represents the weight coefficient assigned to each class. Because sleep data suffers from severe class imbalance—for example, N1 stage sleep is far less frequent than N2 stage sleep in a night—the learning of N1 stage data is insufficient, leading to poor recognition performance. To mitigate this problem, based on some prior knowledge, different learning weights are assigned to the five classes; for example, N1 stage is given a higher weight, allowing the model to focus more on learning N1 stage data. In this example, the weight coefficient matrix for the five classes is [1, 1.5, 1, 1, 1].

[0075] Step 4: Train the sleep staging network model using gradient descent and optimize the model parameters by minimizing the loss function until the loss function converges, thereby obtaining the optimal sleep staging network model and parameters. In this example, the optimization method is the AdamW optimization algorithm, with an initial learning rate of 0.001 and parameters β1 = 0.90 and β2 = 0.99.

[0076] In this embodiment, an electronic device includes a memory and a processor. The memory stores a program that supports the processor in executing the aforementioned lightweight sleep staging method. The processor is configured to execute the program stored in the memory.

[0077] In this embodiment, a computer-readable storage medium stores a computer program that is executed by a processor to perform the steps of the lightweight sleep staging method described above.

[0078] Experimental setup and results analysis:

[0079] (1) Dataset: The experiment used the Sleep-EDF-20 dataset from PhysioNet, which contains 39 sleep data points from 20 subjects.

[0080] (2) Experimental Parameter Settings: Multi-fold cross-validation was used to evaluate model performance, with 20 folds. The AdamW optimizer was used as the optimization function, with an initial learning rate of 0.001. The input sequence length was 32, the batch size was 16, and the model was trained for 100 epochs. In this experiment, the proposed model was developed and executed in a Python environment running on the system using the PyTorch framework. The model was trained on an Nvidia GeForce RTX2080 GPU with 8GB of GPU memory.

[0081] (3) Evaluation Metrics: Multiple metrics were used to evaluate model performance in the experiment. Accuracy (Pr), recall (Re), and F1-Score (F1) were used to evaluate the classification performance of each class. Accuracy (Acc), Cohen's kappa coefficient (k), and Macroaverage-F1 score (MF1) were used to evaluate the overall model performance. These overall performance metrics are defined as follows:

[0082]

[0083] In the formula, C represents the number of categories, and TP i F1 represents the number of true positives in the i-th class, M is the total number of samples, and F1 is the number of true positives in the i-th class. i p represents the F1 score for the i-th class. e This represents the probability of equal chance. i b is the number of the i-th actual sample. i is the number of the i-th predicted sample, and n is the total number of samples. In addition, a confusion matrix is ​​generated to provide a deeper understanding of the classification performance.

[0084] (4) Experimental Evaluation: Classification performance is referenced in Tables 1 and 2. Table 1 shows the confusion matrix of the model classification. The diagonal elements of the confusion matrix represent the consistency with the labels classified by experts. The left side of Table 2 represents the evaluation parameters for each category, and the right side represents the overall evaluation parameters. The higher the evaluation parameters, the better the performance. According to the tables, the classification performance is best in stages W and N2, while the worst performance is in stage N1. This is mainly due to the small amount of data in stage N1 and the similarity between stage N1 and other sleep stages, making stage N1 more difficult to distinguish from other sleep stages.

[0085] Table 1

[0086]

[0087] Table 2

[0088]

[0089] Table 3 presents the experimental results of the proposed method and other existing methods on the dataset. Under similar experimental conditions, the model achieves the best overall performance metrics (Acc, MF1, k) on the Sleep-EDF-20 dataset, with Acc, MF1, and k at 89.1%, 84.4%, and 0.85, respectively. Furthermore, the model achieves the highest F1 scores in the W, N2, and REM stages. Although the model does not preprocess the data, its use of a weighted cross-entropy loss function, which assigns more weight to the N1 stage, results in superior performance compared to most methods in this stage. In conclusion, the proposed model demonstrates highly competitive performance compared to other established automatic sleep staging models.

[0090] Table 3

[0091]

[0092] In the above embodiments, the reference to "this embodiment" in the specification indicates that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least some embodiments, but not necessarily all embodiments. Multiple appearances of "this embodiment" do not necessarily all refer to the same embodiment.

[0093] In the above embodiments, although the invention has been described in conjunction with specific embodiments thereof, many substitutions, modifications, and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory structures (e.g., dynamic RAM (DRAM)) may be used with the embodiments discussed. The embodiments of the invention are intended to cover all such substitutions, modifications, and variations falling within the broad scope of the appended claims.

[0094] This embodiment also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the methods in this embodiment.

[0095] This embodiment also provides an electronic terminal, including: a processor and a memory;

[0096] The memory is used to store computer programs, and the processor is used to execute the computer programs stored in the memory to cause the terminal to perform any of the methods in this embodiment.

[0097] As will be understood by those skilled in the art, the computer-readable storage medium described in this embodiment allows for the implementation of all or part of the steps in the above method embodiments by computer program-related hardware. The aforementioned computer program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0098] The electronic terminal provided in this embodiment includes a processor, a memory, a transceiver, and a communication interface. The memory and the communication interface are connected to the processor and the transceiver and complete communication between them. The memory is used to store computer programs, the communication interface is used to perform communication, and the processor and the transceiver are used to run the computer programs, so that the electronic terminal performs the steps of the above method.

[0099] In this embodiment, the memory may include random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device.

[0100] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0101] This invention can be used in a wide range of general-purpose or special-purpose computing system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices, etc.

[0102] This invention can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This invention can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0103] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. An automatic sleep staging method based on residual networks and multi-level attention using EEG signals, characterized in that: Includes the following steps: S1: Construct a sleep dataset and preprocess the data; S2: Construct a single-channel EEG-based automatic sleep staging network model based on deep learning; S3: Train the model using gradient descent; S4: Implement sleep staging of single-channel EEG signals using a sleep staging model with optimal parameters; The deep learning-based single-channel EEG automatic sleep staging network model includes a feature extraction module, a temporal feature learning module, and a classification layer; The feature extraction module is used to extract feature parameters; The temporal feature learning module first uses a forward gated recurrent network to learn contextual information, then adds a self-attention mechanism to highlight important sequence features, and finally uses a reverse gated recurrent network to learn contextual information from two directions. The classification layer uses global average pooling to reduce network parameters, and a fully connected layer maps the output to the five categories of the sleep stage. The feature extraction module includes an initial convolutional layer, a feature recalibration module, and a pooling layer. The input first passes through the initial convolutional block, then alternately passes through two RCSA blocks and a max pooling layer. After the third RCSA block, a global average pooling layer is used to reduce the network parameters, and finally a random dropout layer is used to prevent the model from overfitting. The initial convolutional layer consists of two one-dimensional convolutional layers, each of which is followed by a BN normalization layer and a ReLU non-linear activation function layer. The Feature Recalibration Module (RCSA) is based on the residual channel attention module and uses a style-based recalibration module (SRM) to replace the excitation-squeeze network to implement the channel attention function, and then adds a spatial attention module. The style-based recalibration module extracts style information from each channel of the feature map through style pooling, including the channel's mean and standard deviation; given the input feature map... To obtain stylistic features Then, the recalibration weights for each channel are estimated through channel-independent style integration to obtain the weights. Finally, the weights are multiplied by the initial input through a broadcast mechanism to reweight the feature channels. The spatial attention module is the spatial attention module in the Convolutional Block Attention Module (CBAM). First, average pooling and max pooling are applied along the channel direction of each feature point and stacked by concatenation. Then, a standard convolutional layer is used for connection and convolution. Next, the sigmoid activation function is used to obtain a two-dimensional spatial attention map, that is, to obtain the weight value of each feature point in the input feature map. Finally, the weights are multiplied and weighted channel by channel onto the input feature layer.

2. The automatic sleep staging method based on residual networks and multi-level attention of EEG signals according to claim 1, characterized in that: Step S1 specifically includes the following steps: S11: Acquire polysomnography signals with sleep tags and extract raw EEG signals from them; S12: The original EEG signals are cropped, and irrelevant data that do not belong to the five sleep stages, such as the MOVEMENT and UNKNOW stages, are removed according to the sleep tags; only the waking period data of 30 minutes before and after sleep is retained for each sleep data; S13: Select a single-channel EEG signal for slice processing.

3. The automatic sleep staging method based on residual networks and multi-level attention of EEG signals according to claim 1, characterized in that: The time step of the gated recurrent network (GRU) is: t The network includes a reset gate. and the update gate , This represents a candidate hidden layer, updating the currently retained information, expressed as follows: In the formula, and These represent the weight matrices of the GRU. Indicates the previous time step Information, Indicates the first t The input vector at each time step, It is the Sigmoid function.

4. The automatic sleep staging method based on residual networks and multi-level attention of EEG signals according to claim 1, characterized in that: In step S3, the loss function of the single-channel EEG automatic sleep staging network model is: In the formula and These represent the actual label and predicted label for each category, respectively, and C represents the number of categories. This represents the weight coefficient assigned to each class; The sleep staging network model is trained using gradient descent, and the model parameters are optimized by minimizing the loss function until the loss function converges, thereby obtaining the optimal sleep staging network model and parameters.

5. The automatic sleep staging method based on residual networks and multi-level attention EEG signals according to claim 1, characterized in that: In step S4, the input data is passed through the fully connected layer in the classification layer to obtain a 5-dimensional vector. Then, the Softmax function is applied to it to obtain the probability of each of the five sleep stages, and finally the staging result is obtained. The Softmax function is as follows: in Let be the output value of the i-th node, C be the number of classification labels for the sample, and e be the exponential function.

Citation Information

Patent Citations

  • Structure-guided style deviation correction type style migration method and system

    CN114757819A

  • Single-channel electroencephalogram signal sleep staging method based on multiple scales and multiple attention

    CN116763324A