A sleep regulation method and system based on a brain-computer interface and a six-axis gyroscope
Patent Information
- Application Number
- CN202610830236.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-09
- Publication Date
- 2026-08-21
AI Technical Summary
但现有技术中的此类方法在可靠性和有效性上仍然存在局限,例如,对睡前阶段的识别多依赖体动下降、主观计时或简单睡眠/清醒判断,缺少客观、明确的判断标准,容易产生误判;输出刺激后通常不再有效利用脑电作为辅助判据,缺少明确的刺激伪迹抑制流程,导致刺激期间脑电难以参与闭环判断;不同睡眠阶段之间的条件跳转较为模糊,缺少结合个体基线、自适应概率更新和时序约束的可执行判定规则;刺激波形通常为固定形式,缺少灵活的场景化动态调节策略;对目标唤醒时刻的唤醒过程多采用突发式触发,难以兼顾唤醒效率与舒适性,也缺少依据脑电和体动反馈提前结束或转入减弱阶段的明确机制
[0015]The beneficial effects of this invention are as follows: This invention provides a sleep regulation method and corresponding system based on brain-computer interface and six-axis gyroscope. Through the fusion acquisition of real-time EEG information and six-axis inertial information, combined with low-frequency pulse electrical stimulation for coordinated regulation, a phased regulation process of "pre-sleep identification and induction - sleep staging and monitoring - target time wake-up" is established. It can complete continuous state identification and corresponding control in the same system, forming a closed-loop process of pre-sleep guidance, sleep monitoring and timed wake-up. Combined with individual baseline normalization, feature mapping network and temporal posterior update mechanism, it can improve the ability to distinguish between states such as resting without sleep, near sleep, stable sleep and wakefulness trend, and reduce the error caused by direct fixed threshold judgment between different individuals. Stimulation reference sequence construction and reference artifact removal processing can still retain the suppressed EEG as an auxiliary criterion in the pre-sleep induction and wake-up stages, and default to discontinuous stimulation in the sleep stage, focusing on monitoring and staging analysis, thereby overcoming the problem of EEG signal contamination by stimulation artifacts and resulting in unstable feedback basis, and can take into account the regulation effectiveness, signal availability and safety.
Smart Images

Figure CN122605067A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of sleep science technology, specifically to a sleep regulation method and system based on brain-computer interface and six-axis gyroscope. Background Technology
[0002] Sleep is an indispensable physiological process for the human body, a crucial stage for self-repair, immune regulation, metabolic balance, and cognitive function consolidation. A normal sleep cycle (wake period, N1 light sleep, N2 light sleep, N3 deep sleep, and REM sleep) is essential for maintaining physical and mental health and ensuring normal brain function. However, sleep disorders are becoming increasingly prominent globally. In my country, the sleep disturbance rate among people aged 18 and above has reached 48.5%, with over 300 million people experiencing various sleep problems such as difficulty falling asleep, light sleep with frequent awakenings, vivid dreams, early awakenings, and disordered sleep structure. Long-term poor sleep not only leads to immediate discomfort such as daytime sleepiness, poor concentration, and memory decline, but also gradually damages the body's immune barrier, increasing the risk of chronic diseases such as cardiovascular disease, diabetes, anxiety, and depression, seriously affecting people's quality of life and physical health. Therefore, developing efficient, non-invasive, and precise sleep regulation technologies has significant practical importance and application value.
[0003] Among existing sleep regulation technologies, non-invasive methods combining EEG detection and electrical stimulation have become a research hotspot due to their high safety and lack of drug dependence. EEG signals can accurately reflect sleep stages, and identifying characteristic EEG waves of different sleep stages can provide an effective basis for electrical stimulation regulation. However, existing methods still have limitations in reliability and effectiveness. For example, the identification of the pre-sleep stage often relies on decreased body movement, subjective timing, or simple sleep / wake judgments, lacking objective and clear judgment criteria, which can easily lead to misjudgments. After output stimulation, EEG is usually no longer effectively used as an auxiliary criterion, lacking a clear stimulus artifact suppression process, making it difficult for EEG to participate in closed-loop judgment during stimulation. The conditional transitions between different sleep stages are relatively vague, lacking executable judgment rules that combine individual baselines, adaptive probability updates, and temporal constraints. Stimulation waveforms are usually fixed in form, lacking flexible, scenario-based dynamic adjustment strategies. The awakening process at the target awakening time often uses sudden triggering, making it difficult to balance awakening efficiency and comfort, and lacking a clear mechanism for early termination or transition to a weakening phase based on EEG and body movement feedback. Therefore, how to provide a reliable and effective sleep regulation method with clear judgment and execution standards based on individual physiological rhythm differences, and how to dynamically adjust sleep stimulation according to the usage scenario, has become a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0004] To address the aforementioned technical problems, this invention provides a sleep regulation method and system based on a brain-computer interface and a six-axis gyroscope.
[0005] This invention provides a sleep regulation method based on a brain-computer interface and a six-axis gyroscope, the method comprising: The preset complete sleep stage is divided into multiple time windows, and the user's physiological signals are collected in real time within at least two consecutive time windows by the EEG acquisition device; the EEG acquisition device is an EEG amplifier equipped with a brain-computer interface and a six-axis gyroscope, and the physiological signals include differential EEG signals and six-axis inertial raw sequences. The controller constructs a sleep staging model based on the physiological signals, and executes the following methods in each of the subsequent time windows: The physiological signals of the user within the current time window are collected, and the collected physiological signals are processed to obtain a unified feature vector representing the individual sleep characteristics of the current user. Based on the sleep stage model and the unified feature vector, the sleep state at the current moment is determined, and it is determined whether the sleep state transition conditions are met; the sleep state includes at least the pre-sleep stage P, the sleep stage S, and the wakefulness stage W; When the sleep state transition conditions are met, based on the determined sleep state within the current time window, the physiological signals within the current time window are used to further determine whether the user's physiological indicators within the current time window meet the safe stimulation conditions for the sleep state within the current time window; the sleep state transition conditions include at least the conditions for transitioning from P to S and the conditions for transitioning from S to W. When the safety stimulation conditions are met, the electrical stimulation device outputs a pre-set electrical stimulation for the current sleep state; when the safety stimulation conditions are not met, the user's physiological signals are collected again and the judgment is made again. Preferably, the brain-computer interface includes at least two acquisition channels; Preferably, the electrical stimulation includes at least one of an asymmetric bipolar rectangular unmodulated wave and a rectangular modulated wave.
[0006] Furthermore, the method for processing the physiological signal includes: The differential EEG signal is sequentially subjected to DC drift removal, power frequency suppression, and bandpass filtering to obtain a preprocessed standardized EEG signal; The data from different axes in the original six-axis inertial sequence are time-synchronized, corrected, and denoised to obtain a preprocessed standardized inertial sequence. Preferably, when the electrical stimulation is applied in the previous time window, the method for preprocessing the physiological signals acquired in the current time window further includes: Based on the application of the electrical stimulation within the migration time window, a virtual temporal electrical stimulation reference sequence is generated, and stimulation artifact suppression is performed on the electrical stimulation.
[0007] Furthermore, the method for processing the physiological signals also includes: EEG features, inertial features, and signal quality features are extracted from the standardized EEG signals and the standardized inertial sequences, and the unified feature vector, individual baseline model, and standardized EEG input for use by the sleep staging model are generated.
[0008] Furthermore, the method for determining the sleep state at the current moment includes: The standardized EEG signal and the standardized inertial sequence are input into the sleep staging model. Based on the master state machine, the final sleep staging result of the current time window is obtained by performing feature mapping and temporal posterior. The master state machine is a three-state master state machine, including three master states: P, S, and W. Preferably, the method for determining the sleep state at the current moment further includes: When the main state is S, the main state machine is further assisted by an auxiliary state machine to determine the final sleep stage result of the current time window. The auxiliary state machine includes five auxiliary states: Wake, light sleep stage 1 N1, light sleep stage 2 N2, deep sleep stage N3, and REM sleep stage.
[0009] Furthermore, the method for determining whether the sleep state transition conditions are met includes: Based on the unified feature vector, for the pre-sleep stage P, the user's pre-sleep preparation index, pre-sleep status score and probability of falling asleep are calculated in the current time window to preliminarily determine whether the user has the conditions for falling asleep. When it is determined that the user has the conditions for falling asleep, continue to calculate the user's sleep state score and wakefulness score within the current time window for the sleep stage S and the wakefulness stage W, and further calculate the local probability that the main state of the current time window belongs to S based on the pre-sleep state score, the sleep state score and the wakefulness score. Perform a temporal posterior on the local probabilities, and confirm the switch from the P stage to the S stage if and only if the sleep preparation probability and the P-to-S switch posterior probability of the most recent N0 time windows simultaneously meet the preset conditions. Preferably, the method for determining whether the sleep state transition conditions are met further includes: After switching from stage P to stage S, based on the unified feature vector, the user's awakening trend score and wake-up warm-up interval flag within the current time window are calculated. Combined with the temporal posterior, the switch from stage S to stage W is confirmed if and only if the awakening trend score, the wake-up warm-up interval flag, and the temporal posterior simultaneously meet preset conditions.
[0010] Furthermore, the method of outputting the electrical stimulation includes: Based on the determined sleep state within the current time window, the system continues to assess whether the user's physiological indicators within the current time window meet the safe stimulation conditions for the sleep state. For the pre-sleep stage P, when the main state remains at P and the user has the conditions for falling asleep, the electrical stimulation device outputs sleep-inducing stimulation. For the sleep stage S, the electrical stimulation device outputs limited intermittent stimulation if and only if the real-time calculated sleep stimulation allowance flag and all parameters used to calculate the sleep stimulation allowance flag meet the preset conditions; if any one or more parameters change or no longer meet the preset conditions during the real-time calculation of the sleep stimulation allowance flag, the current output stimulation is immediately stopped and the sleep state at the current moment is re-determined. The electrical stimulation device outputs a progressively stronger wake-up stimulus if and only if the time in the sleep stage S meets the preset target wake-up time and the preset conditions for switching from stage S to stage W are met.
[0011] Furthermore, the method for determining whether the safe stimulus conditions are met includes: a. When switching from P stage to S stage but not yet to W stage, calculate the sleep stage permission flag based on the final sleep stage result of the current time window, the wakefulness score, and the preset segment blockage condition for switching from N3 stage to REM stage. b. Calculate the body movement safety flag, refractory period safety flag, artifact safety flag, and switching conflict safety flag based on the body movement level, resting degree, end time of the most recent stimulus, stimulus artifact residue, overall signal quality, and master state switching flag, respectively. c. Combine the aforementioned physical safety signs, refractory period safety signs, spurious sign safety signs, and switching conflict safety signs to obtain the overall sleep safety sign; d. Combine the sleep stage permission flag with the sleep safety overall flag to obtain the final sleep stimulation permission flag; the electrical stimulation is permitted to be performed if and only if the sleep stage permission flag and the sleep safety overall flag simultaneously meet the preset conditions.
[0012] Another aspect of the present invention provides a sleep regulation system based on a brain-computer interface and a six-axis gyroscope, comprising the following parts: An EEG acquisition device includes an EEG amplifier and a brain-computer interface, wherein the EEG amplifier is equipped with a six-axis gyroscope and the brain-computer interface includes at least two acquisition channels. An electrical stimulation device, comprising a pulse output device and electrodes connected to the pulse output device and a human body; A controller configured to perform the above-described method.
[0013] Furthermore, the controller includes the following components: The storage module is used to store the preset complete sleep stages and judgment conditions, and to store the physiological signals collected by the EEG acquisition device according to multiple pre-divided time windows. The data preprocessing module is used to preprocess the physiological signals to obtain standardized electroencephalogram (EEG) signals and standardized inertial sequences. The feature extraction module is used to extract features from the standardized EEG signals and the standardized inertial sequences to obtain a unified feature vector, an individual baseline model, and standardized EEG inputs for use by the sleep staging model. The model building module is used to construct a sleep staging model based on the physiological signals collected in at least two consecutive time windows in the early stage. The sleep staging model includes at least three parts: the pre-sleep stage (P), the sleep stage (S), and the wakefulness stage (W). The sleep staging reasoning module is used to input the standardized EEG signal and the standardized inertial sequence into the sleep staging model, and obtain the final sleep staging result of the current time window through feature mapping and temporal posterior. The sleep state transition judgment module is used to score sleep state and determine sleep state transition conditions for the pre-sleep stage (P), the sleep stage (S), and the wakefulness stage (W). It confirms the sleep state transition only when all sleep state transition conditions for a certain stage are met simultaneously. The sleep stimulation output judgment module is used to determine, based on the sleep state within the current time window, whether the user's physiological indicators within the current time window meet the safe stimulation conditions for the sleep state within the current time window according to the physiological signals within the current time window. If and only if all safe stimulation conditions for a certain stage are met simultaneously, the module sends an instruction to the controller to allow the execution of electrical stimulation for the current sleep state.
[0014] Furthermore, the waveform of the electrical stimulation output by the electrical stimulation device includes at least one of an asymmetric bipolar rectangular unmodulated wave and a rectangular modulated wave.
[0015] The beneficial effects of this invention are as follows: This invention provides a sleep regulation method and corresponding system based on brain-computer interface and six-axis gyroscope. Through the fusion acquisition of real-time EEG information and six-axis inertial information, combined with low-frequency pulse electrical stimulation for coordinated regulation, a phased regulation process of "pre-sleep identification and induction - sleep staging and monitoring - target time wake-up" is established. It can complete continuous state identification and corresponding control in the same system, forming a closed-loop process of pre-sleep guidance, sleep monitoring and timed wake-up. Combined with individual baseline normalization, feature mapping network and temporal posterior update mechanism, it can improve the ability to distinguish between states such as resting without sleep, near sleep, stable sleep and wakefulness trend, and reduce the error caused by direct fixed threshold judgment between different individuals. Stimulation reference sequence construction and reference artifact removal processing can still retain the suppressed EEG as an auxiliary criterion in the pre-sleep induction and wake-up stages, and default to discontinuous stimulation in the sleep stage, focusing on monitoring and staging analysis, thereby overcoming the problem of EEG signal contamination by stimulation artifacts and resulting in unstable feedback basis, and can take into account the regulation effectiveness, signal availability and safety. Attached Figure Description
[0016] One or more embodiments are illustrated by way of example with reference to the accompanying drawings, and these illustrative examples are not intended to limit the embodiments. The term "illustrative" as used herein means "serving as an example, embodiment, or illustration." Any embodiment illustrated herein as "illustrative" is not necessarily to be construed as superior to or better than other embodiments.
[0017] Figure 1 This is a schematic diagram of the sleep regulation system based on brain-computer interface and six-axis gyroscope described in Example 1.
[0018] Figure 2 This is a block diagram of the controller in the sleep regulation system based on brain-computer interface and six-axis gyroscope described in Example 1.
[0019] Figure 3 This is a flowchart illustrating the decision-making process for master state updates and electrical stimulation execution in the sleep regulation method based on brain-computer interface and six-axis gyroscope described in Example 2.
[0020] Figure 4 This is a schematic diagram of the unmodulated curve of the asymmetric bipolar rectangular wave applied in the sleep regulation method based on brain-computer interface and six-axis gyroscope described in Example 2.
[0021] Figure 5 This is a schematic diagram of the rectangular wave modulation waveform applied in the sleep regulation method based on brain-computer interface and six-axis gyroscope described in Example 2.
[0022] Figure 6This is a schematic diagram of the rectangular wave modulation wave applied in the sleep regulation method based on brain-computer interface and six-axis gyroscope described in Example 2, as well as the gradually increasing stimulus intensity envelope during the pre-sleep induction and target wake-up phases.
[0023] Figure 7 This is the restricted intermittent stimulation control curve during the sleep stage in the sleep regulation method based on brain-computer interface and six-axis gyroscope described in Example 2. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below. 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. Unless otherwise expressly stated, throughout the specification and claims, the term "comprising" or its variations such as "including" or "comprising of," etc., will be understood to include the stated elements or components, and does not exclude other elements or other components.
[0025] Furthermore, to better illustrate the present invention, numerous specific details are set forth in the following detailed embodiments. Those skilled in the art will understand that the present invention can still be practiced even without certain specific details. In some embodiments, materials, elements, methods, and means well known to those skilled in the art are not described in detail in order to highlight the spirit of the invention.
[0026] In this application, the EEG acquisition device may include two acquisition channels, Fp1 and Fp2, fixed to the user's forehead. It may also be expanded to include more forehead or central frontal leads, but the basic concept remains the same: the acquisition channels are positioned near Fp1 or Fp2, and inertial and EEG information are acquired and fused simultaneously for identification. In the following embodiments, the EEG acquisition device may be an EEG amplifier, specifically a patch-type EEG amplifier, which can be attached to the center of the user's forehead to facilitate the positioning and fixation of the acquisition channels.
[0027] In this application, the controller can be installed in a hardware device with operable input and output devices. Specifically, the hardware device can be a smartphone, tablet, laptop, desktop computer or other device with storage, display, computing and communication functions (collectively referred to as "host" in the following embodiments). It can establish wireless connections with the EEG acquisition device and the electrical stimulation device through Bluetooth, infrared, NFC, LoRa, ZigBee and other methods respectively.
[0028] In this application, the electrical stimulation device is a stimulation device that can output transcranial microcurrent electrical stimulation (CES) according to the instructions issued by the host. Specifically, it can be a conventional commercially available low-frequency pulse therapy device. The waveform output can be an asymmetric bipolar rectangular unmodulated wave and / or a rectangular modulated wave, or it can be other low-frequency microcurrent pulse waveforms with equivalent parameters, such as sine waves, triangular waves / sawtooth waves, trapezoidal waves, etc. In addition to linear gradual increase and decrease, the stimulation intensity adjustment method can also adopt cosine envelope, segmented ramp, or exponential envelope.
[0029] In this application, when using an electrical stimulation device to output electrical stimulation to the human body, an ear clip saline electrode can be used to form a wired connection between the electrical stimulation device and the human body; the ear clip saline electrode can also be replaced by a variety of non-invasive electrodes on the body surface, such as self-adhesive hydrogel patch electrodes, behind-the-ear electrodes, in-ear earplug electrodes, silicone conductive electrodes, headband array electrodes, handheld roller electrodes, metal disc electrodes, sponge-soaked electrodes, and integrated electrodes that combine eye masks / neckbands.
[0030] In this application, the sleep staging model can employ a one-dimensional convolutional network, a convolutional-recurrent network, a lightweight Transformer, or other lightweight deep learning models deployable on a host machine. All models use EEG segments, inertial segments, and their fused features as input, aiming to output the posterior probability of sleep stages. The sleep staging model includes three parts: the pre-sleep stage (P), the sleep stage (S), and the wakefulness stage (W). The sleep stage (S) can be further divided into four auxiliary states: wakefulness (Wake), light sleep (N1 / N2), deep sleep (N3), and REM sleep (Rapid Eye Movement Sleep), or five auxiliary states: wakefulness (Wake), light sleep stage 1 (N1), light sleep stage 2 (N2), deep sleep (N3), and REM sleep (Rapid Eye Movement Sleep). The following embodiments default to using five auxiliary states for sleep staging calculation.
[0031] In this application, the sleep stage can be set to perform only sleep stage analysis and abnormality detection, or limited intermittent CES stimulation when safety conditions, stage conditions and event triggering conditions are met, depending on the application purpose; however, regardless of the strategy adopted, continuous stimulation throughout the night is not a necessary prerequisite.
[0032] Example 1: This embodiment provides a sleep regulation system based on a brain-computer interface and a six-axis gyroscope, such as Figure 1 As shown, it specifically includes the following parts: Host 1, which is equipped with a controller that is configured to execute the entire algorithm for sleep regulation; The EEG amplifier 2 is a patch-type EEG amplifier with an axially symmetrical design. Acquisition electrodes Fp1 and Fp2 are respectively set at the left and right ends to form two acquisition channels. The reference electrode REF and the ground electrode GND are respectively set above and below the center of the line connecting Fp1 and Fp2. The EEG amplifier is equipped with a six-axis gyroscope for acquiring three-axis acceleration and three-axis angular velocity. Low-frequency pulse therapy device 3; and Ear clip saline electrode 4; like Figure 2 As shown, the controller includes the following parts: The storage module 11 is used to store the preset complete sleep stages and judgment conditions, and to store the physiological signals collected by the EEG acquisition device according to multiple pre-divided time windows. The data preprocessing module 12 is used to preprocess physiological signals to obtain standardized EEG signals and standardized inertial sequences; The feature extraction module 13 is used to extract features from standardized EEG signals and standardized inertial sequences to obtain a unified feature vector, an individual baseline model, and standardized EEG inputs for use by the sleep staging model. Model building module 14 is used to build a sleep staging model based on physiological signals collected in at least two consecutive time windows in the early stage. The sleep staging model includes at least three parts: the pre-sleep stage (P), the sleep stage (S), and the wakefulness stage (W). The sleep staging reasoning module 15 is used to input standardized EEG signals and standardized inertial sequences into the sleep staging model, and obtain the final sleep staging result of the current time window through feature mapping and temporal posterior. The sleep state switching judgment module 16 is used to score sleep state and determine sleep state switching conditions for the pre-sleep stage P, the sleep stage S and the wakefulness stage W respectively. It confirms the sleep state transition only when all sleep state switching conditions for a certain stage are met at the same time. The sleep stimulation output judgment module 17 is used to determine whether the user's physiological indicators in the current time window meet the safe stimulation conditions for the sleep state in the current time window based on the determined sleep state in the current time window and the physiological signals in the current time window. If and only if all safe stimulation conditions for a certain stage are met at the same time, the module sends an instruction to the controller to allow the execution of electrical stimulation for the current sleep state.
[0033] The host unit 1 is connected to the EEG amplifier 2 and the low-frequency pulse therapy device 3 via Bluetooth, thus establishing a continuous data acquisition link between the host unit 1 and the EEG amplifier 2, and an electrical stimulation execution link between the host unit 1 and the low-frequency pulse therapy device 3. Simultaneously, the low-frequency pulse therapy device 3 is wired to the human body via ear-clip saline electrodes 4, forming an electrical stimulation execution link. Therefore, the entire system completes the four functions of "acquisition, analysis, decision-making, and execution" in terms of hardware.
[0034] Example 2: This embodiment provides a sleep regulation method based on a brain-computer interface and a six-axis gyroscope, which is implemented using the regulation system provided in Embodiment 1. The specific process is as follows: 1. Initialization, synchronous acquisition and input definition.
[0035] After the system starts, it first completes the Bluetooth connection between the EEG amplifier and the host, the Bluetooth connection between the low-frequency pulse therapy device and the host, clock synchronization, lead contact check, and stimulator standby check. After initialization, the system first collects M preset baseline windows for subsequent individualized modeling, and then enters the formal operation stage. This stage outputs differential EEG input and six-axis inertial raw input, where EEG input is defined by equation (1).
[0036] The original six-axis inertial sequence and the differential EEG signal obtained by equation (1) are continuously acquired on the same time axis; regardless of whether there is electrical stimulation output in subsequent stages, these two types of inputs are used as the unified data entry.
[0037] Equation (1): ; In equation (1), Indicates the first The brainwave channel in the first Differential EEG signals at each sampling point; Indicates the first One electrode potential is collected; Indicates the reference electrode potential; The value is either Fp1 or Fp2. Subsequent EEG preprocessing, spectrum calculation, and feature extraction are all based on the signal obtained from equation (1).
[0038] The six-axis inertial sequence is denoted as ,in Values , , , , , These correspond to triaxial acceleration and triaxial angular velocity, respectively.
[0039] 2. Preprocessing, artifact suppression, and analysis of input construction.
[0040] After entering the formal operation phase, the system first performs uniform preprocessing on each fixed preset time window. For EEG data, the differential EEG signal obtained by equation (1) is first subjected to DC drift removal, power frequency suppression and bandpass filtering in sequence to obtain the EEG signal after basic preprocessing.
[0041] When electrical stimulation is applied in the current time window, for the physiological signals collected in the current time window (hereinafter referred to as the "stimulated window", and the opposite as the "non-stimulated window"), after completing the same basic preprocessing, the system needs to further generate a virtual time-domain electrical stimulation reference sequence according to the current stimulation control command, and perform stimulation artifact suppression to eliminate the noise generated by electrical stimulation on the EEG signal, and finally obtain the EEG input that can be used for subsequent analysis.
[0042] For inertial data, the system preferentially performs time synchronization, outlier removal, and zero-bias correction on the triaxial acceleration and triaxial angular velocity sequences, and further uses low-pass filtering, median filtering, or sliding smoothing to suppress sudden noise and high-frequency jitter; then it completes segmented processing according to the time window consistent with EEG, thereby outputting the preprocessed inertial sequence.
[0043] The preprocessing stage outputs two data streams: one stream serves as input to the feature extraction module 13, used to construct EEG features, inertial features, and quality features; the other stream serves as input to the sleep staging model, used for calculating the posterior probability of sleep stages, wakefulness trend score, and final staging result. Thus, the preprocessing stage itself forms a complete closed loop, no longer isolated from subsequent model analysis.
[0044] Equations (2) to (13) are used to explain the basic EEG preprocessing process shared by the non-stimulation window and the stimulation window; Equations (14) to (16) are used to explain the standardization process of the non-stimulation window and the construction of the virtual temporal electrical stimulation reference sequence and artifact suppression process of the stimulation window.
[0045] Equation (2): ; In equation (2), Indicates the first c Preprocessed EEG signals from each channel; This indicates the DC drift removal operator; Indicates the power frequency suppression operator; This represents the bandpass filter operator.
[0046] Equation (3): ; in, Indicates the first The first channel in the The original electroencephalogram (EEG) signals from each sampling point; This indicates the signal after DC drift removal processing; This indicates the number of sampling points in the current analysis window; This represents the signal mean within the window. Essentially, this operator subtracts the average value within the current window to reduce the impact of DC bias and slow drift on subsequent analysis.
[0047] In the formula, Indicates the power frequency suppression operator; This represents the bandpass filter operator. Wherein, and The following specific digital filtering algorithm can be used to achieve this.
[0048] A second-order digital notch filter is preferred for implementation. It is used to suppress power frequency interference. Its differential expression can be written as: Equation (4): ; in, This represents the EEG signal of the c-th channel after DC drift removal processing; This represents the output signal after power frequency suppression; , , Indicates the numerator coefficients of the notch filter; , This represents the denominator coefficients of the notch filter.
[0049] The transfer function of the second-order digital notch filter can be written as: Equation (5): ; in, The transfer function of the power frequency suppression filter is represented; = Indicates the center angular frequency of the power frequency; This represents the center frequency of the power frequency, taken as 50Hz. Indicates the sampling frequency; Denotes the radius of the pole, satisfying Used to control the notch bandwidth. The closer it is to 1, the narrower the notch band.
[0050] From equation (5), we can obtain: Equation (6): ; Equation (7): ; The algorithm has a clear implementation method and low computational cost, making it suitable for real-time execution on mobile phones, computers, or embedded host devices. It can effectively suppress power frequency and its adjacent narrowband interference while keeping other EEG frequency band components unchanged as much as possible.
[0051] It is preferable to use a digital bandpass filter. This is used to preserve the frequency band relevant to sleep recognition. Specifically, a finite impulse response bandpass filter algorithm can be used, and its convolution expression can be written as: Equation (8): ; in, Indicates the th after bandpass filtering One channel of EEG signals; This represents the input signal after power frequency suppression; Indicates the bandpass filter's first... One tap coefficient; Indicates the filter order.
[0052] The bandpass filter coefficients The ideal bandpass impulse response can be constructed using the window function method, and can be written as: Equation (9): ; Equation (10): when When, equation (9) holds true; Equation (11):
[0053] in, This represents the impulse response of an ideal bandpass filter; Indicates the lower bandpass angular frequency; Indicates the upper bandpass angular frequency; Indicates the lower bandpass cutoff frequency; Indicates the upper limit frequency of the bandpass; Indicates the center position of the filter; Indicates the sampling frequency.
[0054] To obtain realizable finite-length filter coefficients, a window function can be introduced. Therefore: Equation (12): ; in, The window function can be represented by a Hamming window, Hanning window, or Blackman window. Taking the Hamming window as an example, its expression can be written as: Equation (13): ; The passband filtering algorithm allows the passband range to be set as needed. For example, it covers the relevant frequency range for sleep analysis to preserve slow wave, spindle wave, and wakefulness-related frequency components, while suppressing ultra-low frequency drift and high frequency noise. Due to its fixed coefficients and stable structure, it is suitable for real-time EEG preprocessing.
[0055] In the unstimulated window, the preprocessed EEG can be standardized according to the window to obtain unstimulated EEG analysis. In the stimulated window, the system generates a virtual temporal electrical stimulation reference sequence based on the current stimulation control command, and performs artifact suppression on the preprocessed EEG accordingly to obtain stimulated EEG analysis. The preprocessed inertial sequence is then used in conjunction with the above-mentioned EEG analysis input on the same time axis for subsequent feature extraction and sleep staging model.
[0056] Equation (14): ; In equation (14), This represents the standardized electroencephalogram (EEG) signal; The filtered EEG signal obtained by expression (2); Indicates the first The first window The average of each channel; Indicates the first The first window Standard deviation of each channel; This represents a stable term to prevent the denominator from being zero. Equation (14) is derived from equation (2) and is used for calculating spectral and nonlinear characteristics.
[0057] Equation (15): ; In equation (15), This represents the stimulus reference sequence generated based on the current stimulus parameters; This indicates the reference stimulus waveform generation operator; This indicates the preset timing sequence of the stimulation current; This indicates the preset pulse repetition frequency; This indicates the preset pulse width parameter; This represents the preset waveform mode, with values for either unmodulated or modulated waves. Equation (15) generates... Artifact suppression for Equation (16).
[0058] Equation (16): ; In equation (16), This represents the EEG signal after artifact suppression; The preprocessed EEG signal obtained by expression (2); Indicates the first i Stimulus empty window retention gate function within each window; Indicates the preset first Artifact scaling factor for each channel; This represents the interpolation operator for the contaminated region. Equation (16) completes the suppression of stimulus artifacts based on Equations (2) and (15). If there is a stimulus within the window, the EEG features are uniformly calculated based on Equation (16).
[0059] 3. Feature extraction, quality assessment and individualized correction.
[0060] After preprocessing, the system extracts EEG features, inertial features, and signal quality features from the EEG analysis input obtained under no-stimulation or stimulated conditions, the preprocessed inertial sequence, and quality markers, respectively, and constructs a unified feature vector. This unified feature vector is used for subsequent master state determination, as well as for individualized correction, sleep preparation assessment, and stimulus trigger control.
[0061] Equation (17): ; In equation (17), Indicates the first i The complete feature vector of each time window; Represents the subvectors of EEG features; Represents the inertial eigenvector; This represents the signal quality feature vector. Subsequent equations (45) and (46) are based on equation (17) for individualized modeling.
[0062] in, f i EEG The preferred features include frequency domain characteristics, time domain characteristics, nonlinear characteristics, and cross-channel characteristics; The preferred features include those related to head movement intensity, posture changes, and degree of stillness; The preferred features include the proportion of bad segments, the proportion of saturation, and the proportion of residual stimulus artifacts.
[0063] The EEG feature subvector It can be represented as: Equation (18):
[0064]
[0065] ; The definitions of each EEG characteristic are as follows.
[0066] (i) Absolute power is defined as: Equation (19): ; in, Indicates the first Within the first time window Each channel in the frequency band Absolute power; Take Fp1 or Fp2; Pick , , , or ; Indicates the first Within the first time window The spectrum of each channel.
[0067] (ii) Relative power is defined as: Equation (20): ; in, Indicates the first Within the first time window Each channel in the frequency band The relative power on; and These represent the lower and upper limits of the analysis frequency band, respectively.
[0068] (iii) The average relative power of the two channels can be expressed as: Equation (21): ; in, Indicates the first i The average relative power of the two channels in frequency band b within a time window.
[0069] (iv) The frequency band power ratio characteristic is defined as: Equation (22): ; Equation (23): ; in, express Relative power ratio; express Relative power ratio; This represents a stable term that prevents the denominator from being zero.
[0070] (v) The spectral entropy feature is defined as: Equation (24): ; in, Indicates the first Within the first time window Spectral entropy of each channel.
[0071] (vi) The frequency band asymmetry index is defined as: Equation (25): ; in, Indicates the first Frequency band within a time window The bilateral frontal asymmetry index.
[0072] (vii) The phase-locked value is defined as: Equation (26): ; in, Indicates the first Phase lock values of Fp1 and Fp2 within a time window; Indicates the number of sampling points in the window; and These represent the instantaneous phases of the two channels, respectively.
[0073] (viii) The sample entropy is defined as: Equation (27): ; in, Indicates the first Within the first time window The sample entropy of each channel; Indicates the embedding dimension; Indicates tolerance; and They represent lengths of and The number of matching templates.
[0074] The inertial feature vector It can be represented as: Equation (28): ; The inertial characteristics are defined as follows.
[0075] (i) The mean resultant acceleration amplitude is defined as: Equation (29): ; in, , , They represent the first Triaxial acceleration sampling values within a time window.
[0076] (ii) The angular velocity energy is defined as: Equation (30): ; in, , , They represent the first The three-axis angular velocity sampling values within a time window.
[0077] (iii) The variance of the resultant acceleration is defined as: Equation (31): ; in, Equation (32): ; Equation (33): ; in, This represents the resultant acceleration amplitude at the nth sampling point; This represents its window mean.
[0078] (iv) The variance of the resultant angular velocity is defined as: Equation (34): ; in, Equation (35): ; Equation (36): ; in, Indicates the first The magnitude of the resultant angular velocity at each sampling point; This represents its window mean.
[0079] (v) The rate of change of attitude is defined as: Equation (37): ; in, ; and These represent the pitch and roll angles estimated from the six-axis inertial data, respectively.
[0080] (vi) The definition of body movement counting is: Equation (38): ; in, Indicates the first Exceeding the angular velocity threshold within a time window The number of sampling points; Represents the characteristic function.
[0081] (vii) The static index is defined as: Equation (39): ; in, The larger the value, the more inactive the user is; and This indicates the preset weighting coefficients.
[0082] The signal quality feature subvector It can be represented as: Equation (40): ; The signal quality characteristics are defined as follows.
[0083] (i) The percentage of bad segments is defined as: Equation (41): ; in, Indicates the first Within the first time window One channel exceeds the bad segment amplitude threshold. The percentage of sampling points.
[0084] (ii) The saturation ratio is defined as: Equation (42): ; in, Indicates the first Within the first time window One channel exceeds the saturation threshold. The percentage of sampling points; This represents the raw EEG sample value.
[0085] (iii) The percentage of residual stimulus artifacts is defined as: Equation (43): ; in, Indicates the first Within the first time window The percentage of residual stimulus artifacts in each channel; This indicates the signal before artifact suppression; This represents the signal after artifact suppression.
[0086] (iv) The overall signal quality index is defined as follows: Equation (44): ; in, The larger the value, the better the quality of the EEG signal within the current time window.
[0087] Equation (45): ; In equation (45), Represents the vector of individual baseline means; This indicates the number of baseline windows used for modeling during the initialization phase; The first term defined by equation (17) represents the... Each baseline window feature vector.
[0088] Equation (46): ; In equation (46), Represents the individual baseline covariance matrix; superscript This indicates transpose. Equations (46) and (45) together constitute the individual baseline model.
[0089] Equation (47): ; In equation (47), Indicates the first i The feature vector of each window after individual baseline correction; The expression obtained from equation (46) The scale matrix formed by the diagonal elements; This represents the inverse of the scaling matrix. The superscript in subsequent state ratings... All features are obtained from equation (47).
[0090] Through equations (17) to (47), the system obtains a unified feature vector, an individual baseline model, and standardized EEG inputs for use by the sleep staging network; these results together constitute the common input for subsequent state determination and stimulus control.
[0091] 4. State determination and state transition conditions jointly driven by features and model output.
[0092] After preprocessing, the system directly sends the processed EEG and inertial segments into the sleep staging model, and simultaneously sends the unified feature vector into the sleep staging inference module 15. The output of the sleep staging model and the unified feature vector are combined in this step and used together for the determination of the current master state and the calculation of the state transition conditions.
[0093] Equations (48) to (52) are used to explain the feature mapping, stage posterior probability, wakefulness trend score and final stage result of the sleep staging model; Equations (53) to (64) are used to explain the sleep readiness index, master state score, time posterior and state transition conditions from P to S and from S to W.
[0094] Equation (48): ; In equation (48), Indicates the first Temporal features extracted from each window via a feature mapping network; This represents the feature mapping function after offline training is completed; The window data representing the input model can be constructed by splicing EEG segments and inertial segments obtained by Equation (14) or Equation (16); The model parameters are represented. Equation (48) serves as the input for subsequent staging decisions.
[0095] Equation (49): ; In equation (49), Indicates the first This window belongs to the sleep stage. The unnormalized discriminant score; This represents the output layer weight matrix; This represents the output layer bias vector; The values are Wake, N1, N2, N3, and R.
[0096] Equation (50): ; In equation (50), Indicates the first Each window belongs to a stage. The posterior probability; It is given by equation (49). The output of equation (50) is used in equations (51) and (52).
[0097] Furthermore, in order to clarify formula (51) The calculation source is that the instantaneous motion intensity M_i of the current window can be obtained from the aforementioned inertial characteristics. Specifically, The preferred inertial characteristic vector is derived from Equation (28), and the angular velocity energy is defined by Equations (30), (31), (34), (37) and (38) respectively. , variance of combined acceleration Angular velocity variance Rate of change of posture and body movement counting The above inertial characteristics are obtained after individual baseline normalization using equation (47). , , , , The instantaneous motion intensity can be obtained by weighting:
[0098] Obtaining instantaneous motion intensity Then, time-series smoothing is performed on it to obtain the motion index M_{a,i} in equation (51):
[0099] in, to Indicates the weighting of exercise intensity calculation; Indicates the temporal smoothing coefficient of motion intensity; superscript This represents the individual baseline normalized characteristics obtained from equation (47). Therefore, The inertial feature sub-vectors derived from Equation (28) and the specific inertial features in Equations (30), (31), (34), (37), and (38).
[0100] Furthermore, in order to clarify formula (51) The source of the calculation, The power originates from the EEG feature subvectors described in equation (18). The frequency band power characteristics can be calculated using equations (19) to (21). Specifically, the power characteristics of the frequency band are first calculated using equation (19). Each channel within a window The absolute power of the frequency band is then calculated using equation (20). The relative power of the frequency bands is obtained from equation (21), and the average power of the two channels Fp1 and Fp2 is obtained from the equation (21). Relative power. After individual baseline normalization of the power characteristics using equation (47), it is denoted as Between adjacent windows The change in power can be expressed as:
[0101] in, A value greater than 0 indicates the current window The power has increased relative to the previous window. A value less than 0 indicates the current window Power decreases relative to the previous window. Therefore, The β power characteristics are derived from Equations (18) to (21) and the individual baseline normalization process is derived from Equation (47).
[0102] Equation (51): ; In equation (51), Indicates the first i The sobriety trend score of each window; and It is obtained from equation (50); This represents the motion index obtained after time-series smoothing of the window motion intensity; Indicates the distance between adjacent windows Power change; to This represents the weighting coefficient obtained based on offline collected data. Equation (51) is used in equations (64) and (69).
[0103] Equation (52): ; In equation (52), Indicates the first The final sleep staging results for each window; It is obtained from equation (50); This indicates the sleep stage from the previous stage result. Transition to sleep stage The transition probability, a value obtained from a large amount of offline data collection and statistics. The values are Wake, N1, N2, N3, and R. This represents the time-series constraint coefficient preset based on the offline data situation; This indicates the sleep staging results from the previous window.
[0104] The system employs a three-state master state machine, with the state set denoted as P, S, and W. Here, P represents the pre-sleep stage, S represents the sleep stage, and W represents the waking stage. Within any time window, the system first calculates the pre-sleep preparation criteria and the master state posterior, then decides whether to maintain the current stage, switch stages, or trigger subsequent stimuli.
[0105] During the stage determination process, the sleep staging network remains online, but its role changes with the stage: in the P stage, it mainly provides Wake (Wake is the network output result, not equal to the W state, and posterior probability and features such as gyroscopes are also needed for judgment), N1, and N2 to assist in judging the three-state host state; in the S stage, it provides the main staging result; and in the approaching W stage, it provides the awakening trend and exit criteria.
[0106] Equations (53) to (55) first calculate the pre-sleep preparation index, pre-sleep state score, and probability of being ready to fall asleep; these quantities are used to describe whether the user has shifted from "lying still without sleeping" to "having the conditions to fall asleep".
[0107] Based on this, equations (56) to (59) further calculate the scores, local probabilities, and temporal posteriors of the three main states of sleep, sleep and wakefulness, thereby extending the single-window decision to a steady-state estimation over continuous time.
[0108] Subsequently, equations (60) to (64) provide the switching conditions, confirmation windows, and wake-up warm-up conditions for P to S and S to W, respectively. Thus, before the system formally executes the stimulus or monitoring action at any stage, it has already obtained the current master state label, the posterior probability of each state, and the stage switching flag.
[0109] Equation (53): ; In equation (53), Indicates the first The bedtime preparation index for each window; , , , , as well as These represent the key discriminant quantities calculated from the aforementioned EEG features, inertial features, and signal quality features, respectively; where, This represents a robust sample entropy index obtained by combining dual-channel sample entropy and signal quality constraints. This represents the stimulus residue index constructed based on the proportion of artifact residues as described in equation (43); to This represents the weighting coefficient.
[0110] Equation (54): ; In equation (54), Indicates the first i The pre-sleep status score of each window; the superscript {norm} represents the individual baseline normalized feature obtained by equation (47); to The weight of the pre-sleep state score is represented. Equations (54) and (53) are used together in equation (55) for the probability mapping of sleep readiness.
[0111] Equation (55): ; In equation (55), Indicates the first The probability of being ready to fall asleep in each window; It is obtained from equation (53); It is obtained from equation (54); , , This represents the mapping coefficient.
[0112] When equations (53) to (55) indicate that the user is gradually ready to fall asleep, the system does not immediately output a stimulus, but continues to update the three-state master state machine in combination with equations (56) to (59) to avoid erroneous switching based on a single threshold or a single time window.
[0113] The main state machine uses a unified input interface for different stages, but the key criteria called in different stages are different: In stage P, the sleep preparation index obtained by equation (53) is used as the main criterion, and the judgment is made in combination with the auxiliary staging tendency; the auxiliary staging tendency refers to the tendency to fall asleep reflected by the related probabilities of Wake, N1 and N2 in the posterior probability of sleep stages obtained by equation (50). Direction is used to help distinguish between "awake and resting" and "approaching sleep." For example, when Decline and , As the sleep intensity increases, it indicates a stronger tendency for the user to transition from wakefulness to light sleep. In the S phase, the sleep staging results obtained from Equation (52) and the unified feature vector obtained from Equation (17) are primarily used. In the W phase, or the target wakefulness phase, the wakefulness trend score obtained from Equation (51), the temporal posterior obtained from Equation (59), and the preset wakefulness time involved in Equation (63) are primarily used. .
[0114] Therefore, equations (53) to (64) together complete the central step of "stage determination and host status update". The output results determine whether to enter the pre-sleep induction stage or whether to enter the sleep monitoring or target wake-up stage.
[0115] To improve the robustness of state determination, instead of using a single absolute threshold, we first calculate state scores for the three main states, and then perform local probability estimation and temporal posterior update.
[0116] Sleep status score is expressed as: Equation (56): ; In equation (56), Indicates the first A sleep status score for each window; and This represents the slow wave correlation characteristics after normalization by equation (47); This represents the normalized intensity of motion. It represents the normalized arousal tendency characteristics composed of arousal-related frequency band power, relative power ratio, and phase synchronization information; to This indicates the preset weighting coefficients.
[0117] The alertness score is calculated as follows: Equation (57): ; In equation (57), Indicates the first i Awareness score for each window; and They represent the normalized values respectively. , feature; This represents the normalized intensity of motion. It represents the normalized rhythmic characteristics composed of respiratory rhythm, body movement rhythm, or their proxy statistics; to This indicates the preset weight for the alertness score.
[0118] After obtaining the scores of each principal state from equations (54), (56), and (57), the local probability of the principal state is calculated by equation (58): Equation (58): ; In equation (58), Indicates the first This window belongs to the main state. The local probability when; Values , or hour, The equations (54), (56), and (57) are given respectively.
[0119] The posterior probability of the master state is obtained from equation (58) and the master state transition probability, and the calculation formula is equation (59): Equation (59): ; In equation (59), Indicates the first This window belongs to the main state. The temporal posterior probability; Indicates master state slave Transferred to The transition probability, here and Values , or ; This represents the temporal posterior probability of the previous window. Equation (59) updates the state posterior based on Equation (58).
[0120] The mean probability of falling asleep is obtained from equation (55), and the calculation formula is equation (60): Equation (60): ; In equation (60), Indicates as of the date The window, recent The average probability of being ready to fall asleep for each window; Calculated by equation (55); This indicates the number of windows smoothed before sleep.
[0121] The posterior difference between pre-sleep and mid-sleep states is obtained from equation (59), and the calculation formula is equation (61): Equation (61): ; In equation (61), Indicates the first i The pre-sleep to mid-sleep posterior difference for each window; and All are obtained from equation (59).
[0122] The switching flag from P to S is obtained from equations (60) and (61), and the calculation formula is equation (62): Equation (62): ; In equation (62), Indicates the first Does the window satisfy the requirement? arrive Switching conditions; It is obtained from equation (60); This represents the average threshold for sleep preparation. Indicates the posterior difference threshold; Indicates the number of consecutive confirmation windows. The system only responds when... Only when the main state is allowed to change Switch to .
[0123] When equation (62) determines that the switching condition from P to S is met, the system ends the pre-sleep preparation determination mode and enters the sleep stage; when equations (63) and (64) determine that the system has entered the wake-up warm-up stage and meets the switching preparation from S to W, the system then enters the target wake-up stage. For windows in the S stage that have not yet triggered equation (64), the system does not directly issue sleep stimuli, but continues to execute equations (65) to (71) in the order of "permission stage determination → safety sub-condition determination → safety total flag summary → sleep stimulus permission flag output". In other words, the stimulation or monitoring in subsequent stages are all based on the main state result and gating result output in this step.
[0124] The wake-up preheating interval flag is calculated using equation (63): Equation (63): ; In equation (63), Indicates the first Does each window enter the wake-up warm-up zone? Indicates the first Each window corresponds to the current time; Indicates setting the wake-up time; This represents the wake-up warm-up duration, where the wake-up warm-up interval can be written as... .
[0125] The switching flag from S to W is obtained from equations (51), (59), and (63), and the calculation formula is equation (64): Equation (64): ; In equation (64), Indicates the first Does the window satisfy the requirement? arrive Switching conditions; Calculated by equation (51); Indicates the threshold for alertness trend; and Let represent the temporal posterior probabilities of the waking and sleeping states, respectively. The system only... Only when the main state is allowed to change Switch to .
[0126] 5. Calculation of safe stimuli conditions during sleep.
[0127] For restricted stimulation during the sleep stage, after the main state has been determined to be in sleep and the target time wake-up switching process has not yet been entered, the system performs the following judgments for each window in sequence: First, calculate the sleep stage allowable flag (Equation (65)) based on the current stable sleep stage results, wake-up trend and N3 / R stage blocking conditions; Second, calculate the body movement safety flag (Equation (66)), refractory period safety flag (Equation (67)), artifact safety flag (Equation (68)) and switching conflict safety flag (Equation (69)) based on the body movement level, rest level, the time of the last stimulus end, stimulus artifact residue, overall signal quality and main state switching flag; Third, combine the above safety sub-conditions to obtain the sleep safety total flag (Equation (70)); Finally, combine the sleep stage allowable flag with the safety total flag to obtain the final sleep stimulation allowable flag (Equation (71)). The system only allows restricted intermittent stimulation during the sleep stage when both the permissible conditions and all safety conditions are met simultaneously; if any judgment condition fails, the system immediately cancels the current sleep stimulation output and reverts to the monitoring and staged analysis mode.
[0128] The permissible threshold for the sleep phase is calculated using equation (65): Equation (65): ; In equation (65), Indicates the first Does the window indicate a stage where sleep-restricted stimulation is permitted? This represents the current stable sleep stage result obtained from equation (52); The sobriety trend score is calculated using equation (51). This indicates the risk threshold for sleep instability or micro-arousals; and They represent the first i The posterior probabilities of each window belonging to the N3 stage and the R stage are calculated by equation (50). and These represent the probability thresholds for blocking sleep stimuli in the N3 and R stages, respectively. , and These are all stage-gated threshold variables, which can be set by system preset parameters, individual baseline statistical results, or empirical parameters obtained through training. When =1, it indicates that the current window is in the light sleep or unstable sleep range, and does not belong to the deep sleep or REM sleep stage that requires blocking sleep stimulation.
[0129] The physical safety sign is calculated using formula (66): Equation (66): ; In equation (66), Indicates the first Safety signs for movement at each window; Calculated by equation (38), representing the body movement count; Calculated by equation (39), representing the static index; Indicates the threshold for body movement counting; This represents the stillness threshold. Wherein, and These are the body movement safety threshold variables, corresponding to the "maximum allowed body movement count" and the "required minimum stillness level," respectively. Only when the current window's body movement is not excessive and the stillness level still meets the requirements... Only set to 1; if any condition fails, the current window will not be allowed to continue sleep stimulation.
[0130] The safety threshold for the refractory period is calculated using equation (67): Equation (67): ; In equation (67), Indicates the first Safety signs for the irritation refractory period of each window; Indicates the current time corresponding to the current window; Indicates the time when the most recent sleep stimulation ended; This indicates the threshold for the duration of the refractory period during sleep. Among them, This is a refractory period control threshold variable used to limit the minimum time interval between two sleep stimuli, preventing overly frequent stimulation. Only when the time since the most recent sleep stimulus has exceeded the refractory period length... Only take 1; otherwise, the current window must not continue or restart the sleep stimulation.
[0131] The security mark for the fake mark is calculated using equation (68): Equation (68): ; In equation (68), Indicates the first The fake security mark of the window; This represents the stimulus residue index constructed based on the proportion of stimulus artifact residues as described in equation (43); Calculated by equation (44), representing the comprehensive signal quality index; Indicates the artifact residual threshold; This represents the overall signal quality threshold. and These are the artifact and signal quality gating threshold variables, used to limit the stimulus residual from being too large and the effective signal quality from being too low, respectively. Only when the artifact residual is sufficiently low and the signal quality still meets the requirements will the signal quality be optimal. Only 1 is selected; if a strong artifact is detected or the signal quality is significantly reduced, the current window will not allow continued sleep stimulation.
[0132] The state transition conflict safety flag is calculated using equation (69): Equation (69): ; In equation (69), Indicates the first The main state switching conflict safety flag for each window; Calculated by equation (62), it represents the switching flag from P to S; Calculated by equation (64), it represents the switching flag from S to W. When the current window is in the process of confirming the main state switch, Setting it to 0 avoids conflict between restricted stimuli during sleep and the main state transition process. In other words, the main state transition judgment has higher priority than the sleep stimulus execution judgment.
[0133] From equations (66) to (69), the overall safety indicator during sleep is obtained, and the calculation formula is equation (70): Equation (70): ; In equation (70), Indicates the first The main safety sign for sleeping is located in each window; , , and These are given by equations (66), (67), (68), and (69), respectively. Only when all safety sub-conditions are simultaneously satisfied... Only take 1; as long as any safety subcondition becomes 0, That is, synchronization becomes 0.
[0134] The permissible threshold for sleep stimulation is obtained from equations (65) and (70), and its calculation formula is equation (71): Equation (71): ; In equation (71), Indicates the first The final gating sign for whether a window allows the implementation of sleep-restricted stimulation; Given by equation (65); It is given by equation (70). This is a direct decision variable from the output of the fourth stage determination and host status update step to the fifth stage stimulus execution step. The system only... Only during sleep can restricted intermittent stimulation be performed; when When this happens, the system immediately stops the current sleep stimulation, retaining only monitoring, staged analysis, and master state updates.
[0135] Therefore, the decision-making process in Part 4 ultimately produces two types of parallel outputs: one is the master state update result, used to determine whether the current state is P, S, or W; the other is the sleep stimulation permission flag Z_(stim,i), which is calculated only when the master state is S, used to determine whether the current window allows the implementation of sleep restricted stimulation or only maintains monitoring and staging analysis.
[0136] The above , , , , , , and All of these are used as gating threshold variables in the decision-making process. They can be configured by system default parameters, individual baseline statistical results, model training results, or manual settings, thereby making the judgment conditions of "allowing stimulation" and "must withdrawing stimulation" explicit.
[0137] 6. Stimulus output and phased execution method.
[0138] like Figure 3 As shown, after obtaining the master state update result and the sleep stimulation permission flag in Part 4, the system then determines whether to output stimulation and what type of stimulation to output based on the current master state, sleep stage results, wakefulness trend, and time conditions. The entire stimulation output is executed in three scenarios: pre-sleep induction, sleep-restricted intervention, and wake-up at the target time.
[0139] During the pre-sleep stage, when the master state remains at P and the sleep preparation conditions are met, the system outputs an induction stimulus; during the sleep stage, the system only allows the implementation of restricted intermittent stimulation when the sleep stimulation permission flag given by equation (71) is 1. If any stage condition or safety sub-condition fails and causes equation (71) = 0, the current sleep stimulation is immediately stopped and the monitoring and staged analysis is returned; when approaching the target wake-up time and meeting the S to W switching preparation conditions, the system outputs a gradually increasing wake-up stimulus.
[0140] The waveform selection and intensity envelope of the pre-sleep induction stimulus are given by equations (72) to (74), and the host can control the timing of its start, maintenance and exit according to the state determination result.
[0141] The unmodulated basic stimulus waveform during the sleep induction phase (e.g.) Figure 4As shown, the result is calculated from equation (72): Equation (72): ; In equation (72), An unmodulated wave representing an asymmetric bipolar rectangular wave; and These represent the amplitudes of the positive and negative phases, respectively. and These represent the pulse widths for the positive and negative phases, respectively. represents the phase delay; rect· represents the rectangular window function.
[0142] Modulated stimulus waveforms during the sleep induction phase (e.g.) Figure 5 As shown, the result is calculated from equation (73): Equation (73): ; In equation (73), Represents a rectangular wave modulated wave; Indicates the modulation coefficient; Indicates the modulation frequency; This represents a rectangular window function with a period of T.
[0143] The intensity of stimulation gradually increases during the pre-sleep induction phase (e.g., the envelope of stimulation). Figure 6 As shown, the result is calculated from equation (74): Equation (74): ; In equation (74), Indicates the time before bed. The intensity of the stimulus; Indicates the initial intensity of the pre-sleep stimulus; Indicates the target intensity of stimulation before bedtime; This indicates the duration of the gradually increasing pre-sleep stimulation. The host computer can obtain this value according to equation (55). The sum of equation (62) is obtained Control the timing of the execution of equations (72), (73) and (74).
[0144] For the sleep stage, the system primarily monitors and determines the sleep stimulation threshold obtained from equation (71). Only when the time is right should restricted intermittent stimulation be implemented; where Equation (65) gives the permissible stage marker, Equations (66) to (69) give the body movement, refractory period, artifact, and switching conflict safety markers respectively, and Equation (70) gives the overall safety marker during sleep. For the N3 and R stages, it is preferable not to implement regular stimulation, or only allow a strategy of lower intensity and strict restriction.
[0145] like Figure 7As shown, the restricted intermittent stimulation refers to the system not continuously outputting stimulation during the sleep stage S, but rather using the sleep stimulation permission flag obtained from equation (71). Only during a single allowed duration Internal output of a sleep stimulation intensity ;when , entering the stimulus refractory period described in formula (67) If a state switching conflict as described in equation (69) occurs, or if any of the gating conditions in equations (65) to (70) are not met, the system stops outputting stimuli and maintains the monitoring state. This indicates a preset upper limit for stimulation intensity during the sleep stage, used to limit... Maximum output amplitude; This indicates the permissible duration of a single intermittent stimulation during sleep. A single stimulation segment preferably employs an intensity envelope with linear crescendo, amplitude maintenance, and linear fading to avoid abrupt stimulation changes.
[0146] The gradually increasing stimulus intensity envelope during the target wake-up phase is calculated using equation (75): Equation (75): ; In equation (75), This indicates the intensity of the stimulus at time t during the arousal phase; Indicates the initial intensity of the arousal stimulus; Indicates the intensity of the arousal stimulus target; This indicates the duration of the gradually increasing arousal stimulus.
[0147] The arousal stimulus exit flag is calculated using equation (76): Equation (76): If and only if and ;otherwise ; In equation (76), Indicates the first Does each window meet the conditions for exiting the wake-up stimulus? It is obtained from equation (50); The smoothed motion intensity; This indicates the threshold for the probability of exiting while fully conscious; This indicates the exercise intensity exit threshold. The system only exits when... Only then does it enter the gradual withdrawal phase to avoid excessively strong or prolonged arousal stimulation.
[0148] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A sleep regulation method based on brain-computer interface and six-axis gyroscope, characterized in that, The method includes: The preset complete sleep stage is divided into multiple time windows, and the user's physiological signals are collected in real time within at least two consecutive time windows by the EEG acquisition device; the EEG acquisition device is an EEG amplifier equipped with a brain-computer interface and a six-axis gyroscope, and the physiological signals include differential EEG signals and six-axis inertial raw sequences. The controller constructs a sleep staging model based on the physiological signals, and executes the following methods in each of the subsequent time windows: The physiological signals of the user within the current time window are collected, and the collected physiological signals are processed to obtain a unified feature vector representing the individual sleep characteristics of the current user. Based on the sleep stage model and the unified feature vector, the sleep state at the current moment is determined, and it is determined whether the sleep state transition conditions are met; the sleep state includes at least the pre-sleep stage P, the sleep stage S, and the wakefulness stage W; When the sleep state transition conditions are met, based on the determined sleep state within the current time window, the physiological signals within the current time window are used to further determine whether the user's physiological indicators within the current time window meet the safe stimulation conditions for the sleep state within the current time window; the sleep state transition conditions include at least the conditions for transitioning from P to S and the conditions for transitioning from S to W. When the safety stimulation conditions are met, the electrical stimulation device outputs a pre-set electrical stimulation for the current sleep state; when the safety stimulation conditions are not met, the user's physiological signals are collected again and the judgment is made again. Preferably, the brain-computer interface includes at least two acquisition channels; Preferably, the electrical stimulation includes at least one of an asymmetric bipolar rectangular unmodulated wave and a rectangular modulated wave.
2. The sleep regulation method according to claim 1, characterized in that, The method for processing the physiological signal includes: The differential EEG signal is sequentially subjected to DC drift removal, power frequency suppression, and bandpass filtering to obtain a preprocessed standardized EEG signal; The data from different axes in the original six-axis inertial sequence are time-synchronized, corrected, and denoised to obtain a preprocessed standardized inertial sequence. Preferably, when the electrical stimulation is applied in the previous time window, the method for preprocessing the physiological signals acquired in the current time window further includes: Based on the application of the electrical stimulation within the migration time window, a virtual temporal electrical stimulation reference sequence is generated, and stimulation artifact suppression is performed on the electrical stimulation.
3. The sleep regulation method according to claim 2, characterized in that, The method for processing the physiological signals further includes: EEG features, inertial features, and signal quality features are extracted from the standardized EEG signals and the standardized inertial sequences, and the unified feature vector, individual baseline model, and standardized EEG input for use by the sleep staging model are generated.
4. The sleep regulation method according to claim 3, characterized in that, The methods for determining the current sleep state include: The standardized EEG signal and the standardized inertial sequence are input into the sleep staging model. Based on the master state machine, the final sleep staging result of the current time window is obtained by performing feature mapping and temporal posterior. The master state machine is a three-state master state machine, including three master states: P, S, and W. Preferably, the method for determining the sleep state at the current moment further includes: When the main state is S, the main state machine is further assisted by an auxiliary state machine to determine the final sleep stage result of the current time window. The auxiliary state machine includes five auxiliary states: Wake, light sleep stage 1 N1, light sleep stage 2 N2, deep sleep stage N3, and REM sleep stage.
5. The sleep regulation method according to claim 4, characterized in that, The methods for determining whether the sleep state transition conditions are met include: Based on the unified feature vector, for the pre-sleep stage P, the user's pre-sleep preparation index, pre-sleep status score and probability of falling asleep are calculated in the current time window to preliminarily determine whether the user has the conditions for falling asleep. When it is determined that the user has the conditions for falling asleep, continue to calculate the user's sleep state score and wakefulness score within the current time window for the sleep stage S and the wakefulness stage W, and further calculate the local probability that the main state of the current time window belongs to S based on the pre-sleep state score, the sleep state score and the wakefulness score. Perform a temporal posterior on the local probabilities, and confirm the switch from the P stage to the S stage if and only if the sleep preparation probability and the P-to-S switch posterior probability of the most recent N0 time windows simultaneously meet the preset conditions. Preferably, the method for determining whether the sleep state transition conditions are met further includes: After switching from stage P to stage S, based on the unified feature vector, the user's awakening trend score and wake-up warm-up interval flag within the current time window are calculated. Combined with the temporal posterior, the switch from stage S to stage W is confirmed if and only if the awakening trend score, the wake-up warm-up interval flag, and the temporal posterior simultaneously meet preset conditions.
6. The sleep regulation method according to claim 5, characterized in that, The methods for delivering the electrical stimulation include: Based on the determined sleep state within the current time window, the system continues to assess whether the user's physiological indicators within the current time window meet the safe stimulation conditions for the sleep state. For the pre-sleep stage P, when the main state remains at P and the user has the conditions for falling asleep, the electrical stimulation device outputs sleep-inducing stimulation. For the sleep stage S, the electrical stimulation device outputs limited intermittent stimulation if and only if the real-time calculated sleep stimulation allowance flag and all parameters used to calculate the sleep stimulation allowance flag meet the preset conditions; if any one or more parameters change or no longer meet the preset conditions during the real-time calculation of the sleep stimulation allowance flag, the current output stimulation is immediately stopped and the sleep state at the current moment is re-determined. The electrical stimulation device outputs a progressively stronger wake-up stimulus if and only if the time in the sleep stage S meets the preset target wake-up time and the preset conditions for switching from stage S to stage W are met.
7. The sleep regulation method according to claim 6, characterized in that, The methods for determining whether the safety stimulus conditions are met include: a. When switching from P stage to S stage but not yet to W stage, calculate the sleep stage permission flag based on the final sleep stage result of the current time window, the wakefulness score, and the preset segment blockage condition for switching from N3 stage to REM stage. b. Calculate the body movement safety flag, refractory period safety flag, artifact safety flag, and switching conflict safety flag based on the body movement level, resting degree, end time of the most recent stimulus, stimulus artifact residue, overall signal quality, and master state switching flag, respectively. c. Merge the physical safety sign, the refractory period safety sign, the artifact safety sign, and the switching conflict safety sign to obtain the overall sleep safety sign; d. Combine the sleep stage permission flag with the sleep safety overall flag to obtain the final sleep stimulation permission flag; the electrical stimulation is permitted to be performed if and only if the sleep stage permission flag and the sleep safety overall flag simultaneously meet the preset conditions.
8. A sleep regulation system based on a brain-computer interface and a six-axis gyroscope, characterized in that, Includes the following parts: An EEG acquisition device includes an EEG amplifier and a brain-computer interface, wherein the EEG amplifier is equipped with a six-axis gyroscope and the brain-computer interface includes at least two acquisition channels. An electrical stimulation device, comprising a pulse output device and electrodes connected to the pulse output device and a human body; A controller configured to perform the method of any one of claims 1 to 7.
9. The sleep regulation system according to claim 8, characterized in that, The controller includes the following components: The storage module is used to store the preset complete sleep stages and judgment conditions, and to store the physiological signals collected by the EEG acquisition device according to multiple pre-divided time windows. The data preprocessing module is used to preprocess the physiological signals to obtain standardized electroencephalogram (EEG) signals and standardized inertial sequences. The feature extraction module is used to extract features from the standardized EEG signals and the standardized inertial sequences to obtain a unified feature vector, an individual baseline model, and standardized EEG inputs for use by the sleep staging model. The model building module is used to construct a sleep staging model based on the physiological signals collected in at least two consecutive time windows in the early stage. The sleep staging model includes at least three parts: the pre-sleep stage (P), the sleep stage (S), and the wakefulness stage (W). The sleep staging reasoning module is used to input the standardized EEG signal and the standardized inertial sequence into the sleep staging model, and obtain the final sleep staging result of the current time window through feature mapping and temporal posterior. The sleep state transition judgment module is used to score sleep state and determine sleep state transition conditions for the pre-sleep stage (P), the sleep stage (S), and the wakefulness stage (W). It confirms the sleep state transition only when all sleep state transition conditions for a certain stage are met simultaneously. The sleep stimulation output judgment module is used to determine, based on the sleep state within the current time window, whether the user's physiological indicators within the current time window meet the safe stimulation conditions for the sleep state within the current time window according to the physiological signals within the current time window. If and only if all safe stimulation conditions for a certain stage are met simultaneously, the module sends an instruction to the controller to allow the execution of electrical stimulation for the current sleep state.
10. The sleep regulation system according to claim 9, characterized in that, The waveform of the electrical stimulation output by the electrical stimulation device includes at least one of an asymmetric bipolar rectangular unmodulated wave and a rectangular modulated wave.