A sleep staging detection method and apparatus, an electronic device, and a storage medium
By combining convolutional networks and echo-state networks, the problem of neglecting the correlation between sleep stages in traditional sleep staging methods is solved, achieving more accurate and coherent sleep stage detection, especially in terms of accuracy and model generalization ability during stage transitions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING YUAN NEW TECH CO LTD
- Filing Date
- 2026-05-06
- Publication Date
- 2026-06-02
AI Technical Summary
Existing sleep staging methods neglect the correlation between sleep stages, which can easily lead to misjudgment during the transition period. The classification accuracy is difficult to meet clinical needs, and traditional algorithms are complex and have limited generalization ability.
A method combining convolutional networks and echo-state networks is adopted. The convolutional network extracts local temporal features and temporal dependencies of polysomnography data, and the echo-state network's reservoir is used to make joint decisions based on the data features of the preceding and following time segments and the staging results, thereby achieving more accurate sleep staging detection.
It improves the accuracy and consistency of sleep stage segmentation, especially the accuracy of stage transition, reduces computational complexity, and enhances the model's generalization ability.
Smart Images

Figure CN122132931A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and more specifically, to a method, apparatus, electronic device, and storage medium for sleep stage detection. Background Technology
[0002] Sleep occupies about one-third of a human life, and its quality is crucial to physical and mental health. Accurate staged sleep is fundamental for diagnosing sleep disorders and assessing brain function. According to the AASM criteria, sleep is divided into wakefulness (W), non-rapid eye movement (N1, N2, N3) sleep, and rapid eye movement (REM) sleep; accurate identification is essential for analyzing sleep structure.
[0003] Current automatic staging methods based on polysomnography employ segmented processing, but the model design often inputs each sleep segment independently for feature extraction and classification, neglecting the continuity of sleep. This leads to misjudgment during stage transitions (such as the transition from N1 to W, or from N2 to N3), making it difficult to meet clinical needs in terms of classification accuracy, especially in identifying transitional and light sleep stages.
[0004] Furthermore, traditional algorithms are complex to design, rely on manual feature extraction, and have limited generalization ability. Some studies have attempted to introduce recurrent neural networks to capture temporal information, but these networks are complex, computationally burdensome, and difficult to tune parameters. Moreover, long-term reliance on them leads to information decay, making it difficult for historical decision information to effectively influence current judgments. Summary of the Invention
[0005] In view of this, the purpose of this application is to provide a sleep staging detection method, device, electronic device, and storage medium to overcome at least one of the above-mentioned defects.
[0006] In a first aspect, embodiments of this application provide a sleep staging detection method, the method comprising: acquiring polysomnography data of a target object within a preset sleep time period, the preset sleep time period being divided into N time segments, the polysomnography data including polysomnography data under the N time segments sorted by time; inputting the polysomnography data under the i-th time segment into a convolutional network, outputting data features corresponding to the i-th time segment, wherein 1≤i≤N; inputting the data features corresponding to the i-th time segment, the data features corresponding to the (i-1)-th time segment, and the staging result of the (i-1)-th time segment into an echo state network, outputting a probability estimate of the sleep staging of the i-th time segment, wherein the echo state network includes a reserve pool, the reserve pool being composed of multiple neurons, different inputs being able to stimulate different neurons in the reserve pool to change the individual state attributes of the neurons, and the connection weights in the reserve pool being fixed under different inputs.
[0007] In one optional embodiment of this application, the probability estimate of sleep stage for the i-th time segment is obtained as follows: the data features of the i-th time segment, the data features of the (i-1)-th time segment, and the stage result of the (i-1)-th time segment are merged to form the input vector of the echo state network at the current moment; the input vector is mapped to the reserve pool through the input weight matrix, thereby stimulating neurons in the reserve pool to update the state vector at the current moment, wherein the state of the reserve pool is jointly determined by the input vector at the current moment and the state of the reserve pool at the previous moment; the state vector of the reserve pool at the current moment is input to the output layer, and linearly combined through the output weight matrix to generate the probability estimate of sleep stage for the i-th time segment.
[0008] In one optional embodiment of this application, the state vector of the reservoir is updated by combining the input vector at the current moment with the reservoir state vector at the previous moment; and by performing a nonlinear transformation on the combined information using fixed internal connection weights in the reservoir to generate the reservoir state vector at the current moment.
[0009] In one optional embodiment of this application, the convolutional network includes a one-dimensional convolutional layer and a long short-term memory network layer; wherein, the data features corresponding to the i-th time segment are obtained by: inputting the multi-channel sleep map data of the i-th time segment into the one-dimensional convolutional layer, and outputting the convolutional features after convolution operation; inputting the convolutional features into the long short-term memory network layer, and outputting the data features of the time segment after time-series processing.
[0010] In one optional embodiment of this application, the one-dimensional convolutional layer is used to extract local temporal features of polysomnography data, and the long short-term memory network layer is used to extract temporal dependencies in the local temporal features to generate data features that simultaneously contain temporal and frequency domain features.
[0011] In one optional embodiment of this application, when i=1, the data feature of the (i-1)th time segment is set to a zero vector, and the staging result of the (i-1)th time segment is set to a default value to initialize the recursive calculation of the echo state network.
[0012] In one optional embodiment of this application, the probability estimation of sleep stages includes probability values corresponding to the waking period, non-rapid eye movement (NREM) sleep stage 1, NREM sleep stage 2, NREM sleep stage 3, and rapid eye movement (REM) sleep stage, wherein the stage category with the highest probability value is used as the sleep stage result for the i-th time segment.
[0013] Secondly, embodiments of this application also provide a sleep staging detection device, the device comprising: a polysomnography data acquisition module, used to acquire polysomnography data of a target object within a preset sleep time period, the preset sleep time period being divided into N time segments, the polysomnography data including polysomnography data under the N time segments sorted by time; a data feature output module, used to input the polysomnography data under the i-th time segment into a convolutional network and output the data features corresponding to the i-th time segment, where 1≤i≤N; and a probability estimation output module, used to input the data features corresponding to the i-th time segment, the data features corresponding to the (i-1)-th time segment, and the staging result of the (i-1)-th time segment into an echo state network and output a probability estimate of the sleep staging of the i-th time segment, wherein the echo state network includes a reserve pool, the reserve pool being composed of multiple neurons, different inputs can stimulate different neurons in the reserve pool to change the individual state attributes of the neurons, and the connection weights in the reserve pool are fixed under different inputs.
[0014] Thirdly, embodiments of this application also provide an electronic device, including: a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory via the bus, and when the machine-readable instructions are executed by the processor, the steps of the method described above are performed.
[0015] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, performs the steps of the method described above.
[0016] The sleep staging detection method, apparatus, electronic device, and storage medium provided in this application include: acquiring polysomnography data of a target object within a preset sleep time period, wherein the preset sleep time period is divided into N time segments; inputting the polysomnography data of the i-th time segment into a convolutional network and outputting the data features corresponding to the i-th time segment; inputting the data features corresponding to the i-th time segment, the data features corresponding to the (i-1)-th time segment, and the staging result of the (i-1)-th time segment into an echo state network and outputting a probability estimate of the sleep staging of the i-th time segment, wherein the echo state network includes a reserve pool, which is composed of multiple neurons. Different inputs can stimulate different neurons in the reserve pool to change the individual state attributes of the neurons, and the connection weights in the reserve pool are fixed under different inputs. Through this application, the accuracy of sleep staging is improved by contextual association.
[0017] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a flowchart of the sleep staging detection method provided in the embodiments of this application; Figure 2 This is a schematic diagram of the internal structure of the convolutional network provided in the embodiments of this application; Figure 3 This is a schematic diagram illustrating the principle of the sleep staging detection method provided in the embodiments of this application; Figure 4 This is a schematic diagram illustrating different neurons in the activation reservoir provided by different inputs in the embodiments of this application; Figure 5 A schematic diagram of the phased model provided in the embodiments of this application; Figure 6 A flowchart for probabilistic estimation of sleep stages for the i-th time segment provided in an embodiment of this application; Figure 7 A flowchart for updating the state vector of the storage pool is provided in this embodiment of the application; Figure 8 This is a schematic diagram of the sleep staging detection device provided in the embodiments of this application; Figure 9 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. Based on the embodiments of this application, every other embodiment obtained by those skilled in the art without inventive effort falls within the scope of protection of this application.
[0021] First, the applicable scenarios for this application will be introduced. This application can be applied to the field of data processing technology.
[0022] Research has revealed the following shortcomings in existing sleep staging methods: Firstly, single-channel EEG-based classification methods rely on a single signal source and treat each sleep segment as an independent event, failing to consider the sequential relationships between sleep stages. This leads to misclassifications during stage transitions (such as the transition between N1 and W, or N2 and N3), resulting in classification accuracy that falls short of clinical requirements. Secondly, while multimodal methods attempt to integrate multiple physiological signals, they often require manually designing complex feature extraction rules. Furthermore, different modal data must be processed separately before integration, making the process cumbersome and limiting the flexibility of adding or removing leads, thus restricting the model's generalization and adaptability. These deficiencies make it difficult for existing algorithms to accurately reflect the continuous physiological processes of sleep.
[0023] The sleep stages include the following: W stands for Wakefulness.
[0024] NREM 1, short for Non-Rapid Eye Movement Sleep Stage 1, is abbreviated as "N1".
[0025] NREM 2, or Non-Rapid Eye Movement Sleep Stage 2, is abbreviated as "N2".
[0026] NREM 3, or Non-Rapid Eye Movement Sleep Stage 3, is abbreviated as "N3".
[0027] REM, or Rapid Eye Movement Sleep, is a sleep period that begins with rapid eye movement.
[0028] Echo State Network (ESN) is a high-efficiency recurrent neural network that captures dynamic patterns through a reservoir of fixed random connections. Only the output layer weights need to be trained, making it adept at tasks such as time series prediction and pattern recognition.
[0029] Sleep is a continuous process, and simple staged sleep cannot sever the connections between stages. Therefore, fully considering the correlations between sleep stages helps to achieve better sleep staging models. The reservoir of echo state networks can effectively analyze the correlations between sleep stages, providing a feasible approach to achieving this goal.
[0030] This application utilizes the fixed connection weights of the ESN reservoir, requiring only the output layer to be trained, thus reducing computational complexity.
[0031] Based on this, embodiments of this application provide a sleep staging detection method, apparatus, electronic device, and storage medium to solve the problem of insufficient staging accuracy in the prior art due to neglecting the contextual relationship of sleep staging. By combining a convolutional network with an echo state network with fixed connection weights, and using the data features of the preceding and following time segments and the staging results to make decisions, more accurate sleep staging detection can be achieved.
[0032] Please see Figure 1 , Figure 1 This is a flowchart illustrating the sleep staging detection method provided in an embodiment of this application. Figure 1 As shown in the embodiments of this application, the sleep staging detection method includes: S101. Obtain polysomnography data of the target object within a preset sleep time period.
[0033] The preset sleep time period is divided into N time segments, and the polysomnography data includes polysomnography data under the N time segments sorted by time.
[0034] First, physiological signals from the target subject's entire sleep process are collected using polysomnography (PSG) equipment. These signals include electroencephalography (EEG), electrooculography (EOG), electrocardiography (ECG), and electromyography (EMG). Current standard PSG monitoring, in addition to EEG, should include physiological signals from channels such as ECG, EMG, EOG, thoracic and abdominal respiratory tension mapping, nasal and oral ventilation, body position and movement, and blood oxygen saturation. During preprocessing, the desired channels need to be filtered to a reasonable range. The collected raw signals require preprocessing: bandpass filtering of 0.3 to 35 Hz for EEG and EEG signals, bandpass filtering of 0.3 to 70 Hz for ECG signals, and bandpass filtering of 10 to 100 Hz for EMG signals. Simultaneously, all signals undergo 50 Hz notch filtering to remove power frequency interference.
[0035] The filtered signal was divided into 30-second segments according to the American Academy of Sleep Medicine standards, dividing the entire preset sleep period into N consecutive time segments. Each time segment contained physiological signal data from all channels within that time period. Data segmentation facilitates data processing in deep learning models and also ensures more accurate and reliable experimental data, thus laying a solid foundation and providing favorable guarantees for further experiments and analysis. Baseline correction was performed on the segmented data. This process removes noise interference, standardizes the data format, facilitates subsequent deep learning model processing, and ensures that each time segment corresponds to an independent sleep stage unit.
[0036] S102. Input the multi-channel sleep map data under the i-th time segment into the convolutional network and output the data features corresponding to the i-th time segment.
[0037] Where 1≤i≤N.
[0038] The multichannel sleep map data of the i-th time segment (i.e., the filtered signal of all channels within this 30-second period) is input into the pre-built convolutional network.
[0039] The convolutional network consists of a one-dimensional convolutional layer and a long short-term memory network layer. The data features corresponding to the i-th time segment are obtained in the following way: the multi-channel sleep map data of the i-th time segment is input into the one-dimensional convolutional layer, and the convolutional features are output after the convolution operation; the convolutional features are input into the long short-term memory network layer, and the data features of the time segment are output after time-series processing.
[0040] One-dimensional convolutional layers are used to extract local temporal features from polysomnography data, while long short-term memory (LSTM) network layers are used to extract temporal dependencies in local temporal features, in order to generate data features that simultaneously contain temporal and frequency domain features.
[0041] Here, the one-dimensional convolutional layer receives multi-channel sleep map data for each time segment as input. This data is raw physiological signal that has been filtered and segmented, including time series data from multiple channels such as EEG, EEG, ECG, and EMG.
[0042] To address the characteristics of sleep staging, multiple convolutional kernels of varying sizes are used in a one-dimensional convolutional layer. Each kernel slides along the time axis and performs convolution operations with signal values within a local time window. Different kernel sizes are used to capture waveform patterns at different scales in the sleep signal: smaller kernels are suitable for extracting transient features, such as spindle waves; larger kernels are better suited for capturing longer-lasting features, such as slow waves. The weights of the convolutional kernels are automatically learned through training, enabling the identification of typical patterns related to sleep staging, such as K-complex waves and eye-tracking signals. The output of the convolution operation is called a convolutional feature map, with each feature map corresponding to the response intensity of a specific pattern, reflecting the local features of the original signal at different time points. Through processing by the one-dimensional convolutional layer, the original high-dimensional signal is transformed into a series of compact local temporal feature maps. This process removes redundant information, preserves the temporal order of the signal, and highlights local patterns useful for staging, providing information-rich and appropriately dimensional input for subsequent temporal modeling.
[0043] The convolutional feature maps are then fed into a Long Short-Term Memory (LSTM) network layer. Sleep is a continuous process, and the current sleep stage is closely related to the preceding and following time periods; the LTM network is designed for this purpose. This network layer consists of multiple memory units, each containing an input gate, a forget gate, and an output gate, enabling selective memorization and forgetting of historical information. After receiving the convolutional feature maps, the LTM network layer processes the features at each time step sequentially, using a gating mechanism to capture the temporal dependencies between features.
[0044] For example, during the transition from light sleep to deep sleep, features from the previous moment are crucial for current judgments. Long Short-Term Memory (LSTM) networks can encode these dependencies into hidden states through their recurrent connections, enabling the model to maintain stable recognition capabilities during phase transitions. Simultaneously, the forget gate automatically discards outdated information irrelevant to the current task, preventing information overload.
[0045] After multiple time-step iterations, the network outputs the hidden state at each time step. These hidden states incorporate contextual information passed down from all previous time steps. Finally, the hidden state of the last time step is taken as the data feature vector for that time segment. This vector contains both the temporal characteristics of the original signal (such as waveform morphology) and, through the information accumulation effect of the Long Short-Term Memory network, indirectly reflects the frequency domain characteristics (such as rhythmic variation patterns). This design ensures that the final generated feature vector not only reflects the physiological signal characteristics within the current time segment but also contains correlation information with preceding and following time segments. This provides a high-quality input foundation for the echo state network to make contextual decisions, thereby significantly improving the accuracy and consistency of sleep staging.
[0046] First, the input signal is convolved by a one-dimensional convolutional layer to extract local temporal features and obtain a convolutional feature map. Then, the convolutional feature map is input into a long short-term memory network layer, which uses its recurrent structure to capture the temporal dependencies of the signal and further extract temporal features.
[0047] After these two processing layers, the network outputs a fixed-dimensional data feature vector. This vector integrates the time and frequency domain information of the original signal, representing a high-dimensional abstraction of the physiological signal for that time segment. Automatic feature extraction via convolutional networks avoids the tedious process of manually designing features, while simultaneously reducing data dimensionality, providing a compact and information-rich input for subsequent time-series modeling. One-dimensional convolutional layers and long short-term memory (LSTM) network layers jointly construct a feature processing model to process polysomnography data and extract corresponding features, outputting the extracted features to the subsequent state judgment model. The main purpose of the convolutional network is dimensionality reduction, transforming the high-dimensional original signal into a low-dimensional feature representation. The dimensionality-reduced data features are then passed to the echo state network for time-series modeling.
[0048] For further details, please refer to Figure 2 , Figure 2 This is a schematic diagram of the internal structure of the convolutional network provided in an embodiment of this application. Figure 2 As shown, the convolutional network extracts features from the input multi-channel sleep map data through a multi-layer structure. The specific processing flow is as follows: The input polysomnography data is processed in two parallel branches simultaneously. In the left branch, the data first enters the first one-dimensional convolutional layer. This layer (Conv1d) extracts local temporal features by sliding the convolution kernel along the time dimension and performing convolution with signal values within a local time window. The output of the convolution operation then enters a Rectified Linear Unit (ReLU), an activation function that sets negative values to zero and leaves positive values unchanged, introducing non-linear transformation capabilities to the network. This is followed by a Dropout layer, which randomly discards some neuron outputs with a certain probability to prevent overfitting. This structure, consisting of the one-dimensional convolutional layer, the Rectified Linear Unit, and the Dropout layer, is repeated twice to enhance feature extraction capabilities.
[0049] In the right branch, data is directly input into a separate one-dimensional convolutional layer. This convolutional layer uses different kernel parameter settings than the left branch to extract features at different scales from the input signal. The one-dimensional convolutional layer in the right branch is also followed by a linear rectifier unit and a random deactivation layer, forming a simplified convolutional block.
[0050] The outputs of the left branch (after two repetitions) and the right branch are then processed separately. The feature map from the left branch first enters the batch normalization layer (BatchNorm), which normalizes the data for each batch to stabilize the input distribution and accelerate training convergence. The normalized features then pass through a random deactivation layer and are fused with the output from the right branch. The fused features then enter the batch normalization layer again for a second normalization process.
[0051] After the aforementioned dual-branch extraction and fusion process, the feature map is input to the last one-dimensional convolutional layer. This convolutional layer maps the features to the final output dimension through convolution operations, generating the data features corresponding to that time segment. These data features are a high-dimensional abstract representation of the input polysomnography signal, containing both time-domain waveform information and frequency-domain rhythm information, providing the input basis for the subsequent echo-state network.
[0052] This dual-branch convolutional network structure allows different branches to extract features at different scales from the input signal, effectively capturing various typical patterns related to sleep stages, such as spindle waves and K-complex waves. At the same time, batch normalization and random deactivation mechanisms enhance the model's generalization ability and training stability.
[0053] S103. Input the data features corresponding to the i-th time segment, the data features corresponding to the (i-1)-th time segment, and the staging results of the (i-1)-th time segment into the echo state network, and output the probability estimate of the sleep staging of the i-th time segment.
[0054] The echo state network includes a reservoir, which consists of multiple neurons. Different inputs can stimulate different neurons in the reservoir to change the individual state attributes of the neurons. The connection weights in the reservoir are fixed under different inputs.
[0055] For further details, please refer to Figure 3 , Figure 3 This is a schematic diagram of the echo state network provided in an embodiment of this application.
[0056] like Figure 3As shown, the Echo State Network mainly consists of three parts: an input layer, a reservoir, and an output layer. The input vector at the current time step is fed into the input layer. This input vector is composed of the data features of the current time segment, the data features of the previous adjacent time segment, and the staging result of the previous adjacent time segment. The input vector is mapped to the reservoir through an input weight matrix. The reservoir consists of a large number of randomly connected neurons with fixed connection weights. It updates the current time-step state vector based on the current input and the reservoir state at the previous time step, thus storing the temporal context information of sleep staging. The updated reservoir state vector is input into the output layer, where it is linearly combined using a trained output weight matrix to generate a probability estimate of the sleep staging for the current time segment.
[0057] The data features of the current i-th time segment, the data features of the previous time segment (i-1), and the sleep staging results of the previous time segment are combined to form a comprehensive input vector.
[0058] In the sleep staging detection process, when processing the first time segment (i.e., i=1), since there is no actual data for the previous time segment, the recursive calculation of the echo state network needs to be initialized.
[0059] The specific implementation is as follows: The data features of the 0th time segment are set as a zero vector, and the dimension of this zero vector is consistent with the dimension of the feature vector output by the convolutional network; at the same time, the staging result of the 0th time segment is set as a default value, which can usually be set to 0 or a specific value representing "unknown". The reason for this is that when the echo state network updates the current state of the reservoir, it needs to rely on the state vector and staging result of the previous time segment as part of the input.
[0060] For the first time segment, no real historical information is available. Therefore, a zero vector and default values are manually set to fill the gaps, ensuring the network can start normally. This initialization method does not bias the subsequent calculation results because, as time steps progress, real data gradually overwrites the initial values, and the network state quickly converges to a dynamic process driven by the actual input. Through this process, the Echo State Network can achieve coherent recursive calculations throughout the entire sleep period, making full use of the contextual information of preceding and following time segments, thereby improving the accuracy of sleep stage detection.
[0061] The synthesized input vector is then fed into an echo state network for processing. The echo state network consists of an input layer, a reservoir, and an output layer. The reservoir is composed of a large number of randomly connected neurons, and the connection weights between neurons are fixed after initialization. Only the connection weights of the output layer are obtained through training.
[0062] Echo-state networks (ESNs) are essentially recurrent neural networks with loosely connected hidden layers, performing exceptionally well in the presence of chaotic time series. In ESNs, only the output weights need to be trained, significantly accelerating the training speed and providing better predictive performance. The basic idea of ESNs is to generate a complex dynamic space that changes continuously with the input using a reservoir. When this state space is sufficiently complex, these internal states can be used to linearly combine the desired output through the output layer. The connection weights between neurons in the reservoir remain constant, which offers several advantages: first, it greatly reduces the computational cost of training; second, it avoids, to some extent, the local minima problem that easily occurs in traditional gradient descent optimization algorithms; and third, it has good modeling capabilities for problems such as time series prediction and pattern recognition.
[0063] The integrated input vector is mapped to the reservoir through an input weight matrix, stimulating state changes in different neurons within the reservoir: each neuron updates its activity level based on the current input and its previous state. Active neurons (which can be considered "black dots") and inactive neurons ("white dots") together constitute the reservoir state vector at the current moment. This state vector integrates current input information and traces of historical information, reflecting the contextual association of sleep stages.
[0064] Subsequently, the current state vector of the reservoir is input into the output layer, and the trained output weight matrix is linearly combined to generate five values, which correspond to the probability estimates of the wakefulness period, non-rapid eye movement (NREM) stage 1, NREM stage 2, NREM stage 3, and rapid eye movement (REM) sleep period, respectively.
[0065] Finally, the stage category with the highest probability value is selected as the final sleep stage result for the i-th time segment. By incorporating features and stage results from the previous time step, the echo state network can fully utilize the continuity of the sleep process and effectively improve the accuracy of stage transition identification.
[0066] For further details, please refer to Figure 4 , Figure 4 This is a schematic diagram of different neurons in the different input activation reservoirs provided in the embodiments of this application.
[0067] The left side shows the reservoir state of Example 1, and the right side shows the reservoir state of Example 2. The connection structure between neurons in both figures is exactly the same, but the activity state of the neurons changes. Each circle in the figure represents a neuron, where black dots indicate an active neuron and white dots indicate an inactive neuron. In Example 1 on the left, some neurons are black and active, while others are white and inactive. In Example 2 on the right, under the same connection structure, previously active black neurons may become inactive white neurons, and previously inactive white neurons may become active black neurons. This change indicates that when different input signals are input into the reservoir, although the connection weights between neurons remain fixed, the input signals will activate different neurons in the reservoir, changing the individual state attributes of the neurons, thus forming a dynamic state vector reflecting the current input features and contextual information. Through this mechanism, the reservoir can store and transmit the temporal contextual information of sleep stages.
[0068] For further details, please refer to Figure 5 , Figure 5 This is a schematic diagram illustrating the principle of the sleep staging detection method provided in the embodiments of this application.
[0069] like Figure 5 As shown, the entire night's sequence data is divided into multiple consecutive time segments according to chronological order, with each time segment representing an item in the sequence. The polysomnography data of the current time segment is input into a convolutional network, which extracts the data features corresponding to that time segment. Then, the data features of the current time segment, the data features of the previous adjacent time segment, and the staging result of the previous adjacent time segment are input into an echo-state network. The echo-state network integrates the current input information with the contextual information of historical moments, ultimately outputting the sleep staging result for the current time segment. This context-dependent processing method allows the model to fully utilize the continuity of the sleep process, effectively improving the accuracy of identifying sleep phase transitions.
[0070] Please see Figure 6 , Figure 6 This is a flowchart illustrating the probability estimation of sleep stages for the i-th time segment, provided as an embodiment of this application. Figure 6 As shown, the probability estimate of sleep stage for the i-th time segment is obtained in the following way: S201. Combine the data features of the i-th time segment, the data features of the (i-1)-th time segment, and the staging results of the (i-1)-th time segment to form the input vector of the echo state network at the current moment.
[0071] First, the data features of the current i-th time segment are obtained from the convolutional network. This vector is a high-dimensional abstract representation of the polysomnography data within the current 30 seconds. Simultaneously, the data features of the previous time segment (i-1) and the sleep staging result of the previous time segment are read from the storage unit. When i=1, since there is no 0-th time segment, the data features and staging result of the previous moment are set to zero vectors or zero values to ensure the network can start normally.
[0072] These three parts are concatenated according to a preset dimensional order to form a complete input vector. This input vector simultaneously contains the physiological characteristics of the current moment, the physiological characteristics of the previous moment, and the decision information of the previous moment, providing a contextual input basis for the echo state network.
[0073] S202. Map the input vector to the storage pool through the input weight matrix, and stimulate the neurons in the storage pool to update the state vector at the current moment.
[0074] The state of the reservoir is determined by the input vector at the current moment and the state of the reservoir at the previous moment.
[0075] The concatenated input vector is multiplied by a pre-defined input weight matrix to obtain the mapped signal, which is then fed into the reservoir. The reservoir consists of a large number of randomly connected neurons, and the connection weights between neurons are fixed after initialization. These weights determine how information is transmitted between neurons. Each neuron has a current state value, representing its activity level. The reservoir update mechanism ensures that the current state vector is jointly determined by the current input and the reservoir state from the previous time step, thus forming a dynamic state vector reflecting the current input and historical information. This process provides the subsequent output layer with feature representations containing temporal context information, enabling the model to fully utilize the correlation between sleep stages.
[0076] In the reservoir, the state value of each neuron represents its current activity level. When the state value exceeds a preset threshold (e.g., 0.5), the neuron is considered activated, represented as a "black dot," and its state value is recorded as 1; when the state value does not reach the threshold, the neuron is inactive, represented as a "white dot," and its state value is recorded as 0. The state values of all neurons form a 0-1 matrix, which serves as a simplified representation of the reservoir state vector and is passed to the output layer.
[0077] Connections between neurons are categorized into three types: forward connections, backward connections, and no connections. Which neurons establish connections and what type of connections are formed are randomly generated during pool initialization. However, the proportion of forward, backward, and no connections in the entire pool can be preset as needed. Connection types and connection weights remain fixed after initialization and do not change between them.
[0078] Echo-state networks are inherently suitable for processing time-series sequences. This application adjusts and optimizes the reserve layer for sleep staging tasks, making it more suitable for sleep staging detection. The connections between neurons within the reserve layer are sparse, meaning that not all neurons are connected. This sparsity helps reduce computational complexity and avoid overfitting.
[0079] In the reservoir of neurons described in this application, there are numerous backlinks. Backlinks can inhibit neurons, allowing those in an excited state to return to an unexcited state, thus maintaining the dynamic balance of the reservoir and preventing all neurons from simultaneously entering an excited state, which would cause the network to lose its discriminative ability. The neurons in the reservoir are simulated using the LIF (Leaky Integrate-and-Fire) model. This model describes the membrane potential changes of neurons through differential equations, and the Euler method is used for numerical solution to obtain approximate solutions for the neuron state values.
[0080] If the reservoir contains only forward connections, the initial state values of all neurons (e.g., 0.01) will continuously increase with the accumulation of input. After several time steps, all neurons will exceed the threshold and enter the activated state, causing the reservoir to lose its dynamic diversity, and the output will remain unchanged. The role of backward connections is to allow neurons in the activated state to return to the unactivated state, thereby maintaining the dynamic balance of the reservoir. Due to the presence of external input, a large number of backward connections are usually set within the reservoir to prevent neurons from easily reaching all activated states, thus ensuring the rich dynamic characteristics of the network.
[0081] The connection weights between neurons in the sleep reservoir remain fixed after initialization; only the state value of each neuron changes. Taking two neurons as an example, assuming both have a default state value of 0.01 and their connection weight is 2, the update calculates 0.01 + 2 × 0.02 to obtain the new state value. The entire sleep reservoir can be viewed as a dynamically changing graph or matrix. Through a trained output weight matrix, the state values of all neurons in the reservoir are linearly combined and mapped to five output values, each corresponding to the probability of one of the five sleep stages.
[0082] Because the data characteristics of adjacent time segments contain repetitive and invariant parts, the sleep reservoir can remember the sleep state of the previous moment through these repetitive features, thus reflecting the continuity of sleep. In actual simulations, neurons themselves are described by differential equations that cannot be solved directly. Therefore, the Euler method is used for numerical simulation to obtain approximate solutions for the state values.
[0083] For further details, please refer to Figure 7 , Figure 7 This is a flowchart illustrating the updating of the state vector of the storage pool, provided as an embodiment of this application. For example...Figure 7 As shown, the state vector of the reservoir is updated in the following way: S301. Combine the current input vector with the previous reservoir state vector; The input vector for the current time step is obtained from the input layer; this vector is generated in step S201. Simultaneously, the reservoir state vector from the previous time step is read from the storage unit. These two vectors are combined in a predetermined manner, typically by concatenation or addition, and used as input for subsequent nonlinear transformations. This combination operation allows both the current input and historical information to participate in the updating of the neuron state simultaneously, providing a foundation for the fusion context of the reservoir.
[0084] S302. The combined information is transformed nonlinearly by the fixed internal connection weights in the reserve pool to generate the reserve pool state vector at the current moment.
[0085] The combined information is then weighted and summed with fixed internal connection weights in the reservoir. Each neuron in the reservoir is connected to several other neurons, and the weights of these connections remain unchanged after initialization. Each neuron calculates a weighted sum based on the previous state value of its connected neurons and the current input information, using its internal connection weights. This sum is then processed by a nonlinear activation function (such as the hyperbolic tangent function) to obtain the neuron's new state value at the current moment. The new state values of all neurons together constitute the reservoir state vector at the current moment. Neurons with higher state values can be considered active "black dots," while neurons with lower state values can be considered inactive "white dots." Through this nonlinear transformation, the reservoir can generate rich dynamic characteristics, effectively storing and transmitting temporal information of sleep stages.
[0086] S203. Input the current state vector of the reserve pool into the output layer, and generate a probability estimate of the sleep stage for the i-th time segment by linearly combining the output weight matrix.
[0087] The updated reservoir state vector is passed as input to the output layer. The output layer contains a trained output weight matrix, which is determined through the previous training process.
[0088] The state vector is multiplied by the output weight matrix and then linearly combined to obtain five values, which correspond to the initial scores of the waking period, non-rapid eye movement (NREM) stage 1 sleep, NREM stage 2 sleep, NREM stage 3 sleep, and rapid eye movement (REM) sleep, respectively.
[0089] Subsequently, the five initial scores are converted into probability values using a normalized exponential function (Softmax), such that the sum of the five probabilities is 1. These five probability values are the probability estimates of the sleep stage for the i-th time segment, and the stage category with the highest probability value is selected as the final sleep stage result for the current time segment.
[0090] In this way, the Echo State Network makes full use of the contextual information of the preceding and following time segments, making the staging results more coherent in the time series and improving the accuracy of identifying the stage transition period.
[0091] Compared to existing methods that process each sleep segment independently and ignore the contextual relationships between sleep stages, the sleep staging detection method, apparatus, electronic device, and storage medium provided in this application combine convolutional networks and echo-state networks. By inputting the feature vector of the current time segment, the feature vector of the previous adjacent time segment, and the staging result of the previous adjacent time segment into the echo-state network for decision-making, the model can fully utilize historical information when determining the current sleep stage. This effectively overcomes the problem of misjudgment during stage transitions and improves the accuracy and temporal coherence of sleep staging. This application can adaptively process physiological signals from multiple channels, reducing the complex data processing operations of existing sleep staging algorithms. More importantly, this application can combine preceding features to connect different sleep stages, thereby obtaining better staging results.
[0092] Based on the same inventive concept, this application also provides a sleep staging detection device corresponding to the sleep staging detection method. Since the principle of the device in this application is similar to the sleep staging detection method described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0093] Please see Figure 8 , Figure 8 This is a schematic diagram of the sleep staging detection device provided in an embodiment of this application. Figure 8 As shown, the sleep staging detection device 400 includes: The polysomnography data acquisition module 401 is used to acquire polysomnography data of a target object within a preset sleep time period. The preset sleep time period is divided into N time segments, and the polysomnography data includes polysomnography data under the N time segments sorted by time. The data feature output module 402 is used to input the polysomnography data of the i-th time segment into the convolutional network and output the data features corresponding to the i-th time segment, where 1≤i≤N; The probability estimation output module 403 is used to input the data features corresponding to the i-th time segment, the data features corresponding to the (i-1)-th time segment, and the staging result of the (i-1)-th time segment into the echo state network, and output the probability estimate of the sleep staging of the i-th time segment. The echo state network includes a reserve pool, which is composed of multiple neurons. Different inputs can stimulate different neurons in the reserve pool to change the individual state attributes of the neurons. The connection weights in the reserve pool are fixed under different inputs.
[0094] Please see Figure 9 , Figure 9 This is a schematic diagram of the structure of the electronic device provided in an embodiment of this application. Figure 9 As shown, the electronic device 500 includes a processor 510, a memory 520, and a bus 530.
[0095] The memory 520 stores machine-readable instructions executable by the processor 510. When the electronic device 500 is running, the processor 510 and the memory 520 communicate via the bus 530. When the machine-readable instructions are executed by the processor 510, they can perform the operations described above. Figure 1 The steps of the sleep staging detection method in the illustrated method embodiment can be found in the method embodiment for specific implementation, and will not be repeated here.
[0096] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can perform the above-described actions. Figure 1 The steps of the sleep staging detection method in the illustrated method embodiment can be found in the method embodiment for specific implementation, and will not be repeated here.
[0097] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0098] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the shown or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0099] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0100] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0101] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0102] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The scope of protection of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for detecting sleep stages, characterized in that, include: Acquire polysomnography data of the target object within a preset sleep time period, wherein the preset sleep time period is divided into N time segments, and the polysomnography data includes polysomnography data under the N time segments sorted by time. Input the multi-channel sleep map data of the i-th time segment into the convolutional network and output the data features corresponding to the i-th time segment, where 1≤i≤N; The data features corresponding to the i-th time segment, the data features corresponding to the (i-1)-th time segment, and the staging result of the (i-1)-th time segment are input into the echo state network to output the probability estimate of the sleep stage of the i-th time segment. The echo state network includes a reserve pool, which is composed of multiple neurons. Different inputs can stimulate different neurons in the reserve pool to change the individual state attributes of the neurons. The connection weights in the reserve pool are fixed under different inputs.
2. The method according to claim 1, characterized in that, The probability estimate of the sleep stage in the i-th time segment is obtained as follows: The data features of the i-th time segment, the data features of the (i-1)-th time segment, and the staging results of the (i-1)-th time segment are combined to form the input vector of the echo state network at the current moment. The input vector is mapped to the reserve pool through the input weight matrix, which triggers the neurons in the reserve pool to update the state vector at the current time. The state of the reserve pool is determined by the input vector at the current time and the state of the reserve pool at the previous time. The current state vector of the reservoir is input into the output layer, and the output weight matrix is linearly combined to generate a probability estimate of the sleep stage for the i-th time segment.
3. The method according to claim 2, characterized in that, The state vector of the reserve pool is updated in the following manner: Combine the current input vector with the previous state vector of the reservoir; The combined information is nonlinearly transformed by the fixed internal connection weights in the reservoir to generate the reservoir state vector at the current moment.
4. The method according to claim 1, characterized in that, The convolutional network includes one-dimensional convolutional layers and long short-term memory network layers; The data features corresponding to the i-th time segment are obtained in the following way: The multi-channel sleep map data of the i-th time segment is input into the one-dimensional convolutional layer, and the convolutional features are output after the convolution operation. The convolutional features are input into the long short-term memory network layer, and the data features of the time segment are output after time-series processing.
5. The method according to claim 4, characterized in that, The one-dimensional convolutional layer is used to extract local temporal features from the polysomnography data, and the long short-term memory network layer is used to extract temporal dependencies in the local temporal features to generate data features that simultaneously contain temporal and frequency domain features.
6. The method according to claim 1, characterized in that, When i=1, the data features of the (i-1)th time segment are set to zero vectors, and the staging results of the (i-1)th time segment are set to default values to initialize the recursive calculation of the echo state network.
7. The method according to claim 1, characterized in that, The probability estimate of sleep stages includes probability values corresponding to the wakefulness stage, non-rapid eye movement (NREM) sleep stage 1, NREM sleep stage 2, NREM sleep stage 3, and rapid eye movement (REM) sleep stage. The stage category with the highest probability value is used as the sleep stage result for the i-th time segment.
8. A sleep staging detection device, characterized in that, include: The polysomnography data acquisition module is used to acquire polysomnography data of a target object within a preset sleep time period. The preset sleep time period is divided into N time segments, and the polysomnography data includes polysomnography data under the N time segments sorted by time. The data feature output module is used to input the polysomnography data of the i-th time segment into the convolutional network and output the data features corresponding to the i-th time segment, where 1≤i≤N; The probability estimation output module is used to input the data features corresponding to the i-th time segment, the data features corresponding to the (i-1)-th time segment, and the staging result of the (i-1)-th time segment into the echo state network, and output the probability estimate of the sleep staging of the i-th time segment. The echo state network includes a reserve pool, which is composed of multiple neurons. Different inputs can stimulate different neurons in the reserve pool to change the individual state attributes of the neurons. The connection weights in the reserve pool are fixed under different inputs.
9. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is in operation, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the steps of the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the method as described in any one of claims 1 to 7.