Automatic sleep staging method and system

Through the combination of feature pyramids and supervised comparison learning, multi-scale features are extracted and time information is integrated, which solves the problem of insufficient sleep score accuracy in the prior art, and improves the distinction ability and classification accuracy of sleep stages.

CN119312143AInactive Publication Date: 2025-01-14CHANGCHUN UNIV OF SCI & TECH

Patent Information

Application Number
CN202411667658.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-01-14
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing automatic sleep scoring methods are difficult to utilize multi-level features, and do not pay enough attention to scoring accuracy, fail to make full use of a large amount of annotated PSG data, and it is difficult to accurately distinguish the sleep stages within the time and frequency range.

Method used

Using a deep learning model based on feature pyramids, through data augmentation and multi-scale feature extraction, combined with Transformer encoder and supervised contrast learning, features with multiple time and frequency scales are extracted, pyramid-like feature sequences are generated, and time is integrated through attention layer Information to predict sleep stages.

Benefits of technology

It significantly improves the ability to distinguish the sleep stage, reduces the ambiguity of the sleep stage, improves classification accuracy, performs better than traditional methods, especially in the prediction ability of the N1 and REM stages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119312143A_ABST
    Figure CN119312143A_ABST
Patent Text Reader

Abstract

The invention discloses an automatic sleep staging method and system, and relates to the technical field of sleep detection. Comprising the following steps: acquiring electroencephalogram signal data, and enhancing the data; performing multi-scale feature extraction; and the classifier network predicts the sleep stage of the target time period according to the feature vector. According to the technical scheme, the automatic sleep stage staging network combining the feature pyramid and the supervised comparative learning shows a synergistic effect, so that the overall performance and the distinguishing capability of the classifier network are improved; the feature pyramid can process different time and frequency scales, so that the sleep stage in the original single-channel EEG signal can be better distinguished. Meanwhile, by adopting a training framework based on supervised comparative learning and by minimizing intra-class feature distance and maximizing inter-class feature distance, features with higher discrimination capability are extracted, and fuzziness in the sleep stage is relieved. According to the framework, the distinguishing ability of the sleep stage is remarkably improved by fusing the multi-level features and the class distinguishing features.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of sleep detection, and in particular to an automatic sleep staging method and system. Background Art

[0002] Quality sleep is essential for physical and mental health, and sleep disorders may indicate serious health problems such as hypertension, arrhythmias, narcolepsy, and insomnia. According to statistics, 10%-30% of the population suffers from insomnia. Accurately identifying sleep stages is essential for diagnosing and treating these disorders. People with sleep disorders may be at risk for hypertension, heart failure, etc. Polysomnography (PSG) is considered the gold standard for sleep scoring and is used to evaluate typical sleep disorders (such as sleep apnea, hypersomnia, and sleepwalking). The R&K standard divides sleep stages into wakefulness (W), rapid eye movement (REM), and non-rapid eye movement (NREM), and NREM is further subdivided into S1, S2, S3, S4 or N1, N2, N3, N4. The AASM rule merges N3 and N4 into N3 and divides PSG into 5 sleep stages. The AASM rule is widely used in manual sleep scoring, which requires experts to analyze a full night of sleep, and the process is complicated and time-consuming. In contrast, machine learning algorithms can complete sleep scoring in just a few minutes with performance comparable to that of experts, making automated sleep scoring important for healthcare systems.

[0003] Automatic sleep staging methods are mainly divided into traditional machine learning and neural network methods that have become popular in recent years. Traditional machine learning extracts rich information from input signals through receptive field feature maps of different sizes. For example, EEG patterns show different frequency and time characteristics: sleep spindles in stage N2 appear in the range of 12-14Hz and last for 0.5 to 2 seconds; while slow wave activity in stage N3 is in the range of 0.5-2Hz throughout the entire stage. However, traditional methods find it difficult to utilize multi-level features that can cover a wider time scale and frequency range. In addition, although existing automatic scoring methods solve the problem of insufficient labeled PSG data, they do not pay enough attention to the accuracy of scoring and fail to make full use of a large amount of annotated PSG data. Summary of the invention

[0004] The technical solution of the present invention to solve the above technical problem is to provide an automatic sleep staging method, comprising the following steps:

[0005] Step 1: Obtain EEG signal data and label each data segment according to the AASM standard, dividing it into five sleep stages;

[0006] Step 2: Data enhancement, matching PSG element data and Hypnogram data in order, extracting the channel data selected by the user, performing six types of data enhancement processing on each EEG signal period, including adjusting the signal amplitude, time offset, amplitude offset, zero masking, additive Gaussian noise and band-stop filter processing to generate slightly different but essentially the same signal, and passing the enhanced signal through the encoding network Convert to a representation vector Mapping the representation vector to the normalized latent vector

[0007] Step 3: Multi-scale feature extraction, using a deep learning model based on feature pyramid to extract feature sequences from the original EEG signal with multiple time scales and channel dimensions, including convolution blocks formed by repeated one-dimensional convolution layers, one-dimensional batch normalization layers, and parameterized linear rectification functions (PReLU), performing maximum pooling operations between convolution blocks to reduce the time dimension of the feature sequence, and attaching lateral connections at the end of the 3rd, 4th, and 5th convolution blocks to generate pyramid-shaped feature sequences with the same channel dimension;

[0008] Step 4: Classifier network, using Transformer encoder to sequentially model the feature sequence extracted from the feature pyramid, converting the channel dimension of the feature pyramid into the model dimension through a shared fully connected layer, adding the position encoding to the input feature sequence to incorporate temporal information, and using the attention layer to integrate the hidden state of the Transformer encoder output into a unified feature vector, and predicting the sleep stage of the target time period based on the feature vector.

[0009] Further, in step 2, the application probability of the six transformations is 0.5, and the encoding network includes a core backbone network and a global average pooling operation, and the backbone network will enhance the single EEG period Convert to feature sequence F 5 (1) , the representation vector is obtained from the feature sequence through the global average pooling operation, and the representation vector is calculated as:

[0010] r=Avg(F 5 (1) );

[0011] The representation vector is mapped to a normalized latent vector via a projection network where z' = p(r; θ p ), p(·) represents the projection network, θ p is a trainable parameter, d z Represents the dimension of the latent vector.

[0012] Furthermore, in step 3,

[0013] The convolution operation is:

[0014]

[0015] The maximum pooling operation is:

[0016]

[0017] in is the feature sequence after maximum pooling processing;

[0018] A squeeze and excitation module is included before the last activation function of each convolution block; the data input is L continuous EEG signals, and the subsequent feature sequence set is obtained:

[0019]

[0020] Where: represents the output of the i-th convolutional block of the backbone core network, f(·) represents the backbone network, θ f Represents its trainable parameters;

[0021] The channel dimensions of the feature pyramid are set to be the same so that all feature sequences are classified using the same classifier.

[0022] Furthermore, in step 4,

[0023] A shared fully connected layer with PReLU is used to transform the channel dimension d of the feature pyramid f Convert to model dimension d m ; The transformed feature pyramid is represented as The EEG from each convolution stage is mapped into the same feature space;

[0024] Add positional encoding to the input feature sequence to incorporate temporal information:

[0025]

[0026] The position information encoding uses a sine function. Since the two ends of the pyramid feature sequence use the same time index, the time index of the position information encoding is jumped to match the absolute time position between them. At the time index t and the dimension index k, P i (L) The elements of can be defined as:

[0027]

[0028] Where R = r i / ri-1 represents the time reduction factor (set to 5 in our model); when i=3, It will degenerate into the original sinusoidal position information encoding; the output hidden state of the i-th pyramid feature sequence is expressed as:

[0029]

[0030] Output hidden state Projected to the attention hidden state This is done via a single fully connected layer;

[0031] The attention feature vector of the i-th pyramid feature sequence a i,t represents the hidden state at time index t and sequence i; α i,t is the attention weight of each time step; by the attention weight α of each time step i,t and a i,t The attention feature vector is obtained by weighted summation The formula is as follows:

[0032]

[0033] Among them, α i,t is the attention weight at time step t, a i,t is the attention hidden state of the i-th pyramid feature sequence at time step t;

[0034] The attention weight at time step t is obtained by applying a softmax function to the attention score;

[0035] represents a trainable weight matrix used to map attention hidden states to attention scores, as follows:

[0036]

[0037] The attention feature vector obtained from the above formula The output of the i-th pyramid feature sequence is expressed as:

[0038]

[0039] and Represent trainable weights and bias terms respectively;

[0040] Sleep stages during target time period Prediction is based on the following formula:

[0041]

[0042] argmax(·) is an operation that returns the index of the maximum value.

[0043] Furthermore, in step 2, the supervised contrast loss function is:

[0044]

[0045] in, represents the number of positive samples of the nth sample in the multi-view batch, 1[·] represents the indicator function, which means that the value is 1 when the condition is met and 0 otherwise; Indicates that z m The corresponding true label, z m and z n represent the feature vectors of sample n and sample m respectively; τ represents a scalar temperature parameter used to control the smoothness of the similarity.

[0046] Furthermore, the sleep stage classification method based on deep learning also includes step 5: model training and verification, using the training data set to train the deep learning model, and using the verification data set to verify the trained model to evaluate the performance and accuracy of the model.

[0047] Furthermore, in step 5, a cross-validation method is used to improve the generalization ability and stability of the model.

[0048] To solve the above technical problems, the present invention also proposes a system for implementing the sleep stage classification method based on deep learning as described above, comprising a data acquisition module, a data preprocessing module, a feature extraction module, a classifier module and a model training and verification module.

[0049] Furthermore, the data acquisition module is used to collect electroencephalogram (EEG) signals during a whole night of sleep, the data preprocessing module is used to divide the signal data into 30-second time segments and perform label matching and data enhancement processing, the feature extraction module is used to extract multi-scale feature sequences from the processed signal data, the classifier module is used to classify the extracted feature sequences to predict sleep stages, and the model training and verification module is used to train and verify the deep learning model.

[0050] The technical solution of the present invention realizes multi-scale feature representation by introducing a feature pyramid. The feature pyramid can process different time and frequency scales, so as to better distinguish the sleep stages in the original single-channel EEG signal. At the same time, a training framework based on supervised contrastive learning is adopted to extract more discriminative features by minimizing the intra-class feature distance and maximizing the inter-class feature distance, thereby reducing the ambiguity of the sleep stage. The framework significantly improves the ability to distinguish the sleep stages by fusing multi-level features and class discriminative features. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying creative work.

[0052] Figure 1 A flowchart of the automatic sleep staging method of the present invention;

[0053] Figure 2 A network structure diagram of sleep staging in the automatic sleep staging method of the present invention;

[0054] Figure 3 A multi-scale feature extraction network structure diagram of the automatic sleep staging method of the present invention;

[0055] Figure 4 This is the convolutional enhanced network structure of the automatic sleep staging method described in the present invention. DETAILED DESCRIPTION

[0056] The present invention provides an automatic sleep staging method and system, aiming to design an automatic sleep staging method with improved classification accuracy.

[0057] The automatic sleep staging method proposed by the present invention will be described in the following specific embodiments:

[0058] In the technical solution of this embodiment, Figure 1 , Figure 2 As shown, an automatic sleep staging method comprises the following steps:

[0059] Step 1: Obtain EEG signal data and label each data segment according to the AASM standard, dividing it into five sleep stages;

[0060] Specifically, the PSG physiological signals of sleep monitoring are collected, mainly using the electroencephalogram (EEG) signals recorded during a whole night of sleep as input. The signal is recorded at a sampling rate of 100Hz, and the whole night of sleep data is divided into data segments with one frame every 30 seconds. According to the AASM standard, each data segment is labeled and divided into five sleep stages: wakefulness (W), rapid eye movement (REM), and non-REM (N1, N2, N3).

[0061] Step 2: Data enhancement, matching PSG element data and Hypnogram data in order, extracting the channel data selected by the user, performing six types of data enhancement processing on each EEG signal period, including adjusting the signal amplitude, time offset, amplitude offset, zero masking, additive Gaussian noise and band-stop filter processing to generate slightly different but essentially the same signal, and passing the enhanced signal through the encoding network Convert to a representation vector Mapping the representation vector to the normalized latent vector

[0062] Specifically, if Figure 4 As shown in the figure, when processing PSG (polysomnography) data, the PSG element data and Hypnogram (annotation) data are first matched in sequence. Check whether the channel selected by the user (such as "Fpz-Cz") exists, and extract the channel data. The reading process of the PSG signal includes calculating the sampling rate and the number of samples per epoch (period), and dividing the signal data into 30-second time segments. The annotation file provides the start time, duration, and corresponding sleep stage of each stage. This information will be converted into a sequence of labels that match the signal data, and each time segment corresponds to a sleep stage label.

[0063] To ensure the high quality and representativeness of the data, after a series of data cleaning and preprocessing, the signal data and its labels are saved as npz files, including metadata such as sampling rate, channel label, start time, and file length. Next, we will introduce a data augmentation module to convert the EEG signal period x into slightly different but essentially the same signal to further improve the generalization ability of the model.

[0064] A single EEG period x looks like this:

[0065]

[0066] Given a set of randomly sampled data Two different Aug(·) results are is called a multi-view batch, such as Figure 1 As shown (supervised contrastive learning training process), where N b is the batch size, and Since data augmentation is crucial for contrastive learning, six transformations are applied in sequence, adjusting the amplitude of the signal (the signal amplitude can be scaled to between 50% and 200% of the original), time shift (the signal can be moved forward or backward on the time axis by up to 300 samples), amplitude shift (-10-10uv), zero masking (randomly setting part of the signal to zero), additive Gaussian noise (0-0.2σ) and band-stop filter (2Hz bandwidth), with an application probability of 0.5.

[0067] The enhanced single EEG signal period passes through the encoding network Convert to a representation vector The encoding network consists of a sequence of the core backbone network f(·) and the global average pooling operation Aug(·). Therefore, the backbone network initially transforms the enhanced single EEG period into Convert to feature sequence F 5 (1) Then, the representation vector is obtained from the feature sequence through the global average pooling operation. The representation vector is calculated as r = Avg(F 5 (1) ).

[0068] Mapping the representation vector to the normalized latent vector where z' = p(r; θ p ), p(·) represents the projection network, θ p is a trainable parameter, d z represents the dimension of the latent vector. A multilayer perceptron with 128 hidden units is used to obtain a dimension of d z =128 latent vector.

[0069] Step 3: Multi-scale feature extraction, using a deep learning model based on feature pyramid to extract feature sequences from the original EEG signal with multiple time scales and channel dimensions, including convolution blocks formed by repeated one-dimensional convolution layers, one-dimensional batch normalization layers, and parameterized linear rectification functions (PReLU), performing maximum pooling operations between convolution blocks to reduce the time dimension of the feature sequence, and attaching lateral connections at the end of the 3rd, 4th, and 5th convolution blocks to generate pyramid-shaped feature sequences with the same channel dimension;

[0070] Specifically, if Figure 3 As shown, in order to extract feature sequences from raw EEG signals with multiple time scales and channel dimensions, this application proposes a deep learning model based on feature pyramid. Each convolution block is formed by repeating a single convolution layer. In the convolutional neural network, the convolution operation is:

[0071]

[0072] The specific order is: a convolutional enhanced network formed by repeating the unit convolutional layer in the sequence of one-dimensional convolutional layer, one-dimensional batch normalization layer, and parameterized linear rectifier function (PReLU), such as Figure 3 As shown in Figure 2. The filter width of all convolutional layers is 3, the stride is 1, and the padding size is 1 to keep the time dimension within the same convolutional block. A maximum pooling operation is performed between convolutional blocks to reduce the time dimension of the feature sequence. The maximum pooling operation is:

[0073]

[0074] in, It is a feature sequence after maximum pooling. In this way, the length of the feature sequence can be effectively reduced while retaining important feature information. In addition, a squeeze and excitation module is included before the last activation function (PReLU) of each convolution block. The data input is L continuous EEG signals, and the subsequent feature sequence set is obtained:

[0075]

[0076] Where: represents the output of the i-th convolutional block of the backbone core network, f(·) represents the backbone network, θ f represents its trainable parameters. The size of the feature sequence can be expressed as where i∈{3,4,5} represents the stage index of the convolutional block, c i ∈{192, 256, 256} represents the channel dimension of the i-th feature sequence, r i ∈{5 2 ,5 3 ,5 4} represents the time reduction ratio, and [·] represents rounding up. It should be noted that the time reduction ratio r i The input X (L) The length and feature sequence The feature sequences from the first and second convolutional blocks are excluded from the feature pyramid due to their large memory allocation.

[0077] In order to convert feature sequences with different channel dimensions into the same channel dimension by a single convolutional layer, thereby generating a feature pyramid, lateral connections are attached at the end of the 3rd, 4th, and 5th convolutional blocks to form a pyramid-like feature sequence with the same channel dimension. The channel dimension of the feature pyramid is set to the same, so all feature sequences will use the same classifier. Since the feature vectors in the feature pyramid represent different frequency distributions but have the same input signal (EEG), it is appropriate to apply a shared classifier in the method. Formally, the feature pyramid You can use:

[0078]

[0079] Among them, g i (·) indicates The lateral connection of the feature sequence and the parameters θ involved in the training g,i , each lateral connection consists of a convolutional layer with a filter width of 1 and produces a pyramid feature sequence It describes the same time scale Therefore, the size of the pyramid feature sequence is formulated as: d f where is the channel size of the feature pyramid.

[0080] Step 4: Classifier network, using Transformer encoder to sequentially model the feature sequence extracted from the feature pyramid, converting the channel dimension of the feature pyramid into the model dimension through a shared fully connected layer, adding the position encoding to the input feature sequence to incorporate temporal information, and using the attention layer to integrate the hidden state of the Transformer encoder output into a unified feature vector, and predicting the sleep stage of the target time period based on the feature vector.

[0081] Further, in step 2, the application probability of the six transformations is 0.5, and the encoding network includes a core backbone network and a global average pooling operation, and the backbone network will enhance the single EEG period Convert to feature sequence F 5 (1) , the representation vector is obtained from the feature sequence through the global average pooling operation, and the representation vector is calculated as:

[0082] r=Avg(F 5 (1) );

[0083] The representation vector is mapped to a normalized latent vector via a projection network where z' = p(r; θ p ), p(·) represents the projection network, θ p is a trainable parameter, d z Represents the dimension of the latent vector.

[0084] Furthermore, in step 3,

[0085] The convolution operation is:

[0086]

[0087] The maximum pooling operation is:

[0088]

[0089] in is the feature sequence after maximum pooling processing;

[0090] A squeeze and excitation module is included before the last activation function of each convolution block; the data input is L continuous EEG signals, and the subsequent feature sequence set is obtained:

[0091]

[0092] Where: represents the output of the i-th convolutional block of the backbone core network, f(·) represents the backbone network, θ f Represents its trainable parameters;

[0093] The channel dimensions of the feature pyramid are set to be the same so that all feature sequences are classified using the same classifier.

[0094] Furthermore, in step 4,

[0095] A shared fully connected layer with PReLU is used to transform the channel dimension d of the feature pyramid f Convert to model dimension d m ; The transformed feature pyramid is represented as The EEG from each convolution stage is mapped into the same feature space;

[0096] Add positional encoding to the input feature sequence to incorporate temporal information:

[0097]

[0098] The position information encoding uses a sine function. Since the two ends of the pyramid feature sequence use the same time index, the time index of the position information encoding is jumped to match the absolute time position between them. At the time index t and the dimension index k, P i (L) The elements of can be defined as:

[0099]

[0100] Where R = r i / r i-1 represents the time reduction factor (set to 5 in our model); when i=3, It will degenerate into the original sinusoidal position information encoding; the output hidden state of the i-th pyramid feature sequence is expressed as:

[0101]

[0102] Output hidden state Projected to the attention hidden state This is done via a single fully connected layer;

[0103] The attention feature vector of the i-th pyramid feature sequence a i,t represents the hidden state at time index t and sequence i; α i,t is the attention weight of each time step; by the attention weight α of each time step i,t and a i,t The attention feature vector is obtained by weighted summation The formula is as follows:

[0104]

[0105] Among them, α i,t is the attention weight at time step t, a i,t is the attention hidden state of the i-th pyramid feature sequence at time step t;

[0106] The attention weight at time step t is obtained by applying a softmax function to the attention score;

[0107] represents a trainable weight matrix used to map attention hidden states to attention scores, as follows:

[0108]

[0109] The attention feature vector obtained from the above formula The output of the i-th pyramid feature sequence is expressed as:

[0110]

[0111] and Represent trainable weights and bias terms respectively;

[0112] Sleep stages during target time period Prediction is based on the following formula:

[0113]

[0114] argmax(·) is an operation that returns the index of the maximum value.

[0115] Furthermore, in step 2, the supervised contrast loss function is:

[0116]

[0117] in, represents the number of positive samples of the nth sample in the multi-view batch, 1[·] represents the indicator function, which means that the value is 1 when the condition is met and 0 otherwise; Indicates that z m The corresponding true label, z m and z n represent the feature vectors of sample n and sample m respectively; τ represents a scalar temperature parameter used to control the smoothness of the similarity.

[0118] Furthermore, the sleep stage classification method based on deep learning also includes step 5: model training and verification, using the training data set to train the deep learning model, and using the verification data set to verify the trained model to evaluate the performance and accuracy of the model.

[0119] Specifically, model training includes: Contrastive Representation Learning (CRL), which pre-trains the backbone neural network through supervised contrastive learning. In this stage, the backbone network f(·) is trained based on supervised contrast loss to extract features with category discrimination; Multi-Scale Temporal Context Learning (MTCL), which is used to learn sequence relationships in feature pyramids. To this end, the weights learned through CRL are obtained and frozen to maintain category-discriminating features. Other parts of the network (such as g(·) and h(·)) are used to learn multi-scale temporal context by predicting the sleep stage of the target period.

[0120] To prevent overfitting during training, an early stopping mechanism is used in the training step of both CRL and MTCL. The validation process tracks the validation cost (i.e. validation loss) after a certain number of training iterations (i.e. validation period ψ). If the validation loss does not improve within a specified number of times, the training is terminated (i.e. early stopping tolerance φ). This early stopping mechanism ensures better pre-trained parameters in CRL and prevents overfitting in the MTCL step.

[0121] In CRL, a supervised contrastive learning training strategy is adopted to extract class-discriminative features from a single EEG stage. CRL aims to maximize the similarity between two sets of projection vectors based on two different views of a single EEG stage. At the same time, the supervised contrastive loss is optimized to minimize the similarity between two sets of projection vectors from different sleep stages. Therefore, our focus is to reduce ambiguous frequency features by extracting distinguishable sleep stage representations.

[0122] To achieve this goal, individual EEG phases are first transformed by two different data augmentation functions. Subsequently, the encoder network and the projection network map them into a hypersphere to generate a latent vector z. The details have been explained in the previous and subsequent sections: the data augmentation module (including the encoder network, the projection network) and the loss function constitute the components of CRL.

[0123] Contrastive Representation Learning (CRL) and Feature Pyramid Network, one is the preprocessing stage, the other is the training stage. CRL enables the network to learn more discriminative feature representations through contrastive learning, which will force the network to learn representations that bring similar samples (such as EEG data of the same sleep stage) closer together and different samples farther apart. CRL learns discriminative feature representations, brings similar samples closer together and separates different samples, enhances the multi-scale feature representation of the Feature Pyramid Network, makes it more robust and efficient, and improves the overall learning effect of the network through the synergy of contrast loss and classification loss.

[0124] Furthermore, in step 5, a cross-validation method is used to improve the generalization ability and stability of the model.

[0125] To solve the above technical problems, the present invention also proposes a system for implementing the sleep stage classification method based on deep learning as described above, comprising a data acquisition module, a data preprocessing module, a feature extraction module, a classifier module and a model training and verification module.

[0126] Furthermore, the data acquisition module is used to collect electroencephalogram (EEG) signals during a whole night of sleep, the data preprocessing module is used to divide the signal data into 30-second time segments and perform label matching and data enhancement processing, the feature extraction module is used to extract multi-scale feature sequences from the processed signal data, the classifier module is used to classify the extracted feature sequences to predict sleep stages, and the model training and verification module is used to train and verify the deep learning model.

[0127] Verification test:

[0128] Based on the public dataset SleepEDF, the FCZ-PZ EEG channel was selected and 10-fold cross validation was performed to test the overall performance of the sleep staging method of the present invention and compare it with other deep neural network methods. The specific performance index parameters are shown in Tables 1 and 2.

[0129] Table 1. Comparison of staging performance between the present invention and other methods;

[0130]

[0131] Table 2. Classification model performance indicators;

[0132]

[0133] Table 1 shows the performance comparison between the method of the present invention and several other methods. ACC represents the staging accuracy in the overall performance, MF1 represents the macro-average F1 value in the overall performance, and the Kappa coefficient is an indicator of consistency test, which is used to measure the classification accuracy. The method of the present invention achieved an accuracy of 84.1%, an MF1 of 78.9%, and a Kappa coefficient of 0.78, which is better than other automatic sleep staging methods. This shows that the method of the present invention has better performance in data feature expression and capturing sleep stage conversion rules, and shows its effectiveness in automatic sleep staging in terms of the balance between precision and recall.

[0134] This patent invents an automatic sleep stage classification network that combines feature pyramid and supervised contrastive learning. A deep learning model based on feature pyramid is designed, which can capture the multi-level features of EEG signals at different time and frequency scales, so as to accurately reflect the sleep stages. The training framework uses supervised contrastive learning to significantly reduce the ambiguity between sleep stages by extracting discriminative features. The combination of feature pyramid and supervised contrastive learning shows a synergistic effect. When classifying the original EEG signal, various time and frequency scales are considered, thereby improving the overall performance and discrimination ability of the classifier network. Analysis of the model shows that it performs well in the processing of feature hierarchical and sleep stage frequency features. Supervised contrastive learning further improves the overall performance, mainly by significantly reducing the ambiguity between sleep stages, thereby enhancing the prediction ability of N1 and REM stages and improving classification accuracy. Therefore, the automatic sleep staging method proposed in the present invention is very effective.

[0135] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. An automatic sleep staging method, characterized in that: The following steps are involved: Step 1: Obtain EEG signal data, annotate each data segment according to the AASM standard, and divide it into five sleep stages; Step 2: Data enhancement, matching PSG element data and Hypnogram data in order, extracting the channel data selected by the user, performing six types of data enhancement processing on each EEG signal period, including adjusting the signal amplitude, time offset, amplitude offset, zero masking, additive Gaussian noise and band-stop filter processing to generate slightly different but essentially the same signal, and passing the enhanced signal through the encoding network Convert to a representation vector Mapping the representation vector to the normalized latent vector Step 3: Multi-scale feature extraction, using a deep learning model based on a feature pyramid to extract feature sequences from the original EEG signal with multiple time scales and channel dimensions, including convolution blocks formed by repeating one-dimensional convolution layers, one-dimensional batch normalization layers, and parameterized linear rectification functions, performing maximum pooling operations between convolution blocks to reduce the time dimension of the feature sequence, and attaching lateral connections at the end of the 3rd, 4th, and 5th convolution blocks to generate a pyramid-shaped feature sequence with the same channel dimension; Step 4: Classifier network, using Transformer encoder to sequentially model the feature sequence extracted from the feature pyramid, converting the channel dimension of the feature pyramid into the model dimension through a shared fully connected layer, adding position encoding to the input feature sequence to incorporate temporal information, and using the attention layer to integrate the hidden state of the Transformer encoder output into a unified feature vector, and predicting the sleep stage of the target time period based on the feature vector.

2. The sleep stage classification method based on deep learning according to claim 1, characterized in that: In step 2, the application probability of the six transformations is 0.5, and the encoding network includes a core backbone network and a global average pooling operation. The backbone network will enhance the single EEG period Convert to feature sequence F5 (1) , the representation vector is obtained from the feature sequence through the global average pooling operation, and the representation vector is calculated as: r=Avg(F5 (1) ); Avg (average): used to represent the arithmetic mean of a set of data Fs (sampling frequency): represents the number of samples collected per second. The representation vector is mapped to a normalized latent vector through a projection network. where z' = p)r; θ p ), p(·) represents the projection network, θ p is a trainable parameter, d z Represents the dimension of the latent vector.

3. The sleep stage classification method based on deep learning according to claim 1, characterized in that: In step 3, The convolution operation is: in, Represents the feature map of the lth layer, which is the convolution layer input in the neural network; Conv represents the convolution operation; X (L) Represents the feature map or data input to the lth layer; W i represents the weight of the i-th convolution kernel; b i Represents the bias of the i-th convolution kernel; The maximum pooling operation is: in, It is the feature sequence after the maximum pooling process, and MaxPool represents the maximum pooling operation; A squeeze and excitation module is included before the last activation function of each convolution block; the data input is L continuous EEG signals, and the subsequent feature sequence set is obtained: Where: represents the output of the i-th convolutional block of the backbone core network, f(·) represents the backbone network, θ f Represents its trainable parameters; The channel dimensions of the feature pyramid are set to be the same so that all feature sequences are classified using the same classifier.

4. The sleep stage classification method based on deep learning according to claim 1, characterized in that: In step 4, A shared fully connected layer with PReLU is used to transform the channel dimension d of the feature pyramid f Convert to model dimension d m ; The transformed feature pyramid is represented as The EEG from each convolution stage is mapped into the same feature space; Add positional encoding to the input feature sequence to incorporate temporal information: The position information encoding uses a sine function to match the absolute time position between the time index t and the dimension index k by jumping the time index of the position information encoding. i (L) The elements of can be defined as: Where R = r i / r i-1 represents the time reduction factor; when i=3, It will degenerate into the original sinusoidal position information encoding; the output hidden state of the i-th pyramid feature sequence is expressed as: Output hidden state Projected to the attention hidden state This is done via a single fully connected layer; The attention feature vector of the i-th pyramid feature sequence a i,t represents the hidden state at time index t and sequence i; α i,t is the attention weight of each time step; by the attention weight α of each time step i,t and a i,t The attention feature vector is obtained by weighted summation The formula is as follows: Among them, α i,t is the attention weight at time step t, a i,t is the attention hidden state of the i-th pyramid feature sequence at time step t; The attention weight at time step t is obtained by applying the softmax function to the attention score; represents a trainable weight matrix used to map attention hidden states to attention scores, as follows: The output of the i-th pyramid feature sequence is expressed as: and Represent trainable weights and bias terms respectively; Sleep stages during target time period Prediction is based on the following formula: argmax(·) is an operation that returns the index of the maximum value.

5. The sleep stage classification method based on deep learning according to claim 1, characterized in that: Step 2 includes: The supervised contrast loss function is: in, represents the number of positive samples of the nth sample in the multi-view batch, 1[·] represents the indicator function, which means that the value is 1 when the condition is met and 0 otherwise; Indicates that z m The corresponding true label, z m and z n represent the feature vectors of sample n and sample m respectively; τ represents a scalar temperature parameter used to control the smoothness of the similarity.

6. The sleep stage classification method based on deep learning according to claim 1, characterized in that: The method also includes step 5: model training and verification, which uses the training data set to train the deep learning model and uses the verification data set to verify the trained model to evaluate the performance and accuracy of the model.

7. The sleep stage classification method based on deep learning according to claim 6, characterized in that: In the model training and verification steps, a cross-validation method is used to improve the generalization ability and stability of the model.

8. A system for implementing the deep learning-based sleep stage classification method according to any one of claims 1 to 7, characterized in that: It includes data acquisition module, data preprocessing module, feature extraction module, classifier module and model training and verification module.

9. The system according to claim 8, characterized in that The data acquisition module is used to collect EEG signals during a whole night of sleep, the data preprocessing module is used to divide the signal data into 30-second time segments and perform label matching and data enhancement processing, the feature extraction module is used to extract multi-scale feature sequences from the processed signal data, the classifier module is used to classify the extracted feature sequences to predict the sleep stage, and the model training and verification module is used to train and verify the deep learning model.

Citation Information

Patent Citations

  • Sleep staging method, system and device based on ballistocardiogram signal and medium

    CN114376564A

  • Sleep staging method and system based on self-supervised learning and Mama network

    CN118490179A

Cited By

  • Sleep stage classification method based on multi-scale feature contrast learning

    CN120154301A

  • A sleep stage classification method based on multi-scale feature contrast learning

    CN120154301B

  • Sleep management optimization system and method based on image recognition and environment perception

    CN120388672A

  • Sleep quality monitoring method fusing multi-scale features

    CN120827347A

  • Balanced contrast learning and multi-scale characterization-based electroencephalogram processing device and method

    CN121845614A