Processing method, device and storage medium of sleep data
By constructing a channel functional connectivity matrix and a graph attention mechanism, combined with a sleep stage transition probability matrix, the functional coupling relationship between multi-channel signals is explicitly modeled, solving the problem of insufficient accuracy in sleep staging in existing technologies and improving the accuracy and stability of sleep staging, especially the ability to distinguish transition periods.
Patent Information
- Application Number
- CN202611357068.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-03
- Publication Date
- 2026-11-06
- Estimated Expiration
- 2046-09-03
AI Technical Summary
Existing sleep staging methods lack the ability to explicitly model the functional coupling relationship between multi-channel signals, resulting in insufficient accuracy in sleep staging, especially in the discrimination of transitional sleep stages.
By constructing a channel functional connection matrix, generating a channel relationship graph representation using a graph attention mechanism, and updating the sleep stage prototype vector by combining the sleep stage transition probability matrix, cross-time context modeling is performed. The channel relationship graph and stage relationship graph representations are then fused to output the sleep stage classification results.
Explicitly modeling the functional coupling relationship between multi-channel signals improves the accuracy and stability of sleep stage identification, especially significantly enhancing the ability to distinguish the transitional sleep stage.
Smart Images

Figure CN122842819B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent physiological signal analysis technology, and in particular to a method, device and storage medium for processing sleep data. Background Technology
[0002] Sleep staging is a core tool for assessing sleep quality and diagnosing sleep disorders, and its accuracy directly impacts the effectiveness of clinical decision-making. Currently, clinical sleep staging mainly relies on professionals manually annotating each segment of polysomnography signals. This method is not only labor-intensive and inefficient, but the interpretation results are also easily affected by subjective experience and fatigue, making it difficult to meet the needs of automated analysis for large-scale sleep monitoring.
[0003] However, most deep learning solutions do not integrate the multi-dimensional physiological and pathological information upon which sleep staging relies for modeling. This leads to the fragmentation of three key types of information crucial for staging: the functional coupling between multi-channel EEG and EEG signals, the temporal evolution of sleep stage transitions, and continuous contextual information across sleep segments. Using only simple cascaded or single model structures results in models that struggle to fully capture the multi-source collaborative change patterns during sleep, particularly performing poorly in distinguishing transitional sleep stages (such as N1 stage).
[0004] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0005] The main objective of this application is to provide a method, device, and storage medium for processing sleep data, aiming to solve the technical problem that the lack of explicit modeling capability for the functional coupling relationship between multi-channel signals in existing sleep staging methods leads to insufficient accuracy in sleep staging.
[0006] To achieve the above objectives, this application proposes a method for processing sleep data, the method comprising: Based on a preset duration, the sleep physiological signals collected by multiple detection channels are divided into multiple sleep segments; Based on the pairwise correlation between the detection channels, a channel function connection matrix is constructed; Temporal features are extracted from the channel signals of each sleep segment to obtain the local temporal features corresponding to each detection channel; The local temporal features corresponding to each detection channel of the same sleep segment are used as node features, and the channel function connection matrix is used as a prior constraint to generate a channel relationship graph representation of the sleep segment through a graph attention mechanism. The learnable sleep stage prototype vector is updated based on the sleep stage transition probability matrix, and the matching degree is calculated based on the channel average features of the sleep segment and the updated sleep stage prototype vector to obtain the stage relationship graph representation of the sleep segment. The channel relationship diagram representation and the stage relationship diagram representation are fused to obtain the corresponding fused features; Cross-time context modeling is performed based on the fusion features of multiple consecutive sleep segments, and the sleep stage classification results of each sleep segment are output according to the context modeling results.
[0007] In one embodiment, the sleep physiological signals include electroencephalogram (EEG) signals from the EEG signal detection channel and electrooculogram (EOG) signals from the EOG signal detection channel. After the step of acquiring continuous sleep physiological signals, the method further includes: The electroencephalogram (EEG) signal is bandpass filtered using a first frequency band, and the electrooculogram (EOG) signal is bandpass filtered using a second frequency band to obtain a filtered sleep physiological signal, wherein the high-frequency cutoff frequency of the first frequency band is higher than that of the second frequency band. The mean and standard deviation of each channel signal were calculated based on the filtered sleep physiological signals of the same subject. The sleep physiological signals of the subject at each sampling point in the corresponding detection channel are subjected to zero-mean unit variance transformation using the mean and the standard deviation to obtain standardized sleep physiological signals. The standardized sleep physiological signals are used as input data for subsequent construction of the channel functional connectivity matrix and extraction of the local temporal features.
[0008] In one embodiment, the standardized sleep physiological signal includes multiple detection channels, and the step of calculating the correlation between the detection channels based on the sleep physiological signal and constructing a channel functional connectivity matrix includes: Treating each detection channel as a graph node, vectorization expansion is performed on the channel signals of any two detection channels of the standardized sleep physiological signal to obtain two one-dimensional vectors. Calculate the Pearson correlation coefficient between the two one-dimensional vectors, and use the absolute value of the Pearson correlation coefficient as the functional connectivity strength value between the corresponding two detection channels; Traverse all detection channel combinations and arrange all corresponding functional connection strength values into a square matrix with a dimension equal to the square of the number of detection channels to obtain the channel functional connection matrix.
[0009] In one embodiment, the step of performing temporal convolution processing on each channel signal of each sleep segment to obtain the corresponding local temporal features of each detection channel includes: The channel signals of each of the sleep segments are respectively input into an enhanced residual temporal convolutional network composed of cascaded multi-layer residual convolutional blocks; Each residual convolutional block sequentially performs one-dimensional convolution, batch normalization, nonlinear activation, random deactivation, and a second one-dimensional convolution. The input features of the residual convolutional block are added to the output features of the second one-dimensional convolution to obtain the corresponding residual block output. At least one residual convolutional block uses dilated convolution. An adaptive average pooling operation is performed on the output features of the last residual convolutional block, and a linear mapping is performed on the average pooling operation result through a fully connected layer to obtain the local temporal features corresponding to each detection channel of each sleep segment of a preset dimension.
[0010] In one embodiment, the step of using the local temporal features of each detection channel within the same sleep segment as node features, and using the channel functional connectivity matrix as a priori constraint, to generate a channel relationship graph representation of the sleep segment through a graph attention mechanism includes: Each detection channel within the same sleep segment is defined as a graph node, and the local temporal features corresponding to each detection channel are assigned to the corresponding graph node as the initial features of the graph node. The functional connection strength value between any two detection channels in the channel functional connection matrix is used as the prior relation weight between the corresponding graph nodes of the two detection channels. For each attention head in the graph attention mechanism, the initial features of each graph node are mapped to the subspace of the corresponding attention head using a learnable matrix to obtain the corresponding mapped features. For each pair of graph nodes, the mapping features of each pair of graph nodes in the subspace are concatenated and projected through the learnable attention vector corresponding to the attention head to obtain the basic attention score between the pair of graph nodes. The logarithm of the functional connection strength value of the detection channel corresponding to the graph node in the functional connection matrix is multiplied by a preset modulation coefficient, and the resulting product is added to the basic attention score to obtain the prior relation modulated attention score. For each graph node, the attention score modulated by the prior relationship between the graph node and all other nodes is normalized according to the normalized exponential function to obtain the attention weight of the graph node to each other node. The initial features of each other node are weighted and aggregated according to the attention weights, and the features obtained by aggregating multiple attention heads are concatenated to obtain the multi-head aggregated features of the graph nodes. The multi-head aggregated features are added to the mapped features of the initial features of the graph nodes after linear projection, and the addition result is subjected to layer normalization to obtain the updated feature representation of the graph nodes. The updated feature representations of each graph node are weighted and summed by learningable channel aggregation weights to obtain the channel relationship graph representation of the sleep segment.
[0011] In one embodiment, the step of updating the learnable sleep stage prototype vector using the sleep stage transition probability matrix and calculating the matching degree based on the channel average features of the sleep segment and the updated sleep stage prototype vector to obtain the stage relationship graph representation of the sleep segment includes: Obtain the learnable sleep stage prototype vectors corresponding to each sleep stage category; The sleep stage transition probability matrix is multiplied by the matrix composed of the learnable sleep stage prototype vectors to obtain the updated sleep stage prototype vectors corresponding to each sleep stage category. The channel-averaged features of the sleep segment are obtained by averaging the local temporal features corresponding to each detection channel of the sleep segment. The matching degree of the channel average feature is calculated with each of the updated sleep stage prototype vectors to obtain the matching score between the sleep segment and each sleep stage category. The matching scores are normalized using a normalized exponential function to obtain the attention weights of the sleep segments to the updated sleep stage prototype vectors corresponding to each sleep stage category. The updated sleep stage prototype vectors are weighted and summed according to the attention weights to obtain the weighted summation result; The weighted summation result is added to the result of linear projection of the channel average feature, and layer normalization is performed to obtain the stage relationship diagram representation of the sleep segment.
[0012] In one embodiment, the step of fusing the channel relationship diagram representation and the stage relationship diagram representation to obtain the corresponding fused features includes: The channel relationship diagram representation and the stage relationship diagram representation corresponding to the same sleep segment are concatenated along the feature dimension to obtain a concatenated joint feature vector. The joint feature vector is input into a gating network, and a linear transformation is performed through the gating network to generate a dimension-wise gating vector; The fusion feature is obtained by performing an element-wise weighted summation operation on the channel relationship graph representation and the stage relationship graph representation using the dimension-wise gated vector.
[0013] In one embodiment, the step of performing cross-time context modeling based on the fusion features of multiple consecutive sleep segments, and outputting the sleep stage classification result of each sleep segment according to the context modeling result, includes: The fusion features corresponding to multiple consecutive sleep segments in a continuous context window are obtained, and the fusion features are arranged in chronological order according to the corresponding sleep segments to form a fusion feature sequence. The fused feature sequence is input into a bidirectional long short-term memory network. The fused features are processed sequentially in chronological order through the forward propagation path of the bidirectional long short-term memory network to capture the contextual dependencies from past time periods to the current time period. The fused features are processed sequentially in reverse chronological order through the backward propagation path of the bidirectional long short-term memory network to capture the contextual dependencies from future time periods to the current time period. The hidden states output by the forward propagation path and the backward propagation path are concatenated to obtain the context hidden state corresponding to each sleep segment. The contextual hidden states of each sleep segment are input into a classifier. The classifier maps each contextual hidden state into a classification score vector that is equal to the number of sleep stage categories. The classification score vector is then converted into a probability distribution for each sleep stage using a normalized exponential function. The sleep stage category corresponding to the maximum probability is selected as the sleep stage classification result of the sleep segment.
[0014] Furthermore, to achieve the above objectives, this application also proposes a sleep data processing apparatus, which includes: The signal acquisition module is used to divide the sleep physiological signals collected by multiple detection channels into multiple sleep segments based on a preset duration. The detection channel connection graph construction module is used to construct a channel function connection matrix based on the correlation between each pair of detection channels; The temporal convolution feature extraction module is used to extract temporal features from each channel signal of each sleep segment to obtain the local temporal features corresponding to each detection channel. The multi-detection channel graph attention module is used to take the local temporal features corresponding to each detection channel of the same sleep segment as node features, and use the channel function connection matrix as a prior constraint to generate a channel relationship graph representation of the sleep segment through a graph attention mechanism. The stage relationship graph attention module is used to update the learnable sleep stage prototype vector based on the sleep stage transition probability matrix, and calculate the matching degree based on the channel average features of the sleep segment and the updated sleep stage prototype vector to obtain the stage relationship graph representation of the sleep segment. The gated fusion module is used to fuse the channel relationship diagram representation with the stage relationship diagram representation to obtain the corresponding fusion feature; The cross-sleep time period classification module is used to perform cross-sleep time period context modeling based on the fusion features of multiple consecutive sleep segments, and output the sleep stage classification results of each sleep segment according to the context modeling results.
[0015] In addition, to achieve the above objectives, this application also proposes a sleep data processing device, the device comprising: a memory, a processor, and a computer program stored on the memory and executable thereon, the computer program being configured to implement the steps of the sleep data processing method described above.
[0016] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and which, when executed by a processor, implements the steps of the sleep data processing method described above.
[0017] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the sleep data processing method described above.
[0018] The one or more technical solutions proposed in this application have at least the following technical effects: 1. Acquiring continuous sleep physiological signals; 2. Dividing the continuous sleep physiological signals into multiple sleep segments according to a preset duration; 3. Establishing the basic time unit for all subsequent processing. 4. Quantifying the physiological coupling strength between different detection channels based on the pairwise correlation between detection channels; 5. Constructing a channel functional connectivity matrix; 6. Transforming invisible correlations into explicit prior knowledge. 7. Performing temporal convolution processing on the channel signals of each sleep segment to obtain the corresponding local temporal features of each detection channel; 7. Using the local temporal features of each detection channel within the same sleep segment as node features; 8. Dynamically fusing the association information of multiple detection channels with the channel functional connectivity matrix as a prior constraint; 9. Generating a channel relationship graph representation of the sleep segment through a graph attention mechanism. 10. Obtaining the sleep stage transition probability matrix; 11. Updating the learnable sleep stage prototype vector based on the sleep stage transition probability matrix; 22. Calculating the matching degree based on the channel average features of the sleep segment and the updated sleep stage prototype vector; 3. Obtaining a stage relationship graph representation of the sleep segment; 4. Updating the sleep stage prototype based on the statistical law of sleep stage jumps; 5. Matching the sleep segment with various sleep standard templates; 6. Mining the sleep evolution characteristics of the sleep segment. This application fuses channel relationship graph representations with stage relationship graph representations to obtain corresponding fused features, forming complete single-segment features. Based on the fused features of multiple consecutive sleep segments, cross-time context modeling is performed to mine the context dependencies between sleep segments. Based on the context modeling results, the sleep stage classification results of each sleep segment are output. On the one hand, this application refines the extraction of sleep waveform details of a single detection channel, and on the other hand, it explicitly models the dynamic physiological coupling relationship of multiple leads. At the same time, it integrates sleep evolution laws and long-term context, making up for the shortcomings of traditional methods that simply splice detection channels and lose lead linkage information. This solves the technical problem that the lack of explicit modeling ability of functional coupling relationship between multi-channel signals in existing sleep staging methods leads to insufficient sleep staging accuracy, and improves the recognition accuracy and result stability of all sleep stages. Attached Figure Description
[0019] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart illustrating an embodiment of the sleep data processing method of this application. Figure 2A schematic diagram of the architecture of a sleep data processing model provided in this application; Figure 3 A performance comparison chart of the sleep data processing method provided in this application on a test set; Figure 4 A confusion matrix result diagram of a sleep data processing method provided in this application; Figure 5 Comparison of ablation experiment results for a sleep data processing method provided in this application; Figure 6 This is a schematic diagram of the module structure of the sleep data processing device according to an embodiment of this application; Figure 7 This is a schematic diagram of the hardware operating environment involved in the sleep data processing method in the embodiments of this application.
[0022] Label: Detailed Implementation It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0023] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0024] The main solution of this application embodiment is as follows: Based on a preset duration, the sleep physiological signals collected by multiple detection channels are divided into multiple sleep segments; a channel functional connection matrix is constructed according to the correlation between each pair of detection channels; temporal features are extracted from the signals of each channel in each sleep segment to obtain the local temporal features corresponding to each detection channel; the local temporal features corresponding to each detection channel in the same sleep segment are used as node features, and the channel functional connection matrix is used as a prior constraint to generate a channel relationship graph representation of the sleep segment through a graph attention mechanism; the learnable sleep stage prototype vector is updated based on the sleep stage transition probability matrix, and the matching degree is calculated based on the channel average features of the sleep segment and the updated sleep stage prototype vector to obtain a stage relationship graph representation of the sleep segment; the channel relationship graph representation and the stage relationship graph representation are fused to obtain the corresponding fused features; cross-time context modeling is performed based on the fused features of multiple consecutive sleep segments, and the sleep stage classification results of each sleep segment are output according to the context modeling results.
[0025] In this embodiment, for ease of description, the sleep data processing system will be used as the execution subject in the following description.
[0026] Sleep staging refers to the process by which continuous sleep recordings are divided into different sleep stages—wakefulness (W), light sleep (N1), light sleep (N2), deep sleep (N3), and rapid eye movement (REM)—based on changes in physiological signals such as electroencephalography (EEG), electrooculography (EOG), and electromyography (EMG) during sleep, according to the American Academy of Sleep Medicine (AASM). Sleep staging results reflect a subject's sleep structure, sleep cycle, number of awakenings, and duration of each stage, serving as an important basis for sleep quality assessment, sleep disorder diagnosis, neuropsychiatric research, and long-term health monitoring.
[0027] Current clinical sleep staging typically relies on manual annotation by professionals based on polysomnography signals and related interpretation rules. While manual interpretation has strong clinical interpretability, it requires examining waveforms from multiple detection channels for each epoch, resulting in a large workload, long processing time, and high cost. Furthermore, interpretation results are easily affected by the interpreter's experience, fatigue level, signal quality, differences in equipment setup, and individual differences among subjects. Inconsistencies may exist between different interpreters, making it difficult to meet the automated analysis needs of large-scale, long-term, and home-based sleep monitoring.
[0028] To reduce the burden of manual interpretation and improve interpretation efficiency and result stability, early automated sleep staging methods typically extracted manually generated features from EEG and EOG signals, such as frequency band energy, spectral entropy, time-domain statistics, eye-tracking indicators, or waveform complexity indicators. These features were then used to construct classification models using machine learning methods such as support vector machines and random forests. While these methods achieved a degree of automation, they relied on feature engineering, requiring extensive domain knowledge for feature selection. Furthermore, manually designed features struggled to fully describe the complex variation patterns of EEG and EOG signals. Additionally, the distributional differences between different datasets, acquisition devices, and subject populations meant that the generalization ability of fixed features and traditional classifiers was often insufficient.
[0029] In recent years, deep learning technology has been increasingly applied to the task of automatic sleep staging. Some studies utilize convolutional neural networks to learn local waveforms or time-frequency features, while recurrent neural networks, Transformers, and other structures model the contextual relationships between adjacent epochs. Graph neural networks have also been used to process multi-channel signal relationships. These methods reduce reliance on manual feature design, but existing solutions still have shortcomings: First, some existing solutions, when processing EEG and EOG signals from multiple detection channels, often use simple cascading or empirically fixed weighting for feature fusion, lacking explicit representation of the functional coupling relationship between different leads, making it difficult to adapt to changes in the dynamic correlation structure between detection channels caused by individual differences in subjects and the evolution of sleep processes. Second, sleep phase transitions have inherent temporal dependence and statistical regularity; however, existing solutions either completely ignore this regularity or only utilize it in the post-processing stage as a fixed rule, failing to effectively integrate the prior constraints of phase transitions into the model's feature learning process. Third, some existing solutions adopt independent inference strategies for each epoch, resulting in insufficient modeling depth of contextual information, which limits the model's ability to discriminate local signal perturbations and short-term artifacts, especially the recognition performance of low-proportion phases such as N1, which needs improvement and is prone to confusion in classification decisions.
[0030] In summary, existing automatic sleep staging techniques still struggle to fully utilize local waveform rhythms, spatial correlations across multiple detection channels, sleep stage transition patterns, and continuous contextual information across epochs. Therefore, it is necessary to propose an automatic sleep staging method that can jointly model the functional connectivity relationships of detection channels and the evolutionary relationships of sleep stages, and incorporate cross-epoch memory mechanisms for center epoch discrimination, in order to improve the accuracy, stability, and interpretability of automatic sleep stage identification.
[0031] This application provides a solution that first acquires continuous sleep physiological signals and divides them into multiple sleep segments according to a preset duration, providing standardized input for segment-by-sleep analysis. Then, based on the correlation between each pair of detection channels, a channel functional connectivity matrix is constructed, thereby explicitly quantifying the functional coupling strength between leads in a data-driven manner, transforming the detection channel association structure originally implicit in the signal into a computable topological description. On this basis, temporal convolution processing is performed on the signals of each channel in each sleep segment to extract local temporal features, preserving the discriminative information of the waveform rhythm of a single detection channel. Furthermore, the local temporal features of each detection channel are used as node features, with the channel functional connectivity matrix as a prior constraint, and a channel relationship graph representation is generated through a graph attention mechanism. This allows for the dynamic aggregation of neighboring detection channel information on an explicit graph structure, with attention weights adaptively adjusted according to sleep progress and individual differences, thus overcoming the deficiency of fixed fusion methods in failing to reflect the dynamic coupling between detection channels. Simultaneously, the learnable stage prototype vector is updated using the sleep stage transition probability matrix, and a stage relationship graph representation is generated based on the matching degree between the channel average features and the updated prototype, incorporating the temporal prior of stage evolution into feature learning. The channel relationship graph representation is then fused with the stage relationship graph representation to achieve a joint representation of spatial coupling and temporal evolution. Finally, cross-time context modeling is performed based on the fusion features of multiple consecutive segments, and classification results are output. Local artifact interference is suppressed by leveraging the contextual constraints of preceding and following segments. Thus, this application transforms the detection of channel functional coupling relationships from an implicit, static fusion method to an explicit, dynamic, and learnable graph structure modeling, effectively solving the technical problem of insufficient stage classification accuracy caused by the lack of explicit functional coupling modeling.
[0032] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or a sleep data processing device capable of performing the above functions. The following description uses a sleep data processing system as an example to illustrate this embodiment and the subsequent embodiments.
[0033] Based on this, embodiments of this application provide a method for processing sleep data, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the sleep data processing method of this application.
[0034] In this embodiment, the method for processing sleep data includes steps 101-107: Step 101: Based on a preset duration, divide the sleep physiological signals collected by multiple detection channels into multiple sleep segments.
[0035] Specifically, the input signals can originate from polysomnography (PSG) devices or from publicly available or clinical datasets that have been authorized for use. This application uses the Sleep-EDF-20 dataset as the source of experimental data. Sleep-EDF-20 is a commonly used experimental version of the Sleep Cassette subset in the Sleep-EDF Expanded database of the PhysioNet platform. It contains overnight sleep records of 20 healthy subjects, typically including 10 men and 10 women, aged 25 to 34 years. The subjects in this dataset did not use any sleep-related medications, and the recorded content mainly includes physiological signals from multiple detection channels such as electroencephalography (EEG) and electrooculography (EOG).
[0036] In one feasible implementation, the continuous sleep physiological signals need to originate from continuous sleep recordings. These recordings include at least an EEG detection channel and an EOG detection channel, and may further include physiological detection channels such as electromyography (EMG), electrocardiography (ECG), respiration, blood oxygenation, or body movement, depending on the actual acquisition conditions. For ease of explanation, this embodiment can use three detection channels—EEG Fpz-Cz, EEGPz-Oz, and EOG horizontal—as an example of input detection channels, i.e., the number of detection channels. However, this application is not limited to this specific combination of detection channels; when the input device provides more detection channels, the detection channel dimensions can be expanded in the same way and a corresponding detection channel function connection diagram can be constructed.
[0037] Continuous sleep physiological signals are divided into multiple sleep segments (epochs) of fixed duration. As a commonly used sleep staging method, each epoch is 30 seconds long. Sleep stage labels include wakefulness (W), light sleep (N1), light sleep (N2), deep sleep (N3), and REM sleep, for a total of K=5 categories. If the original signal sampling frequency is 100Hz, each detection channel within a single epoch contains L=3000 sampling points. If the original sampling frequency is different, resampling to a uniform sampling rate can be performed, or the value of L can be adjusted according to the sampling rate. For batch training or inference processes, the input samples can be represented as a four-dimensional tensor X, with dimensions... , .
[0038] Where B represents the batch size, S represents the number of consecutive epochs within a central sliding window, C represents the number of detection channels, and L represents the number of sampling points per detection channel within a single epoch. This dimensional definition allows the sleep data processing model of this application to simultaneously retain the batch sample dimension, cross-epoch context dimension, detection channel spatial dimension, and intra-detection channel temporal sampling dimension, providing a unified input format for subsequent temporal convolution, graph attention, and cross-epoch memory modeling.
[0039] In this application, epoch refers to a fixed-length sleep segment used for sleep staging, typically 30 seconds in a common setting.
[0040] Optionally, the detection channels include an electroencephalogram (EEG) signal detection channel and an electrooculogram (EOG) signal detection channel. Sleep physiological signals include EEG signals and EOG signals. After the step of acquiring continuous sleep physiological signals, the method further includes: The electroencephalogram (EEG) signal in the sleep physiological signal is bandpass filtered using the first frequency band, and the electrooculogram (EOG) signal in the sleep physiological signal is bandpass filtered using the second frequency band to obtain the filtered sleep physiological signal. The high-frequency cutoff frequency of the first frequency band is higher than that of the second frequency band. Based on the filtered sleep physiological signals of the same subject, the mean and standard deviation of each detection channel were calculated. Zero-mean unit variance transformation was performed on the sleep physiological signals of each sampling point under the corresponding detection channel of the subject using the mean and standard deviation to obtain standardized sleep physiological signals. The standardized sleep physiological signals were used as input data for subsequent construction of channel functional connectivity matrix and extraction of local temporal features.
[0041] Specifically, the sleep physiological signal involves the simultaneous acquisition of multiple channels of human sleep bioelectrical signals. This application includes at least two independent acquisition circuits: an EEG signal detection channel and an EEG signal detection channel. The generation mechanisms and effective waveform frequency bands of the two signals are completely different, and their processing methods cannot be mixed. The EEG signal in the sleep physiological signal is captured by scalp electrodes to capture the synchronous firing waveforms of brain neurons, including slow waves, spindle waves, and other core features that distinguish between deep and light sleep, with a wider effective signal frequency band. The EEG signal in the sleep physiological signal is captured by periocular electrodes to capture the potential difference waveform of the eyeball, relying only on low-frequency eye deflection signals to distinguish REM sleep, without high-frequency effective information. The first frequency band (EEG filtering band) can be 0.5Hz to 35Hz, with low frequencies covering deep sleep delta waves and high frequencies retaining sleep spindle waves, and a larger high-frequency cutoff value. The second frequency band (EEG filtering band) can be 0.3Hz to 10Hz, retaining only low-frequency eye movement waveforms, with a lower high-frequency cutoff value, filtering out high-frequency muscle noise. Bandpass filtering is a signal processing operation that preserves the waveform within a set frequency band and filters out interference noise outside the frequency band. The two types of signals are filtered separately to adapt to their respective physiological characteristics.
[0042] For example, after acquiring continuous sleep physiological signals and dividing them into sleep segments of fixed duration, differential filtering preprocessing is first performed on the sleep physiological signals. Specifically, since the effective physiological information of EEG signals is mainly concentrated in the frequency band of 0.5Hz to 35Hz, which contains rhythmic components closely related to sleep stages such as delta waves, theta waves, alpha waves, sleep spindle waves, and K-complex waves, while the effective components of EOS signals are mainly concentrated in the low-frequency range of 0.3Hz to 10Hz, used to characterize EOS activity features such as slow eye movement and rapid eye movement, the first frequency band of 0.5Hz to 35Hz is used for bandpass filtering of the EEG signal detection channel to retain EEG sleep rhythm information and suppress low-frequency drift and high-frequency electromyographic noise; the second frequency band of 0.3Hz to 10Hz is used for bandpass filtering of the EOS signal detection channel to highlight low-frequency components related to eye movement and filter out high-frequency interference. After differential filtering is completed, subject-level standardization is performed on all valid sleep segments of the same subject: For the signal of the u-th subject and the c-th detection channel, the mean μ(u,c) and standard deviation σ(u,c) are calculated based on all valid sampling points of the subject in the detection channel, and then zero-mean unit variance transformation is performed on each sampling point n belonging to the subject in the detection channel according to the following formula (2): (2) , in, Indicates the original sampling amplitude. The amplitude is represented by ε, which is a preset numerical stability constant used to avoid division-by-zero anomalies when the standard deviation approaches zero. Through this subject-level standardization, signal amplitude scale shifts caused by differences in electrode impedance, scalp contact status, acquisition device gain, or individual physiological differences among different subjects are effectively eliminated, while the relative waveform structure evolving with the sleep process within the same subject is fully preserved. After the above differential filtering and subject-level standardization, a standardized sleep physiological signal is obtained. This standardized sleep physiological signal serves as input data for subsequent construction of the channel functional connectivity matrix and extraction of local temporal features. On the one hand, standardization eliminates the interference caused by differences in the dimensions and amplitude scales of signals from different channels on correlation calculations, enabling the channel functional connectivity matrix based on the Pearson correlation coefficient to truly reflect the physiological coupling strength between different brain regions / electrooscopic signal detection channels. On the other hand, the standardized signal has a more stable amplitude distribution and a more balanced gradient range, which is beneficial for parameter updates and convergence of the temporal convolutional network during training, thus providing a clean, comparable, and unbiased signal input basis for the subsequent processing of the entire automatic sleep staging method. By purifying the signal frequency band through differential filtering and then eliminating individual amplitude differences through subject-level standardization, clean, comparable, and unbiased input data is provided for subsequent detection channel correlation calculation and deep feature extraction.
[0043] Optionally, after completing the differential filtering and subject-level standardization of the sleep physiological signals, a continuous context window for context modeling is further constructed. Specifically, the standardized sleep physiological signal sequence is first divided into several continuous valid label segments according to the subject number, sleep record number, and label validity of each sleep segment. The sleep segments within each continuous valid label segment are arranged in chronological order, and adjacent sleep segments are all from the same subject and the same night record, thus ensuring that sleep segments from different subjects, different records, or unknown label intervals are not mistakenly spliced together during the subsequent window construction process. For the i-th sleep segment in any continuous valid label segment, it is determined as the central sleep segment to be classified, and the window radius is set to r. Then the window length S = 2r + 1, and the context window centered on the central sleep segment is constructed according to the following formula (3). :
[0044] This window is from the central sleep segment The window is composed of r sleep segments before the central sleep segment and r sleep segments after the central sleep segment. During window construction, when ir is less than the starting index of the current consecutive valid label segment or i+r is greater than the ending index of the current consecutive valid label segment, the out-of-bounds index value is restricted to the beginning or end index of the current consecutive valid label segment through a boundary clipping operation. This ensures that each context window maintains a fixed window length S and does not cross the segment boundary, while ensuring that all sleep segments involved in the processing have valid label information.
[0045] In one feasible embodiment of this application, the window radius r is set to 3, and the corresponding window length S is 7. That is, each central sleep segment to be classified uses its preceding 3 sleep segments, itself, and its following 3 sleep segments, totaling 7 consecutive sleep segments, to form a context window, covering 210 seconds of sleep context information. Through the above-mentioned central sliding window construction method, the sleep segment at the center of the window is used as the final classification object in both the training and inference phases. At the same time, the temporal evolution information of multiple consecutive sleep segments within the window can be observed simultaneously, providing a structured continuous input sequence for subsequent cross-time period context modeling, and effectively reducing the risk of misclassification of a single sleep segment due to short-term signal perturbations or artifact interference.
[0046] During training, each training sample contains S consecutive epochs, and its tensor shape can still be represented as... Further formation during batch input .
[0047] Step 102: Construct a channel function connection matrix based on the correlation between each pair of detection channels.
[0048] Specifically, the channel function connection matrix refers to a matrix formed based on the correlation or coupling relationship between different detection channels.
[0049] In some embodiments, based on standardized sleep physiological signals containing multiple detection channels that have been standardized at the subject level, all standardized waveforms of the same subject are vectorized separately for each detection channel. The Pearson correlation coefficient is calculated for the vectors of any detection channel i and detection channel j, and the absolute value is taken. The functional connectivity strength between the i-th detection channel and the j-th detection channel is calculated using formula (4): (4)
[0050] Among them, as, Let be the functional connectivity strength between the i-th and j-th detection channels. Iterate through all combinations of detection channels, treating each channel as a graph node and each functional connectivity strength as the edge weight between nodes, forming a channel functional connectivity matrix of dimension C×C. Where C represents the total number of detection channels. Channel function connection matrix. Each element takes a value between 0 and 1, with larger values indicating a stronger degree of synchronization between the two corresponding detection channels within the current subject or the current sleep record range. This channel functional connectivity matrix serves as a priori constraint input to the subsequent multi-detection channel graph attention module, ensuring that the graph attention learning process is not only data-driven but also guided by the measured coupling relationships of the detection channels, thereby achieving an explicit representation of the functional coupling relationships between sleep signals from multiple detection channels.
[0051] Optionally, the standardized sleep physiological signals include channel signals corresponding to multiple detection channels. The step of constructing a channel functional connectivity matrix based on the pairwise correlation between detection channels includes: Treat each detection channel as a graph node, and perform vectorization expansion operations on the channel signals of any two detection channels of the standardized sleep physiological signal to obtain two one-dimensional vectors; Calculate the Pearson correlation coefficient between two one-dimensional vectors, and use the absolute value of the Pearson correlation coefficient as the functional connectivity strength value between the corresponding two detection channels; Traverse all detection channel combinations and arrange all corresponding functional connection strength values into a square matrix with a dimension equal to the square of the number of detection channels to obtain the channel functional connection matrix.
[0052] For example, each detection channel is defined as a graph node in a graph structure. For any two detection channels i and j in the standardized sleep physiological signal, all sampling point sequences of the two detection channels within the same time range are extracted, and vectorization expansion operations are performed on each to convert the time-series signal data of each detection channel into a one-dimensional vector form, resulting in two one-dimensional vectors. Subsequently, according to the formula... Calculate the absolute value of the Pearson correlation coefficient between two one-dimensional vectors, and use this absolute value as the functional connectivity strength value between the i-th and j-th detection channels, where vec represents the vectorization expansion operation and corr represents the Pearson correlation coefficient operation. Iterate through all detection channel combinations, and arrange all the calculated functional connectivity strength values in order of detection channel index into a C×C square matrix to obtain the channel functional connectivity matrix. Where C represents the total number of detection channels. Since the absolute value of the Pearson correlation coefficient is taken, the elements in this channel functional connectivity matrix range from 0 to 1. A larger value indicates a stronger degree of synchronous change at the physiological level between the corresponding two detection channels, i.e., tighter functional coupling. Both positive and negative correlations are unified as a measure of coupling strength, thus comprehensively capturing the synchronous change relationship between detection channels without losing negative coupling information. This channel functional connectivity matrix serves as a priori relation input to the subsequent multi-detection channel graph attention module, making the learning process of graph attention weights not only data-driven but also guided and constrained by the measured coupling relationship of detection channels. When the functional connectivity strength between two detection channels is high, their corresponding attention scores are improved, and the sleep data processing model tends to focus more on the information interaction between these two detection channels; conversely, when the functional connectivity strength is low, the sleep data processing model's attention to the corresponding detection channel pair is suppressed. By constructing a channel functional connectivity matrix, an explicit representation and dynamic modeling of the functional connectivity relationships between sleep signals from multiple detection channels are achieved. This can adapt to changes in the correlation structure between detection channels caused by individual differences and the evolution of sleep processes in different subjects, avoiding the problem of spatial correlation information loss caused by simple cascading or fixed-weight fusion in existing technologies.
[0053] Step 103: Extract the temporal features of each channel signal for each sleep segment to obtain the local temporal features corresponding to each detection channel.
[0054] In some embodiments, for the standardized channel signals of each detection channel within each sleep segment, a sliding convolution operation is performed along the time axis using an independent one-dimensional convolution kernel. The convolution kernel size can be set to k, and the stride to s. The convolution kernel slides position-by-position on the signal sequence of length N for each detection channel, performing a weighted summation on the k consecutive sampling points covered and applying nonlinear activation, outputting the local temporal features corresponding to that detection channel. Each detection channel is convolved independently, without mixing across detection channels, thus preserving the local morphology and rhythmic information of the sleep waveform (such as spindle waves, K-complex waves, slow waves, etc.) within a single detection channel, providing a feature representation with temporal local awareness for subsequent fusion between detection channels.
[0055] Optionally, the step of extracting temporal features from each channel signal of each sleep segment to obtain the local temporal features corresponding to each detection channel includes: The signals from each channel of each sleep segment are input into an enhanced residual temporal convolutional network composed of cascaded layers of residual convolutional blocks; Each residual convolutional block sequentially performs one-dimensional convolution, batch normalization, nonlinear activation, random deactivation, and a second one-dimensional convolution. The input features of the input residual convolutional block are added to the output features of the second one-dimensional convolution to obtain the corresponding residual block output. At least one residual convolutional block uses dilated convolution. An adaptive average pooling operation is performed on the output features of the last residual convolutional block, and a linear mapping is performed on the average pooling operation results through a fully connected layer to obtain the local temporal features corresponding to each detection channel of each sleep segment in a preset dimension.
[0056] Specifically, this application provides a sleep data processing model for sleep staging of various sleep segments. Channel signals refer to the temporal signals recorded by each independently acquired channel in polysomnography, such as the EEG signal detection channel recording brain waves and the EEG signal detection channel recording eye movement potentials. These detection channels are acquired in parallel, collectively constituting sleep physiological signals. The sleep data processing model of this application includes an enhanced residual temporal convolutional network (RTC). The RTC is an improved convolutional neural network based on a temporal convolutional network architecture, incorporating a residual connection mechanism to alleviate the gradient vanishing problem in deep networks, and employing dilated convolution to expand the receptive field. It is specifically designed to extract local waveform features from one-dimensional temporal signals. Residual convolutional blocks are the basic processing units constituting the enhanced residual temporal convolutional network. Each residual convolutional block contains two one-dimensional convolution operations and corresponding batch normalization, nonlinear activation, and random deactivation. The input and output are added through residual connections, forming a closed-loop processing sequence of input-convolution transformation-residual addition.
[0057] For example, the enhanced residual temporal convolutional network consists of multiple cascaded residual convolutional blocks. Each residual convolutional block sequentially performs a one-dimensional convolution operation on the input data (standardized sleep physiological signals) to slide the convolutional kernel along the time dimension to extract local waveform patterns, a batch normalization operation to stabilize feature distribution and accelerate convergence, a nonlinear activation operation to introduce nonlinear expressive power, a random deactivation operation to randomly discard some neurons to reduce the risk of overfitting, and a second one-dimensional convolution operation to further abstract features. Subsequently, the original input features of the input residual convolutional block are added to the output features obtained after the second one-dimensional convolution operation to obtain the residual block output. This residual connection operation enables gradients to propagate more smoothly in the backpropagation process, effectively alleviating the gradient vanishing problem in deep network training. At least one residual convolutional block employs dilated convolution, which expands the receptive field of the convolutional kernel without increasing the number of parameters, enabling the sleep data processing model to capture sleep rhythm changes over a longer time range.
[0058] In one embodiment of this application, the enhanced residual temporal convolutional network includes three sequentially connected residual temporal convolutional blocks. The first residual convolutional block is used to extract local waveform features within a shorter time range. The second and third residual convolutional blocks employ dilated convolution with dilation factors set to 2 and 4, respectively, to progressively expand the temporal receptive field. The dropout rate for random deactivation in each residual block is set to 0.3. After the signals from each channel are processed by the above three layers of residual convolution, adaptive average pooling is performed on the feature map output by the last residual convolutional block to uniformly compress the time dimensions of different lengths into a fixed-length feature vector. Then, a fully connected layer performs a linear mapping on the pooled features to transform the feature vector into a preset dimension. The local temporal characteristics. In this implementation, a preset dimension. The value can be 128, therefore, for a sample containing S epochs and C detection channels, the temporal convolution output can be represented as H∈R^( ).
[0059] The extraction of temporal features from each channel signal of a sleep segment can be expressed by formula (5), which is as follows: , Where TCN represents Enhanced Residual Temporal Convolutional Network, and F(x) represents the convolutional feature transformation in the residual block. (x) represents the shortcut branch, and y represents the residual block output. For local temporal features, The signal represents the channel signal of a sleep segment. The ReLU function is defined as ReLU(x) = max(0,x), used to introduce non-linear expressive power; batch normalization is used to stabilize the feature distribution of different batches; adaptive average pooling is used to unify the temporal features of different lengths or different convolution output scales into a fixed-dimensional representation. Therefore, for a sample containing S sleep segments and C detection channels, the tensor dimension of the local temporal feature is S×C×128. Through the above processing, the original sampling point sequence of each detection channel is transformed into a fixed-dimensional local temporal feature, which simultaneously contains short-term waveform details and sleep rhythm information over a longer range. By performing temporal convolution processing on the channel signals corresponding to each detection channel of each sleep segment, the local temporal features corresponding to each detection channel are obtained. On the one hand, this allows the sleep data processing model to automatically learn rhythmic patterns such as delta waves, theta waves, sleep spindle waves, and K-complex waves related to sleep stages from the original waveform, freeing it from dependence on manual feature engineering. On the other hand, the local temporal features corresponding to each detection channel with fixed dimensions can serve as unified detection channel-level feature inputs for subsequent multi-detection channel graph attention modules and sleep stage relationship graph attention modules. This enables the graph attention mechanism to model the relationship between detection channels and learn the rules between stages in a fully abstracted and compressed feature space, providing a discriminative feature foundation that combines local details and temporal context for the entire automatic sleep staging method.
[0060] Step 104: The local temporal features corresponding to each detection channel of the same sleep segment are used as node features. The channel function connection matrix is used as a prior constraint. The channel relationship graph representation of the sleep segment is generated through the graph attention mechanism.
[0061] In some embodiments, after obtaining the local temporal features of each detection channel, the local temporal features of C detection channels within the same sleep segment are used as the graph node features of the detection channels. The channel functional connection matrix is used as the prior relationship between detection channels. The basic attention score between each detection channel node is calculated through a multi-head graph attention mechanism. Then, the functional connection strength in the channel functional connection matrix is logarithmically superimposed on the basic attention score. After normalization, the attention weight modulated by the measured coupling relationship of the detection channels is obtained. The features of each detection channel node are weighted and aggregated according to the attention weight. After residual connection, layer normalization and learnable channel aggregation weight aggregation, the channel relationship graph representation of the sleep segment is generated. Thus, the originally independent multi-channel signals are explicitly aggregated through graph structure to obtain the spatial correlation and functional coupling information between detection channels. This allows the sleep data processing model to adaptively extract the cooperative patterns between detection channels under the guidance of measured physiological relationships, providing discriminative features of the spatial dimension for subsequent fusion.
[0062] Optionally, the steps of using the local temporal features corresponding to each detection channel of the same sleep segment as node features, and using the channel function connectivity matrix as a prior constraint, to generate a channel relationship graph representation of the sleep segment through a graph attention mechanism include: Each detection channel within the same sleep segment is defined as a graph node, and the local temporal features corresponding to each detection channel are assigned to the corresponding graph node as the initial features of the graph node. The functional connection strength value between any two detection channels in the channel functional connection matrix is used as the prior relation weight between the corresponding graph nodes of the two detection channels. For each attention head in the graph attention mechanism, the initial features of each graph node are mapped to the subspace of the corresponding attention head using a learnable matrix to obtain the corresponding mapped features. For each pair of graph nodes, the mapping features of each pair of graph nodes in the subspace are concatenated and projected through the learnable attention vector corresponding to the attention head to obtain the basic attention score between the graph nodes. The logarithm of the functional connection strength value of the detection channel corresponding to the graph node in the functional connection matrix is multiplied by the preset modulation coefficient, and the resulting product is added to the basic attention score to obtain the prior relation modulated attention score. For each graph node, the attention score after modulating the prior relationship between the graph node and all other nodes is normalized according to the normalized exponential function to obtain the attention weight of the graph node to each other node. The initial features of other nodes are weighted and aggregated according to the attention weights, and the features obtained by aggregating multiple attention heads are concatenated to obtain the multi-head aggregated features of the graph nodes. The multi-head aggregated features are added to the mapped features of the initial features of the graph nodes after linear projection, and the addition result is subjected to layer normalization to obtain the updated feature representation of the graph nodes. By using learnable channel aggregation weights to perform weighted summation of the updated feature representations of each graph node, a channel relationship graph representation of the sleep segment is obtained.
[0063] For example, each detection channel within the same sleep segment is defined as a graph node, and the local temporal features corresponding to each detection channel are assigned to the corresponding graph node as its initial features. Simultaneously, the functional connectivity strength value between any two detection channels in the channel functional connectivity matrix is used as the prior relation weight between the graph nodes corresponding to the two detection channels. This prior relation weight directly participates in the modulation of the attention score in subsequent steps. For the k-th attention head in the graph attention mechanism, a learnable matrix is used... Perform a linear mapping on the initial features of each graph node, and then map the initial features of each node ( =[ , ,…, Projecting the attention onto the subspace of the corresponding attention head allows different attention heads to measure the correlation between nodes in their respective independent subspaces. , ,…, These correspond to the local temporal features of each detection channel for the sleep segment. For each pair of graph nodes (e.g., node i and node j), their mapping features in the subspace are concatenated and then processed through the learnable attention vector corresponding to the attention head. Projecting is performed, and then activated by a Leaky ReLU function to obtain the basic attention score between the graph nodes, as shown in Equation (6). Where || represents feature concatenation. This represents the basic attention score of node i to node j in the k-th attention head. Let be the learnable matrix of the k-th attention head. Let i be the initial feature of the graph node i. Let j be the initial features of the graph node. This is the attention vector corresponding to the k-th attention head. This is a linear activation function with leakage correction. The basic attention score is data-driven and does not contain any prior physiological information.
[0064] To incorporate the measured coupling relationship of the detection channels into the attention learning process, the logarithm of the functional connection strength value of the detection channel corresponding to the pair of graph nodes in the functional connection matrix is multiplied by a preset modulation coefficient λ, and the resulting product is superimposed on the basic attention score to obtain the attention score modulated by the prior relationship. This prior relationship modulation mechanism makes the attention score of the two detection channels significantly improved when the functional connection strength values of the two detection channels are large, and the sleep data processing model tends to focus more on the information interaction between the two nodes; when the functional connection strength value is small, the detection channel pair is suppressed in the attention calculation. The value of λ is preset according to the characteristics of the task and is used to control the strength of the prior constraint. When λ=0, it degenerates into pure data-driven graph attention. Then, for each graph node, its modulated attention score with all other nodes is normalized according to the normalized exponential function to obtain the attention weight of the graph node to each other node, as shown in formula (7): ,in, This represents the attention weight of node i to node j in the k-th attention head. This refers to the element in the i-th row and j-th column of the channel functional connectivity matrix, which represents the calculated functional connectivity strength value between detection channel i and detection channel j. The normalized exponential function operation is performed along the dimension of node j, where λ represents the functional connectivity prior modulation coefficient. Used to avoid log(0). When When the value is large, the attention score of the corresponding detection channel pair is more easily improved; when When the values are small, the detection channels can still acquire certain weights through learnable attention parameters, but these weights are suppressed by prior relationships. Therefore, this mechanism strikes a balance between empirical functional connectivity and task-driven learning. Through this prior modulation mechanism, the learning of graph attention is simultaneously guided by both data-driven approaches and the experimental coupling relationships of the detection channels.
[0065] Next, the initial features of other graph nodes are weighted and aggregated according to the aforementioned attention weights. The features obtained by the aggregation of multiple attention heads are then concatenated to obtain the multi-head aggregated feature of graph node i. The multi-head aggregation feature of graph node i can be obtained through formula (8). : Formula (8)
[0066] in, Let k be the total number of attention heads in a multi-head attention mechanism, and k iterates from 1 to H, traversing all attention heads. This is a vector concatenation operation. Let be the attention weight between node i and node j in the k-th attention head. Let be the learnable weight matrix corresponding to the k-th attention head. The initial features of the j-th graph node. In one implementation, the number of attention heads... The output dimension of each head is The concatenated data still yields a 128-dimensional node representation. The multi-head mechanism enables sleep data processing models to capture diverse detection channel interaction patterns from multiple different subspaces, enhancing feature expressiveness. To further improve training stability, multi-head feature aggregation is performed. The result of linear projection of the initial features of the graph nodes Add them together, and compare the results of the addition. Perform layer normalization to obtain the updated feature representation of node i in the graph. Specifically, the updated feature representation of graph node i can be calculated using the following formula (9). : Formula (9)
[0067] Here, LayerNorm represents layer normalization, which is used to standardize individual samples in the feature dimension; Proj represents linear projection, which is used to align dimensions when necessary; residual connections preserve the original feature information; and layer normalization stabilizes the feature distribution during training.
[0068] Finally, the updated feature representations of each graph node are weighted and summed using learnable channel aggregation weights, thus aggregating the information of all detection channel nodes within the sleep segment into a unified vector, yielding the channel relationship graph representation of the sleep segment. As shown in formula (10):
[0069] in, This can be obtained through softmax normalization, where represents the weight coefficient corresponding to the i-th channel, such that the sum of the aggregated weight coefficients of all channels equals 1. Let i be the updated feature representation of graph node i. The dimension is This includes spatial correlation and functional coupling information between different EEG / EOG detection channels within the same epoch. Thus, the originally independent multi-channel signals are explicitly aggregated through a graph structure to include spatial correlation and functional coupling information between detection channels. This allows sleep data processing models to adaptively extract collaborative patterns between detection channels under the guidance of measured physiological relationships. This addresses the problem of insufficient feature discriminativeness in existing technologies due to a lack of explicit modeling capabilities for detection channel correlations, and provides spatially discriminative features for subsequent adaptive fusion with stage relationship graph representations.
[0070] By embedding the physiological linkage of objective detection channels as a priori constraint into the attention weight calculation, the sleep data processing model adaptively allocates fusion weights based on the synchronization strength of real leads, explicitly models the spatial functional association of multiple detection channels, and outputs a detection channel relationship graph that can fully represent the collaborative sleep rhythm information of multiple leads, improve feature discrimination, provide high-quality spatial association representation for subsequent gating fusion, and solve the defects of existing technologies such as coarse detection channel fusion methods and loss of physiological coupling information leading to insufficient staging accuracy.
[0071] Step 105: Update the learnable sleep stage prototype vector based on the sleep stage transition probability matrix, and calculate the matching degree based on the channel average features of the sleep segment and the updated sleep stage prototype vector to obtain the stage relationship graph representation of the sleep segment.
[0072] In some embodiments, the sleep stage transition probability matrix P obtained by statistical normalization of the training set labels is retrieved, and learnable prototype vectors U corresponding to the five sleep stages W, N1, N2, N3, and REM are set. Matrix operations are then performed. The prototype is updated, incorporating stage evolution priors. The average local temporal features of all detection channels for a single sleep segment are averaged to obtain channel-averaged features. These are then used to calculate matching scores by performing scaled dot products with each updated prototype, followed by softmax to obtain stage attention weights. Stage prototypes are then aggregated using these weights, added to the channel-averaged feature projection results, and layer-normalized to output a stage relationship graph. Embedding sleep physiological transition patterns into feature learning, unlike post-processing rule correction, fully utilizes temporal evolution information to supplement the stage temporal correlations missing from the spatial features of the detection channels, thus improving the stability of transitional sleep segment discrimination.
[0073] Optionally, before the step of updating the learnable sleep stage prototype vector based on the sleep stage transition probability matrix, the method further includes: A sleep stage transition probability matrix is constructed by statistically analyzing the stage transition frequency between adjacent sleep segments based on sleep stage label sequences.
[0074] Specifically, the sleep stage transition probability matrix refers to the stage transition relationship matrix obtained by statistically analyzing adjacent epoch labels in the training set.
[0075] For example, obtain the continuous sleep stage label sequence of each subject in the training set, traverse each pair of adjacent sleep segments in the label sequence, and count the number of times the transition from one sleep stage a to another sleep stage b occurs. Let N(a,b) represent the number of times sleep stage a transitions to sleep stage b. Since sleep stages have a clear temporal evolution pattern in physiology—for example, the waking period usually enters the first light sleep stage first, and then gradually transitions to the second light sleep stage, deep sleep stage, or REM sleep stage, rather than being able to jump directly between any two stages—the frequency of stage transitions between adjacent sleep segments is not uniformly distributed, but rather concentrated between certain specific stages. After completing the frequency statistics for all training samples, calculate the sleep stage transition probability matrix P according to formula (11): Formula (11)
[0076] Where K represents the number of sleep stage categories, Let K be the transition probability, representing the probability that when a sleep segment is in sleep stage a, the next adjacent sleep segment will switch to sleep stage b. In this embodiment, K=5, corresponding to the waking period, the first light sleep period, the second light sleep period, the deep sleep period, and the REM sleep period, respectively. ε is a preset numerical stability constant used to avoid the denominator being zero when the total number of transitions from a certain initial stage is zero. For each initial sleep stage a, the number of times it transitions to each target stage b is divided by the total number of transitions from that initial stage to all K target stages, and then normalized to obtain the sleep stage transition probability matrix P expressed in probabilistic form. The resulting P is a K×K matrix, where the sum of the elements in each row is 1, representing the probability distribution of transitions from a specific initial stage to each target stage. After the sleep stage transition probability matrix is constructed, it serves as the prior structural input to the attention module of the sleep stage relationship graph, used to update the learnable sleep stage prototype vector. This ensures that the update process of each sleep stage node strictly follows the stage transition rules obtained from the training set statistics. Specifically, when updating, a stage node absorbs information from its "most likely to transition" neighboring stage nodes with higher weights, while absorbing information from stage nodes with lower transition probabilities with lower weights. Through this statistical normalization process, the stage evolution rules in clinical sleep staging can be transformed into computable numerical prior knowledge, providing a quantifiable and propagable transition probability basis for the subsequent generation of the stage relationship graph representation. This allows the sleep data processing model to perceive the temporal dependencies between sleep stages during the feature learning stage, rather than simply making fixed rule corrections after classification output. In the leave-one-out cross-validation scenario, the sleep stage transition probability matrix P is obtained only from the statistical analysis of the real label sequences of the training subjects, strictly avoiding the leakage of label information from the test subjects and ensuring the objectivity and reliability of the sleep data processing model evaluation.
[0077] Optionally, the steps of updating the learnable sleep stage prototype vector based on the sleep stage transition probability matrix and calculating the matching degree based on the channel average features of the sleep segment and the updated sleep stage prototype vector to obtain the stage relationship graph representation of the sleep segment include: Obtain the learnable sleep stage prototype vectors corresponding to each sleep stage category; The sleep stage transition probability matrix is multiplied by the matrix composed of the prototype vectors of each learnable sleep stage to obtain the updated sleep stage prototype vectors corresponding to each sleep stage category. The channel-averaged features of the sleep segment are obtained by averaging the local temporal features corresponding to each detection channel of the sleep segment. The matching degree between the channel average feature and each updated sleep stage prototype vector is calculated to obtain the matching score between the sleep segment and each sleep stage category. The matching scores are normalized using a normalized exponential function to obtain the attention weights of the sleep segments to the updated sleep stage prototype vectors corresponding to each sleep stage category. The updated sleep stage prototype vectors are weighted and summed according to the attention weights to obtain the weighted summation result. The weighted summation result is added to the result of linear projection of the channel average feature, and then layer normalization is performed to obtain a stage relationship diagram representation of the sleep segment.
[0078] For example, obtain the learnable sleep stage prototype vectors corresponding to each sleep stage category, and set K learnable sleep stage nodes, i.e. , ,…, Let U be a matrix consisting of K sleep stage categories, each corresponding to a learnable sleep stage prototype vector. U = [ , ,…, Each stage node is a preset dimension. The vector is U, therefore the dimension of U is . Unlike fixed one-hot encoded labels, stage nodes are learnable parameters that are updated together with other network parameters during the training of the sleep data processing model. They are used to learn typical patterns of different sleep stages in the feature space. Subsequently, the sleep stage transition probability matrix P is multiplied by the matrix U composed of the prototype vectors of each learnable sleep stage, according to formula (12). Obtain the updated sleep stage prototype vectors corresponding to each sleep stage category. Where, the dimension of P is... The dimension of U is ,therefore The dimension is still The physical meaning of this matrix multiplication operation is as follows: each stage node absorbs information from other stage nodes according to the transition probabilities statistically obtained from the training set. For example, when updating, the first light sleep stage node will absorb information from the awake stage node and the second light sleep stage node with a higher weight because physiologically there is a high transition probability between the awake stage and the first light sleep stage, and between the first light sleep stage and the second light sleep stage; while it will absorb information from stage nodes with lower transition probabilities with a lower weight. Through this propagation and update mechanism, the stage nodes are no longer independent of each other, but carry the prior knowledge of the transitions between sleep stages, enabling the sleep data processing model to perceive the temporal evolution pattern of the stages in the subsequent matching process.
[0079] After completing the prior propagation update for the learnable stage nodes, the local temporal features of each detection channel of the sleep segment are averaged channel by channel. The average of the local temporal features of the C detection channels is then calculated along the detection channel dimension to obtain the channel-averaged feature of the sleep segment. Channel average characteristics of sleep segments It aggregates overall information from all detection channels of the current sleep segment, with dimensions of Subsequently, the channel average characteristics were... Each updated sleep stage prototype vector The matching degree is calculated by using formula (13) to calculate the scaled dot product matching score between the current sleep segment and the prototype of each stage. : Formula (13)
[0080] in, This represents the matching score between the current sleep segment and the r-th sleep stage category. This is a scaling factor used to prevent softmax saturation caused by excessively large dot product values. This is a learnable query mapping weight matrix used to linearly map the channel-averaged features of sleep segments to obtain the query vector. This is a learnable key-map weight matrix used to linearly map the updated sleep stage prototype vector to obtain the key vector. This is the updated prototype vector for the r-th sleep stage; This represents the degree of attention the current sleep segment pays to the r-th stage prototype, i.e., the normalized matching score. The calculation of this attention weight allows the sleep data processing model to adaptively select the most relevant stage prototype for information aggregation based on the features of the current segment.
[0081] Next, based on attention weights For each updated sleep stage prototype vector Perform a weighted summation to obtain the weighted summation result. This weighted summation result aggregates information from all updated stage prototypes, with higher-weighted stage prototypes occupying a larger proportion of the aggregated result. Finally, the weighted summation result is combined with the result obtained by linear projection of the channel average features. The results are summed and layer normalized. The stage relationship diagram of the sleep segment is then calculated according to formula (14). : Formula (14)
[0082] in, For learnable projection mapping operations, This is the updated prototype vector for the r-th sleep stage. This represents the normalized matching weight between the sleep segment and the prototype of the r-th sleep stage. The stage relationship diagram represents the channel average characteristics of the sleep segment. The dimension is This stage relationship graph simultaneously carries three layers of information: first, the stage transition prior carried by the updated stage prototype; second, the signal state reflected by the channel average features of the current sleep segment; and third, the attention distribution determined by the matching relationship between the current segment and each stage prototype. The resulting stage relationship graph provides discriminative features in the temporal dimension for subsequent adaptive fusion with the channel relationship graph, enabling the sleep data processing model to perceive the statistical evolutionary relationships between sleep stages during the feature learning stage. This effectively improves upon the limitation of traditional methods where stage transition rules are only used as post-processing rules for correction.
[0083] Step 106: Merge the channel relationship diagram representation and the stage relationship diagram representation to obtain the corresponding fused features.
[0084] In some embodiments, after obtaining the channel relationship graph representation and the stage relationship graph representation respectively, the two are adaptively fused using a gating fusion mechanism. Specifically, the channel relationship graph representation corresponding to the same sleep segment is fused... Relationship diagram of stages The vectors are concatenated along the feature dimension, then input into a linear gated network and activated by the Sigmoid function to generate a dimensionally gated vector with the same feature dimension. , Each dimension of the dimension-by-dimensional gating vector takes a value between 0 and 1, and then is processed according to the formula. The two types of graph representations (channel relationship graph representation and stage relationship graph representation) are fused element-wise with weighted fusion. This represents element-wise multiplication. When one dimension of the dimensional gating vector is close to 1, that dimension emphasizes the information of the detection channel relationship graph; when one dimension of the dimensional gating vector is close to 0, it emphasizes the information of the stage relationship graph. Thus, adaptive fusion of the two types of graph representations is achieved, enabling the sleep data processing model to dynamically weigh the contribution of the spatial correlation information of the detection channel and the prior information of stage evolution to the current judgment based on the signal state of different sleep segments. This provides information-complete fusion features for subsequent cross-time period context modeling.
[0085] Optionally, the step of fusing the channel relationship diagram representation and the stage relationship diagram representation to obtain the corresponding fused features includes: The channel relationship graph representation and the stage relationship graph representation corresponding to the same sleep segment are concatenated along the feature dimension to obtain the concatenated joint feature vector; The joint feature vector is input into the gating network, and a linear transformation is performed through the gating network to generate a dimension-wise gating vector; By using the dimension-wise gated vectors to perform element-wise weighted summation on the channel relationship graph representation and the stage relationship graph representation, the fused features are obtained.
[0086] For example, the channel relationship diagram is represented Relationship diagram with stages Concatenation is performed along the feature dimension to obtain a dimension of 2. joint eigenvectors This concatenation operation places the detection channel spatial correlation information and stage evolution prior information into the same vector space, providing a complete input for the gating network. Subsequently, the joint feature vector is input into the linear gating network, and activated by a linear transformation and a nonlinear activation function, namely the Sigmoid function, according to the formula... Generate a gated vector with the same dimension as the feature. ,in and As learnable parameters for the gated network, the Sigmoid function restricts the gate value of each dimension to between 0 and 1, thereby allowing independent control of the proportion of the two types of graph representations in the fusion result according to the feature dimension.
[0087] Obtaining the dimension-wise gate vector Then, according to the formula Channel relationship diagram representation Relationship diagram with stages Perform element-wise weighted fusion, where ⊙ represents element-wise multiplication. The fused sleep segment-level features still have the following dimensions. This fusion mechanism is used when the dimension-wise gated vector... When a certain dimension's value is close to 1, the fusion result for that dimension mainly originates from the corresponding dimension information in the channel relationship graph representation, indicating that detecting the spatial correlation between channels is more crucial in that feature dimension of the current sleep segment; when When the value of a certain dimension is close to 0, the fusion result of that dimension mainly comes from the corresponding dimension information in the stage relationship graph representation, indicating that the temporal evolution pattern of sleep stages in that dimension is more discriminative; while when the gate value is in the middle value, the information of both types of graph representations is adopted proportionally.
[0088] This dimension-wise gating fusion mechanism enables adaptive fusion of channel relationship graph representations and stage relationship graph representations. The fusion weights are not pre-set fixed values, but are dynamically generated by the gating network based on the signal state of the current sleep segment. This allows the sleep data processing model to adaptively adjust the contribution ratio of spatial correlation information of detection channels and stage evolution prior information in the fusion features according to individual differences among subjects and the signal characteristics of different sleep stages (such as sleep onset, deep sleep, and REM sleep). This avoids the limitations of fixed-weight fusion strategies when dealing with diverse sleep patterns. The resulting fusion features... It also carries the functional coupling relationship between multiple detection channels within the same sleep segment and the temporal evolution law between sleep stages, providing complete and dynamically adaptable input features for subsequent cross-time context modeling.
[0089] Step 107: Perform cross-time context modeling based on the fusion features of multiple consecutive sleep segments, and output the sleep stage classification results of each sleep segment according to the context modeling results.
[0090] In some embodiments, the fusion features corresponding to multiple sleep segments in a continuous context window are arranged chronologically into a fusion feature sequence and input into a bidirectional long short-term memory network. The network captures dependencies from the past to the present through a forward propagation path and dependencies from the future to the present through a backward propagation path. The bidirectional hidden states are then concatenated to obtain the contextual hidden states of each sleep segment. These contextual hidden states are then input into a classifier, which converts them into a sleep stage probability distribution through linear mapping and a normalized exponential function. The probability distribution at the center of the window is selected as the final classification result for the current sleep segment to be classified. This ensures that the classification decision for each segment is made within the global context of the entire sleep process, effectively resisting local signal disturbances and short-term artifacts, and improving the accuracy and stability of sleep stage discrimination.
[0091] Optionally, the steps of performing cross-segment context modeling based on the fusion features of multiple consecutive sleep segments, and outputting the sleep stage classification results for each sleep segment based on the context modeling results, include: The fusion features corresponding to multiple consecutive sleep segments in a continuous context window are obtained, and the fusion features are arranged in chronological order of the corresponding sleep segments to form a fusion feature sequence. The fused feature sequence is input into a bidirectional long short-term memory network. The fused features are processed sequentially in chronological order through the forward propagation path of the bidirectional long short-term memory network to capture the contextual dependencies from past time periods to the current time period. The fused features are processed sequentially in reverse chronological order through the backward propagation path of the bidirectional long short-term memory network to capture the contextual dependencies from future time periods to the current time period. The hidden states output by the forward propagation path and the backward propagation path are concatenated to obtain the context hidden state corresponding to each sleep segment. The contextual hidden states of each sleep segment are input into the classifier. The classifier maps each contextual hidden state into a classification score vector with the same number of sleep stage categories. The classification score vector is then converted into a probability distribution of each sleep stage using a normalized exponential function. The sleep stage category corresponding to the maximum probability is selected as the sleep stage classification result of the sleep segment.
[0092] For example, the fusion features corresponding to S consecutive sleep segments in a continuous context window are obtained. These fusion features have been generated and stored in chronological order during preprocessing. The fusion features are then arranged according to the chronological order of their corresponding sleep segments, forming a dimensional array of S×... fusion feature sequence[ , ,…, ],in This represents the fused feature vector of the S-th sleep segment. The feature dimension is defined as follows. This fused feature sequence maintains the temporal order of sleep segments in the original recording, ensuring that subsequent temporal modeling can capture the true evolution trend of sleep processes. The fused feature sequence is then input into a bidirectional long short-term memory (LSTM) network. The bidirectional LSM network contains two independent propagation paths: a forward propagation path processes each fused feature sequentially from the beginning to the end of the window, allowing the network to gradually accumulate sleep state evolution information from the past to the present; the reverse propagation path processes each fused feature sequentially from the end to the beginning of the window, enabling the network to trace back contextual information from the future to the past. The hidden state dimension of both the forward and reverse paths is set to a preset value (128 in this embodiment). The hidden states output by each path are concatenated at each time step to form a contextual hidden state with a dimension of 2 × 128 = 256. It can also be remapped to 128 dimensions through linear projection. This process can be expressed as formula (16). Through a bidirectional propagation mechanism, the contextual hidden state of each sleep segment is... It also integrates sleep state information before and after the segment. The forward path captures the evolution trend from the past period to the current period, while the reverse path captures the retrospective information from the future period to the current period. This makes the judgment decision of the current segment not only depend on its own characteristics, but also benefit from the global context of the entire sleep process.
[0093] After obtaining the contextual hidden states of each sleep segment, each hidden state is input into a classifier for classification. The classifier includes a random dropout layer and a fully connected layer. The random dropout layer randomly drops some neurons with a preset probability to prevent overfitting, and the fully connected layer classifies each contextual hidden state... The latent state space is linearly mapped to a K-dimensional classification score vector (K is the number of sleep stage categories; in this embodiment, K=5, corresponding to the waking period, the first light sleep stage, the second light sleep stage, the deep sleep stage, and the REM sleep stage, respectively). Then, the classification score vector is converted into a probability distribution using a normalized exponential function. According to formula (17), the probability distribution of the s-th sleep segment belonging to each sleep stage is calculated.
[0094] Formula (17)
[0095] in, and These are the learnable parameters of the classifier. The category corresponding to the maximum probability value in the probability distribution is taken as the sleep stage classification result for that sleep segment. It should be noted that although the classification probability is calculated for all S consecutive sleep segments within the window, during training and inference, only the classification probability distribution located at the center of the window—that is, the (r+1)th position—is selected. As the final output of the sleep segment to be classified, this selection rule can be expressed as follows: The rationale behind this center selection strategy lies in the fact that when constructing a window centered on the i-th sleep segment, this segment is located in the very center of the window, and the r sleep segments before and after it serve as contextual information to aid in its discrimination. Other positions within the window lack this symmetrical contextual support. Therefore, during training, only the classification results at the center position are used to calculate the loss and perform backpropagation. This cross-segment contextual modeling step ensures that the final classification decision for each sleep segment is placed within the global context of the entire sleep process, effectively resisting interference from local signal disturbances and short-term artifacts, and particularly improving the discrimination reliability of transitional sleep stages such as N1.
[0096] Based on the sleep data processing method provided in this application, continuous sleep physiological signals are acquired and divided into multiple sleep segments according to a preset duration, establishing the basic time unit for all subsequent processing. The correlation between detection channels is calculated based on the sleep physiological signals, quantifying the strength of physiological coupling between different detection channels, and constructing a channel functional connectivity matrix to transform invisible correlations into explicit prior knowledge. Next, temporal convolution processing is performed on the signals of each channel in each sleep segment to obtain the corresponding local temporal features of each detection channel. The local temporal features of each detection channel within the same sleep segment are used as node features. Using the channel functional connectivity matrix as a prior constraint, the association information of multiple detection channels is dynamically fused, and a channel relationship graph representation of the sleep segment is generated through a graph attention mechanism. The sleep stage transition probability matrix is obtained, and the learnable sleep stage prototype vector is updated using this matrix. The matching degree is calculated based on the channel average features of the sleep segment and the updated sleep stage prototype vector, resulting in a stage relationship graph representation of the sleep segment. The sleep stage prototype is updated based on the statistical regularity of sleep stage jumps, and the sleep segment is matched with various sleep standard templates to mine the sleep evolution characteristics of the sleep segment. This application fuses channel relationship graph representations with stage relationship graph representations to obtain corresponding fused features, forming complete single-segment features. Based on the fused features of multiple consecutive sleep segments, cross-time context modeling is performed to mine the context dependencies between sleep segments. Based on the context modeling results, the sleep stage classification results of each sleep segment are output. On the one hand, this application refines the extraction of sleep waveform details of a single detection channel, and on the other hand, it explicitly models the dynamic physiological coupling relationship of multiple leads. At the same time, it integrates sleep evolution laws and long-term context, making up for the shortcomings of traditional methods that simply splice detection channels and lose lead linkage information. This solves the technical problem that the lack of explicit modeling ability of functional coupling relationship between multi-channel signals in existing sleep staging methods leads to insufficient sleep staging accuracy, and improves the recognition accuracy and result stability of all sleep stages.
[0097] In this application, the structure of the sleep data processing model provided is as follows: Figure 2 As shown.
[0098] Furthermore, training the sleep data processing model can employ the Focal Loss loss function with class weights. . The calculation method is shown in formula (18): Formula (18):
[0099] in, This represents the predicted probability corresponding to the true category. This represents the class weights corresponding to the true classes, and γ represents the focusing coefficient. This loss function... Introducing class weights on top of cross-entropy The focus factor γ allows the sleep data processing model to pay more attention to sleep stages with fewer samples and higher classification difficulty, especially helping to improve the identification performance of low-proportion stages such as N1, which are easily confused with W and N2. In one implementation, γ can be 2; the class weights can be determined based on the reciprocal of the number of samples for each sleep stage in the training set or its normalized form. The parameters of the sleep data processing model can be updated using the Adam or AdamW optimizer, and the initial learning rate can be set to... The weight decay coefficient can be set to The batch size is set to 32, and learning rate decay and early stopping strategies can be set in combination with validation set loss or validation set accuracy to improve training stability and generalization ability.
[0100] like Figure 3 As shown in the experimental results, the SleepGAT model proposed in this study achieved good sleep staging performance on the overall test results of 20 subjects, with an accuracy of 85.34%, a Macro-F1 score of 83.37%, and a Cohen's Kappa score of 80.47%. The Macro-F1 score indicates that the model has a relatively balanced classification ability in identifying multiple sleep stages, and the Cohen's Kappa score exceeding 80% indicates a high consistency between the model's predictions and the actual labels, demonstrating relatively stable overall staging performance.
[0101] Such as confusion matrix Figure 4 As shown, SleepGAT performed well in the W, N2, N3, and REM stages, with classification accuracy rates of 89.82%, 87.53%, 88.62%, and 90.33%, respectively. The REM stage had the highest recognition rate, indicating that the sleep data processing model could effectively capture the characteristic patterns of the REM sleep stage. The W and N3 stages also maintained recognition rates close to 90%, demonstrating the sleep data processing model's strong ability to distinguish between wakefulness and deep sleep. In contrast, the N1 stage had a recognition rate of 61.57%, significantly lower than other stages, with the main misclassifications being N2 stage (16.30%), REM stage (11.55%), and W stage (10.07%). This is consistent with the characteristics of the N1 stage in sleep staging tasks, such as a smaller sample size, less obvious transitional features, and blurred boundaries with adjacent stages, indicating that N1 remains the main challenge for sleep data processing models in identification.
[0102] From the error distribution, the misclassification of sleep data processing models mainly occurred between stages with similar physiological characteristics or frequent transitions. For example, there was some confusion between W and N1, with N1 being frequently misclassified as N2 or REM; 11.12% of N3 stages were misclassified as N2, reflecting that there is still feature overlap between deep sleep and light sleep in some segments. Overall, SleepGAT did not show a significant single-class bias, but maintained a high level of recognition in most sleep stages.
[0103] For example, the results of the ablation experiment are as follows Figure 5 As shown, the complete SleepGAT model achieves optimal performance, with accuracy, Macro-F1 score, and Cohen's Kappa of 85.34%, 83.37%, and 80.47%, respectively. When the multi-channel graph attention module is removed, the accuracy drops to 83.52%, the Macro-F1 score to 81.06%, and the Kappa to 78.14%, indicating that the multi-channel graph attention mechanism can effectively model the spatial correlation between different EEG detection channels and plays a crucial role in improving sleep staging performance.
[0104] After removing the sleep stage relationship graph attention module, the model accuracy was 83.89%, a decrease of 1.45 percentage points compared to the complete model. The Macro-F1 score and Kappa score dropped to 81.44% and 78.66%, respectively. This indicates that the temporal relationship graph attention module can further capture the temporal dependencies between sleep stages and makes a positive contribution to improving overall classification consistency. After removing BiLSTM, the accuracy dropped to 82.41%, the Macro-F1 score dropped to 79.68%, and the Kappa score dropped to 76.62%, showing the most significant performance decline. This demonstrates that bidirectional temporal modeling is crucial for extracting contextual features of sleep stages.
[0105] Furthermore, removing Focal Loss resulted in a model accuracy of 84.63%, a decrease of 0.71 percentage points compared to the full model, indicating that Focal Loss plays a role in mitigating class imbalance and improving the ability to identify difficult samples. Using only EnhancedResTCN, the accuracy was 80.96%, the Macro-F1 score was 77.83%, and the Kappa score was 74.85%, significantly lower than the full model, suggesting that relying solely on local temporal convolutional features is insufficient for fully identifying complex sleep stages.
[0106] In summary, SleepGAT achieves superior overall sleep staging performance through the synergistic effects of Enhanced ResTCN, multi-detection channel graph attention module, sleep stage relationship graph attention module, BiLSTM, and Focal Loss. Ablation experiments further validated the effectiveness of each component. BiLSTM, the graph attention module, and the class imbalance optimization strategy all significantly contributed to improving the performance of the sleep data processing model. The complete SleepGAT architecture can more fully integrate local temporal features, spatial relationships between detection channels, and dynamic dependencies between stages, thereby achieving optimal classification results.
[0107] This application also provides a sleep data processing device, please refer to... Figure 6 The sleep data processing device includes: The signal acquisition module 601 is used to divide the sleep physiological signals collected by multiple detection channels into multiple sleep segments based on a preset duration. The detection channel connection diagram construction module 602 is used to construct a channel function connection matrix based on the correlation between each pair of detection channels; The temporal convolution feature extraction module 603 is used to extract temporal features from each channel signal of each sleep segment to obtain the local temporal features corresponding to each detection channel. The multi-detection channel graph attention module 604 is used to take the local temporal features corresponding to each detection channel of the same sleep segment as node features, and use the channel function connection matrix as a prior constraint to generate a channel relationship graph representation of the sleep segment through the graph attention mechanism. The stage relationship graph attention module 605 is used to update the learnable sleep stage prototype vector based on the sleep stage transition probability matrix, and calculate the matching degree based on the channel average features of the sleep segment and the updated sleep stage prototype vector to obtain the stage relationship graph representation of the sleep segment. The gated fusion module 606 is used to fuse the channel relationship diagram representation and the stage relationship diagram representation to obtain the corresponding fusion features; The cross-sleep time classification module 607 is used to perform cross-sleep time context modeling based on the fusion features of multiple consecutive sleep segments, and output the sleep stage classification results of each sleep segment according to the context modeling results.
[0108] The sleep data processing apparatus provided in this application, employing the sleep data processing method described in the above embodiments, can solve the technical problem of insufficient sleep staging accuracy caused by the lack of explicit modeling capability for the functional coupling relationship between multi-channel signals in existing sleep staging methods. Compared with the prior art, the beneficial effects of the sleep data processing apparatus provided in this application are the same as those of the sleep data processing method provided in the above embodiments, and other technical features in the sleep data processing apparatus are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0109] This application provides a sleep data processing device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the sleep data processing method in the first embodiment described above.
[0110] The following is for reference. Figure 7 The diagram illustrates a structural schematic of a sleep data processing device suitable for implementing embodiments of this application. The sleep data processing device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, personal digital assistants (PDAs), tablet computers (PADs), portable media players (PMPs), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 7 The sleep data processing device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of this application.
[0111] like Figure 7As shown, the sleep data processing device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1002 or a program loaded from storage device 1003 into random access memory (RAM) 1004. The random access memory 1004 also stores various programs and data required for the operation of the sleep data processing device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the sleep data processing device to communicate wirelessly or wiredly with other devices to exchange data. Although a sleep data processing device with various systems is shown in the figure, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented alternatively.
[0112] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0113] The sleep data processing device provided in this application, employing the sleep data processing method described in the above embodiments, can solve the technical problem of insufficient sleep staging accuracy caused by the lack of explicit modeling capability for the functional coupling relationship between multi-channel signals in existing sleep staging methods. Compared with the prior art, the beneficial effects of the sleep data processing device provided in this application are the same as those of the sleep data processing method provided in the above embodiments, and other technical features in this sleep data processing device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0114] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0115] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included 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.
[0116] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, which are used to execute the sleep data processing method in the above embodiments.
[0117] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0118] The aforementioned computer-readable storage medium may be included in a sleep data processing device; or it may exist independently and not assembled into a sleep data processing device.
[0119] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by the sleep data processing device, the sleep data processing device performs the following actions: Based on a preset duration, it divides sleep physiological signals collected by multiple detection channels into multiple sleep segments; constructs a channel functional connection matrix based on the pairwise correlation between detection channels; extracts temporal features from each channel signal of each sleep segment to obtain local temporal features corresponding to each detection channel; uses the local temporal features corresponding to each detection channel of the same sleep segment as node features, and generates a channel relationship graph representation of the sleep segment through a graph attention mechanism, using the channel functional connection matrix as a prior constraint; updates the learnable sleep stage prototype vector based on the sleep stage transition probability matrix, and calculates the matching degree based on the channel average features of the sleep segment and the updated sleep stage prototype vector to obtain a stage relationship graph representation of the sleep segment; fuses the channel relationship graph representation and the stage relationship graph representation to obtain corresponding fused features; performs cross-time-segment context modeling based on the fused features of multiple consecutive sleep segments, and outputs the sleep stage classification results of each sleep segment based on the context modeling results.
[0120] Computer program products for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0121] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation that may be implemented in systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0122] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0123] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described sleep data processing method. This addresses the technical problem in existing sleep staging methods where the lack of explicit modeling of the functional coupling relationship between multi-channel signals leads to insufficient sleep staging accuracy. Compared to the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the sleep data processing method provided in the above embodiments, and will not be elaborated upon here.
[0124] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the sleep data processing method described above.
[0125] The computer program product provided in this application can solve the technical problem of insufficient sleep staging accuracy caused by the lack of explicit modeling capability of the functional coupling relationship between multi-channel signals in existing sleep staging methods. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as the beneficial effects of the sleep data processing method provided in the above embodiments, and will not be repeated here.
[0126] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A method for processing sleep data, characterized in that, The method for processing the sleep data includes: Based on a preset duration, the sleep physiological signals collected by multiple detection channels are divided into multiple sleep segments; Based on the pairwise correlation between the detection channels, a channel function connection matrix is constructed; Temporal features are extracted from the channel signals of each sleep segment to obtain the local temporal features corresponding to each detection channel; The local temporal features corresponding to each detection channel of the same sleep segment are used as node features, and the channel function connection matrix is used as a prior constraint to generate a channel relationship graph representation of the sleep segment through a graph attention mechanism. The learnable sleep stage prototype vector is updated based on the sleep stage transition probability matrix, and the matching degree is calculated based on the channel average features of the sleep segment and the updated sleep stage prototype vector to obtain the stage relationship graph representation of the sleep segment. The channel relationship diagram representation and the stage relationship diagram representation are fused to obtain the corresponding fused features; Cross-time context modeling is performed based on the fusion features of multiple consecutive sleep segments, and the sleep stage classification results of each sleep segment are output according to the context modeling results. The step of generating a channel relationship graph representation of the sleep segment by using the local temporal features corresponding to each detection channel of the same sleep segment as node features, and the channel function connection matrix as a prior constraint, through a graph attention mechanism includes: Each detection channel of the same sleep segment is defined as a graph node, and the local temporal features corresponding to each detection channel are assigned to the corresponding graph node as the initial features of the graph node. The functional connection strength value between any two detection channels in the channel functional connection matrix is used as the prior relationship weight between the graph nodes corresponding to the two detection channels. For each attention head in the graph attention mechanism, the initial features of each graph node are mapped to the subspace of the corresponding attention head using learnable matrix features, thereby obtaining the corresponding mapped features; For each pair of graph nodes, the mapping features of each pair of graph nodes in the subspace are concatenated and projected through the learnable attention vector corresponding to the attention head to obtain the basic attention score between the pair of graph nodes. The logarithm of the functional connection strength value of the detection channel corresponding to the graph node in the functional connection matrix is multiplied by a preset modulation coefficient, and the resulting product is added to the basic attention score to obtain the prior relation modulated attention score. For each graph node, the attention score modulated by the prior relationship between the graph node and all other nodes is normalized according to the normalized exponential function to obtain the attention weight of the graph node to each other node. The initial features of each other node are weighted and aggregated according to the attention weights, and the features obtained by aggregating multiple attention heads are concatenated to obtain the multi-head aggregated features of the graph nodes. The multi-head aggregated features are added to the mapped features of the initial features of the graph nodes after linear projection, and the addition result is subjected to layer normalization to obtain the updated feature representation of the graph nodes. The updated feature representations of each graph node are weighted and summed by learningable channel aggregation weights to obtain the channel relationship graph representation of the sleep segment.
2. The method for processing sleep data as described in claim 1, characterized in that, The detection channels include an electroencephalogram (EEG) signal detection channel and an electrooculogram (EOG) signal detection channel. The sleep physiological signals include EEG signals and EOG signals. After the step of acquiring continuous sleep physiological signals, the method further includes: The electroencephalogram (EEG) signal in the sleep physiological signal is bandpass filtered using a first frequency band, and the electrooculogram (EOG) signal in the sleep physiological signal is bandpass filtered using a second frequency band to obtain the filtered sleep physiological signal, wherein the high-frequency cutoff frequency of the first frequency band is higher than the high-frequency cutoff frequency of the second frequency band. Based on the filtered sleep physiological signals of the same subject, the mean and standard deviation of each detection channel are calculated. The sleep physiological signals of the subject at each sampling point in the corresponding detection channel are subjected to zero-mean unit variance transformation using the mean and the standard deviation to obtain standardized sleep physiological signals. The standardized sleep physiological signals are used as input data for subsequent construction of the channel functional connectivity matrix and extraction of the local temporal features.
3. The method for processing sleep data as described in claim 2, characterized in that, The standardized sleep physiological signal includes channel signals corresponding to multiple detection channels. The step of constructing a channel functional connectivity matrix based on the pairwise correlation between the detection channels includes: Treating each detection channel as a graph node, a vectorization expansion operation is performed on the channel signals of any two detection channels of the standardized sleep physiological signal to obtain two one-dimensional vectors; Calculate the Pearson correlation coefficient between the two one-dimensional vectors, and use the absolute value of the Pearson correlation coefficient as the functional connectivity strength value between the corresponding two detection channels; Traverse all detection channel combinations and arrange all corresponding functional connection strength values into a square matrix with a dimension equal to the square of the number of detection channels to obtain the channel functional connection matrix.
4. The method for processing sleep data as described in claim 2, characterized in that, The step of extracting temporal features from the channel signals of each sleep segment to obtain the local temporal features corresponding to each detection channel includes: The channel signals of each of the sleep segments are respectively input into an enhanced residual temporal convolutional network composed of cascaded multi-layer residual convolutional blocks; Each residual convolutional block sequentially performs one-dimensional convolution, batch normalization, nonlinear activation, random deactivation, and a second one-dimensional convolution. The input features of the residual convolutional block are added to the output features of the second one-dimensional convolution to obtain the corresponding residual block output. At least one residual convolutional block uses dilated convolution. An adaptive average pooling operation is performed on the output features of the last residual convolutional block, and a linear mapping is performed on the average pooling operation result through a fully connected layer to obtain the local temporal features corresponding to each detection channel of each sleep segment of a preset dimension.
5. The method for processing sleep data as described in claim 1, characterized in that, The steps of updating the learnable sleep stage prototype vector based on the sleep stage transition probability matrix, and calculating the matching degree based on the channel average features of the sleep segment and the updated sleep stage prototype vector to obtain the stage relationship graph representation of the sleep segment include: Obtain the learnable sleep stage prototype vectors corresponding to each sleep stage category; Multiply the sleep stage transition probability matrix with the matrix composed of the learnable sleep stage prototype vectors to obtain the updated sleep stage prototype vectors corresponding to each sleep stage category. The channel-averaged features of the sleep segment are obtained by averaging the local temporal features corresponding to each detection channel of the sleep segment. The matching degree of the channel average feature is calculated with each of the updated sleep stage prototype vectors to obtain the matching score between the sleep segment and each sleep stage category. The matching scores are normalized using a normalized exponential function to obtain the attention weights of the sleep segments to the updated sleep stage prototype vectors corresponding to each sleep stage category. The updated sleep stage prototype vectors are weighted and summed according to the attention weights to obtain the weighted summation result; The weighted summation result is added to the result of linear projection of the channel average feature, and layer normalization is performed to obtain the stage relationship diagram representation of the sleep segment.
6. The method for processing sleep data as described in claim 1, characterized in that, The step of fusing the channel relationship diagram representation with the stage relationship diagram representation to obtain the corresponding fused features includes: The channel relationship diagram representation and the stage relationship diagram representation corresponding to the same sleep segment are concatenated along the feature dimension to obtain a concatenated joint feature vector. The joint feature vector is input into a gating network, and a linear transformation is performed through the gating network to generate a dimension-wise gating vector; The fusion feature is obtained by performing an element-wise weighted summation operation on the channel relationship graph representation and the stage relationship graph representation using the dimension-wise gated vector.
7. The method for processing sleep data as described in claim 1, characterized in that, The step of performing cross-time context modeling based on the fusion features of multiple consecutive sleep segments, and outputting the sleep stage classification result of each sleep segment according to the context modeling result, includes: The fusion features corresponding to multiple consecutive sleep segments in a continuous context window are obtained, and the fusion features are arranged in chronological order according to the corresponding sleep segments to form a fusion feature sequence. The fused feature sequence is input into a bidirectional long short-term memory network. The fused features are processed sequentially in chronological order through the forward propagation path of the bidirectional long short-term memory network to capture the contextual dependencies from past time periods to the current time period. The fused features are processed sequentially in reverse chronological order through the backward propagation path of the bidirectional long short-term memory network to capture the contextual dependencies from future time periods to the current time period. The hidden states output by the forward propagation path and the backward propagation path are concatenated to obtain the context hidden state corresponding to each sleep segment. The contextual hidden states of each sleep segment are input into a classifier. The classifier maps each contextual hidden state into a classification score vector that is equal to the number of sleep stage categories. The classification score vector is then converted into a probability distribution for each sleep stage using a normalized exponential function. The sleep stage category corresponding to the maximum probability is selected as the sleep stage classification result of the sleep segment.
8. A sleep data processing device, characterized in that, The device includes: a memory, a processor, and a computer program stored on and executable on the memory, the computer program being configured to implement the steps of the method for processing sleep data as claimed in any one of claims 1 to 7.
9. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the sleep data processing method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Method and system for personalized, molecular based health management and digital consultation and treatment
US20210005327A1
Real-time artifact processing and feature extraction method and system for electroencephalogram signal
US20260058007A1
