Sleep spindle wave layered detection method and device based on double-branch BiLSTM

By employing a dual-branch BiLSTM sleep spindle layering detection method, combined with XGBoost and BiLSTM models, the problems of data imbalance and lack of BECTS patient characteristics were solved, achieving efficient and accurate detection of sleep spindles, applicable to a variety of populations.

CN121579977APending Publication Date: 2026-02-27HANGZHOU DIANZI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511702076.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-19
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

Existing sleep spindle wave detection methods have limitations in terms of data imbalance and lack of specificity for BECTS patients. Furthermore, single-channel analysis limits the comprehensive capture of relevant information from brain regions, resulting in low detection accuracy and insufficient generalization performance.

Method used

A sleep spindle wave hierarchical detection method based on bi-branch BiLSTM is adopted. By combining the extreme gradient boosting tree (XGBoost) model and bidirectional long short-term memory network (BiLSTM) with a multi-channel fusion algorithm, EEG data is preprocessed, features are extracted and classified. The optimal detection threshold is obtained by using Gaussian distribution and Gaussian mixture model, negative samples are removed and spindle wave features of lesion area and non-lesion area are distinguished.

Benefits of technology

It improves the accuracy and applicability of sleep spindle wave detection, especially in BECTS patients, with an overall detection accuracy of 90.5%, which is significantly better than other models and is suitable for healthy individuals and BECTS patients.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121579977A_ABST
    Figure CN121579977A_ABST
Patent Text Reader

Abstract

The invention discloses a sleep spindle wave layered detection method and device based on a double-branch BiLSTM. Firstly, feature-based threshold detection and result coding are performed on each channel; secondly, adopting an extreme gradient to promote an ensemble learning model, constructing a layered feature interaction mechanism, integrating multi-channel space-time correlation features, and generating a preliminary detection result; and finally, aiming at the problem that the sleep spindle wave features in the normal state of the BECTS have significant differences, performing deep detection by using a double-branch bidirectional long-short-term memory network, thereby improving the accuracy of sleep spindle wave detection. The method not only can provide reliable support for BECTS clinical diagnosis, but also can provide a reusable technical framework for similar medical signal detection, and has cross-crowd and cross-scene popularization potential.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of medical signal processing, relates to the cross technical field of medicine, computer science and bioengineering, and particularly relates to a sleep spindle wave hierarchical detection method and device based on a double-branch BiLSTM. BACKGROUND

[0002] Sleep spindle wave, as a key physiological signal during sleep, presents a spindle shape in electroencephalogram (EEG), and its waveform characteristics are a series of sinusoidal wave clusters with a frequency of 11-16 Hz and a duration of about 0.5-3 seconds, and it plays a crucial role in the process of cognition and memory consolidation. The density, amplitude and synchronicity of sleep spindle wave are closely related to learning ability and memory retention efficiency, and it has irreplaceable significance for the development of children's brain and the maintenance of adult cognitive function. However, artificial detection of spindle wave by viewing electroencephalogram is both time-consuming and laborious: a professional physician often needs several hours to analyze one hour of sleep EEG data, and long-term observation is easy to cause fatigue error; at the same time, different physicians have subjective judgment standards for the start and end points of spindle wave and the integrity of waveform, which may lead to significant differences in detection results, which will seriously affect the consistency and reliability of data in multi-center clinical research or long-term follow-up.

[0003] With the development of computer technology, various automatic detection algorithms have emerged, providing a new way for efficient and objective detection of sleep spindle wave. Existing electroencephalogram waveform automatic detection methods are mainly divided into three categories: threshold-based detection, traditional machine learning-based detection and deep learning-based detection.

[0004] Threshold-based detection methods are the earliest automatic detection means applied, whose core idea is to analyze the key features of the signal and set the corresponding threshold to realize the recognition of spindle wave. The most critical features include energy characteristics (the energy of sleep spindle mainly concentrates in the 11-16 Hz frequency band), amplitude (usually higher than a certain multiple of the background electroencephalogram), duration, and periodicity of the waveform. For example, after extracting the signal in the 11-16 Hz frequency band through a band-pass filter, the energy value is calculated. When the energy exceeds the preset threshold and the duration meets the characteristics of spindle, it is determined as spindle. This kind of method is simple in principle, small in calculation, and easy to implement in embedded devices, but it is extremely sensitive to threshold setting - differences in electroencephalogram signals of different individuals (such as the amplitude difference of spindle between children and adults), background noise interference and other factors may lead to increased false negative rate or false positive rate, and the generalization ability is limited. The method based on traditional machine learning extracts hand-crafted features (such as energy, frequency, and waveform complexity) from the electroencephalogram signal, trains a classifier (such as support vector machine, random forest, and logistic regression) using these features to distinguish spindle and non-spindle electroencephalogram segments. Compared with the threshold method, this method can learn the complex relationship between features through the classifier, and has stronger adaptability to individual differences and noise, and better detection performance. However, this method is highly dependent on the quality of manual feature engineering. If the features do not fully represent the essential properties of spindle, the model performance will be directly limited, and the difficulty of feature design increases significantly for clinical data with poor signal quality or large variation (such as electroencephalogram signals of epilepsy patients).

[0005] In recent years, deep learning models have shown great potential in sleep spindle detection due to their powerful automatic feature extraction capabilities. These methods do not require manual feature design, but use convolutional neural networks, recurrent neural networks, and Transformers to extract multi-level and complex features directly from raw electroencephalogram data, automatically learning the waveform patterns, temporal and spatial distribution, and other key information of spindle.

[0006] Although these methods can detect spindle, they have certain limitations due to their characteristics:

[0007] Threshold-based methods often lack adaptability and are heavily dependent on prior knowledge about sleep spindle.

[0008] Machine learning and deep learning-based methods based on classifiers usually require larger data sets and are susceptible to data imbalance, as sleep spindle only accounts for a small percentage of electroencephalogram signals.

[0009] Most of these methods are limited to single-channel analysis, limiting the comprehensive capture of brain region-related information. In addition, there is a lack of spindle detection methods specifically for children with benign epilepsy with centrotemporal spikes (BECTS). SUMMARY

[0010] In order to solve the problem of data imbalance in spindle wave monitoring and lack of consideration of the specific characteristics of spindle waves of BECTS patients, the application provides a sleep spindle wave hierarchical detection method and device based on a double-branch BiLSTM. The application proposes a multi-channel fusion algorithm, which fuses single-channel detection based on a threshold and an extreme gradient boosting tree (XGBoost) model to eliminate negative samples and alleviate data imbalance. Then, a bidirectional long short-term memory network (BiLSTM) model is used to distinguish the spindle wave characteristics of the lesion area and the non-lesion area of BECTS patients. Although the application is designed for BECTS, it is also effective for healthy people, and has wide applicability.

[0011] To achieve the above-mentioned goal, the technical scheme of the application mainly includes the following steps:

[0012] In a first aspect, the application provides a sleep spindle wave hierarchical detection method based on a double-branch BiLSTM, including the following steps:

[0013] First, collect EEG data through a hospital's EEG acquisition device, preprocess the acquired data, and label the segments obtained by preprocessing, dividing them into spindle wave segments and non-spindle wave segments.

[0014] Then, perform multi-angle feature extraction on the data segments, use Gaussian distribution and Gaussian mixture distribution for fitting, perform posterior probability density calculation on the feature distribution obtained after fitting, and obtain the optimal detection threshold.

[0015] Based on the optimal detection threshold, evaluate the spindle wave detection state, combine an extreme gradient boosting tree (XGBoost) model to obtain a multi-channel comprehensive detection result, and screen the pre-detection result.

[0016] Finally, split each segment corresponding to the pre-detection result into a focal channel and a non-focal channel, use a double-branch BiLSTM network containing a focal branch and a non-focal branch to extract spatial information, fuse through a full connection layer to obtain a feature containing time and space, and obtain the final detection result.

[0017] In a possible implementation, the optimal detection threshold is obtained as follows:

[0018] First, extract the channels corresponding to the spindle waves in all segments; for each segment after channel extraction, extract feature information from multiple angles.

[0019] Model the positive class (i.e., the spindle wave segment features extracted) using Gaussian distribution, and use a Gaussian mixture model to fit the negative class (i.e., the non-spindle wave segment features extracted), to obtain the feature distribution of spindle waves and non-spindle waves, respectively.

[0020] The value is taken in the interval of the feature distribution, the posterior probability P (positive class | threshold) of each threshold belonging to the positive class is calculated, and the threshold determined by maximizing the posterior probability is the optimal detection threshold.

[0021] In a possible implementation, the acquisition of the pre-detection result is specifically as follows:

[0022] Based on the obtained optimal detection threshold, the features of each dimension extracted for each segment are compared to obtain the corresponding detection result, and all feature detection results (i.e., the preliminary judgment results obtained after each feature is compared with the optimal detection threshold) are voted to evaluate the spindle wave detection state of each channel to obtain the corresponding encoding result, and the feature matrix is formed by splicing.

[0023] The obtained feature matrix is considered by an extreme gradient boosting tree (XGBoost) model, and a multi-channel comprehensive detection result considering the channel weight is obtained by optimizing the difference of different channels.

[0024] Then, the samples predicted as positive classes are retained as the pre-detection result.

[0025] In a possible implementation, the specific pre-processing of the electroencephalogram signal is as follows:

[0026] EEG data of BECTS patients (experimental group) and normal people (control group) is collected, the obtained EEG data is filtered by using band-pass filtering (1-70 Hz) and band-stop filtering (50 ZHz), and slicing processing is performed, then the segment where the spindle wave is located is labeled as 1, and the segment where the non-spindle wave is located is labeled as 0.

[0027] In a possible implementation, the specific steps of obtaining the optimal detection threshold are as follows:

[0028] 2-1. Extract the channels corresponding to the spindle wave in all segments, each segment contains the signals of 9 target channels (including Fp1, Fp2, F3, F4, C3, C4, Fz, Cz, and Pz), and the signal dimension of each channel is , that is, the dimension of each segment data is 9 x .

[0029] 2-2. For each segment after channel extraction, features are extracted from multiple angles:

[0030] The features of spindle wave energy, time-frequency, morphology, periodicity, and sharpness dimension are extracted:

[0031] The root mean square (RMS) is used to reflect the signal energy intensity, and the high-amplitude oscillation characteristics of the spindle wave are quantified.

[0032] The Morlet wavelet power is used to depict the time-frequency energy distribution of the signal in the 11-16 Hz band, highlighting the characteristic frequency component of the spindle wave.

[0033] The signal envelope is used to capture the low-frequency trend of the signal, representing the periodic amplitude fluctuation pattern of the spindle wave.

[0034] The zero-crossing rate (ZCR) is used to quantify the frequency of the signal crossing zero, reflecting the periodicity and high-frequency oscillation characteristics of the spindle wave.

[0035] The kurtosis is used to describe the "sharpness" of the signal distribution, depicting the sharp peak characteristics of the spindle wave.

[0036] 2-3. For each segment, the extracted features in each dimension are modeled by a probability distribution to describe the feature distribution of the spindle wave (positive class) and non-spindle wave (negative class). The optimal detection threshold is calculated and selected as follows:

[0037] Positive class (i.e., the extracted spindle wave segment features): the feature values follow a Gaussian distribution, and the probability density function is:

[0038]

[0039] where the mean and the standard deviation are obtained from the spindle wave segments through maximum likelihood estimation.

[0040] Negative class (i.e., the extracted non-spindle wave segment features): a three-component Gaussian mixture model (GMM) is used for fitting, and the probability density function is:

[0041]

[0042] where , are the weight, mean, and standard deviation of the th component, respectively, and The model parameters are estimated by the EM algorithm.

[0043] Generate 100 uniformly distributed candidate thresholds in the full range of feature distribution Calculate the posterior probability of belonging to the positive class for each threshold:

[0044]

[0045] Select the candidate threshold that maximizes the posterior probability as the optimal detection threshold , i.e.:

[0046]

[0047] In one possible implementation, the specific steps of pre-detection result acquisition are as follows:

[0048] 3-1. Spindle wave threshold detection:

[0049] Statistically determine whether the extracted features of each segment exceed the optimal detection threshold. If the number of effective features exceeds the threshold, mark it as "effective feature". For a single channel, if the number of effective features of the channel exceeds the threshold , the encoding result is 1 (marked as a potential spindle wave event); otherwise, the encoding result is 0 (marked as a non-spindle wave event).

[0050] Each channel obtains a corresponding encoding result to reflect the detection state of the channel on the spindle wave.

[0051] The encoding results of the 9 channels are spliced in channel order to form a feature matrix of length 9 , that is:

[0052]

[0053] wherein, is the encoding result (0 or 1) of the corresponding subscript channel, and the feature matrix integrates the spindle wave detection information of all channels.

[0054] 3-2. Output multi-channel comprehensive detection result by considering weight through XGBoost, the specific operation is as follows:

[0055] Input the constructed feature matrix into the XGBoost model, and the model automatically learns the weight coefficient based on the contribution of each channel (n=1-9, corresponding to Fp1, Fp2, F3, F4, C3, C4, Fz, Cz, Pz in turn), satisfying the normalization condition:

[0056]

[0057] The multi-channel comprehensive detection result is calculated by the following formula:

[0058]

[0059] wherein: K is a Sigmoid activation function, is a bias term fitted by the model, is the encoding result (0 or 1) of the nth(n=1-9, corresponding to Fp1, Fp2, F3, F4, C3, C4, Fz, Cz, Pz in turn) channel.

[0060] When , the output result is 1 (judged as spindle wave); when When t = 0, the output result is 0 (determined as non-spindle wave).

[0061] 3-3. Four basic parameters, true positive, true negative, false positive and false negative, are counted, and true positive and false positive are selected as the pre-detection result, which is input into the next step of the double-branch BiLSTM network.

[0062] In a possible implementation, the feature extraction and classification process of the double-branch BiLSTM network is as follows:

[0063] Each segment corresponding to the pre-detection result is split according to the focal channel and the non-focal channel, and is input into the stacked BiLSTM structure of the corresponding branch. The first BiLSTM layer of each branch is used to extract the overall time sequence dependence, and the calculation formula is as follows:

[0064]

[0065] wherein, is the hidden state at time t, is the input signal, is the cell state at the previous time; after passing through the Dropout layer, the final hidden state is output by the second BiLSTM layer. After the outputs of the two branches are spliced, they are sequentially transformed by two fully connected layers, and the transformation formula is as follows:

[0066]

[0067] wherein,

[0068] is the weight matrix, is the input of the previous layer, is the bias vector, and a Dropout layer is arranged after each fully connected layer; finally, the prediction probability is output by the Sigmoid activation function:

[0069] When t = 1, the output result is 1 (determined as spindle wave); when t = 0, the output result is 0 (determined as non-spindle wave), which is the final detection result.

[0070] In a possible implementation, during the model training process, the detection accuracy is taken as the core optimization target, the accuracy loss of the detection result and the true label is calculated, and the network parameters are updated layer by layer by using the back propagation algorithm.

[0071] In a possible implementation, during the model training process, the detection accuracy is taken as the core optimization target, the accuracy loss of the detection result and the true label is calculated, and the network parameters are updated layer by layer by using the back propagation algorithm.

[0072] ​​In a second aspect, the embodiment of the present application provides a sleep spindle layered detection device based on a double-branch BiLSTM, comprising the following steps:

[0073] The data preprocessing module collects EEG data through a hospital electroencephalogram acquisition device, pre-processes the acquired data, labels the segments obtained through the pre-processing, and divides the segments into spindle wave segments and non-spindle wave segments.

[0074] The threshold calculation module extracts multi-angle features from the data segments, adopts Gaussian distribution and Gaussian mixture distribution for fitting, performs posterior probability density calculation on the feature distribution obtained after the fitting, and obtains an optimal detection threshold.

[0075] The pre-detection module evaluates spindle wave detection states based on the optimal detection threshold, obtains a multi-channel comprehensive detection result in combination with an extreme gradient boosting tree (XGBoost) model, and screens pre-detection results.

[0076] The final detection module splits each segment corresponding to the pre-detection result into a focal channel and a non-focal channel, extracts spatial information by using a double-branch BiLSTM network containing a focal branch and a non-focal branch, fuses the information through a full connection layer to obtain a feature containing time and space, and obtains a final detection result.

[0077] In a third aspect, the embodiment of the present application provides an electronic device, comprising a processor and a memory.

[0078] The memory is used to store a computer program.

[0079] The processor is used to execute the program stored on the memory, and implement the sleep spindle layered detection method in any of the embodiments of the present application.

[0080] In a fourth aspect, the embodiment of the present application provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the sleep spindle layered detection method in any of the embodiments of the present application.

[0081] In a fifth aspect, the embodiment of the present application provides a computer program product containing instructions, which, when executed on a computer, causes the computer to perform the sleep spindle layered detection method in any of the embodiments of the present application.

[0082] Compared with the prior art, the present application has the following beneficial effects:

[0083] The present application adopts five features for threshold-based single-channel detection. The threshold hyperparameters are determined by simulating feature distribution with a labeled spindle wave database, avoiding overfitting to a specific dataset while ensuring the inclusion of real spindle waves as much as possible. After independent detection of each feature, a preliminary result of each channel is generated through a voting mechanism. After single-channel detection is completed, the XGBoost model evaluates the contribution weight of each channel and fuses the results, successfully eliminating negative samples and alleviating the data imbalance problem.

[0084] The present application designs a BiLSTM-based detection model for distinguishing the spike waves of the lesion area and the non-lesion area of BECTS patients. The model can extract different spindle wave features from the lesion area and the non-lesion area by considering the past and future information of each time step. This distinction in time and space ensures comprehensive characterization of the occurrence of spindle waves. BRIEF DESCRIPTION OF DRAWINGS

[0085] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.

[0086] Figure 1 The present application designs a BiLSTM-based detection model for distinguishing the spike waves of the lesion area and the non-lesion area of BECTS patients. The model can extract different spindle wave features from the lesion area and the non-lesion area by considering the past and future information of each time step. This distinction in time and space ensures comprehensive characterization of the occurrence of spindle waves.

[0087] Figure 2 The present application designs a BiLSTM-based detection model for distinguishing the spike waves of the lesion area and the non-lesion area of BECTS patients. The model can extract different spindle wave features from the lesion area and the non-lesion area by considering the past and future information of each time step. This distinction in time and space ensures comprehensive characterization of the occurrence of spindle waves.

[0088] Figure 3 The present application designs a BiLSTM-based detection model for distinguishing the spike waves of the lesion area and the non-lesion area of BECTS patients. The model can extract different spindle wave features from the lesion area and the non-lesion area by considering the past and future information of each time step. This distinction in time and space ensures comprehensive characterization of the occurrence of spindle waves. DETAILED DESCRIPTION

[0089] The technical solutions in the present application will be described in detail below with reference to the drawings in the embodiments of the present application. It should be noted that the described embodiments are actually only some embodiments of the present application, not all embodiments, and are actually illustrative only, and are by no means any limitation on the present application and its applications or uses. The protection scope of the present application shall be subject to the appended claims.

[0090] This invention aims to address the problems of low detection accuracy, failure to distinguish between lesion and non-lesion areas, and insufficient generalization performance caused by imbalanced clinical BECTS data samples in existing technologies. The invention designs a hierarchical sleep spindle detection algorithm based on multi-channel EEG with temporal dynamic features, aiming to achieve accurate detection of sleep spindles. This method first performs feature-based threshold detection and result encoding for each channel; then, it employs an extreme gradient boosting ensemble learning model to integrate multi-channel spatiotemporal correlation features through a hierarchical feature interaction mechanism, generating preliminary detection results; finally, addressing the significant differences in sleep spindle features under normal BECTS conditions, it utilizes a bi-branch bidirectional long short-term memory network for deep detection, thereby improving the accuracy of sleep spindle detection.

[0091] This application provides a sleep spindle wave layering detection method based on dual-branch BiLSTM, such as... Figure 1 As shown, it includes the following steps:

[0092] Step 1: Reliable and accurate spindle wave EEG data, in the N2 phase and of medical significance, are collected using the hospital's EEG acquisition equipment. The data is then preprocessed to remove interference. The preprocessed segments are labeled and divided into spindle wave segments and non-spindle wave segments.

[0093] Step 2: Extract features from the data segments from multiple angles, fit them using Gaussian distribution and Gaussian mixture distribution, calculate the posterior probability density on the feature distribution obtained after fitting, and obtain the optimal detection threshold.

[0094] First, the channels corresponding to the spindle waves in all segments are extracted; then, features are extracted from each segment after channel extraction to extract feature information from multiple angles in order to comprehensively characterize the physiological characteristics of the spindle waves.

[0095] Since sleep spindle waves share common characteristics, while non-spindle waves exhibit multiple categories in reality, this invention uses a Gaussian distribution to model the positive class (i.e., the extracted spindle wave segment features) and a Gaussian mixture model to fit the negative class (i.e., the extracted non-spindle wave segment features), thereby obtaining the feature distributions of spindle waves and non-spindle waves respectively.

[0096] Values ​​are taken within the range of the feature distribution, and the posterior probability P(positive class | threshold) of each threshold belonging to the positive class is calculated. The threshold determined by maximizing the posterior probability is the optimal detection threshold.

[0097] Step 3: Evaluate the spindle wave detection status based on the optimal detection threshold, and obtain the multi-channel comprehensive detection result by combining the Extreme Gradient Boosting Tree (XGBoost) model.

[0098] Based on the obtained optimal detection threshold, the features extracted for each segment are compared to obtain the corresponding detection results. All feature detection results (i.e., the preliminary judgment results obtained after comparing each feature with the optimal detection threshold) are voted on to evaluate the spindle wave detection state of each channel and obtain the corresponding encoding results. The results are then spliced ​​together to form a feature matrix.

[0099] The obtained feature matrix is ​​weighted using the Extreme Gradient Boosting Tree (XGBoost) model. To address the differences between different channels, a multi-channel integrated detection result considering channel weights is obtained.

[0100] The samples predicted as positive are then retained as pre-detection results, providing data input for the next step of the dual-branch BiLSTM network.

[0101] Step 4: Each segment corresponding to the pre-detection result is split into focal and non-focal channels. Spatial information is extracted using a dual-branch BiLSTM network containing focal and non-focal branches. After fusion through a fully connected layer, features containing time and space are obtained, thus obtaining excellent final detection results.

[0102] In one possible implementation, the specific preprocessing of the EEG signals is as follows:

[0103] EEG data were collected from 17 BECTS patients (experimental group) and 5 normal individuals (control group). Bandpass filtering (1-70Hz) and bandstop filtering (50Hz) were used to filter the obtained EEG data, and a one-second slice was processed. The spindle wave segment was then labeled as 1. Considering the complexity of non-spindle waves, different waveforms were selected as non-spindle waves, including slow waves, peak waves, interference, etc., and non-spindle waves were uniformly labeled as 0.

[0104] In one possible implementation, step 2 is specifically performed as follows:

[0105] 2-1. Extract the channels corresponding to the spindle waves in all segments. Each segment contains signals from 9 target channels (including Fp1, Fp2, F3, F4, C3, C4, Fz, Cz, and Pz), with each channel having a signal dimension of [missing information]. =500 (sampling rate 500Hz), meaning each data segment has a dimension of 9× .

[0106] 2-2. For each segment after channel extraction, extract feature information from multiple perspectives:

[0107] The characteristics of spindle waves, including energy, time-frequency, morphology, periodicity, and sharpness, are extracted. The specific definitions and calculation formulas are as follows:

[0108] The root mean square (RMS) is used to reflect the signal energy intensity and quantify the high-amplitude oscillation characteristics of the spindle wave. The calculation formula is as follows:

[0109]

[0110] The number of data points in the analysis window is: , For the first The signal value of each data point.

[0111] The Morlet wavelet power is used to characterize the time-frequency energy distribution of the signal in the 11-16Hz frequency band, highlighting the characteristic frequency components of the spindle wave. The calculation formula is as follows:

[0112]

[0113] in, The target frequency is 11-16Hz. For time, For wavelet scale indexing, The total number of wavelet scales. For scale ,time Morlet wavelet coefficients at the location.

[0114] The low-frequency trend of the signal is captured by the signal envelope, which characterizes the periodic amplitude fluctuation pattern of the spindle wave. The calculation formula is as follows:

[0115]

[0116] in, For time The original signal value at that location, Its time derivative.

[0117] The frequency at which the signal crosses zero is quantized using the zero-crossing rate (ZCR), reflecting the periodicity and high-frequency oscillation characteristics of the spindle wave. The calculation formula is as follows:

[0118]

[0119] in, For the first The signal value of each sample, This is an indicator function (it takes the value 1 if the condition is true, otherwise it takes the value 0).

[0120] Kurtosis is used to describe the "sharpness" of signal distribution, characterizing the sharp peak features of a spindle wave. The calculation formula is as follows:

[0121]

[0122] in, The mean of the signal. This represents the standard deviation of the signal.

[0123] In the embodiment, the feature statistics are as follows:

[0124]

[0125] 2-3. For each segment, the feature distributions of the extracted dimensions are described using probability distribution modeling for spindle waves (positive class) and non-spindle waves (negative class). The optimal detection threshold is then calculated and selected, as follows:

[0126] Positive class (i.e., the extracted spindle wave segment features): Assuming its feature values ​​follow a Gaussian distribution, the probability density function is:

[0127]

[0128] Among them, the mean and standard deviation Obtained from spindle wave segments via maximum likelihood estimation.

[0129] Negative class (i.e., the extracted non-spindle wave segment features): Due to its multi-class characteristics, a three-component Gaussian mixture model (GMM) is used for fitting, and the probability density function is:

[0130]

[0131] in, , The first The weights, mean, and standard deviation of each component, and Model parameters are estimated using the EM algorithm.

[0132] Generate 100 uniformly distributed candidate thresholds across the entire feature distribution range. For each threshold, calculate the posterior probability of belonging to the positive class:

[0133]

[0134] Choose the option that makes the posterior probability The largest candidate threshold is used as the optimal detection threshold. ,Right now:

[0135]

[0136] In one possible implementation, step 3 is specifically performed as follows:

[0137] 3-1. Spindle wave threshold detection is as follows:

[0138] We count whether the features extracted from each segment exceed the optimal detection threshold. If they exceed the threshold, they are recorded as "valid features." For a single channel, the number of valid features for that channel is... The encoding result (Marked as a potential spindle wave event); otherwise, the encoding result (Marked as a non-spindle wave event).

[0139] Through the above steps, each channel obtains a corresponding encoding result that integrates 5 features, reflecting the detection status of the spindle wave for that channel.

[0140] The encoded results of the nine channels are then concatenated in channel order to form a feature sequence of length 9. ,Right now:

[0141]

[0142] in, For the first The encoding results (0 or 1) of each channel, feature matrix It integrates spindle wave detection information from all channels.

[0143] 3-2. Using XGBoost to output multi-channel comprehensive detection results considering weights, the specific operation is as follows:

[0144] The XGBoost model parameters used were set as follows: 100 base learners, 42 random seeds, automatic label encoding disabled, log loss as the evaluation metric, and positive and negative sample weights set by the ratio of the number of negative to positive samples in the training set to balance the data class distribution.

[0145] The constructed feature matrix When input into the XGBoost model, the model automatically learns weight coefficients based on the contribution of each channel. (n=1-9, corresponding to Fp1, Fp2, F3, F4, C3, C4, Fz, Cz, Pz respectively), satisfying the normalization condition:

[0146]

[0147] The results of multi-channel integrated testing are calculated using the following formula:

[0148]

[0149] Where: K is the Sigmoid activation function. This is the bias term for model fitting. This is the encoding result (0 or 1) of the nth channel (n=1-9, corresponding to Fp1, Fp2, F3, F4, C3, C4, Fz, Cz, Pz in sequence).

[0150] when When the output is 1, it is determined to be a spindle wave; when When the output is 0, it is determined to be a non-spindle wave.

[0151] 3-3. Calculate four basic parameters: true positive, true negative, false positive, and false negative. Based on these parameters, calculate precision, accuracy, recall, and F1 score. Select true positives and false positives as pre-detection results and input them into the next step of the dual-branch BiLSTM network.

[0152] In one possible implementation, such as Figure 3 As shown, the feature extraction and classification process of the dual-branch BiLSTM network is as follows:

[0153] The segments corresponding to the pre-detection results are split into focal and non-focal channels, and then input into the corresponding stacked BiLSTM structures. The full temporal dependency is extracted through the first BiLSTM layer (50 neurons) of each branch, calculated as follows:

[0154]

[0155] in, for The hidden state at all times For input signal, The cell state is the state at the previous moment; after passing through a Dropout layer with a dropout rate of 0.2, the final hidden state is output through a second BiLSTM layer (50 neurons) to preserve key sequence information.

[0156] After concatenating the outputs of the two branches, the layers are transformed sequentially through two fully connected layers containing 128 neurons and 64 neurons, respectively. The transformation formula is as follows:

[0157]

[0158] Among them, This is the weight matrix. For the input of the previous layer, Each fully connected layer is followed by a Dropout layer with a dropout rate of 0.2 to set the bias vector; finally, the predicted probability is output after passing through a Sigmoid activation function.

[0159]

[0160] when When the output is 1 (indicated as a spindle wave); when When the output is 0 (determined to be a non-spindle wave), this is the final detection result.

[0161] The data was divided into training, validation, and test sets in a 6:2:2 ratio. After the training and validation sets were input into the neural network, the binary cross-entropy loss function was used to optimize feature reconstruction and classification learning, respectively, to obtain the spindle wave classification result. During model training, detection accuracy was the core optimization objective. The network parameters (including hidden state weights of BiLSTM layers, weight matrices of fully connected layers, and bias vectors) were updated layer by layer using the backpropagation algorithm by calculating the accuracy loss between the predicted results and the true labels. Specifically, the gradient descent step size was dynamically adjusted based on the accuracy performance of each iteration, allowing the model to minimize the proportion of misclassified samples while continuously optimizing the targeting of feature extraction, especially strengthening the ability to capture the difference in spindle wave characteristics between lesion and non-lesion areas in BECTS patients, ultimately achieving a steady improvement in detection performance.

[0162] The effectiveness of the focal / non-focal model was verified using a combination of multiple channels as follows:

[0163] Single-channel models extract information from only one channel, allowing us to evaluate the performance of each channel in binary classification tasks. Multi-channel models (which do not distinguish between focal and non-focal areas) extract information from all channels and do not differentiate between lesion and non-lesion regions. They fuse multi-channel information without lesion segmentation, providing a benchmark for dual-branch networks.

[0164] The detection results for different channels shown in Table 1 demonstrate the significant advantages of this invention, achieving an accuracy of 90.5%, recall of 91.0%, precision of 87.4%, and an F1 score of 89.2%. These metrics far surpass those of single-channel models. In particular, the accuracy for channels F3 and C4 is only 73.6% and 66.9%, respectively, indicating limitations in information capture for single-channel models. In contrast, although the multi-channel model achieves an accuracy of 82.0%, the dual-branch network performs better. This means that the dual-branch network can more effectively consider the differences between lesion and non-lesion areas, thereby improving the model's flexibility and accuracy. Notably, in terms of recall, the dual-branch network excels in identifying lesion features, reducing the risk of missed detections.

[0165] Table 1 Performance Comparison of Different Models

[0166]

[0167] To verify the superiority of the bi-branch BiLSTM network compared to other networks, we designed a series of experiments to highlight its performance advantages in multi-channel spindle wave detection. Given the relative scarcity of multi-channel detection algorithms, this invention selects classic machine learning models as benchmarks: Random Forest (RF), Support Vector Machine (SVM), K-Nearest Neighbors (KNN), Logistic Regression (LR), Naive Bayes (NB), and Gradient Boosting Tree (GBT) are fundamental algorithmic frameworks in time series signal analysis, and their effectiveness in feature extraction and pattern recognition has been widely validated. These models have demonstrated robust performance in single-channel spindle wave classification tasks. In particular, Random Forest and Support Vector Machine, due to their good adaptability, have been used by many researchers to develop high-performance spindle wave models. Leveraging this adaptability, these methods can be extended from single-channel to multi-channel scenarios, serving as benchmarks for verifying the performance of the model proposed in this invention.

[0168] The results, as shown in Table 2, demonstrate that the bi-branch BiLSTM network outperforms other models across all metrics, achieving an accuracy of 90.5%, a recall of 91.0%, a precision of 87.4%, and an F1 score of 89.2%. This significantly surpasses other models such as Random Forest (82.1% accuracy, 82.1% F1 score), K-Nearest Neighbors (82.5% accuracy, 82.5% F1 score), and Support Vector Machines and Naive Bayes (with accuracies below 65.0%). In conclusion, the bi-branch BiLSTM network demonstrates superior performance in the main spindle wave detection task, fully showcasing its effectiveness in multi-channel data processing.

[0169] Table 2 Comparison of detection results of different models

[0170]

[0171] This invention constructs dedicated distribution models for spindle and non-spindle waves to obtain adaptive thresholds, combines XGBoost ensemble learning to form a cascaded screening mechanism, and designs a dual-branch network to model the differentiated spatiotemporal features of EEG signals in lesion and non-lesion areas. Validated by 17 clinically confirmed cases at the Children's Hospital Affiliated to Zhejiang University School of Medicine, the overall detection accuracy reached 90.5%. This not only provides reliable support for the clinical diagnosis of BECTS but also provides a reusable technical framework for similar medical signal detection, possessing the potential for cross-population and cross-scenario promotion.

[0172] This application also provides a sleep spindle wave layering detection device based on dual-branch BiLSTM, including the following steps:

[0173] Data preprocessing module: Collects EEG data through the hospital's EEG acquisition equipment, preprocesses the acquired data, and labels the preprocessed segments, dividing them into spindle wave segments and non-spindle wave segments.

[0174] Threshold calculation module: Extracts features from multiple angles from the data segment, fits the data using Gaussian distribution and Gaussian mixture distribution, calculates the posterior probability density on the feature distribution obtained after fitting, and obtains the optimal detection threshold.

[0175] Pre-detection module: Evaluates the detection status of the spindle wave based on the optimal detection threshold, and obtains multi-channel comprehensive detection results by combining the Extreme Gradient Boosting Tree (XGBoost) model, and filters the pre-detection results.

[0176] The final detection module splits each segment corresponding to the pre-detection result into focal and non-focal channels, uses a dual-branch BiLSTM network containing focal and non-focal branches to extract spatial information, and then fuses the spatiotemporal features through a fully connected layer to obtain the final detection result.

[0177] In one possible implementation, the threshold calculation module is specifically implemented as follows:

[0178] First, the channels corresponding to the spindle waves in all segments are extracted; for each segment after channel extraction, feature information is extracted from multiple angles.

[0179] A Gaussian distribution was used to model the positive class (i.e., the extracted spindle wave segment features), and a Gaussian mixture model was used to fit the negative class (i.e., the extracted non-spindle wave segment features), to obtain the feature distributions of spindle waves and non-spindle waves, respectively.

[0180] Values ​​are taken within the range of the feature distribution, and the posterior probability P(positive class | threshold) of each threshold belonging to the positive class is calculated. The threshold determined by maximizing the posterior probability is the optimal detection threshold.

[0181] In one possible implementation, the pre-detection module is specifically implemented as follows:

[0182] Based on the obtained optimal detection threshold, the features extracted for each segment are compared to obtain the corresponding detection results. All feature detection results (i.e., the preliminary judgment results obtained after comparing each feature with the optimal detection threshold) are voted on to evaluate the spindle wave detection state of each channel and obtain the corresponding encoding results. The results are then spliced ​​together to form a feature matrix.

[0183] The obtained feature matrix is ​​weighted using the Extreme Gradient Boosting Tree (XGBoost) model. To address the differences between different channels, a multi-channel integrated detection result considering channel weights is obtained.

[0184] The samples predicted as positive are then retained as pre-detection results.

[0185] This application also provides an electronic device, including a processor and a memory.

[0186] The memory is used to store computer programs.

[0187] When the processor executes a program stored in the memory, it implements any of the methods described in this application.

[0188] In one possible implementation, the electronic device of this application embodiment further includes a communication interface and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus.

[0189] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc.

[0190] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0191] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0192] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0193] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements any of the methods described in this application.

[0194] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform any of the methods described in this application.

[0195] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).

[0196] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0197] The various embodiments in this specification are described in a related manner. Each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other.

[0198] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.

Claims

1. A sleep spindle wave layering detection method based on dual-branch BiLSTM, characterized in that, The steps include the following: First, EEG data is collected using the hospital's EEG acquisition equipment. The acquired data is preprocessed, and the preprocessed segments are labeled and divided into spindle wave segments and non-spindle wave segments. Then, multi-angle feature extraction is performed on the data fragments, and Gaussian distribution and Gaussian mixture distribution are used for fitting. The posterior probability density is calculated on the feature distribution obtained after fitting, and the optimal detection threshold is obtained. The detection status of the spindle wave is evaluated based on the optimal detection threshold, and the multi-channel comprehensive detection results are obtained by combining the limit gradient boosting tree model to screen the pre-detection results. Finally, each segment corresponding to the pre-detection result is split into focal and non-focal channels. Spatial information is extracted using a bi-branch BiLSTM network containing focal and non-focal branches. After fusion through a fully connected layer, features containing time and space are obtained, thus obtaining the final detection result.

2. The sleep spindle wave layering detection method based on dual-branch BiLSTM according to claim 1, characterized in that, The optimal detection threshold is obtained as follows: First, the channels corresponding to the spindle waves in all segments are extracted; for each segment after channel extraction, feature information is extracted from multiple angles. Gaussian distribution is used to model the features of the positive class, i.e. the extracted spindle wave segments, and Gaussian mixture model is used to fit the features of the negative class, i.e. the extracted non-spindle wave segments, to obtain the feature distributions of spindle waves and non-spindle waves respectively. The values ​​are selected within the range of the feature distribution, and the posterior probability of each threshold belonging to the positive class is calculated. The threshold determined by maximizing the posterior probability is the optimal detection threshold.

3. The sleep spindle wave layering detection method based on dual-branch BiLSTM according to claim 1, characterized in that, The specific steps for obtaining the pre-detection results are as follows: Based on the obtained optimal detection threshold, the features extracted for each segment are compared to obtain the corresponding detection results. All feature detection results are voted on to evaluate the spindle wave detection state of each channel and obtain the corresponding encoding results. The results are then spliced ​​together to form a feature matrix. The obtained feature matrix is ​​weighted using the Extreme Gradient Boosting Tree (XGBoost) model. To address the differences between different channels, the multi-channel comprehensive detection result considering channel weights is obtained. The samples predicted as positive are then retained as pre-detection results.

4. The sleep spindle wave layering detection method based on dual-branch BiLSTM according to claim 1, characterized in that, The specific preprocessing of EEG signals is as follows: EEG data were collected from BECTS patients and normal individuals. Bandpass and bandstop filtering were used to filter the obtained EEG data, and the data were sliced. Segments containing spindle waves were labeled as 1, and segments containing non-spindle waves were labeled as 0.

5. The sleep spindle wave layering detection method based on dual-branch BiLSTM according to claim 2, characterized in that, The specific steps for obtaining the optimal detection threshold are as follows: 2-1. Extract the channels corresponding to the spindle waves in all segments. Each segment contains signals from 9 target channels, and the signal dimension of each channel is... That is, the dimension of each data segment is 9× ; 2-2. For each segment after channel extraction, extract feature information from multiple perspectives: Extracting features of spindle waves in terms of energy, time-frequency, morphology, periodicity, and sharpness: The root mean square (RMS) method is used to reflect the signal energy intensity and quantify the high-amplitude oscillation characteristics of the spindle wave. Morlet wavelet power is used to characterize the time-frequency energy distribution of the signal in the 11-16Hz frequency band, highlighting the characteristic frequency components of the spindle wave; The low-frequency trend of the signal is captured by the signal envelope, which characterizes the periodic amplitude fluctuation pattern of the spindle wave. The frequency at which the signal crosses zero is quantized using the zero-crossing rate (ZCR) to reflect the periodicity and high-frequency oscillation characteristics of the spindle wave. Kurtosis is used to describe the "sharpness" of the signal distribution, characterizing the sharp peak features of the spindle wave; 2-3. For each segment, the features extracted in each dimension are modeled using probability distributions to describe the feature distributions of spindle waves and non-spindle waves. The optimal detection threshold is then calculated and selected, as follows: The positive class refers to the extracted spindle wave segment features: their feature values ​​follow a Gaussian distribution, and the probability density function is: Among them, the mean and standard deviation Obtained from spindle wave segments by maximum likelihood estimation; The negative class, i.e., the extracted non-spindle wave segment features, is fitted using a three-component Gaussian mixture model (GMM), with the probability density function as follows: in, , The first The weights, mean, and standard deviation of each component, and Model parameters are estimated using the EM algorithm; Generate 100 uniformly distributed candidate thresholds across the entire feature distribution range. For each threshold, calculate the posterior probability of belonging to the positive class: Choose the option that makes the posterior probability The largest candidate threshold is used as the optimal detection threshold. ,Right now: 。 6. The sleep spindle wave layering detection method based on dual-branch BiLSTM according to claim 3, characterized in that, The specific steps for obtaining the pre-detection results are as follows: 3-1. Spindle wave threshold detection: We count whether the features extracted from each segment exceed the optimal detection threshold. If they exceed the threshold, they are recorded as "valid features". For a single channel, the number of valid features for that channel is... If the result is 1, the encoding result is 1, and it is marked as a potential spindle wave event; otherwise, the encoding result is 0, and it is marked as a non-spindle wave event. Each channel receives a corresponding encoding result to reflect the detection status of the spindle wave for that channel; The encoding results of the 9 channels are concatenated in channel order to form a feature matrix of length 9. ,Right now: in, The feature matrix represents the encoding result for the corresponding subscript channel. It integrates spindle wave detection information from all channels; 3-2. Using XGBoost to output multi-channel comprehensive detection results considering weights, the specific operation is as follows: The constructed feature matrix When input into the XGBoost model, the model automatically learns weight coefficients based on the contribution of each channel. n=1-9, corresponding to Fp1, Fp2, F3, F4, C3, C4, Fz, Cz, Pz respectively, satisfying the normalization condition: The results of multi-channel integrated testing are calculated using the following formula: Where: K is the Sigmoid activation function. This is the bias term for model fitting. This is the encoding result for the nth channel; when When the output is 1, it is determined to be a spindle wave; when When the output is 0, it is determined to be a non-spindle wave; 3-3. Statistically determine the four basic parameters, namely true positive, true negative, false positive and false negative. Select true positive and false positive as the pre-detection results and input them into the next step of the dual-branch BiLSTM network.

7. The sleep spindle wave layering detection method based on dual-branch BiLSTM according to claim 1, characterized in that, The feature extraction and classification process of the dual-branch BiLSTM network is as follows: Each segment corresponding to the pre-detection result is split into focal and non-focal channels, and input into the corresponding stacked BiLSTM structure. The full temporal dependency is extracted through the first BiLSTM layer of each branch, and the calculation formula is as follows: in, for The hidden state at all times For input signal, The cell state is the state at the previous moment; after passing through the Dropout layer, the final hidden state is output through the second BiLSTM layer. After concatenating the outputs of the two branches, the result is transformed through two fully connected layers in sequence. The transformation formula is as follows: in, This is the weight matrix. For the input of the previous layer, As the bias vector, a Dropout layer is applied after each fully connected layer; finally, the predicted probability is output after passing through a Sigmoid activation function. when When the output is 1, it is determined to be a spindle wave; when When the output is 0, it is determined to be a non-spindle wave, which is the final detection result.

8. The sleep spindle wave layering detection method based on dual-branch BiLSTM according to claim 7, characterized in that, During model training, detection accuracy is the core optimization objective. The network parameters are updated layer by layer by calculating the accuracy loss between the detection results and the true labels and using the backpropagation algorithm.

9. A sleep spindle wave stratification detection device based on dual-branch BiLSTM, characterized in that, The steps include the following: Data preprocessing module: Collects EEG data through the hospital's EEG acquisition equipment, preprocesses the acquired data, and labels the preprocessed segments, dividing them into spindle wave segments and non-spindle wave segments; Threshold calculation module: Extracts features from multiple angles from data segments, fits them using Gaussian distribution and Gaussian mixture distribution, calculates the posterior probability density on the feature distribution obtained after fitting, and obtains the optimal detection threshold; Pre-detection module: Evaluates the detection status of the spindle wave based on the optimal detection threshold, and obtains multi-channel comprehensive detection results by combining the limit gradient boosting tree model, and filters the pre-detection results; The final detection module splits each segment corresponding to the pre-detection result into focal and non-focal channels, uses a dual-branch BiLSTM network containing focal and non-focal branches to extract spatial information, and then fuses the spatiotemporal features through a fully connected layer to obtain the final detection result.

10. An electronic device, characterized in that, Including processor and memory; The memory is used to store computer programs; When the processor executes the program stored in the memory, it implements the sleep spindle wave layering detection method according to any one of claims 1-8.