Electroencephalogram signal automatic sleep staging method based on residual network and multi-level attention
By adopting residual network and multi-level attention methods in the automatic sleep staging task of EEG signal, a deep learning network model is constructed and combined with multi-layer feature extraction and timing information learning, the existing model is solved in sleep staging accuracy. The shortcomings of this paper achieve higher sleep staging accuracy and model performance.
Patent Information
- Application Number
- CN202411437319.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-10-15
AI Technical Summary
The existing deep learning models have problems such as gradient descent, channel attention ignoring spatial information, and GRU networks cannot highlight important information in long sequences, resulting in insufficient accuracy of sleep staging.
Using the automatic sleep staging method of EEG signals based on residual network and multi-level attention, the single-channel EEG automatic sleep staging network model of deep learning is constructed, and the gradient descent method is used for training, and combined with feature extraction module and timing feature learning The module and classification layer utilize forward and reverse gated recurrent networks, self-attention mechanisms and weighted cross-entropy loss functions to enhance the model's feature extraction and timing information capture capabilities.
It improves the accuracy of sleep staging of EEG signals, enhances the model's ability to capture important EEG waveforms, alleviates the problem of category imbalance, and improves the overall performance of sleep staging.
Smart Images

Figure CN119385505A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of sleep monitoring, and relates to an automatic sleep staging method for electroencephalogram signals based on residual networks and multi-level attention. Background Art
[0002] Sleep is very important for human health and plays a vital role in maintaining optimal cognitive and emotional functions in daily life. As more and more people face sleep problems, it is important to accurately assess sleep quality to ensure timely medical intervention. Sleep staging is the primary task of sleep research. Staging the human sleep state through various physiological signals is an effective way to objectively evaluate sleep quality.
[0003] Polysomnography (PSG) is commonly used in clinical practice to analyze patients' sleep patterns. It is widely regarded as the gold standard for sleep staging. It can record multiple electrophysiological signals such as electroencephalogram (EEG), electromyogram (EOG), electromyogram (EMG), electrocardiogram (ECG), etc. Sleep experts stage sleep based on the characteristics of 30-second sleep data. The American Association of Sleep Medicine (AASM) divides sleep stages 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 classification results are easily affected by the subjectivity of experts. Therefore, it is very important to use automatic sleep staging technology.
[0004] Many studies use machine learning algorithms for sleep staging, which usually involves feature engineering to extract relevant features in the time domain, frequency domain, time-frequency domain, etc. Then classifiers such as random forests, support vector machines, and decision trees are used to classify the extracted sleep features, which requires domain knowledge and may lead to information loss. In addition, there are many types of features that can be selected, which makes it difficult to select features.
[0005] In recent years, deep learning methods have achieved good results in automatic sleep staging tasks, and the models have shown comparable performance to sleep experts in terms of accuracy. Convolutional neural networks (CNNs) are used to extract the 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. Such methods do not rely on expert experience and can reduce the workload of clinicians. Although various deep learning models have been applied to sleep staging tasks, there are still some problems: deepening the network depth to fully extract sleep features will lead to gradient descent, and the single channel attention ignores the contribution of spatial information in the same channel to the model classification performance. The GRU network can use its gating mechanism to alleviate the problem of information loss in long time series, but it cannot highlight important information in long sequences, which will weaken the network's ability to learn the rules of sleep stage conversion. Summary of the invention
[0006] In view of this, the purpose of the present 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 the relevant features of sleep EEG and better learn the staging rules, thereby improving the accuracy of sleep staging for EEG signals.
[0007] In order to achieve the above object, the present invention provides the following technical solutions:
[0008] An automatic sleep staging method for EEG signals based on residual network and multi-level attention includes the following steps:
[0009] S1: construct sleep dataset and perform data preprocessing;
[0010] S2: Build a single-channel EEG automatic sleep staging network model based on deep learning;
[0011] S3: training the model using a gradient descent method;
[0012] S4: Use the sleep staging model with optimal parameters to realize sleep staging of single-channel EEG signals.
[0013] Further, step S1 specifically includes the following steps:
[0014] S11: obtaining a polysomnography signal with a sleep label and extracting a raw EEG signal from it;
[0015] S12: trimming the original EEG signal, and removing irrelevant data of the MOVEMENT and UNKNOW stages that do not belong to the five sleep stages according to the sleep label; for each sleep data, only the wakefulness period data of 30 minutes before and after sleep is retained;
[0016] S13: Select a single-channel EEG signal for slicing processing.
[0017] Furthermore, the single-channel EEG automatic sleep staging network model based on deep learning 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 uses a fully connected layer to map the output to five categories of sleep stages.
[0021] Furthermore, the feature extraction module includes an initial convolution layer, a feature recalibration module, and a pooling layer; the input first passes through the initial convolution block, and then alternately passes through two RCSA blocks and a maximum pooling layer, and after passing through 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 model overfitting.
[0022] Furthermore, the initial convolution layer is composed of two one-dimensional convolution layers, each of which is followed by a BN normalization layer and a ReLU nonlinear activation function layer;
[0023] The feature recalibration module RCSA uses a style-based recalibration module (SRM) to replace the excitation-squeeze network to implement the channel attention function based on the residual channel attention module, and then adds a spatial attention module;
[0024] The style-based recalibration module is as follows: style information is extracted from each channel in the feature map by style pooling, including the mean and standard deviation of the channel; given an input feature map Get style features Then the recalibration weight of each channel is estimated by channel-independent style integration to obtain the weight Finally, the weights are multiplied by the initial input through the broadcast mechanism to re-weight the feature channels;
[0025] The spatial attention module is a spatial attention module in a convolutional block attention module (CBAM). First, average pooling and maximum pooling are applied along the channel direction of each feature point and stacked up through a splicing operation. Then, a standard convolutional layer is used for connection and convolution. Then, a sigmoid activation function is used to obtain a two-dimensional spatial attention map, that is, the weight value of each feature point in the input feature map is obtained, and finally, the weight is weighted to the input feature layer channel by channel through multiplication.
[0026] Furthermore, the time step of the gated recurrent network GRU is t, and the network includes a reset gate r t and update gate zt, Represents the candidate hidden layer and updates the currently retained information. The expression is 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] Where W r ,W z ,W,U z and U represent the weight matrix of GRU, h t-1 represents the information of the previous time step t-1, x t represents the input vector at the tth time step, and σ is the Sigmoid function.
[0031] Furthermore, in step S3, the loss function of the single-channel EEG automatic sleep staging network model is:
[0032]
[0033] Where y i and Represents the actual label and predicted label of each category, C represents the number of categories, and w i represents the weight coefficient assigned to each class;
[0034] The sleep staging network model is trained using the gradient descent method, 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] Further, in step S4, after the input data finally passes through the fully connected layer in the classification layer, a 5-dimensional vector can be obtained, and then the Softmax function is used to obtain the probabilities of the five sleep stages respectively, and finally the stage classification result is obtained. The Softmax function is as follows:
[0036]
[0037] where x i is the output value of the i-th node, C is the number of classification labels of the samples, and e is the exponential function.
[0038] The beneficial effects of the present invention are:
[0039] (1) The present invention improves on the residual channel attention network and uses a style-based recalibration module to replace the squeeze and excitation module, which can fully explore the various style information of the channel; the spatial attention mechanism is added 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) The present invention uses wide kernel convolution in the initial convolution module of feature extraction to obtain a larger receptive field, and subsequently uses smaller convolution kernels to achieve multi-scale feature extraction.
[0041] (3) The present invention uses a gated recurrent network to capture contextual information. Compared with the long short-term memory network, it has fewer parameters and faster speed. In addition, the addition of a self-attention mechanism and a reverse gated recurrent network 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 category imbalance in the five categories of data in the sleep data and improve the accuracy of sleep staging.
[0043] Other advantages, objectives and features of the present invention will be described in the following description to some extent, and to some extent, will be obvious to those skilled in the art based on the following examination and study, or can be taught from the practice of the present invention. The objectives and other advantages of the present invention can be realized and obtained through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention will be described in detail below in conjunction with the accompanying drawings, wherein:
[0045] Figure 1 is a flow chart of the method of the present invention;
[0046] Figure 2 It is the overall framework diagram of the automatic sleep staging model of the present invention;
[0047] Figure 3 It is the overall framework diagram of the feature extraction module of the present invention;
[0048] Figure 4 It is the network structure diagram of the RCSA module in the feature extraction module of the present invention;
[0049] Figure 5 It is a diagram of the SRM network structure in the feature extraction module of the present invention;
[0050] Figure 6 It is a diagram of the gated cyclic network structure of the present invention;
[0051] Figure 7 It is the temporal information learning network of the present invention. DETAILED DESCRIPTION
[0052] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways 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 only illustrate the basic concept of the present invention in a schematic manner, and the following embodiments and features in the embodiments can be combined with each other without conflict.
[0053] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0054] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present invention difficult to understand.
[0055] The present invention provides an automatic sleep staging method for EEG signals based on residual networks and multi-level attention. The automatic sleep staging model of the present invention adopts a sequence-to-sequence model framework, uses a convolutional network to extract multi-level features from the signal, and uses a GRU network to capture sequence features. The convolutional network uses kernels of different sizes to extract feature information from EEG signals of different frequencies. The RCSA module solves the gradient degradation problem 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 a reverse GRU is added to capture sleep features from two directions. Finally, a weighted cross entropy loss function is used to alleviate category imbalance and improve network performance. The overall flow chart is as follows Figure 1 Specifically, the steps include:
[0056] Step 1. Obtain a polysomnography signal with a sleep label and extract the sleep EEG signal from it. The original EEG signal data set is trimmed to remove some irrelevant data such as MOVEMENT and UNKNOW that do not belong to the five sleep stages. In order to increase the focus on the sleep stage, each sleep data only retains the wake data of 30 minutes before and after sleep, so as to prevent the model from having too much wake data and causing the recognition effect of other stages to decrease. Finally, a single-channel EEG signal is selected for slicing processing to facilitate input into the neural network model. The public data set used in this example is Sleep-EDF-20, which contains 39 full-night sleep data of 20 subjects, and the EEG data of the Fpz-Cz channel is selected. At the same time, the experiment adopts the K-fold cross-validation method, that is, the data set is divided into K parts, K-1 parts are used as training sets, and the remaining 1 part is used as a validation set. The loop is executed K times (each validation set is different), and finally the average value of K times is taken as the final result.
[0057] Step 2: Build a deep learning automatic sleep staging network model framework, including: feature extraction module, temporal feature learning module, classification layer, such as Figure 2 shown.
[0058] The feature extraction module includes the initial convolution layer, feature recalibration module, and pooling layer, such as Figure 3 shown.
[0059] The initial convolution layer consists of two one-dimensional convolution layers, each of which is followed by a BN normalization layer and a ReLU nonlinear activation function layer. In this example, the first convolution layer has 1 input channel, 128 output channels, a convolution kernel size of 128×1, a step size of S=2, and padding of 3. The second convolution layer has 32 output channels, a convolution kernel size of 15×1, a step size of S=1, and padding of 7.
[0060] The feature recalibration module (RCSA) is improved on the basis of the residual channel attention module: the style-based recalibration module (SRM) is used to replace the excitation-squeeze network to implement the channel attention function, and a spatial attention module is added after it, such as Figure 4-5As shown. In the trunk branch, two one-dimensional convolutions are first performed, followed by an SRM module for channel recalibration, and finally a spatial attention module to enhance the ability to capture 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 trunk and the convolution in the branch change the number of channels during the operation, while the other convolutions do not change the number of channels during the operation. The following introduces the style-based recalibration module and spatial attention module used:
[0061] Style-based recalibration module: First, style information is extracted from each channel in the feature map through style pooling, which includes the mean and standard deviation of the channel. Given an input feature map Style features can be obtained Then, the recalibration weight of each channel is estimated by the channel-independent style integration, and the weight can be obtained By multiplying the weights with the initial input through a broadcast mechanism, the channels of the features can be re-weighted. By incorporating the relative importance of each style into the feature map, SRM effectively enhances the representation ability of CNN.
[0062] In addition, the spatial attention module used is the spatial attention module in the Convolutional Block Attention Module (CBAM). First, average pooling and maximum pooling are applied along the channel direction of each feature point (both poolings are for the channels of the input feature layer) and stacked through splicing operations, and then a standard convolutional layer (convolution with a channel number of 1) 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, that is, the weight value (between 0 and 1) of each feature point in the input feature map. Finally, the weight is weighted to the input feature layer channel by channel through multiplication.
[0063] The overall framework of the feature extraction module is as follows: Figure 3As shown in the figure, the input first passes through the initial convolution block, then alternately passes through two RCSA blocks and the maximum pooling layer, and after the third RCSA block, a global average pooling layer is used to reduce the network parameters, and a random dropout layer is used at the end to prevent the model from overfitting. In this example, the number of input channels of the first RCSA block is 32, the number of output channels is 64, the convolution kernel size used is 3×1, the step size is S=1, and the padding is 1. The number of input channels of the second RCSA block is 64, the number of output channels is 128, the convolution kernel size used is 5×1, the step size is S=1, and the padding is 2. The number of input channels of the third RCSA block is 128, the number of output channels is 128, the convolution kernel size used is 7×1, the step size is S=1, and the padding is 3. The convolution kernel size used in the two maximum pooling layers is 4×1, and the step size is S=4. And 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, and the self-attention module is added to highlight important information in the sequence.
[0065] Figure 6 is the internal structure of the GRU unit with time step t, and Represents 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 to discard and which to add, and the reset gate determines how much of the network state at the previous moment is written to capture short-term memory. Represents the candidate hidden layer and updates the currently retained information. The expression is 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] Where W r ,W z ,W,U z and U represent the weight matrix of GRU, h t-1represents the information of the previous time step t-1, x t represents the input vector at the tth time step, and σ is the Sigmoid function.
[0070] The temporal information learning network designed by the present 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, and finally a reverse gated recurrent network is used to learn contextual information from two directions to enhance the expressiveness of the model.
[0071] The classification layer includes a global average pooling layer and a fully connected layer. Using global average pooling can further reduce network parameters, and using a fully connected layer to map the output to five categories of sleep stages.
[0072] Step 3: Use the following formula to construct the loss function Loss of the automatic sleep staging network:
[0073]
[0074] In the formula, y i and Represents the actual label and predicted label of each category, C represents the number of categories, and w i Represents the weight coefficient assigned to each class. Because the categories in the sleep data have serious imbalance problems, for example, the N1 stage is far less than the N2 stage in one night's sleep, this situation will lead to insufficient learning of the N1 stage data, resulting in poor recognition effect. In order to alleviate this problem, according to some prior knowledge, different learning weights are assigned to the five categories, such as giving a higher weight to the N1 stage, so that the model focuses more on learning the N1 period. In this example, the weight coefficient matrix of the five categories is [1,1.5,1,1,1].
[0075] Step 4: Use the gradient descent method to train the sleep staging network model, and use the minimization of the loss function as the optimization goal to optimize the model parameters until the loss function converges, thereby obtaining the optimal sleep staging network model and parameters. The optimization method in this example is the AdamW optimization algorithm, with an initial learning rate of 0.001 and a parameter β 1 =0.90, β 2 =0.99.
[0076] In this embodiment, an electronic device includes a memory and a processor. The memory is used to store a program that supports the processor to execute the above-mentioned 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 on the computer-readable storage medium, and the computer program executes the steps of the above-mentioned lightweight sleep staging method when executed by a processor.
[0078] Experimental setup and results analysis:
[0079] (1) Dataset: The experiment uses the Sleep-EDF-20 dataset in PhysioNet, which contains 39 full nights of sleep data from 20 subjects.
[0080] (2) Experimental parameter settings: The experiment uses multi-fold cross validation to evaluate the model performance, and the number of folds is set to 20. The optimization function uses the AdamW optimizer, and the initial learning rate is set to 0.001. The input sequence length of the model is 32, the batch size is 16, and the model is trained for 100 epochs. In this experiment, the proposed model was developed and executed in the Python environment running on the system using the PyTorch framework. The model was trained on an Nvidia GeForce RTX2080 GPU with 8GB GPU memory.
[0081] (3) Evaluation indicators: Various indicators are used in the experiment to evaluate model performance. Precision (Pr), recall (Re), and F1-Score (F1) are used to evaluate the classification performance of each category. Accuracy (Acc), Cohen's kappa coefficient (k), and Macroaverage-F1 score (MF1) are used to evaluate the overall model performance. The definitions of these overall performance indicators are as follows:
[0082]
[0083] Where C represents the number of categories, TP i represents the number of true positives in the i-th category, M is the total number of samples, and F1 i is the F1 score of the i-th category. e represents the probability of chance agreement. i is the number of actual samples of the ith 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 gain insight into the classification performance.
[0084] (4) Experimental evaluation: Classification performance Refer to 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 of each category, and the right side represents the overall evaluation parameters. The higher the evaluation parameter, the better the performance. According to the table, the classification effect of W and N2 stages is the best, while the worst performance is in N1 stage. This is mainly due to the small amount of data in N1 stage and the similarity between N1 stage and other sleep stages, which makes N1 stage more difficult to distinguish from other sleep stages.
[0085] Table 1
[0086]
[0087] Table 2
[0088]
[0089] Table 3 shows the experimental results of the method used in the present invention and other existing methods on the data set. Under similar experimental conditions, the model achieved the best results in terms of overall indicators (Acc, MF1, k) on the Sleep-EDF-20 data set, with Acc, MF1, and k being 89.1%, 84.4%, and 0.85, respectively. In addition, the model achieved the highest F1 score in the W, N2, and REM stages. Although the model did not preprocess the data, because the model adopted a weighted cross entropy loss function, more weight was given to the N1 stage, making the performance of this stage better than most methods. In summary, compared with other established automatic sleep staging models, the proposed model exhibits very competitive performance.
[0090] Table 3
[0091]
[0092] In the above embodiments, the description's reference to "this embodiment" indicates that a particular feature, structure, or characteristic described in conjunction with the embodiment is included in at least some embodiments, but not necessarily all embodiments. Multiple occurrences of "this embodiment" do not necessarily all refer to the same embodiment.
[0093] In the above-described embodiments, although the invention has been described in conjunction with specific embodiments of the invention, many substitutions, modifications, and variations of these embodiments will be apparent to those of ordinary skill in the art based on the foregoing description. For example, other storage structures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed. Embodiments of the invention are intended to encompass all such substitutions, modifications, and variations that fall within the broad scope of the appended claims.
[0094] This embodiment further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, any one of the methods in this embodiment is implemented.
[0095] This embodiment also provides an electronic terminal, including: a processor and a memory;
[0096] The memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the terminal executes any one of the methods in this embodiment.
[0097] The computer-readable storage medium in this embodiment can be understood by ordinary technicians in this field: all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to the computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
[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 with each other. The memory is used to store computer programs, the communication interface is used to communicate, and the processor and the transceiver are used to run computer programs so that the electronic terminal executes each step of the above method.
[0099] In this embodiment, the memory may include a random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0100] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0101] The present invention can be used in many general or special computing system environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like.
[0102] The present invention may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located 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 solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution, which should be included in the scope of the claims of the present invention.
Claims
1. An automatic sleep staging method for EEG signals based on residual network and multi-level attention, characterized by: The following steps are involved: S1: construct sleep dataset and perform data preprocessing; S2: Build a single-channel EEG automatic sleep staging network model based on deep learning; S3: training the model using a gradient descent method; S4: Use the sleep staging model with optimal parameters to realize sleep staging of single-channel EEG signals.
2. The method for automatic sleep staging based on EEG signals using residual networks and multi-level attention according to claim 1, characterized in that: Step S1 specifically includes the following steps: S11: obtaining a polysomnography signal with a sleep label and extracting a raw EEG signal from it; S12: trimming the original EEG signal, and removing irrelevant data of the MOVEMENT and UNKNOW stages that do not belong to the five sleep stages according to the sleep label; for each sleep data, only the wakefulness period data of 30 minutes before and after sleep is retained; S13: Select a single-channel EEG signal for slicing processing.
3. The method for automatic sleep staging based on EEG signals using residual networks and multi-level attention according to claim 1, characterized in that: The single-channel EEG automatic sleep staging network model based on deep learning 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 uses a fully connected layer to map the output to five categories of sleep stages.
4. The method for automatic sleep staging based on EEG signals using residual networks and multi-level attention according to claim 3, characterized in that: The feature extraction module includes an initial convolution layer, a feature recalibration module, and a pooling layer; the input first passes through the initial convolution block, and then alternately passes through two RCSA blocks and a maximum pooling layer. After passing through 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 model overfitting.
5. The method for automatic sleep staging based on EEG signals using residual network and multi-level attention according to claim 4, characterized in that: The initial convolution layer is composed of two one-dimensional convolution layers, each of which is followed by a BN normalization layer and a ReLU nonlinear activation function layer; The feature recalibration module RCSA uses a style-based recalibration module (SRM) to replace the excitation-squeeze network to implement the channel attention function based on the residual channel attention module, and then adds a spatial attention module; The style-based recalibration module is as follows: style information is extracted from each channel in the feature map by style pooling, including the mean and standard deviation of the channel; given an input feature map Get style features Then the recalibration weight of each channel is estimated by channel-independent style integration to obtain the weight Finally, the weights are multiplied by the initial input through the broadcast mechanism to re-weight the feature channels; The spatial attention module is a spatial attention module in a convolutional block attention module (CBAM). First, average pooling and maximum pooling are applied along the channel direction of each feature point and stacked up through a splicing operation. Then, a standard convolutional layer is used for connection and convolution. Then, a sigmoid activation function is used to obtain a two-dimensional spatial attention map, that is, the weight value of each feature point in the input feature map is obtained, and finally, the weight is weighted to the input feature layer channel by channel through multiplication.
6. The method for automatic sleep staging based on EEG signals using residual network and multi-level attention according to claim 3, characterized in that: The time step of the gated recurrent network GRU is t, and the network contains a reset gate r t and update gate z t , Represents the candidate hidden layer and updates the currently retained information. The expression is as follows: r t =σ(W r x t +U r h t-1 ) z t =σ(W z x t +U z h t-1 ) Where W r ,W z ,W,U z and U represent the weight matrix of GRU, h t-1 represents the information of the previous time step t-1, x t represents the input vector at the tth time step, and σ is the Sigmoid function.
7. The method for automatic sleep staging based on EEG signals using residual networks and multi-level attention according to claim 1, characterized in that: In step S3, the loss function of the single-channel EEG automatic sleep staging network model is: Where y i and Represents the actual label and predicted label of each category, C represents the number of categories, and w i represents the weight coefficient assigned to each class; The sleep staging network model is trained using the gradient descent method, 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.
8. The method for automatic sleep staging based on EEG signals using residual networks and multi-level attention according to claim 1, characterized in that: In step S4, the input data finally passes through the fully connected layer in the classification layer to obtain a 5-dimensional vector, and then the Softmax function is used to obtain the probabilities of the five sleep stages respectively, and finally the stage classification result is obtained. The Softmax function is as follows: where x i is the output value of the i-th node, C is the number of classification labels of the samples, and e is the exponential function.
Citation Information
Patent Citations
Nodule ultrasonic classification data processing method and data processing system
CN113780483A
Structure-guided style deviation correction type style migration method and system
CN114757819A
Electroencephalogram signal automatic sleep staging method based on multi-scale attention
CN115530847A
Single-channel electroencephalogram signal sleep staging method based on multiple scales and multiple attention
CN116763324A
Motor bearing fault diagnosis method based on improved CNN model
CN118709073A
Cited By
Sleep staging identification method and system based on multi-mode signal fusion
CN122310434A