Sleep stage diagnosis method, device and system and storage medium
The sleep EEG staging method based on multi-scale features and dual-path attention mechanism addresses the shortcomings of existing sleep staging methods in modeling dynamic sleep characteristics, significantly improving the accuracy and robustness of sleep staging, especially the recognition rate of N1 stage, and achieving efficient automatic sleep staging.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGDONG UNIV OF TECH
- Filing Date
- 2026-03-23
- Publication Date
- 2026-05-12
AI Technical Summary
Existing EEG sleep staging methods are unable to effectively model the periodicity of sleep as a long-term series and the dynamic characteristics of continuous and gradual changes between stages. They cannot discover unknown or difficult-to-describe feature patterns using existing knowledge, resulting in insufficient accuracy and robustness of automatic sleep staging.
A sleep EEG staging method based on multi-scale features and dual-path attention mechanism is adopted. Multi-scale features are extracted by wide-kernel and narrow-kernel convolutional branches. Adaptive residual channel attention, bidirectional long short-term memory network and hierarchical attention mechanism are combined to capture local temporal dependence and contextual information. Feature fusion is performed through dual-path sparse cross attention mechanism to enhance the ability to capture transient features.
It significantly improves the accuracy and robustness of sleep staging, especially the recognition rate of N1 stage, enhances the model's overall understanding and generalization ability of complex sleep patterns, and achieves efficient end-to-end automatic sleep staging.
Smart Images

Figure CN122004777A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of sleep EEG signal processing technology, specifically to a sleep EEG staging method, device, equipment, and storage medium based on multi-scale and dual-path attention mechanisms. Background Technology
[0002] Sleep is a crucial physiological foundation for maintaining human health. Sleep disorders can impair the function of multiple systems, including the immune system and memory, and are associated with the risk of various chronic diseases. Therefore, its detection in clinical practice is of paramount importance. However, manual diagnosis of EEG by experienced clinicians is time-consuming and inefficient, especially during long-term monitoring. Consequently, much research has focused on developing computer-aided diagnostic and automated classification methods to improve the efficiency of sleep analysis.
[0003] Existing EEG sleep staging methods can be broadly categorized into two types based on their processing logic: The first type relies on machine learning methods based on handcrafted features. These features are constructed using knowledge of sleep physiology to identify different sleep stages. For example, Zaman et al. extracted 14 time-domain features, 8 frequency-domain features, and 19 frequency-domain derived features from EEG signals using feature engineering blocks, and then used a machine learning model for classification, enhancing model interpretability. Mai et al. used nonlinear dimensionality reduction to reduce high dimensions to a two-dimensional power spectral density, and used feature-weighted kernel density estimation (KDE) to incorporate different physiological features as weights into the KDE, estimating the probability density distribution of different sleep stages on a two-dimensional plane, thus completing the staging. However, these methods treat sleep as a classification problem of a series of independent static segments, failing to effectively model the inherent periodicity and dynamic characteristics of sleep as a long-term series, and also failing to discover unknown or difficult-to-describe feature patterns using existing knowledge. The second type relies on data-driven deep learning methods to automatically extract discriminative features from EEG signals. For example, AttnSleep employs a dual-path convolutional neural network architecture, using convolutional kernels of different sizes to capture low-frequency and high-frequency features in sleep waveforms. This effectively enhances the model's ability to perceive multi-scale sleep events. XSleepNet, FFTCN, and MixSleepNet integrate time-frequency analysis to transform time-domain signals into the frequency domain for feature mining. This strategy helps the model utilize sleep physiological markers more directly. HybridDomainSleepNet uses a three-branch architecture to learn temporal, spatial, and spectral features respectively. The multi-domain feature fusion strategy constructs more discriminative feature representations, enhancing the model's overall understanding and generalization ability of complex sleep patterns. Yulita et al. combined long short-term memory units with deep belief networks to apply to sleep stage recognition, modeling the long-periodic temporal relationships of sleep stages. Zhao et al. proposed a multi-task deep learning framework that introduces an auxiliary task of sequence reconstruction. While completing the main task (sleep stage), the model needs to learn how to reconstruct or represent the input temporal data. This process forces the model to learn and retain richer, more discriminative temporal contextual features, thereby indirectly but effectively enhancing the staged sleep task's ability to perceive the dynamic transition patterns between sleep stages. The core innovation of Eldele et al. lies in a temporal context encoder that utilizes causal convolution to ensure predictive causality and employs an improved self-attention mechanism to capture global temporal correlations, thus directly characterizing the macroscopic cyclical pattern of sleep. Both Averbuch et al. and He et al. utilize wavelet theory to improve sleep staged sleep performance: the former focuses on signal purification fidelity through a directional wavelet packet algorithm, while the latter emphasizes enhancing the model's feature learning ability through a two-stream network based on wavelet decomposition. Summary of the Invention
[0004] The present invention aims to solve the above-mentioned problems existing in the prior art and provide a method, device, equipment and storage medium for sleep EEG staging based on multi-scale features and dual-path attention mechanism, so as to comprehensively capture the dynamic characteristics of sleep EEG signals and improve the accuracy and robustness of automatic sleep staging.
[0005] The present invention solves the technical problem by adopting the following technical solution:
[0006] This invention provides a sleep EEG staging method based on multi-scale features and a dual-path attention mechanism, comprising:
[0007] Step S1: Preprocess the raw sleep EEG signals to obtain the data to be classified;
[0008] Step S2: Input the EEG data to be classified into the multi-scale feature extraction module, and extract multi-scale features of the EEG signal in parallel through wide kernel convolution branches and narrow kernel convolution branches. The wide kernel convolution branch is used to capture low-frequency delta band features, and the narrow kernel convolution branch is used to capture α and θ band features.
[0009] Step S3: For the extracted multi-scale features, model the interdependencies between features through an adaptive residual channel attention module, and adaptively select the most discriminative features.
[0010] Step S4: Input the recalibrated multi-scale features into a parallel temporal attention network. The first path uses a bidirectional long short-term memory network combined with a temporal attention mechanism to extract local temporal dependencies, while the second path uses a hierarchical attention mechanism to capture contextual information between epochs of different coarse and fine granularities.
[0011] Step S5: The two features are interactively fused through dual-path sparse cross attention. During the fusion process, the extreme point features are extracted and dynamically fused with multi-scale pooling features to enhance the ability to capture transient theta waves. Then, the dynamic difference relationship between time steps is modeled through the differential attention mechanism to obtain a time series representation with full context awareness.
[0012] Step S6: Input the time series representation into the classification head to obtain the sleep stage prediction result.
[0013] Preferably, in step S2, the wide-kernel convolutional branch uses a convolutional layer with a kernel size of 400 and a stride of 5, corresponding to a 4-second time window; the narrow-kernel convolutional branch uses a convolutional layer with a kernel size of 50 and a stride of 6, corresponding to a 0.5-second time window; each branch consists of three convolutional layers and two max-pooling layers, and each convolutional layer is followed by a batch normalization layer using a Gaussian error linear unit as the activation function.
[0014] Preferably, in step S4, the second hierarchical attention mechanism reshapes the input features into a continuous sequence of segments. The segment sequence is grouped and compressed by the compression and selection module to generate compression keys and compression values. The most relevant group is selected and retained based on the importance score, thereby capturing contextual information between epochs of different coarse and fine granularities.
[0015] Preferably, in step S5, the dual-path sparse cross-attention module includes: in each branch, extracting multi-scale pooling features and extreme point features from the input features, and dynamically fusing them through learnable parameters to obtain keys and values; performing Top-K sparsification by querying the similarity matrix with the keys to generate two attention weights with different sparsities; and finally, using a gating network to weighted sum the outputs of the two branches.
[0016] This invention also provides a sleep EEG staging device based on multi-scale features and a dual-path attention mechanism, comprising:
[0017] The first processing module is used to preprocess the raw sleep EEG signals to obtain EEG data to be classified.
[0018] The second processing module is used to input the EEG data to be classified into the multi-scale feature extraction module, and extract multi-scale features of the EEG signal in parallel through wide kernel convolution branches and narrow kernel convolution branches. The wide kernel convolution branch is used to capture low-frequency delta band features, and the narrow kernel convolution branch is used to capture α and θ band features.
[0019] The third processing module is used to model the interdependencies between the extracted multi-scale features through an adaptive residual channel attention module, and adaptively select the most discriminative features.
[0020] The fourth processing module is used to input the multi-scale features into a parallel temporal attention network. The first path uses a bidirectional long short-term memory network combined with a temporal attention mechanism to extract local temporal dependencies, and the second path uses a hierarchical attention mechanism to capture contextual information between epochs of different coarse and fine granularities.
[0021] The fifth processing module uses dual-path sparse cross-attention to interactively fuse the two features, and then uses a differential attention mechanism to model the dynamic difference relationship between time steps to obtain a temporal representation with full context awareness.
[0022] The sixth processing module is used to input the time series representation into the classification head to obtain the sleep stage prediction result.
[0023] The present invention also provides a sleep EEG staging system, including a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes the sleep staging method described above when executed by the processor.
[0024] The present invention also provides a storage medium storing a computer program, which executes a sleep EEG staging method based on multi-scale features and a dual-path attention mechanism when running.
[0025] Compared with the prior art, the present invention has the following beneficial effects:
[0026] First, this invention uses a parallel temporal attention network, employing Bi-LSTM combined with temporal attention to extract local temporal dependencies within an epoch, and a hierarchical attention mechanism to capture contextual information between epochs. This effectively solves the imbalance between the global correlation modeling ability and the local continuous dynamic characterization ability of existing methods, and is more in line with the physiological continuity of sleep from light sleep to deep sleep and from wakefulness to sleep.
[0027] Second, the dual-path sparse cross-attention mechanism proposed in this invention maintains the integrity of information within and between cycles through a dual-path fusion architecture, avoiding feature loss. At the same time, an extremum enhancement mechanism is introduced to enhance the representation ability of the theta wave in the N1 stage of transient events by extracting local extremum features, which significantly improves the problem of low recognition rate in the N1 stage of traditional methods. Furthermore, by dynamically fusing multi-path features through learnable parameters, the overall understanding and generalization ability of the model for complex sleep patterns are improved. Attached Figure Description
[0028] To more clearly illustrate the technical solution of the present invention, the drawings used in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0029] Figure 1 This is a flowchart of the sleep staging method of the present invention;
[0030] Figure 2 To extract multi-scale feature structure maps;
[0031] Figure 3 This is a structural diagram of the adaptive residual channel attention module;
[0032] Figure 4 This is a schematic diagram of a multi-scale periodic network;
[0033] Figure 5 This is a schematic diagram of a parallel temporal attention module;
[0034] Figure 6 This is a schematic diagram of a dual-path sparse cross-attention module; Detailed Implementation
[0035] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0036] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0037] Example 1
[0038] like Figure 1 As shown, this invention provides a method for sleep staging based on multi-scale and dual-path attention mechanisms, comprising:
[0039] Step S1: Preprocess the raw sleep EEG signals;
[0040] Step S2: Input the EEG data to be classified into the multi-scale feature extraction module, and extract multi-scale features of the EEG signal in parallel through wide kernel convolution branches and narrow kernel convolution branches. The wide kernel convolution branch is used to capture low-frequency delta band features, and the narrow kernel convolution branch is used to capture α and θ band features.
[0041] Step S3: Recalibrate the weights of the fused multi-scale features using adaptive channel residuals, and adaptively select the most discriminative features;
[0042] Step S4: Input the recalibrated features into a parallel temporal attention network. The first path uses a bidirectional long short-term memory network combined with a temporal attention mechanism to extract temporal dependencies within an epoch. The second path uses compression and selection mechanisms to capture contextual information between epochs of different coarse and fine granularities.
[0043] Step S5: The two features are interactively fused through dual-path sparse cross-attention. The information of extreme points is introduced into the dual-path fusion to enhance the model's ability to capture theta waves, thereby improving the classification accuracy of N1 sleep stages. Then, the dynamic difference relationship between time steps is modeled through differential attention mechanism to obtain a temporal representation with full context awareness.
[0044] Step S6: Input the time series representation into the classification head to obtain the sleep stage prediction result.
[0045] Each stage unfolds from bottom to top: First, multi-scale feature extraction captures features of different frequency bands in parallel; then, feature weights are recalibrated through adaptive channel attention; subsequently, the optimized features are input into a parallel temporal attention network to capture local and long-term temporal dependencies within and between epochs, and multi-perspective feature dynamic fusion is achieved through dual-path sparse cross attention; finally, sleep staging results are output through the classification head to complete end-to-end intelligent diagnosis.
[0046] As one embodiment of the present invention, step S1 includes:
[0047] Step 1.1: Prepare the dataset
[0048] We used the public datasets Sleep-EDF78 and SHHS as our experimental datasets. The Sleep-EDF78 dataset contains data from 78 subjects, with two polysomnography (PSG) datasets, each approximately 20 hours long. Data from the first night of subject 36, the first night of subject 52, and the second night of subject 13 were lost, resulting in a total of 153 sleep data points at a sampling rate of 100 Hz. The SHHS dataset contains two independent acquisition phases: SHHS-v1 and SHHS-v2. Each record includes a 125 Hz dual-channel electroencephalogram (EEG), a dual-channel electromyography (EMG), and a lead II electrocardiogram (ECG). Due to computational resource limitations and to reduce the impact of disease diversity on the analysis, we selected 329 PSG records from SHHS-v1 and analyzed them using the C4-A1 EEG channels. According to the American Academy of Sleep Medicine (AASM) guidelines, sleep is divided into wakefulness, rapid eye movement (REM) sleep, and non-rapid eye movement (NREM) sleep. NREM is further subdivided into N1, N2, and N3.
[0049] In this invention, the data is divided using five-fold cross-validation. Specifically, the subjects in the dataset are randomly divided into five folds, each containing data from different subjects. During each validation process, one fold is selected as the test set, and the data from the remaining four folds is used three times for training and once for validation. In this way, the data from each subject is used as part of the test set, ensuring the stability of the results and the generalization ability of the model.
[0050] Step 1.2: Data Preprocessing
[0051] All data is divided into 30-second segments and then filtered through a bandpass filter from 0.5Hz to 45Hz.
[0052] As one embodiment of the present invention, step S2 includes:
[0053] Step 2.1: Multi-scale feature extraction
[0054] The structure of a multi-scale feature extractor is as follows: Figure 2 As shown in (a), the network consists of two parallel branches at different scales. Each branch consists of three convolutional layers and two max-pooling layers, where each convolutional layer contains a batch normalization layer and uses a Gaussian error linear unit (GELU) as the activation function, as follows. Figure 2 As shown in (b), the first convolutional layer uses a kernel size of 50, 32 channels, and a stride of 6, and a kernel size of 400, 32 channels, and a stride of 5 to capture information at different scales, while increasing the channel dimension to 32. The second layer uses a kernel size of 8, 64 channels, and a stride of 1, and a kernel size of 7, 64 channels, and a stride of 1 to expand the channel dimension to 64 to enhance feature representation. The third layer is designed the same as the second layer, further deepening feature extraction without changing the dimension. Finally, the two branches are connected in the time dimension. To reduce overfitting, a dropout mechanism is applied after the first max pooling of the two branches.
[0055] As one embodiment of the present invention, step S3 includes:
[0056] Step 3.1 Adaptive Residual Channel Attention Calibration
[0057] The extracted multi-scale features are recalibrated using adaptive residual channel attention (ASE) to improve the performance of the learned features. The ASE structure is as follows: Figure 3 As shown, the module first performs a series of convolutional transformations on the input features, then compresses spatial information through global average pooling to generate statistics that describe the global feature distribution. These statistics undergo nonlinear transformations through two fully connected layers. The first fully connected layer reduces dimensionality, while the second fully connected layer restores the original dimensionality and applies a sigmoid activation function, thereby generating corresponding weight coefficients for each feature channel. These weight coefficients are multiplied element-wise with the original features to achieve adaptive weighting for different feature channels, enhancing useful features and suppressing redundant information. Finally, a residual connection is introduced to add the original input to the weighted features, preserving the original feature information while incorporating the enhanced features learned by the module.
[0058] As one embodiment of the present invention, step S4 includes:
[0059] Step 4.1 Parallel Temporal Context Modeling
[0060] Parallel temporal attention networks employ a dual-path parallel attention mechanism to capture the temporal dynamics of electroencephalogram (EEG) signals within and between segments. Parallel temporal attention networks, such as... Figure 5 As shown.
[0061] After adaptive residual channel attention (ASE) is obtained B represents the batch size, L represents the length, and C represents the number of channels. Within a segment, to avoid the high computational cost of standard self-attention mechanisms on long sequences, a more computationally efficient Bi-LSTM is used to model long-range bidirectional dependencies and extract periodic temporal dynamics.
[0062]
[0063] These features are then optimized using token-attention to enhance the representation of key time steps. First, adaptive average pooling is applied to the input features. Next, the pooling results are sequentially fed into two linear layers, and attention weights are generated using the sigmoid function. Finally, these weights are multiplied element-wise with the original features to obtain the optimized features. .
[0064]
[0065] To capture long-range dependencies within long-term sleep time-series segments, this invention transforms individual segments into consecutive segments and then introduces a "compression and selection" module. First, the segments are... Remodeling 'n' represents the number of tokens. Specifically, the features... The input is processed by a "compression and selection" algorithm, which divides the multi-time-segment feature sequence into fixed-length sub-units. Generate query tags through linear transformation Each subunit is then compressed using MLP to generate a compression key. Compression value representation Compressed representations can capture coarser-grained, high-level semantic information and reduce the computational burden of attention mechanisms.
[0066]
[0067]
[0068]
[0069] The selection strategy identifies and retains the tokens of the most relevant groups using compressed key-value pairs. These tokens are retained from the top n groups ranked by group importance score, calculated using the following formula:
[0070]
[0071]
[0072]
[0073] in, This indicates the ranking position in descending order. The highest score. The set of group indices selected based on ranking. For fine-grained values. There are similar formulas. (Settings) This means focusing on the group with the highest score.
[0074] Final output between segments It is a dynamic combination of the two mapping strategies mentioned above, specifically expressed as follows:
[0075]
[0076] in, and These are the gate scores for the corresponding strategies, obtained from the query through MLP and sigmoid activation functions. This is derived from...
[0077]
[0078] As one embodiment of the present invention, step S5 includes:
[0079] Step 5.1 Dual-path feature fusion
[0080] Existing multi-scale sparse cross-attention mechanisms employ a single-path mechanism, making it difficult to fully integrate complementary information from intra-cycle and inter-cycle contexts. Furthermore, their simple pooling and fusion strategies struggle to effectively capture transient features in sleep EEG signals. This limitation is particularly pronounced when identifying the N1 sleep stage, where the distinctive, transient, and dispersed theta bands are difficult to detect effectively using conventional methods. These bands appear only as isolated, sparse local feature points in the waveform, and this transient pattern is difficult for conventional methods to capture effectively. To address these issues, this invention proposes a dual-path sparse cross-attention mechanism: while retaining the multi-scale and sparsity advantages of multi-scale sparse cross-attention, two key improvements are introduced: first, a dual-path fusion architecture is employed to maintain the integrity of intra-cycle and inter-cycle information; second, extreme value features are introduced to enhance transient representation, and dynamic feature fusion is achieved through learnable parameters. The dual-path multi-scale sparse cross-attention structure is as follows: Figure 6 As shown.
[0081] First, in each independent branch, from the input (or Extract multi-scale pooling features and extreme point information (N) from the data, and dynamically fuse them to obtain the desired results. (or These features are then projected onto the key K and value V tags.
[0082]
[0083] in, and These are learnable parameters, with average pooling sizes of 3, 5, and 7. The calculation formula is as above. The calculation method for the extreme point (N) is as follows: for each element of the input sequence... (or Applying first-order differences, where i ∈ 1, 2, ..., n, yields a difference sequence. (i ∈ 1, 2, ..., n−1). The first n−2 terms are designated as the left difference. Finally, the n-2 terms are defined as the right-hand difference. .like and If the signs are opposite, the corresponding mask value is set to 1; otherwise, it is set to 0. The formula is as follows:
[0084]
[0085] The first and last elements of the input sequence are predefined as extreme points, thus generating an extreme value mask N. Finally, through learnable parameters... and Multi-scale average pooling features are fused with extreme point features.
[0086] Subsequently, the attention similarity matrix for each branch is obtained by multiplying Q and K⊤ and then performing softmax normalization. Each matrix is then subjected to Top-K sparsification: in the first branch, the first row of each row is retained... The elements are retained in the second branch. elements ( This generates two independent sparse attention maps, as shown in the following formula:
[0087]
[0088] Another branch The formula is as above. Finally, the outputs of the two parallel branches are summed by a gating network to obtain the final result.
[0089] To enhance the modeling ability of long-term features, the fused features are optimized using a differential attention mechanism, followed by layer normalization. The normalized features undergo a non-linear transformation through a feedforward network consisting of two linear layers and a ReLU activation function, with residual connections introduced to preserve original information and mitigate gradient vanishing. Finally, the processed features are fed into a classification head to complete the prediction during the sleep phase, such as... Figure 4 As shown.
[0090] The final deployment model of this invention can achieve lightweight end-to-end inference while maintaining high accuracy, thereby constructing a low-cost, high-efficiency, and easy-to-deploy automated sleep staging system. This invention realizes a natural transition from "multi-scale, multi-perspective feature learning" to "end-to-end staging decision-making," enabling the model to complete clinically valuable automated sleep staging tasks without relying on complex preprocessing or multimodal devices in actual clinical applications.
[0091] This invention constructs a smart diagnostic framework for sleep EEG staging based on "multi-scale feature extraction—dual-path temporal modeling—dynamic cross-fusion". Its innovations are reflected in the following two aspects:
[0092] (1) At the temporal modeling level, a dual-path parallel temporal attention network was designed.
[0093] To address the physiological characteristics of sleep stages, which are influenced by both the signal features within a single epoch and the evolutionary patterns of the transition period between adjacent epochs, this invention constructs two parallel pathways: one within an epoch and one between epochs. The intra-epoch pathway employs a bidirectional long short-term memory network combined with a temporal attention mechanism to accurately extract key time-step features within a single epoch. The inter-epoch pathway uses a hierarchical attention mechanism, taking a continuous epoch sequence as input and capturing contextual information of varying granularities through compression and selection modules. This dual-parallel structure effectively solves the imbalance between global correlation modeling and local continuous dynamic characterization in existing methods, achieving comprehensive modeling of the dynamic evolutionary patterns of sleep stages.
[0094] (2) At the feature fusion level, a dual-path sparse cross-attention mechanism that incorporates extreme point information is designed.
[0095] To fully integrate complementary features within and between epochs, this invention employs a dual-path fusion architecture to maintain the integrity of both paths of information and avoid feature loss. Simultaneously, for the numerous transient features present in sleep EEG (such as theta waves in the N1 stage), an innovative extreme point enhancement mechanism is introduced: local extreme points are extracted using first-order difference to generate an extreme value mask, which is then dynamically fused with multi-scale pooling features through learnable parameters. This effectively enhances the ability to capture sparse transient events, solves the problems of excessive smoothing and noise redundancy caused by conventional pooling and standard cross-attention, and significantly improves the recognition accuracy for difficult-to-separate stages such as N1.
[0096] The present invention has the following beneficial effects:
[0097] (1) Modeling the dynamic characteristics of sleep time sequence to improve the accuracy of stage segmentation. This invention constructs parallel feature extraction branches within and between epochs to capture the local temporal features within a single sleep stage and the continuous evolution patterns between adjacent stages. Compared with traditional methods that treat sleep stages as independent static segments, this invention can effectively model the physiological continuity of sleep transition from wakefulness to deep sleep, especially enhancing the sensitivity to transitional signals (such as N1 and REM transition periods), thereby significantly improving the overall stage segmentation accuracy, especially improving the classification performance at stage boundaries and enhancing the robustness of the model.
[0098] (2) Significantly improves transient feature recognition ability. Addressing the sparse transient features commonly found in EEG but difficult to capture (such as the theta wave burst in the N1 phase), this invention innovatively introduces an extreme point detection mechanism into the dual-path sparse cross-attention module. By extracting local extreme features to generate an extreme value mask and dynamically fusing it with multi-scale pooling features, the over-smoothing problem caused by conventional pooling is effectively avoided, enhancing the response to key transient events. This significantly improves the classification accuracy for difficult-to-identify phases such as N1, demonstrating superior discrimination accuracy and stronger robustness.
[0099] Example 2
[0100] The present invention also provides a sleep diagnostic device, comprising: a first processing module for preprocessing the acquired raw electroencephalogram (EEG) information;
[0101] The second processing module is used to input the preprocessed EEG data into the multi-scale feature extraction module, and extract multi-scale features of the EEG signal in parallel through wide kernel convolution branches and narrow kernel convolution branches. The wide kernel convolution branch is used to capture low-frequency delta band features, and the narrow kernel convolution branch is used to capture α and θ band features.
[0102] The third processing module is used to recalibrate the weights of the fused multi-scale features and adaptively select the most discriminative features; the fourth processing module is used to input the multi-scale features into a parallel temporal attention network, wherein the first path uses a bidirectional long short-term memory network combined with a temporal attention mechanism to extract local temporal dependencies, and the second path uses a hierarchical attention mechanism to capture contextual information between epochs of different coarse and fine granularities.
[0103] The fifth processing module uses dual-path sparse cross-attention to interactively fuse the two features, and then uses a differential attention mechanism to model the dynamic difference relationship between time steps to obtain a temporal representation with full context awareness.
[0104] The sixth processing module is used to input the time series representation into the classification head to obtain the sleep stage prediction result.
[0105] As one embodiment of the present invention, the first processing module filters the segmented 30-second sleep information to obtain a standardized sleep sample.
[0106] Example 3
[0107] The present invention also provides a sleep staging diagnostic system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program, when executed by the processor, performs a sleep EEG staging method based on a multi-scale and dual-path attention mechanism.
[0108] Example 4
[0109] The present invention also provides a storage medium storing a computer program, which executes a sleep EEG staging method when running.
[0110] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made by those skilled in the art to the technical solutions of the present invention without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.
Claims
1. A sleep EEG staging method based on multi-scale and dual-path attention mechanisms, characterized in that, include: Step S1: Preprocess the raw sleep EEG signals; Step S2: Input the EEG data to be classified into the multi-scale feature extraction module, and extract multi-scale features of the EEG signal in parallel through wide kernel convolution branches and narrow kernel convolution branches. The wide kernel convolution branch is used to capture low-frequency delta band features, and the narrow kernel convolution branch is used to capture α and θ band features. Step S3: Recalibrate the weights of the fused multi-scale features using adaptive channel residual channel attention, and adaptively select the most discriminative features; Step S4: Input the recalibrated features into a parallel temporal attention network. The first path uses a bidirectional long short-term memory network combined with a temporal attention mechanism to extract temporal dependencies within an epoch. The second path uses compression and selection mechanisms to capture contextual information between epochs of different coarse and fine granularities. Step S5: The two features are interactively fused through dual-path sparse cross attention. The information of extreme points is introduced into the dual-path fusion to enhance the model’s ability to capture theta waves, thereby improving the accuracy of N1 class. Then, the dynamic difference relationship between time steps is modeled through differential attention mechanism to obtain a time series representation with full context awareness. Step S6: Input the time series representation into the classification head to obtain the sleep stage prediction result.
2. The sleep EEG staging method as described in claim 1, characterized in that, In step S2, the wide-kernel convolution branch uses a convolutional layer with a kernel size of 400 and a stride of 5, corresponding to a 4-second time window; the narrow-kernel convolution branch uses a convolutional layer with a kernel size of 50 and a stride of 6, corresponding to a 0.5-second time window; each branch consists of three convolutional layers and two max-pooling layers, and each convolutional layer is followed by a batch normalization layer with Gaussian error linear units as the activation function.
3. The sleep EEG staging method as described in claim 1, characterized in that, In step S4, the second hierarchical attention mechanism reshapes the input features into a continuous sequence of segments. The segment sequence is grouped and compressed by the compression and selection module to generate compression keys and compression values. The most relevant group is selected and retained based on the importance score, thereby capturing contextual information between epochs of different coarse and fine granularities.
4. The sleep EEG staging method as described in claim 1, characterized in that, In step S5, the dual-path sparse cross-attention module includes: in each branch, extracting multi-scale pooling features and extreme point features from the input features, and dynamically fusing them through learnable parameters to obtain keys and values; performing Top-K sparsification by querying the similarity matrix with the keys to generate two attention weights with different sparsities; and finally, using a gating network to weighted sum the outputs of the two branches.
5. A sleep EEG staging device based on multi-scale features and a dual-path attention mechanism, characterized in that, include: The first processing module is used to preprocess the acquired raw EEG information; The second processing module is used to input the preprocessed EEG data into the multi-scale feature extraction module, and extract multi-scale features of the EEG signal in parallel through wide kernel convolution branches and narrow kernel convolution branches. The wide kernel convolution branch is used to capture low-frequency delta band features, and the narrow kernel convolution branch is used to capture α and θ band features. The third processing module is used to recalibrate the weights of the fused multi-scale features and adaptively select the most discriminative features; the fourth processing module is used to input the multi-scale features into a parallel temporal attention network, wherein the first path uses a bidirectional long short-term memory network combined with a temporal attention mechanism to extract local temporal dependencies, and the second path uses a hierarchical attention mechanism to capture contextual information between epochs of different coarse and fine granularities. The fifth processing module uses dual-path sparse cross-attention to interactively fuse the two features, and then uses a differential attention mechanism to model the dynamic difference relationship between time steps to obtain a temporal representation with full context awareness. The sixth processing module is used to input the time series representation into the classification head to obtain the sleep stage prediction result.
6. A sleep EEG staging system based on multi-scale features and a dual-path attention mechanism, characterized in that, include: The memory and processor, wherein the memory stores a computer program executed by the processor, the computer program executing the sleep EEG staging method based on multi-scale features and dual-path attention mechanism as described in any one of claims 1 to 5 when executed by the processor.
7. A storage medium, characterized in that, The storage medium stores a computer program that, when running, executes the sleep EEG staging method based on multi-scale features and dual-path attention mechanism as described in any one of claims 1 to 5.