Sleep spindle automated detection method and device fusing timing correlation and soft attention mechanism
Patent Information
- Application Number
- CN202410112142.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-26
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2044-01-26
AI Technical Summary
[0004]本发明提供了一种融合时序关联性与软注意力机制的睡眠纺锤波自动化检测方法及装置,用以解决或者至少部分解决现有技术中存在的检测精度不高的技术问题
[0048]本发明提出的融合时序关联性与软注意力机制的睡眠纺锤波自动化检测方法,选取脑电图中的C3通道数据作为源数据,只需进行简单预处理即可输入到模型中得到最终的睡眠纺锤波检测结果,不需要专家先验知识辅助。构建并训练了一个融合时序关联性与软注意力机制的事件检测网络,该网络通过一个编码模块和解码模块实现对脑电信号中每个采样点进行分类,同时针对睡眠脑电信号非平稳随机性的特点,设计了时序建模模块从而实现对信号中所蕴含时序信息的建模,并通过引入软注意力机制让模型关注对事件检测更重要的部分,极大地提升了睡眠纺锤波事件的检测精度。此外,本发明提供的自动化检测模型具有一定的通用性,可以迁移到其他睡眠特征波检测任务(如:K复合波)中,为生物信号中异常事件检测提供了一个参考。
Smart Images

Figure CN118035825B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of EEG feature wave recognition, and more particularly to an automated method and apparatus for detecting sleep spindle waves that integrates temporal correlation and soft attention mechanisms. Background Technology
[0002] Sleep spindles are neural oscillatory activities observed during non-rapid eye movement (NREM) sleep and are clinically considered to be related to brain health status, including sleep quality and cognitive abilities. Characteristics of sleep spindles (such as oscillation frequency, spindle density, and duration) can serve as important biomarkers for assessing cognitive abilities and related impairments. Detecting sleep spindles from overnight electroencephalograms (EEGs) is fundamental to obtaining these characteristics and therefore has significant clinical research value. However, current clinical diagnosis and identification of sleep spindles still primarily rely on visual EEG examination by experts. This manual calibration method is highly specialized, costly, inefficient, and inconsistent. Therefore, there is an urgent need for an accurate and efficient automated method for detecting sleep spindles to address these issues.
[0003] In recent years, many scholars have dedicated themselves to research in this field, resulting in a large number of automated spindle wave detection algorithms and achieving certain results. These algorithms can be mainly divided into three categories: template matching-based methods, classifier-based methods, and deep learning-based methods. Template matching-based methods calculate the envelope plane of the original signal using bandpass filtering or signal decomposition and then use fixed or adaptive thresholds for detection. Classifier-based methods mainly use machine learning classifiers (such as SVM, decision trees, and combinations of methods) to directly classify the time-frequency representations and nonlinear features extracted from EEG. Deep learning-based methods typically utilize neural network models to automatically extract morphological features from the signal to determine the presence of sleep spindle wave events. However, these deep learning-based automated detection methods still face some challenges in detection accuracy, and few focus on the statistical aspects of sleep spindle wave counts over the entire night's sleep, while these sleep spindle wave features are important physiological markers for assessing cognitive abilities. Summary of the Invention
[0004] This invention provides an automated method and apparatus for detecting sleep spindle waves that integrates temporal correlation and soft attention mechanisms, in order to solve or at least partially solve the technical problem of low detection accuracy in the prior art.
[0005] To address the aforementioned technical problems, the first aspect of this invention provides an automated sleep spindle wave detection method that integrates temporal correlation and soft attention mechanisms, comprising:
[0006] S1: Extract the C3 channel signal from the sleep EEG as the raw signal, preprocess the raw signal, and obtain the input signal based on the raw signal and the preprocessed signal;
[0007] S2: Resample the input signal and standardize the original signal and the preprocessed signal contained in the input signal respectively. Then, label the standardized signal data for sleep spindle events. Then, prune the labeled data and use a balancing strategy to balance the training samples.
[0008] S3: The balanced samples are input into the event detection network that integrates temporal correlation and soft attention mechanisms for training. The event detection network that integrates temporal correlation and soft attention mechanisms includes an encoding module, a temporal modeling module, a jump-connected attention module, and a decoding module. The encoding module is used to perform multi-level feature extraction on the input signal and obtain the context information of the input signal. The temporal modeling module is used to model the temporal information within the signal segment. The jump-connected attention module is used to concatenate the feature map in the encoding module with the feature map in the decoding module using a soft attention mechanism. The decoding module is used to concatenate the features output by the jump-connected attention module with the features output by the upsampled convolutional block and then decode to obtain the final feature output.
[0009] S4: Post-process the final feature output to obtain the detection results of the sleep spindle wave.
[0010] In one implementation, step S1 includes:
[0011] S1.1: Extract the C3 channel signal from the sleep EEG as the raw signal;
[0012] S1.2: Apply an 8th-order Butterworth filter to the original signal to obtain the filtered signal. Then concatenate the original signal and the filtered signal to obtain the concatenated vector X = [X1, X2], which is used as the input signal, where X1 represents the original signal and X2 represents the filtered signal.
[0013] In one implementation, step S2 includes:
[0014] S2.1: For each channel i in vector X, the corresponding data X i Resampling to 100Hz is performed, followed by standardization using a robust standardization method. The standardization formula is as follows:
[0015]
[0016] Where m i Representing data X iThe median, IQR i Z represents the interquartile range. i It is X i Standardized data;
[0017] S2.2: Assign labels to sleep spindle wave events in the standardized data, and mark the start and end times of each spindle wave event when assigning labels;
[0018] S2.3: Use a sliding time window of length L to prune the labeled data to obtain samples with a time length of L;
[0019] S2.4: Randomly sample negative samples until the ratio of negative samples to positive samples is 1:1.
[0020] In one implementation, the encoding module includes a three-layer encoding module and two downsampling modules, and the processing procedure of the encoding module includes:
[0021] S3.1.1: Feature extraction is performed on the input signal through the first-layer encoding module;
[0022] S3.1.2: Perform a downsampling operation on the feature vector obtained in step S3.1.1 using the downsampling module;
[0023] S3.1.3: Encode the features obtained in step S3.1.2 using the second-layer encoding module;
[0024] S3.1.4: Perform downsampling operation on the features encoded in step S3.1.3 using the downsampling module;
[0025] S3.1.5: Encode the features obtained in step S3.1.4 through the third-layer encoding module to obtain the encoded features.
[0026] In one implementation, the processing procedure of the timing modeling module includes:
[0027] S3.2.1: Construct sequence data based on the feature vectors output by the encoding module;
[0028] S3.2.2: Input the sequence data constructed in step S3.2.1 into the long short-term memory network for processing to capture the temporal information present in the data;
[0029] S3.2.3: Transform the data obtained in step S3.2.2 to obtain the output data of the time series modeling module.
[0030] In one implementation, the processing steps of the skip-connection attention module and the decoding module include:
[0031] S3.3.1: Upsample the output of the temporal modeling module using upsampled convolutional blocks;
[0032] S3.3.2: Combine the feature g output by the upsampled convolutional block obtained in step S3.3.1 with the encoded feature F of the second-layer encoding module in step S3.1.3. 2 The inputs are combined into the soft attention mechanism to obtain the first output of the jump-connected attention module.
[0033] S3.3.3: The first output of the jump-connected attention module obtained in step S3.3.2 The output of the upsampled convolutional block obtained in step S3.3.1 is concatenated with the output of the convolutional block in the channel dimension, and then decoded through a convolutional block;
[0034] S3.3.4: The decoded feature vector obtained in step S3.3.3 is then input into the upsampling convolution block for a 2x upsampling process;
[0035] S3.3.5: Combine the features output by the upsampled convolutional block obtained in step S3.3.4 with the encoded features F of the first-layer encoding module in step S3.1.1. 1 They are input together into the soft attention mechanism to obtain the second output of the jump-connected attention module;
[0036] S.3.6: The second output of the skip-connected attention module obtained in step S3.3.5 is concatenated with the features output of the upsampled convolutional block obtained in step S3.3.4 in the channel dimension, and then a decoding operation is performed through a convolutional block to obtain the final feature output of the decoding module.
[0037] In one implementation, step S4 includes:
[0038] S4.1: Use a convolutional layer to convolve the output of the decoding module, and output two values at each sampling point, representing the probability that the sampling point belongs to the sleep spindle wave event and the probability that it belongs to the background, respectively.
[0039] S4.2: The label corresponding to the highest probability of each sampling point is used as the label of that sampling point, where the label of sleep spindle event is 1 and the label of background is 0; then, the consecutive 1s in the EEG signal are merged to obtain the start time and end time of each sleep spindle event, and sleep spindle events with a duration less than the threshold are filtered to obtain the final detection result.
[0040] Based on the same inventive concept, a second aspect of the present invention provides an automated sleep spindle wave detection device that integrates temporal correlation and soft attention mechanisms, comprising:
[0041] The input data acquisition module is used to extract the C3 channel signal from the sleep EEG as the raw signal, preprocess the raw signal, and obtain the input signal based on the raw signal and the preprocessed signal.
[0042] The preprocessing module is used to resample the input signal and standardize the original signal and the preprocessed signal contained in the input signal respectively. Then, the standardized signal data is labeled with sleep spindle events. The labeled data is then cropped and the training samples are balanced using a balancing strategy.
[0043] The model building and training module is used to input balanced samples into an event detection network that integrates temporal correlation and soft attention mechanisms for training. The event detection network integrating temporal correlation and soft attention mechanisms includes an encoding module, a temporal modeling module, a jump-connected attention module, and a decoding module. The encoding module is used to perform multi-level feature extraction on the input signal and obtain the contextual information of the input signal. The temporal modeling module is used to model the temporal information within the signal segment. The jump-connected attention module is used to concatenate the feature maps in the encoding module and the feature maps in the decoding module using a soft attention mechanism. The decoding module is used to concatenate the features output by the jump-connected attention module and the features output by the upsampled convolutional block and then decode them to obtain the final feature output.
[0044] The post-processing module is used to post-process the final feature output to obtain the detection results of sleep spindle waves.
[0045] Based on the same inventive concept, a third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed, implements the method described in the first aspect.
[0046] Based on the same inventive concept, a fourth aspect of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described in the first aspect.
[0047] Compared with the prior art, the advantages and beneficial technical effects of the present invention are as follows:
[0048] This invention proposes an automated sleep spindle detection method that integrates temporal correlation and soft attention mechanisms. It selects C3 channel data from electroencephalograms (EEGs) as source data, requiring only simple preprocessing before inputting it into the model to obtain the final sleep spindle detection results, without the need for expert prior knowledge. An event detection network integrating temporal correlation and soft attention mechanisms was constructed and trained. This network classifies each sampling point in the EEG signal through an encoding and decoding module. Furthermore, considering the non-stationary randomness of sleep EEG signals, a temporal modeling module was designed to model the temporal information contained in the signal. By introducing a soft attention mechanism, the model focuses on the more important parts for event detection, greatly improving the detection accuracy of sleep spindle events. In addition, the automated detection model provided by this invention has certain versatility and can be transferred to other sleep feature wave detection tasks (such as K-complex waves), providing a reference for the detection of abnormal events in biological signals.
[0049] Furthermore, this invention performs post-processing on the final feature output, which can simultaneously count the number of sleep spindle events throughout the night, and can automatically provide the location information of each sleep spindle event like an expert, which is expected to assist doctors in the clinical field to calibrate sleep spindle events. Attached Figure Description
[0050] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0051] Figure 1 This is a flowchart of an automated sleep spindle detection method that integrates temporal correlation and soft attention mechanisms in an embodiment of the present invention;
[0052] Figure 2 This is a structural diagram of the convolution block in an embodiment of the present invention;
[0053] Figure 3 This is a diagram of the upsampling convolution block structure in an embodiment of the present invention;
[0054] Figure 4 This is a schematic diagram of the soft attention mechanism structure in an embodiment of the present invention. Detailed Implementation
[0055] To address the issue of low detection accuracy in existing technologies, this invention proposes an automated sleep spindle detection method that integrates temporal correlation and soft attention mechanisms, aiming to achieve accurate identification of sleep spindle events. To achieve this goal, the invention employs the following conceptual framework:
[0056] Using the C3 channel, which exhibits the largest spindle wave amplitude in electroencephalograms (EEGs), as the data foundation, an event detection network integrating temporal correlation and soft attention mechanisms was designed based on the U-Net architecture. This network model comprises four parts: an encoding module that performs multi-level feature extraction and downsampling on the input data; a temporal modeling module that models the temporal information within signal segments to extract temporal correlation information; a skip-connection attention module that suppresses irrelevant regions, allowing the model to focus more on useful salient features; and a decoding module that restores the low-resolution feature map to the resolution of the input sequence and performs feature fusion during the decoding process. This model employs an end-to-end training mode, enabling simultaneous statistical analysis and location localization of sleep spindle wave events.
[0057] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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, 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.
[0058] Example 1
[0059] This invention provides an automated method for detecting sleep spindle waves that integrates temporal correlation and soft attention mechanisms, including:
[0060] S1: Extract the C3 channel signal from the sleep EEG as the raw signal, preprocess the raw signal, and obtain the input signal based on the raw signal and the preprocessed signal;
[0061] S2: Resample the input signal and standardize the original signal and the preprocessed signal contained in the input signal respectively. Then, label the standardized signal data for sleep spindle events. Then, prune the labeled data and use a balancing strategy to balance the training samples.
[0062] S3: The balanced samples are input into the event detection network that integrates temporal correlation and soft attention mechanisms for training. The event detection network that integrates temporal correlation and soft attention mechanisms includes an encoding module, a temporal modeling module, a jump-connected attention module, and a decoding module. The encoding module is used to perform multi-level feature extraction on the input signal and obtain the context information of the input signal. The temporal modeling module is used to model the temporal information within the signal segment. The jump-connected attention module is used to concatenate the feature map in the encoding module with the feature map in the decoding module using a soft attention mechanism. The decoding module is used to concatenate the features output by the jump-connected attention module with the features output by the upsampled convolutional block and then decode them to obtain the final feature output.
[0063] S4: Post-process the final feature output to obtain the detection results of the sleep spindle wave.
[0064] In general, the C3 channel signal from the sleep EEG is extracted as the original signal X1. The original signal is then bandpass filtered to obtain the filtered signal X2. The original signal and the filtered signal are then concatenated into a vector X = [X1, X2], which, after preprocessing, is used as the input data for the model. This invention defines the label y for sleep spindle events as 1 and the label y for non-sleep spindle events as 0. Subsequently, a sample balancing method is used to balance the training samples. Finally, an event detection network integrating temporal correlation and soft attention mechanisms is designed, and the training dataset is input into the model for training.
[0065] In one implementation, step S1 includes:
[0066] S1.1: Extract the C3 channel signal from the sleep EEG as the raw signal;
[0067] S1.2: Apply an 8th-order Butterworth filter to the original signal to obtain the filtered signal. Then concatenate the original signal and the filtered signal to obtain the concatenated vector X = [X1, X2], which is used as the input signal, where X1 represents the original signal and X2 represents the filtered signal.
[0068] Specifically, sleep EEG data is typically collected using a 10-20 international standard lead system with electrode placement, covering multiple brain regions such as the frontal lobe, occipital lobe, and central region. Sleep spindle waves usually have the largest amplitude recorded in the central region leads, and experts primarily refer to central region EEG data when annotating events. Therefore, the C3 channel signal located in the central region of the EEG is extracted as the source data.
[0069] Sleep spindle events are mainly distributed between 11 and 16 Hz. To enhance the ability of this invention to capture sleep spindle events, the C3 channel signal extracted from the EEG that is strongly correlated with sleep spindle event discrimination is filtered. Specifically, an 8th-order Butterworth filter is used for bandpass filtering, with cutoff frequencies set at 10 Hz and 17 Hz, to obtain the filtered signal. Then, the vector X = [X1, X2] formed by concatenating the original signal and the filtered signal is used as the input source data of the model, where X1 represents the original C3 channel signal and X2 represents the filtered signal.
[0070] In one implementation, step S2 includes:
[0071] S2.1: For each channel i in vector X, the corresponding data X i Resampling was performed to 100Hz, followed by standardization using a robust standardization method.
[0072] S2.2: Assign labels to sleep spindle wave events in the standardized data, and mark the start and end times of each spindle wave event when assigning labels;
[0073] S2.3: Use a sliding time window of length L to prune the labeled data to obtain samples with a time length of L;
[0074] S2.4: Randomly sample negative samples until the ratio of negative samples to positive samples is 1:1.
[0075] Specifically, the standardization process in S2.1 is shown in Formula 2.1.
[0076]
[0077] Where m i Representing data X i The median, which is the value in the middle when the data is sorted in ascending order; IQR i This represents the interquartile range, i.e., the data X. i The difference is calculated after dividing the sample into four equal parts in ascending order; Z i It is channel data X i The result obtained after standardization. The standardized data is used as the training data z = [Z1, Z2] for the convolutional neural network.
[0078] Step 2.2: Assign labels to sleep spindle wave events in the standardized data. Experts will specify the start and end times of each spindle wave event during labeling; that is, for the j-th sleep spindle wave event, its start time s can be determined from the expert label. j and termination time e jLabeling data means assigning labels to the data. j and e j The label y of sampling points within the range is defined as 1, and the label y of sampling points outside the range of any sleep spindle wave event is defined as 0.
[0079] Step 2.3: Use a sliding time window of length L to prune the preprocessed data Z, obtaining samples with a time length of L. L This serves as the final input data for the model. Therefore, the shape of the model input data is (2, L×fs), where 2 represents two channels and fs represents the sampling frequency, which is 100 in this embodiment.
[0080] Step 2.4 involves sample balancing. Sleep spindle events are generally rare in the entire night's sleep EEG, resulting in a significantly larger number of negative samples (samples without sleep spindle events) than positive samples (samples containing sleep spindle events). To construct a balanced dataset, this invention randomly samples negative samples until the ratio of negative to positive samples is 1:1.
[0081] In one implementation, the encoding module includes a three-layer encoding module and two downsampling modules, and the processing procedure of the encoding module includes:
[0082] S3.1.1: Feature extraction is performed on the input signal through the first-layer encoding module;
[0083] S3.1.2: Perform a downsampling operation on the feature vector obtained in step S3.1.1 using the downsampling module;
[0084] S3.1.3: Encode the features obtained in step S3.1.2 using the second-layer encoding module;
[0085] S3.1.4: Perform downsampling operation on the features encoded in step S3.1.3 using the downsampling module;
[0086] S3.1.5: Encode the features obtained in step S3.1.4 through the third-layer encoding module to obtain the encoded features.
[0087] Specifically, the event detection network designed in this invention first includes an encoding module responsible for multi-level feature extraction of the input signal. This module uses convolutional and pooling layers to reduce the size of the feature map and gradually captures the contextual information of the input signal as the network depth increases. In specific implementation, this can be achieved through the following methods:
[0088] Step S3.1.1: First layer encoding module. The input data (signal) first passes through a convolutional block with a kernel size of 7*1 and an output channel of 32. The features encoded in the first layer are denoted as F.1 The convolutional block consists of two convolutional layers with a kernel size of 7*1, and both layers have 32 output channels. After each convolutional layer, a batch normalization (BN) layer and the ReLU activation function are used. To ensure the length of the input sequence remains constant, the padding value of the convolutional layers is set to 3. Each convolutional layer can be abstracted as shown in Equation 3.1.
[0089]
[0090] in and These represent the results obtained from the k-th output channel of the (l-1)-th convolutional layer and the k-th output channel of the l-th convolutional layer, respectively. This represents the convolution kernel parameters between the k-th and j-th channel feature maps in the l-th layer; represents the bias term of the feature map of the k-th channel in the l-th layer; bn(·) represents the batch normalization operation; relu(·) represents the ReLU activation operation.
[0091] Step S3.1.2: Downsampling Operation. The feature vector encoded in Step S3.1.1 is downsampled using a dropout layer and a max pooling layer. The dropout layer has a parameter of 0.2, meaning that during training, a subset of neurons' outputs are set to zero with a probability of 0.2. This improves the model's generalization ability and prevents overfitting. The max pooling layer has a kernel size of 2 and a stride of 2, halving the sequence length after max pooling while retaining the maximum value of every two adjacent elements. This reduces data dimensionality while preserving key features. The specific operation is shown in Formula 3.2.
[0092] y u =max(z) 2u , z 2u+1 (3.2)
[0093] Among them, y u z represents the output of the u-th sampling point of the max pooling layer. 2u and z 2u+1 These represent two adjacent elements at the 2u-th and 2u+1-th sampling points in the input sequence, respectively.
[0094] Step S3.1.3: Second-layer encoding module. The second encoding module is similar in composition to the first, also using a convolutional block to encode the features. This convolutional block has a kernel size of 7*1 and 64 output channels. The features encoded by the second layer are denoted as F. 2Downsampling to reduce the dimensionality of the data may result in the loss of some detailed information. Therefore, the number of channels was increased from 32 to 64 using convolutional blocks to help the network learn higher-level features and improve the model's representational capabilities.
[0095] Step 3.1.4: Downsampling operation. Perform a downsampling operation on the feature vector encoded in step S3.1.3, using the same method as in step S3.1.2.
[0096] Step 3.1.5: Third-layer encoding module. A convolutional block similar to those used in steps S3.1.1 and S3.1.3 is employed to encode the downsampled data. This convolutional block has a kernel size of 7*1 and 128 output channels. The features encoded by the third layer are denoted as F. 3 .
[0097] In one implementation, the processing procedure of the timing modeling module includes:
[0098] S3.2.1: Construct sequence data based on the feature vectors output by the encoding module;
[0099] S3.2.2: Input the sequence data constructed in step S3.2.1 into the long short-term memory network for processing to capture the temporal information present in the data;
[0100] S3.2.3: Transform the data obtained in step S3.2.2 to obtain the output data of the time series modeling module.
[0101] Specifically, electroencephalogram (EEG) signals are a type of time-series data with non-stationary characteristics. The temporal correlation information contained within them is crucial for the identification and detection of sleep spindles. To this end, this invention designs a temporal modeling module to model the temporal information within signal segments, helping the model to more effectively understand and capture the temporal features within signal segments.
[0102] In practice, this can be achieved through the following methods:
[0103] Step S3.2.1: Constructing Sequence Data. Since the encoding module is mainly composed of a convolutional neural network, its output differs from the input required by the time series modeling module. Therefore, data manipulation is necessary to construct the sequence data. The output of the encoding module can be represented as (N, C, T), where N represents the number of samples, C represents the number of channels, and T represents the time series. In this implementation, the second and third dimensions of the encoding module's output are interchanged to obtain a feature vector in the format (N, T, C), which is then used as the input to the time series modeling module.
[0104] Step S3.2.2: Temporal Information Modeling. The data output from Step S3.2.1 is input into a Long Short-Term Memory (LSTM) network to capture the temporal information present in the data. In this invention, the number of LSTM layers is set to 2, and each LSTM has 128 units, where the update of each unit can be represented as the operation shown in Equation 3.3.
[0105] (c t h t )=f(x t h t-1 c t-1 (3.3)
[0106] Where, x t h represents the input at time step t. t-1 c represents the hidden state of the previous time step. t-1 Represents the cell state at the previous time step, f(·) represents the function of the LSTM unit, and c t and h t The sub-tables represent the cell state and hidden state output at time step t. An LSTM model consists of multiple such units, each responsible for processing a portion of the input sequence and passing the state between time steps, thus effectively capturing both long-term and short-term temporal dependencies.
[0107] Step S3.2.3: Data Shape Change. The data output by LSTM has a shape of (N, T, C). In order to match the input format required by the subsequent decoding module, the second and third dimensions of the data need to be transformed to obtain the output in (N, C, T) format, which will serve as the final output of the time series modeling module.
[0108] In particular, regarding the temporal modeling module proposed in this invention, compared with the temporal correlation embedding module in the prior art CN112450881A, a multimodal sleep staging method based on temporal correlation, the two use different models. This invention uses a Long Short-Term Memory Network (LSTM), while the prior art uses a Recurrent Neural Network (RNN). Compared with the model in the prior art, the model of this invention has significant advantages in capturing long-term dependencies, avoiding the gradient vanishing problem, and supporting parallel computing. More importantly, their purposes and functions are different. Existing technologies believe that sleep staging results between different segments will not produce cross-stage changes (e.g., they will not directly change from N1 to N3), so they focus on capturing the temporal correlation between adjacent signal segments to constrain this cross-stage change phenomenon. In this technology, the length of the input sequence (i.e., the number of signal segments) is a hyperparameter that needs to be manually adjusted as needed. However, this invention believes that the waveform discrimination of sleep spindle waves is affected by the sampling points around the event, so it focuses on temporal modeling of the information between sampling points within each signal segment. The sequence length is determined by the size of the input feature map, eliminating the need for manual parameter tuning and enhancing the robustness of the model.
[0109] In one implementation, the processing steps of the skip-connection attention module and the decoding module include:
[0110] S3.3.1: Upsample the output of the temporal modeling module using upsampled convolutional blocks;
[0111] S3.3.2: Combine the feature g output by the upsampled convolutional block obtained in step S3.3.1 with the encoded feature F of the second-layer encoding module in step S3.1.3. 1 The inputs are combined into the soft attention mechanism to obtain the first output of the jump-connected attention module.
[0112] S3.3.3: The first output of the jump-connected attention module obtained in step S3.3.2 The output of the upsampled convolutional block obtained in step S3.3.1 is concatenated with the output of the convolutional block in the channel dimension, and then decoded through a convolutional block;
[0113] S3.3.4: The decoded feature vector obtained in step S3.3.3 is then input into the upsampling convolution block for a 2x upsampling process;
[0114] S3.3.5: Combine the features output by the upsampled convolutional block obtained in step S3.3.4 with the encoded features F of the first-layer encoding module in step S3.1.1. 1 They are input together into the soft attention mechanism to obtain the second output of the jump-connected attention module;
[0115] S3.3.6: The second output of the skip connection attention module obtained in step S3.3.5 is concatenated with the features output of the upsampled convolution block obtained in step S3.3.4 in the channel dimension, and then a decoding operation is performed through a convolution block to obtain the final feature output of the decoding module.
[0116] Specifically, since the encoding module is mainly composed of convolutional neural networks, its output differs from the input required by the time series modeling module. Therefore, data manipulation is necessary to construct the sequence data. The output of the encoding module can be represented as (N, C, T), where N represents the number of samples, C represents the number of channels, and T represents the time series. Here, the second and third dimensions of the encoding module's output are interchanged to obtain a feature vector in the format (N, T, C), which is then used as the input to the time series modeling module.
[0117] In practice, this can be achieved through the following methods:
[0118] Step S3.3.1: Upsample the output of the temporal modeling module using an upsampling convolutional block to improve the resolution of the feature map. The upsampling convolutional block uses linear interpolation to upsample the feature map by a factor of 2. Then, it performs convolution on the upsampled signal through a one-dimensional convolutional layer with a kernel size of 7*1 and a stride of 1, while halving the number of channels. Finally, it obtains the output of the upsampling convolutional block through batch normalization and the ReLU activation function. If (N, 2C, T) represents the dimension of the input features of the upsampling convolutional block, then the dimension of the output features of the upsampling convolutional block is (N, C, 2T), thus achieving the effect of halving the number of channels and doubling the sequence length. Linear interpolation is a simple and common interpolation method that inserts a new sampling point between two adjacent sampling points, as shown in Equation 3.4.
[0119]
[0120] in, This indicates rounding down to the nearest integer less than or equal to the calculated result. m This represents the m-th sampling point after linear interpolation. When m is an even number, it represents the original data. When m is odd, it represents the original data. and The average value.
[0121] Step S3.3.2: Combine the features (denoted as g) output by the upsampled convolutional block obtained in step S3.3.1 with the encoded features F of the second-layer encoding module in step S3.1.3. 2 (denoted as x) are input together into the soft attention mechanism to obtain the output of the jump-connected attention module. The soft attention mechanism first uses a one-dimensional convolutional layer with a 1*1 kernel to convolve g and x, and then sums the convolution results. Next, it activates the g and x using the ReLU activation function. The activated output is then fed into a one-dimensional convolutional layer with a 1*1 kernel and passes through a Sigmoid activation function to generate a set of weights α. Finally, α is compared with the feature F. 2 Multiplying these yields the output of the second-layer skip-connected attention module. The specific operation can be represented by formulas 3.5 and 3.6.
[0122]
[0123]
[0124] Step S3.3.3: The output of the skip-connected attention module obtained in step S3.3.2 is concatenated with the output of the upsampled convolutional block obtained in step S3.3.1 in the channel dimension, and then decoded through a convolutional block. The kernel size of the convolutional block is 7*1, and the number of output channels is set to 64.
[0125] Step S3.3.4: Input the decoded feature vector obtained in step S3.3.3 into the upsampling convolution block and perform upsampling on the features by a factor of 2 according to the operation described in step 3.3.1.
[0126] Step S3.3.5: Combine the features output by the upsampled convolutional block obtained in step S3.3.4 with the encoded features F of the first-layer encoding module in step S3.1.1. 1 They are input together into the soft attention mechanism, and the specific operation method and network structure are completely consistent with those described in step 3.3.2.
[0127] Step S3.3.6: Concatenate the output of the skip-connected attention module obtained in step S3.3.5 with the output of the upsampled convolutional block obtained in step S3.3.4 along the channel dimension, and then perform a decoding operation through a convolutional block to obtain the final feature output of the decoding module. The convolutional block has a kernel size of 7*1 and the number of output channels is set to 32.
[0128] The jump-connected attention module proposed in this invention differs in purpose and function from the dual attention module in the prior art CN114711725A, "A Method and Device for Sleep Apnea Detection Based on a Dual Attention Mechanism." The jump-connected attention module of this invention is based on spatial attention, using high-resolution and low-resolution feature maps as inputs. Within the module, these two feature maps are fused, and the weight of each sampling point is calculated using all channel features. This enhances the region of interest (ROI) in the feature map and suppresses non-ROI regions, allowing the decoding module to retain more detailed information during decoding. The model can then focus on the more important parts for event detection, ultimately improving the model's detection accuracy. In contrast, the dual attention mechanism in the prior art uses channel attention, calculating the weight of each channel using information from all sampling points. This enhances the weight of channels more important for result discrimination but cannot enhance the weight of ROI regions exhibiting spindle-shaped patterns. Furthermore, the model structure of the jump-connected attention module proposed in this invention is simpler, while the dual attention mechanism in the prior art contains a bidirectional long short-term memory network, resulting in a higher number of parameters and greater model training complexity, and is not suitable for non-temporal data.
[0129] In one implementation, step S4 includes:
[0130] S4.1: Use a convolutional layer to convolve the output of the decoding module, and output two values at each sampling point, representing the probability that the sampling point belongs to the sleep spindle wave event and the probability that it belongs to the background, respectively.
[0131] S4.2: The label corresponding to the highest probability of each sampling point is used as the label of that sampling point, where the label of sleep spindle event is 1 and the label of background is 0; then, the consecutive 1s in the EEG signal are merged to obtain the start time and end time of each sleep spindle event, and sleep spindle events with a duration less than the threshold are filtered to obtain the final detection result.
[0132] The present invention has the following positive effects and advantages:
[0133] 1) This invention selects C3 channel data from electroencephalograms as source data. Only simple preprocessing is required before it can be input into the model to obtain the final sleep spindle wave detection result, without the need for expert prior knowledge.
[0134] 2) The automated sleep spindle detection method designed in this invention can simultaneously count the number of sleep spindle events throughout the night, and can automatically provide the location information of each sleep spindle event like an expert, which is expected to assist doctors in the clinical field to calibrate sleep spindle events.
[0135] 3) To address the issue of low accuracy in sleep spindle detection, this invention designs an encoding module and a decoding module to classify each sampling point in the EEG signal. At the same time, considering the non-stationary randomness of sleep EEG signals, a time-series modeling module is designed to model the temporal information contained in the signal. Furthermore, by introducing a soft attention mechanism, the model focuses on the more important parts for event detection, which greatly improves the detection accuracy of sleep spindle events.
[0136] 4) The automated detection model designed in this invention has a certain degree of universality and can be transferred to other sleep feature wave detection tasks (such as K-complex waves), providing a reference for the detection of abnormal events in biological signals.
[0137] The following description, in conjunction with the accompanying drawings and specific embodiments, illustrates the following:
[0138] Part 1: EEG Data Extraction and Preprocessing
[0139] 1. Extract the C3 channel EEG data with the largest amplitude of sleep spindle wave events from the EEG as the original signal X1. Considering that sleep spindle wave events are mainly distributed between 11 and 16 Hz, the C3 channel signal is bandpass filtered to obtain the filtered signal X2. Then, the vector X = [X1, X2] concatenated from the original signal and the filtered signal is used as the input source data of the model.
[0140] 2. In order to reduce the impact of noise and improve the analysis speed, the above signal is resampled in this example, and the sampling rate is set to 100Hz. The resampled data is then standardized using the Robust Scale method to ensure the consistency and comparability of the data.
[0141] 3. Based on the expert annotation information, assign labels to the standardized data for sleep spindle events: define the label y of the sampling points within the duration of the sleep spindle event as 1, and define the label y of the sampling points outside the duration of the sleep spindle event as 0.
[0142] 4. Use a sliding time window to crop the preprocessed data to obtain training samples. In this example, the time window length is set to 20s, the sliding distance is set to 20s, and there is no overlap between two adjacent cropped samples. Therefore, the data shape of the model input in this example is (2, 2000).
[0143] 5. Sleep spindle events are generally rare in overnight sleep EEG, resulting in a significantly larger number of negative samples (samples without sleep spindle events) than positive samples (samples containing sleep spindle events). To construct a balanced dataset, in this example, negative samples are randomly sampled until the ratio of negative to positive samples is 1:1. This ensures a balance between positive and negative samples during training, thereby improving the model's ability to recognize sleep spindle events.
[0144] The second part is the network model design:
[0145] 1. To better characterize the features in EEG signals, this example designs an encoding module to encode the information contained in the signal. For example... Figure 1 As shown, the encoding module mainly consists of convolutional blocks and downsampling operations. The encoding module designed in this example contains three encoding layers and two downsampling layers. Furthermore, the number of channels is doubled after each downsampling operation to reduce information loss caused by the downsampling operation. Figure 2 The encoding module mainly consists of two convolutional layers. In this example, all convolutional operations use 7*1 kernels to capture more information. Through convolution and downsampling operations in the encoding module, the size of the feature map can be gradually reduced, enabling multi-level feature extraction of the input signal. Simultaneously, as the network depth increases, the encoding module gradually captures the contextual information of the input signal, thereby improving the model's feature representation capability.
[0146] 2. Electroencephalogram (EEG) signals are time-series data with non-stationary characteristics. The temporal correlation information contained within them is crucial for the identification and detection of sleep spindles. Therefore, this example designs a temporal modeling module to model the temporal information within signal segments, helping the model to more effectively understand and capture the temporal features within those segments. For example... Figure 1 As shown, the timing modeling module designed in this example consists of two LSTM layers, each with 128 units. This design ensures that the LSTM output features can be directly input into the decoding module after format conversion, without any other operations.
[0147] 3. This example aims to perform probability prediction for each sampling point in the input data; therefore, a decoding module was designed to restore the low-resolution feature map to the resolution of the input sequence. For example... Figure 1 As shown, the decoding module mainly consists of two layers. Each layer uses skip connections to fuse the features from the encoding and decoding modules. During decoding, feature upsampling is required; this example primarily uses upsampling convolutional blocks to achieve this effect. For example... Figure 3As shown, the upsampling convolutional block mainly consists of a linear interpolation upsampling operation and a one-dimensional convolution. Simultaneously, a soft attention mechanism (such as...) is added to the skip connections. Figure 4 This allows the model to learn to suppress irrelevant regions and focus on useful salient features during training.
[0148] The third part is the training and testing of the network model:
[0149] 1. In this example, an end-to-end approach is used to train the network model. All sample data is divided into training, validation, and test sets, and 10-fold cross-validation is used for training and testing. Specifically, stochastic gradient descent (SGD) is used for training, with a total of 50 epochs. Early stopping is used during training to prevent overfitting. The initial learning rate is set to 0.001, and a 1-cycle learning rate strategy is adopted, adjusting the learning rate after each epoch.
[0150] 2. Use the trained network model to test the test data.
[0151] Example 2
[0152] Based on the same inventive concept, this embodiment discloses an automated sleep spindle wave detection device that integrates temporal correlation and soft attention mechanisms, comprising:
[0153] The input data acquisition module is used to extract the C3 channel signal from the sleep EEG as the raw signal, preprocess the raw signal, and obtain the input signal based on the raw signal and the preprocessed signal.
[0154] The preprocessing module is used to resample the input signal and standardize the original signal and the preprocessed signal contained in the input signal respectively. Then, the standardized signal data is labeled with sleep spindle events. The labeled data is then cropped and the training samples are balanced using a balancing strategy.
[0155] The model building and training module is used to input balanced samples into an event detection network that integrates temporal correlation and soft attention mechanisms for training. The event detection network integrating temporal correlation and soft attention mechanisms includes an encoding module, a temporal modeling module, a jump-connected attention module, and a decoding module. The encoding module is used to perform multi-level feature extraction on the input signal and obtain the contextual information of the input signal. The temporal modeling module is used to model the temporal information within the signal segment. The jump-connected attention module is used to concatenate the feature maps in the encoding module and the feature maps in the decoding module using a soft attention mechanism. The decoding module is used to concatenate the features output by the jump-connected attention module and the features output by the upsampled convolutional block and then decode them to obtain the final feature output.
[0156] The post-processing module is used to post-process the final feature output to obtain the detection results of the sleep spindle wave.
[0157] Since the device described in Embodiment 2 of this invention is the same device used in implementing the automated sleep spindle wave detection method integrating temporal correlation and soft attention mechanism in Embodiment 1 of this invention, those skilled in the art can understand the specific structure and variations of this device based on the method described in Embodiment 1 of this invention, and therefore will not be repeated here. All devices used in the method of Embodiment 1 of this invention fall within the scope of protection of this invention.
[0158] Example 3
[0159] Based on the same inventive concept, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed, implements the method described in Embodiment 1.
[0160] Since the computer-readable storage medium described in Embodiment 3 of this invention is the same computer-readable storage medium used in implementing the automated sleep spindle wave detection method integrating temporal correlation and soft attention mechanisms in Embodiment 1 of this invention, those skilled in the art can understand the specific structure and variations of this computer-readable storage medium based on the method described in Embodiment 1 of this invention, and therefore will not be repeated here. All computer-readable storage media used in the method of Embodiment 1 of this invention fall within the scope of protection of this invention.
[0161] Example 4
[0162] Based on the same inventive concept, this application also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method in Embodiment 1.
[0163] Since the computer device described in Embodiment 4 of this invention is the same computer device used to implement the automated sleep spindle wave detection method integrating temporal correlation and soft attention mechanisms in Embodiment 1 of this invention, those skilled in the art can understand the specific structure and variations of this computer device based on the method described in Embodiment 1 of this invention, and therefore will not be repeated here. All computer devices used in the method of Embodiment 1 of this invention fall within the scope of protection of this invention.
[0164] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0165] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0166] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention. Clearly, those skilled in the art can make various modifications and variations to the embodiments of the invention without departing from the spirit and scope of the invention. Thus, if these modifications and variations of the embodiments of the invention fall within the scope of the claims of the invention and their equivalents, the invention also intends to include these modifications and variations.
Claims
1. An automated method for detecting sleep spindle waves that integrates temporal correlation and soft attention mechanisms, characterized in that, include: S1: Extract the C3 channel signal from the sleep EEG as the raw signal, preprocess the raw signal, and obtain the input signal based on the raw signal and the preprocessed signal; S2: Resample the input signal and standardize the original signal and the preprocessed signal contained in the input signal respectively. Then, label the standardized signal data for sleep spindle events. Then, prune the labeled data and use a balancing strategy to balance the training samples. S3: The balanced samples are input into the event detection network that integrates temporal correlation and soft attention mechanisms for training. The event detection network that integrates temporal correlation and soft attention mechanisms includes an encoding module, a temporal modeling module, a jump-connected attention module, and a decoding module. The encoding module is used to perform multi-level feature extraction on the input signal and obtain the context information of the input signal. The temporal modeling module is used to model the temporal information within the signal segment. The jump-connected attention module is used to concatenate the feature map in the encoding module with the feature map in the decoding module using a soft attention mechanism. The decoding module is used to concatenate the features output by the jump-connected attention module with the features output by the upsampled convolutional block and then decode them to obtain the final feature output. S4: Post-process the final feature output to obtain the detection results of sleep spindle waves; The encoding module consists of a three-layer encoding module and two downsampling modules. The processing steps of the encoding module include: S3.1.1: Feature extraction is performed on the input signal through the first-layer encoding module; S3.1.2: Perform a downsampling operation on the feature vector obtained in step S3.1.1 using the downsampling module; S3.1.3: Encode the features obtained in step S3.1.2 using the second-layer encoding module; S3.1.4: Perform downsampling operation on the features encoded in step S3.1.3 using the downsampling module; S3.1.5: Encode the features obtained in step S3.1.4 using the third-layer encoding module to obtain the encoded features; The processing steps of the time series modeling module include: S3.2.1: Construct sequence data based on the feature vectors output by the encoding module; S3.2.2: Input the sequence data constructed in step S3.2.1 into the long short-term memory network for processing to capture the temporal information present in the data; S3.2.3: Transform the data obtained in step S3.2.2 to obtain the output data of the time series modeling module; The processing steps of the skip connection attention module and the decoding module include: S3.3.1: Upsample the output of the temporal modeling module using upsampled convolutional blocks; S3.3.2: The features output by the upsampled convolutional block obtained in step S3.3.1 The encoding features of the second-layer encoding module in step S3.1.3 The inputs are combined into the soft attention mechanism to obtain the first output of the jump-connected attention module. ; S3.3.3: The first output of the jump-connected attention module obtained in step S3.3.2 The output of the upsampled convolutional block obtained in step S3.3.1 is concatenated with the output of the convolutional block in the channel dimension, and then decoded through a convolutional block; S3.3.4: The decoded feature vector obtained in step S3.3.3 is then input into the upsampling convolution block for a 2x upsampling process; S3.3.5: Combine the features output by the upsampled convolutional block obtained in step S3.3.4 with the encoded features of the first-layer encoding module in step S3.1.
1. They are input together into the soft attention mechanism to obtain the second output of the jump-connected attention module; S3.3.6: The second output of the skip connection attention module obtained in step S3.3.5 is concatenated with the features output of the upsampled convolution block obtained in step S3.3.4 in the channel dimension, and then a decoding operation is performed through a convolution block to obtain the final feature output of the decoding module.
2. The automated sleep spindle wave detection method integrating temporal correlation and soft attention mechanisms as described in claim 1, characterized in that, Step S1 includes: S1.1: Extract the C3 channel signal from the sleep EEG as the raw signal; S1.2: Apply an 8th-order Butterworth filter to the original signal for bandpass filtering to obtain the filtered signal. Then concatenate the original signal with the filtered signal to obtain the concatenated vector. , and take it as the input signal, where, Represents the original signal. This represents the filtered signal.
3. The automated sleep spindle wave detection method integrating temporal correlation and soft attention mechanisms as described in claim 2, characterized in that, Step S2 includes: S2.1: For vectors Each channel in Corresponding data Resampling was performed to 100Hz, followed by standardization using a robust standardization method. S2.2: Assign labels to sleep spindle wave events in the standardized data, and mark the start and end times of each spindle wave event when assigning labels; S2.3: Using a length of A sliding time window is used to prune the labeled data to obtain a time length of [missing information]. The sample; S2.4: Randomly sample negative samples until the ratio of negative samples to positive samples is 1:
1.
4. The automated sleep spindle wave detection method integrating temporal correlation and soft attention mechanisms as described in claim 1, characterized in that, Step S4 includes: S4.1: Use a convolutional layer to convolve the output of the decoding module, and output two values at each sampling point, representing the probability that the sampling point belongs to the sleep spindle wave event and the probability that it belongs to the background, respectively. S4.2: The label corresponding to the highest probability of each sampling point is used as the label of that sampling point, where the label of sleep spindle event is 1 and the label of background is 0; then, the consecutive 1s in the EEG signal are merged to obtain the start time and end time of each sleep spindle event, and sleep spindle events with a duration less than the threshold are filtered to obtain the final detection result.
5. An automated sleep spindle wave detection device integrating temporal correlation and soft attention mechanisms, characterized in that, To implement the method as described in claim 1, comprising: The input data acquisition module is used to extract the C3 channel signal from the sleep EEG as the raw signal, preprocess the raw signal, and obtain the input signal based on the raw signal and the preprocessed signal. The preprocessing module is used to resample the input signal and standardize the original signal and the preprocessed signal contained in the input signal respectively. Then, the standardized signal data is labeled with sleep spindle events. The labeled data is then cropped and the training samples are balanced using a balancing strategy. The model building and training module is used to input balanced samples into an event detection network that integrates temporal correlation and soft attention mechanisms for training. The event detection network integrating temporal correlation and soft attention mechanisms includes an encoding module, a temporal modeling module, a jump-connected attention module, and a decoding module. The encoding module is used to perform multi-level feature extraction on the input signal and obtain the contextual information of the input signal. The temporal modeling module is used to model the temporal information within the signal segment. The jump-connected attention module is used to concatenate the feature maps in the encoding module and the feature maps in the decoding module using a soft attention mechanism. The decoding module is used to concatenate the features output by the jump-connected attention module and the features output by the upsampled convolutional block and then decode them to obtain the final feature output. The post-processing module is used to post-process the final feature output to obtain the detection results of the sleep spindle wave.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed, it implements the method as described in any one of claims 1 to 4.
7. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Multi-mode sleep staging method based on time sequence relevance driving
CN112450881A
Multi-modal multi-scale sleep staging method for improving N1 period category confusion
CN116172515A
Sleep staging detection system based on graph attention mechanism and space-time graph convolution
CN117158912A