Adaptive transcranial electrical stimulation sleep aid method, system, and computer readable storage medium

By constructing an individual-specific sleep baseline model and real-time sleep staging, and dynamically generating electrical stimulation parameters, the low efficiency and insufficient safety of existing transcranial electrical stimulation sleep aids have been solved, enabling personalized sleep intervention and improving sleep quality and safety.

CN122479306APending Publication Date: 2026-07-31HANGZHOU MAIDONG SHUKANG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HANGZHOU MAIDONG SHUKANG TECH CO LTD
Filing Date
2026-06-30
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing transcranial electrical stimulation (TCS) sleep aid technology suffers from low open-loop control efficiency, lack of personalized adaptation, and insufficient safety. It cannot identify sleep stages in real time and cannot adapt to the differences in skull thickness and EEG characteristics among different users, resulting in some users feeling that it is ineffective or experiencing discomfort.

Method used

By collecting users' EEG and heart rate variability signals, an individual-specific sleep baseline model is constructed. Convolutional neural networks are used for real-time sleep staging, and electrical stimulation parameters are dynamically generated and adaptively adjusted through feedback control algorithms. Combined with electrode and skin impedance monitoring and micro-awakening event detection, a safety circuit breaker mechanism is implemented.

Benefits of technology

It enables real-time adjustments based on individual brain state, improving the efficiency and safety of sleep intervention, shortening sleep onset time, prolonging deep sleep duration, improving sleep quality, and consolidating memory.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122479306A_ABST
    Figure CN122479306A_ABST
Patent Text Reader

Abstract

This invention provides an adaptive transcranial electrical stimulation (TCS) method, system, and computer-readable storage medium for sleep aid. The method first constructs a sleep baseline model, mapping the individual's alpha wave peak frequency to a cortical excitability benchmark and deriving the neural excitability current threshold. A sleep latency prediction function is established based on heart rate variability, transforming general stimulation parameters into individualized dynamic benchmarks. Physiological signals are collected and compared with the baseline model, and a lightweight convolutional neural network is used to achieve millisecond-level sleep staging. Stimulation parameters are dynamically generated based on the staging results. During the difficulty falling asleep stage, a frequency-skipping strategy decreasing from the individual's intracranial electrical activity (IAF) to the Theta band is implemented. During deep sleep, slow-wave phase real-time prediction and locking technology is used to precisely apply the same-frequency stimulation. Simultaneously, a multi-level safety system is constructed through impedance monitoring, micro-awakening event detection, and PID feedback control to eliminate the risk of stinging sensations and skin burns.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of neuromodulation technology, specifically to an adaptive transcranial electrical stimulation sleep aid method, system, and computer-readable storage medium based on multimodal closed-loop feedback. Background Technology

[0002] Sleep disorders have become a widespread problem affecting the physical and mental health of modern populations, mainly manifested as difficulty falling asleep, difficulty maintaining sleep, and insufficient deep sleep. Long-term sleep deprivation can lead to decreased cognitive ability, weakened immunity, and an increased risk of cardiovascular disease. Current mainstream intervention methods are divided into two categories: pharmacological and non-pharmacological. Pharmacological treatment is fast-acting but easily leads to drug tolerance and dependence, and may also cause side effects such as drowsiness the following day. Non-pharmacological treatment is represented by cognitive behavioral therapy for insomnia (CBT-I), but the intervention period is long, it relies heavily on professional physicians, and is difficult to popularize widely.

[0003] Current non-invasive physical interventions primarily utilize transcranial microcurrent stimulation (CES) and transcranial direct current stimulation (tDCS). These products mostly employ open-loop control, directly outputting weak currents of fixed frequency and waveform. By regulating the secretion of neurotransmitters (such as serotonin and gamma-aminobutyric acid) in the hypothalamus and brainstem reticular formation, they alter neuronal membrane potentials and modulate cortical excitability, thereby improving sleep. However, these approaches rely on statistical averages and do not dynamically adjust to the individual's real-time brain physiological state.

[0004] Currently, this type of technology has two major drawbacks: First, open-loop blind stimulation is inefficient, the device cannot identify sleep stages in real time, fixed stimulation may cause unexpected awakening during deep sleep, or fail to effectively guide sleep during wakefulness; Second, it lacks personalized parameter adaptation, uniform stimulation parameters cannot adapt to the differences in skull thickness and EEG characteristics of different users, which may result in some users feeling no effect, while others may experience discomfort such as tingling or dizziness. Summary of the Invention

[0005] This invention aims to address the problems of low open-loop control efficiency, lack of personalized adaptation, and insufficient safety in existing transcranial electrical stimulation (TCS) sleep aid techniques, and provides an adaptive TCS sleep aid method: Collect users' resting physiological signals, which include at least electroencephalogram (EEG) signals and heart rate variability signals. Use feature extraction to identify the individual's alpha wave peak frequency and autonomic nervous system balance. The peak frequency of an individual's alpha wave is mapped to a cortical excitability benchmark value using the Sigmoid function; this benchmark value is then mapped to a neural excitability current threshold; and a sleep latency prediction function is established based on heart rate variability characteristics. The calculated cortical excitability baseline value, neural excitability current threshold, and sleep latency prediction function value are combined into a feature vector to construct a sleep baseline model; The user's physiological signals collected in real time are compared with the sleep baseline model, and a convolutional neural network is used to determine sleep stages. The sleep stages include at least one or more of the following: wakefulness, light sleep, deep sleep, and REM sleep. Based on real-time sleep stage results, electrical stimulation parameter instructions adapted to the current brain state are dynamically generated. The instructions include stimulation mode, frequency, current intensity, and waveform. During stimulation, based on real-time electrode and skin impedance monitoring and micro-awakening event detection, the current intensity is adaptively adjusted through a feedback control algorithm or a safety fuse is triggered in case of an abnormality.

[0006] The specific steps for constructing a sleep baseline model that includes individual-specific sleep latency characteristics and neural excitability thresholds include: The alpha peak frequency (IAF) of an individual is mapped to a baseline value of cortical excitability using the sigmoid function. ; Based on the mapping of cortical excitability benchmark values ​​to neural excitability current thresholds ; Establish a sleep latency prediction function based on heart rate variability characteristics. ; The calculated baseline value of cortical excitability Threshold of nerve excitability current and sleep latency prediction function The data is encapsulated into feature vectors to construct a sleep baseline model that includes individual-specific neural excitability boundaries and time response curves.

[0007] Secondly, the present invention provides an adaptive transcranial electrical stimulation sleep aid system, comprising: The signal acquisition module is used to acquire resting-state electroencephalogram (EEG) signals, electrooculogram (EOG) signals, and heart rate variability signals after the user wears the device, as well as to acquire physiological signals during sleep in real time. The baseline construction module is used to identify an individual's Alpha wave peak frequency and autonomic nervous system balance state through feature extraction and multidimensional data fusion analysis algorithms, and to construct a sleep baseline model that includes individual-specific sleep latency characteristics and neural excitability thresholds. The sleep staging module is used to perform real-time sleep staging discrimination based on the comparison between real-time collected physiological signals and the sleep baseline model, using a lightweight convolutional neural network. The stimulation generation module is used to dynamically generate electrical stimulation parameter instructions that are adapted to the current brain state based on the sleep stage results. When the user is detected to be awake or having difficulty falling asleep, the frequency glide strategy is executed. When the user is detected to have entered the N2 or N3 sleep stage and slow wave activity is detected, closed-loop phase-locked stimulation is executed. The safety monitoring module is used to monitor electrode-skin impedance and micro-awakening events after stimulation in real time. It adaptively adjusts the current intensity through a PID feedback control algorithm and triggers a safety fuse mechanism in case of abnormality.

[0008] Thirdly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to perform the above-described adaptive transcranial electrical stimulation sleep aid method.

[0009] This invention first constructs a sleep baseline model that includes individual sleep latency characteristics and neural excitability thresholds, and performs in-depth analysis of the user's EEG signals and heart rate variability in a resting state. The model uses the Sigmoid function to map the individual's Alpha wave peak frequency to a cortical excitability benchmark value, and calculates a unique neural excitability current threshold accordingly. At the same time, a sleep latency prediction function is established based on heart rate variability characteristics to accurately quantify the relationship between the balance state of the sympathetic and parasympathetic nervous systems and the duration of sleep onset, converting general stimulation parameters into a dynamic benchmark adapted to the individual, providing a precise individualized reference for subsequent closed-loop regulation.

[0010] Based on this, the system collects users' physiological signals in real time and compares them with a sleep baseline model, using a lightweight convolutional neural network for real-time sleep stage discrimination. Using a standardized state difference tensor as input, combined with depthwise separable convolution and attention mechanisms, it achieves millisecond-level accurate identification of wakefulness, light sleep, deep sleep, and REM sleep on the embedded device. This provides real-time judgment for stimulus regulation, ensuring that intervention strategies strictly follow the brain's current state, avoiding awakenings caused by stage errors in open-loop stimulation, and guaranteeing a continuous and stable sleep process.

[0011] Based on this, the present invention dynamically generates electrical stimulation parameters that match the current brain state according to real-time sleep staging results. It employs either a frequency-skipping strategy or closed-loop phase-locked stimulation at different sleep stages to precisely synchronize the stimulation pattern with the brain's endogenous activity. During the difficulty falling asleep stage, tACS stimulation, linearly decreasing from the individual's IAF to the Theta band, is used to smoothly guide the brain into sleep through the brainwave entrainment effect. During deep sleep, the slow-wave phase is predicted in real-time using Hilbert transform and an autoregressive model. Simultaneous so-tDCS stimulation is precisely applied at the slow-wave peak, achieving seamless connection and precise intervention between the sleep onset and deep sleep modes. This effectively shortens sleep onset time, significantly increases slow-wave amplitude, prolongs deep sleep duration, thereby improving sleep quality and consolidating memory.

[0012] The above description is merely an overview of the technical solution disclosed herein. In order to better understand the technical means of this disclosure and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0013] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0014] Figure 1 A flowchart of an adaptive transcranial electrical stimulation sleep aid method based on multimodal closed-loop feedback provided in this embodiment of the disclosure.

[0015] Figure 2 A flowchart illustrating the method for constructing a sleep baseline model provided in this embodiment.

[0016] Figure 3 A flowchart illustrating the real-time sleep staging and stimulation strategy generation method provided in this embodiment.

[0017] Figure 4 A flowchart of a frequency conversion induction method for the sleep induction period provided in an embodiment of this disclosure.

[0018] Figure 5 A flowchart of a phase-locking enhancement method for deep sleep provided in an embodiment of this disclosure.

[0019] Figure 6 This is a flowchart of the security monitoring and end-point feedback adjustment method provided in the embodiments of this disclosure.

[0020] Figure 7This is a schematic diagram of an adaptive transcranial electrical stimulation sleep aid system provided in an embodiment of this disclosure.

[0021] Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure. Detailed Implementation

[0022] The embodiments of this disclosure will now be described in detail with reference to the accompanying drawings.

[0023] It should be understood that the following specific examples illustrate the implementation of this disclosure, and those skilled in the art can easily understand other advantages and effects of this disclosure from the content disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. This disclosure can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this disclosure. It should be noted that, in the absence of conflict, the following embodiments and features in the embodiments can be combined with each other. Based on the embodiments in this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0024] It should be noted that various aspects of embodiments within the scope of the appended claims are described below. It will be apparent that the aspects described herein can be embodied in a wide variety of forms, and any particular structure and / or function described herein is merely illustrative. Based on this disclosure, those skilled in the art will understand that one aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects set forth herein can be used to implement the device and / or practice the method. Additionally, this device and / or method can be implemented using structures and / or functionalities other than one or more of the aspects set forth herein.

[0025] It should also be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this disclosure. The drawings only show the components related to this disclosure and are not drawn according to the number, shape and size of the components in actual implementation. In actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.

[0026] Furthermore, specific details are provided in the following description to facilitate a thorough understanding of the examples. However, those skilled in the art will understand that the described aspects can be practiced without these specific details.

[0027] See Figure 1As shown, this embodiment provides an adaptive transcranial electrical stimulation sleep aid method based on multimodal closed-loop feedback, which specifically includes the following steps: Step S1. Collect physiological signals such as resting-state electroencephalogram (EEG), electrooculogram (EOG), and heart rate variability (HRV) after the user wears the device. Through feature extraction and multidimensional data fusion analysis, identify the individual's alpha wave peak frequency (IAF) and autonomic nervous system balance state, and construct a sleep baseline model that includes individual-specific sleep latency characteristics and neural excitability thresholds. See Appendix Figure 2 The construction of a sleep baseline model is achieved through the following steps: Step 101: Collect physiological signals such as resting-state electroencephalogram (EEG), electrooculogram (EOG), and heart rate variability (HRV) after the user wears the device.

[0028] The device utilizes a sensor array integrated within the head-mounted display to perform data acquisition. Specifically, flexible dry electrode sensors, corresponding to the Fp1 and Fp2 sites of the international 10-20 system, are distributed on the forehead and mastoid process behind the ears to construct a differential signal acquisition loop to obtain bioelectrical signals containing EEG and EEG characteristics. Simultaneously, a reflective photoplethysmography (PPG) sensor, attached to the skin surface, collects pulse wave data by monitoring changes in subcutaneous vascular volume. The acquired raw signals are processed by a low-noise amplifier and an analog-to-digital converter, and then analyzed in real time into physiological signals such as the user's resting-state EEG, EEG, and heart rate variability (HRV) calculated based on pulse wave intervals.

[0029] Step 102: Apply feature extraction and data fusion analysis algorithms to identify the individual's Alpha peak frequency (IAF) and the balance state of the autonomic nervous system.

[0030] First, the acquired raw EEG signals were subjected to bidirectional zero-phase filtering using a fourth-order Butterworth bandpass filter, with passband cutoff frequencies set at 0.5Hz and 45Hz. Then, a 5-layer discrete wavelet transform (DWT) was performed using a db4 wavelet basis to remove artifacts from the electrooculogram (EOG) and electromyogram (EMG) signals with soft thresholding. Subsequently, the power spectral density (PSD) was estimated using the Welch periodogram method with a Hanning window, and Gaussian fitting was performed within the 8-13Hz alpha band. Finally, a nonlinear least squares method, such as the Levenberg-Marquardt algorithm, was used to accurately determine the individual alpha peak frequency (IAF).

[0031] Simultaneously, photoplethysmography (PPG) data is processed using an adaptive differential thresholding algorithm, and a dynamic threshold is set. , ( (as weighting coefficients), precisely locating the peak point of the pulse wave. Extracting RR interval sequences To meet the requirement of equal-interval sampling for frequency domain analysis, the non-uniformly sampled RRI sequence was resampled using 4Hz cubic spline interpolation; the power spectrum of heart rate variability was calculated using Fast Fourier Transform (FFT). According to the formula respectively and Frequency domain integration is performed, where LF represents low-frequency power, reflecting mixed sympathetic and parasympathetic activity; HF represents high-frequency power, primarily reflecting parasympathetic activity. Finally, the ratio of the two is calculated. The system uses a sliding average filter with a window length of 5 minutes for smoothing to quantify the dynamic balance between the sympathetic and parasympathetic nervous systems, thereby identifying the balance state of the autonomic nervous system.

[0032] Step 103: Based on the parameters identified above, construct a sleep baseline model that includes individual-specific sleep latency characteristics and neural excitability thresholds.

[0033] Based on the identified Alpha wave peak frequency (IAF), the frequency shift deviation of IAF relative to the population mean is mapped to a cortical excitability baseline using the Sigmoid nonlinear transfer function. ,in It can be set to It is the average frequency of alpha waves in the general population. This is the sensitivity coefficient. The higher the IAF, The larger the value, the higher the baseline level of cortical excitability. This baseline value is mapped to the upper limit of the initial stimulus current, i.e., the neural excitability current threshold. , The maximum permissible current is set to 2.0 mA according to IEC 60601-1 standard. This threshold is used as an upper limit constraint for subsequent stimulus intensity settings. Simultaneously, to address the impact of autonomic nervous system regulation on sleep onset speed, a sleep latency prediction function is established based on heart rate variability characteristics. The baseline time coefficients were calculated using historical clinical data and the least squares method. With pressure sensitivity coefficient The positive correlation between the sympathetic / parasympathetic balance ratio (LF / HF) and sleep onset time was quantified. The sleep latency prediction function was used to generate slowly time-varying regulation parameters, while real-time closed-loop control was rapidly updated based on EEG signals. Finally, the calculated current threshold was... With predicted incubation period Cortical excitability benchmark The mapping rules between cortical excitability and stimulation parameters are encapsulated into feature vectors to construct a sleep baseline model that includes individual-specific neural excitability boundaries and time response curves.

[0034] The model encapsulates the current intensity boundary determined based on IAF frequency shift deviation, the time response curve fitted based on the autonomic nerve balance ratio LF / HF, the frequency glide slope corresponding to different cortical excitability, and the initial current intensity rules into a multidimensional feature vector to guide the initialization of stimulus parameters.

[0035] Step S2. Based on the comparison between real-time acquired physiological signals and the baseline model, a lightweight convolutional neural network (CNN) is used to perform real-time sleep stage discrimination (awake stage, N1 / N2 light sleep stage, N3 deep sleep stage, REM sleep stage), dynamically generating electrical stimulation parameter instructions (including stimulation mode, frequency, current intensity, and waveform) adapted to the current brain state. See Appendix Figure 3 Real-time sleep staging and stimulation strategy generation are achieved through the following steps: Step 201: Compare the real-time collected physiological signals with the sleep baseline model.

[0036] The fourth-order Butterworth bandpass filter and db4 wavelet soft thresholding denoising algorithm from step 102 are reused to preprocess the real-time physiological signals, filtering out power line interference and electromyography artifacts, and improving the signal-to-noise ratio. Subsequently, a sliding time window with a window length of 30 seconds and an overlap rate of 75% is used to construct a real-time EEG time-frequency map through short-time Fourier transform (STFT), decomposing the non-stationary EEG signal into a two-dimensional time-frequency matrix to capture the dynamic changes of transient EEG features such as spindle waves and K-complexes during sleep.

[0037] The power integral of the Beta band (13Hz–30Hz) and the Alpha band (8Hz–13Hz) is calculated in real time to obtain the Beta / Alpha power ratio. Calculate the real-time cortical excitability bias. This indicator reflects the degree to which the current cortical arousal level deviates from the individual's baseline. A positive value indicates over-arousal, and a negative value indicates relaxation. It also simultaneously calculates the real-time low-to-high frequency ratio of heart rate variability. This method quantifies the real-time antagonistic balance between the sympathetic and parasympathetic nervous systems, serving as a quantitative indicator for assessing the body's autonomic nervous system regulatory capacity. Real-time feature vectors are mapped to the sleep baseline model space, and the real-time alpha peak frequency is calculated using a difference metric algorithm. The frequency domain Euclidean distance between the frequency corresponding to the maximum power spectral density in the 8-13Hz band and the baseline IAF. This indicator is used to quantify the frequency shift of the current dominant brain rhythm relative to an individual's resting baseline, reflecting brain fatigue and sleep onset trends. Combining these features with the bias quantity generates a state difference tensor, which serves as input for subsequent sleep staging models.

[0038] Step 202: Use a lightweight convolutional neural network (CNN) to perform real-time sleep stage discrimination to determine whether the user is in the waking stage, N1 / N2 light sleep stage, N3 deep sleep stage, or REM stage.

[0039] The standardized state difference tensor is input into a pre-defined improved EEGNet-SE lightweight convolutional neural network model. This model employs a fusion architecture of depthwise separable convolutions and channel attention mechanisms adapted for embedded edge inference, consisting of three cascaded processing units: the first layer uses a 1×64 kernel temporal convolutional layer to extract broadband temporal features; the core is a depthwise separable convolutional block, which first extracts spatial topological features through a C×1 kernel deep convolutional layer, embedding an SE channel attention module to adaptively strengthen the weights of key features such as sleep spindle waves, and then completes cross-channel information fusion through a 1×1 pointwise convolutional layer. Batch normalization (BN) layers and ELU activation functions are set between each processing unit, and dimensionality reduction is achieved using an average pooling layer with a stride of 1×4. Finally, the feature tensor is flattened by a global average pooling layer and then fed into a fully connected layer through a Dropout layer with a dropout rate of 0.5. The Softmax classification function calculates the probability distribution of the current time period corresponding to the awake period, N1 / N2 light sleep period, N3 deep sleep period and REM period, and outputs the real-time sleep staging results according to the principle of maximum probability.

[0040] Step 203: Based on the real-time staging results, dynamically generate electrical stimulation parameter instructions that are adapted to the current brain state, including stimulation mode, frequency, current intensity and waveform.

[0041] The pre-defined stage-strategy mapping logic library is invoked to match the corresponding stimulation modality based on the real-time sleep stage results. If the sleep stage is determined to be awake or N1 / N2 light sleep, a transcranial alternating current stimulation (tACS) command is generated, using a sine wave waveform. The initial frequency is anchored to the user's alpha wave peak frequency (IAF), and the step parameters are calculated to linearly decrease to the Theta band. If the sleep stage is determined to be N3 deep sleep, a slow oscillation transcranial direct current stimulation (so-tDCS) command is generated, using a 0.75Hz quasi-sine wave waveform, with the current intensity set to 80% of the neural excitability threshold in the baseline model. If the sleep stage is determined to be REM sleep, a zero-intensity silence command is generated. The awake and N1 / N2 stages employ a frequency-induction (frequency glide) strategy, utilizing the brainwave entrainment effect to smoothly transition the brain from a high-arousal state to a sleep state. This includes sleep difficulty detection, frequency glide parameter calculation, waveform generation, and brainwave entrainment verification, detailed in step S3. Finally, the parameter set containing the stimulation mode, frequency, intensity and waveform is encoded into a control signal and sent to the hardware execution end.

[0042] If the patient is determined to be awake or experiencing difficulty falling asleep, a transcranial alternating current stimulation (tACS) command is generated. The waveform is set to a sine wave with a duty cycle of 100%, a current ripple coefficient ≤5%, an initial frequency anchored to the user's alpha peak frequency (IAF), a termination frequency of 4-6 Hz, a frequency jump slope of 0.1-0.2 Hz / s, and a current intensity of 0.5 × 10⁻⁶ Hz. ~0.8× The duration of a single stimulation is 10-30 minutes. The electrode sites are Fp1 / Fp2, the bilateral main stimulation electrodes, and M1 / M2, the reference electrodes. The bipolar circuit has independent output.

[0043] If the determination result is N1 light sleep stage, generate a weak tACS stimulus instruction with a frequency of 6-8Hz in the Theta band and a current intensity of 0.3× ~0.5× With a duty cycle of 50%, the electrode sites are kept at Fp1 / Fp2, and the stimulation intensity is reduced to avoid micro-awakening.

[0044] If the determination result is N2 light sleep stage, a microcurrent of 0.1-0.2mA is applied to the so-tDCS only when sleep spindle waves are detected to enhance the coupling between spindle waves and slow waves, and the electrode site is switched to the Fz midline.

[0045] If the determination result is N3 deep sleep stage, generate a slow oscillation transcranial direct current stimulation (so-tDCS) command, setting the frequency to a quasi-sine wave of 0.5-1Hz and the current intensity to 0.7× ~0.9× (Absolute range 1.0-1.5mA), single stimulation lasts 1s, stimulation interval 3-5s, inter-electrode voltage ≤3V, electrode site is the main stimulating electrode of Fz midline, and the reference electrode M1+M2 combined.

[0046] If the REM sleep is detected, a zero-intensity silence command is generated to completely shut off the stimulation current and the electrode carrier signal to avoid interfering with rapid eye movement sleep.

[0047] Step S3. When the user is detected to be awake or having difficulty falling asleep, the frequency glide strategy of transcranial alternating current stimulation (tACS) is executed, so that the stimulation frequency gradually decreases linearly from the individual IAF frequency to the Theta band. The brain wave entrainment effect is used to inhibit cortical over-arousal and guide the brain to smoothly enter the N1 sleep stage. For the specific frequency induction implementation steps, please refer to Figure 4.

[0048] Step 301: Monitor EEG signals in real time. When the system detects that the user is awake or has difficulty falling asleep with a high proportion of Beta waves.

[0049] Real-time reading of sleep staging results; if the sleep stage is determined to be awake, further frequency domain analysis of the EEG signal is performed. The real-time EEG data is windowed using the Hanning window, and the absolute power in the Beta band (13-30Hz) is calculated using Fast Fourier Transform. and total power across the entire frequency band Calculate the relative power index Utilizing frequency resolution The physical frequency is mapped to an index interval, and the absolute power of the Beta band (13-30Hz) is calculated by discrete summation. and total power across the entire frequency band , This represents the one-sided power spectral density. The relative power index, after normalization, eliminates differences in the absolute amplitude of EEG signals between individuals, focusing on assessing the proportion of high-frequency components in the total energy, directly reflecting the brain's alertness or anxiety level. The Beta / Alpha energy ratio is also calculated. ,in The power is measured in the 8-13 Hz frequency band. The Beta / Alpha energy ratio, as a core feature for measuring cortical arousal, quantifies the brain's tendency to shift from an Alpha-dominant relaxed state to a Beta-dominant active state.

[0050] When the judgment logic is met for three consecutive sliding time windows. or ;in, The preset threshold for the percentage of anxiety state power. The baseline neural excitability threshold, When determining the tolerance coefficient for individual tolerance bias, a high arousal flag is set to indicate that the user is in a state of difficulty falling asleep due to high cortical arousal.

[0051] Step 302: Implement the frequency glide strategy of transcranial alternating current stimulation (tACS), gradually and linearly decreasing the stimulation frequency from the individual alpha wave peak frequency (IAF) to the Theta band of 4–8 Hz.

[0052] A time-varying sinusoidal function is constructed based on the principle of linear frequency modulation (LFM). Instantaneous phase is generated by integrating the instantaneous frequency over time, maintaining phase continuity of the waveform during frequency switching and avoiding visual hallucinations or tingling sensations caused by phase jumps. The electrodes employ dual main stimulators (Fp1 / Fp2) and reference electrodes (M1 / M2), with an electrode spacing of 3-4 cm and an effective contact area of ​​2 cm². The bipolar circuits Fp1-M1 and Fp2-M2 have independent outputs, ensuring uniform stimulation of both sides of the prefrontal cortex. In this function, the instantaneous frequency f(t) is defined as a linearly decreasing function. The instantaneous phase expression is The equation aims to construct a frequency-guided curve that conforms to the brain's natural sleep patterns, forcibly guiding the dominant cortical rhythm to smoothly transition from the individualized alpha peak frequency (IAF) to the Theta band; whereby... The amplitude of the stimulation current is given by IAF, which is the peak frequency of the individual alpha wave, i.e., the initiation frequency of the glide jump. The center value of the Theta band, i.e., the skid jump termination frequency, is set to 6Hz. The preset frequency-induced total duration of the jump is used, with the jump slope dynamically adjusted according to the cortical excitability benchmark value, ranging from 0.1 to 0.2 Hz / s, and the frequency step size increasing from 0.1 to 0.2 Hz / s.

[0053] A direct digital frequency synthesis (DDS) technique is employed in an embedded processor to digitally generate waveforms. A 32-bit phase accumulator is configured to calculate the dynamic frequency control word in real time based on the system sampling clock, achieving a precise mapping from analog frequency to digital phase increments and meeting microhertz-level adjustment resolution. The phase is accumulated and updated in each clock cycle, utilizing analog... Overflow characteristics ensure continuous phase without jumps; the high M bits of the phase accumulator are extracted as the address, the amplitude quantization value is obtained by reading the sine wave lookup table in the ROM, the output is processed by the digital-to-analog converter (DAC), and smoothed by a low-pass reconstruction filter with a cutoff frequency of 50Hz. Finally, the output frequency is a high-precision AC stimulation current that seamlessly and linearly decreases from IAF to the Theta band (4–8Hz).

[0054] Step 303 utilizes the brainwave entrainment effect to inhibit excessive cortical arousal and guide the brain smoothly into the N1 sleep stage.

[0055] A uniform, time-varying electric field is created in the prefrontal cortex to periodically regulate the transmembrane potentials of cortical pyramidal neurons with subthreshold intensity. Utilizing the nonlinear resonance mechanism of the Arnold tongue, the neuronal population firing rhythm is phase-locked with external sinusoidal stimulation. As the stimulation frequency steadily decreases at a preset slope (e.g., 0.2 Hz / s), the frequency-pulling effect gradually shifts the endogenous dominant oscillation frequency of the cerebral cortex from the high-arousal Beta / Alpha band to the low-arousal Theta band, regulating the balance of excitatory and inhibitory postsynaptic potentials and blocking excessive activation of the central nervous system by high-frequency cortical activity. Simultaneously, the data processing module continuously monitors changes in the EEG spectrum through short-time Fourier transform (STFT). When a peak wave characteristic with an amplitude greater than 50 μV and a duration less than 200 ms is detected, and the Theta band power percentage remains stable above 55% for three consecutive analysis windows, brainwave entrainment is considered successful, confirming that the brain has smoothly entered the N1 sleep stage.

[0056] Step S4. Upon detecting that the user has entered the N2 or N3 sleep stage and slow-wave activity is observed, closed-loop phase-locked stimulation technology is used to predict the phase of endogenous slow waves in real time. At a specific phase, slow-oscillating transcranial direct current stimulation (so-tDCS) of the same frequency is applied to increase the amplitude of slow waves using the resonance effect, thereby prolonging the duration of deep sleep and consolidating memory. See Appendix. Figure 5 Phase locking enhancement during deep sleep is achieved through the following steps: Step 401: Monitor EEG signals in real time. When the user is detected to have entered the N2 or N3 sleep stage and slow wave activity is observed.

[0057] Real-time reading of sleep staging results; if N2 or N3 is identified, slow-wave feature tracking of the prefrontal EEG signal is immediately initiated. First, a second-order Butterworth bandpass filter is used to filter out high-frequency electromyographic interference and low-frequency baseline drift, accurately extracting the slow-wave component from 0.5Hz to 4Hz. To eliminate the nonlinear phase shift caused by the IIR filter, a piecewise bidirectional zero-phase filter is used, ensuring no shift in the slow-wave component on the time axis, providing a benchmark for accurate phase locking. The discrete Hilbert transform is used to construct an analytic signal, extending the one-dimensional real-domain EEG signal to the two-dimensional complex plane. The imaginary part is obtained through discrete convolution of the input signal and the Hilbert impulse response. Based on this, the instantaneous amplitude envelope and instantaneous phase are calculated in real time. The former is used to quantify the real-time intensity fluctuations of the slow waves, and the latter utilizes the four-quadrant arctangent function to output a range within... The precise phase angle is obtained. Simultaneously, a sliding time window of length L is applied to calculate the energy proportion of the slow wave band. Where X(k) is the discrete Fourier transform result of the window data, Corresponding to frequency index limits of 0.5Hz and 4Hz respectively, this formula quantifies the purity of the signal from a frequency domain perspective by calculating the proportion of energy in the slow wave band in the total energy, thus eliminating motion artifacts that, although having high amplitude, have a cluttered spectrum. When the system detects the peak-to-trough peak-to-peak difference of the slow wave component... and At that time, the dual criteria confirmed that both the time domain intensity and the frequency domain purity met the characteristics of deep sleep, thus determining that there was real slow wave activity generated by the synchronized firing of neurons.

[0058] Step 402: Using closed-loop phase-locked stimulation technology, the phase of the endogenous slow wave is predicted in real time, and slow oscillation transcranial direct current stimulation so-tDCS with the same frequency is applied at a specific phase such as the peak.

[0059] For slow-wave signals, a 15th-order autoregressive (AR) model is constructed using the Burg algorithm as an adaptive phase prediction algorithm. This model extrapolates the slow-wave amplitude and phase trajectory within the next 500ms in real time using EEG data from the past 2 seconds. Simultaneously, an orthogonal demodulation digital phase-locked loop (PLL) continuously tracks the instantaneous phase changes of the intrinsic slow waves. The error between the predicted and actual phases is fed into a loop filter for integration and feedback correction, stably locking the slow-wave fundamental frequency within the range of 0.5–1Hz. When the predicted moment before the slow wave reaches its positive peak (0° phase) is detected, the system adjusts the timing based on a pre-calibrated total hardware delay. (e.g., 35ms) The system automatically calculates the advance trigger time and sends a trigger command to the stimulator. The stimulator then outputs a short-duration DC pulse of half-sine wave with the same frequency (approximately 0.75Hz) as the endogenous slow wave, with precise phase alignment and a duration of 1 second, so that the external electric field and the endogenous neural oscillation can be coherently superimposed in the time domain.

[0060] The total delay of hardware communication and circuit response The calibration is predetermined via offline calibration, specifically as follows: During system initialization or factory calibration, the signal acquisition channel and stimulus output channel are short-circuited. The embedded processor generates a square wave trigger signal with a known timestamp, which serves as both the trigger command for the stimulus output and a synchronization marker for the acquisition loop. The processor records the transmission time of the trigger signal. The rising edge of the current waveform actually output by the stimulus output module is detected at the zero-crossing point through the acquisition circuit. ; Calculate total delay Repeated measurements are taken multiple times and the average value is calculated to eliminate random errors. The total delay includes the signal processing algorithm time, data communication transmission time, digital-to-analog converter setup time, and output stage circuit response time. Calibration is performed separately for different stimulation modes such as tACS and so-tDCS with different sampling rate configurations, and the results are stored in non-volatile memory. In actual closed-loop control, the processor reads the corresponding delay value according to the current mode and compensates for it in the calculation at the trigger time to ensure that the external electric field and the endogenous neural oscillation are accurately and coherently superimposed.

[0061] Step 403 utilizes the resonance effect to increase the amplitude of slow waves, prolong the duration of deep sleep, and consolidate memory.

[0062] The stimulator injects current according to precise phase, applying a positive DC bias at the rising edge of the intrinsic slow wave phase (between 0° and 90°), thereby enhancing the membrane potential depolarization level of the cortical neuronal population through the superposition of an external electric field. In this embodiment, the system output current is set to a subthreshold intensity of 1.0mA–1.5mA, utilizing a stochastic resonance mechanism to synchronously engage critically affected neurons in the slow wave firing cycle, significantly increasing the peak-to-peak amplitude of slow wave activity from 75μV to over 95μV. The enhanced slow wave oscillations can suppress the firing of arousal centers such as the locus coeruleus, effectively deepening sleep and extending the average single cycle of the N3 deep sleep stage by 15%–20%. Simultaneously, the enhanced slow waves can precisely induce 12–15Hz thalamic spindle waves at the peak position, promoting precise coupling of hippocampal sharp wave ripples through the cortex-thalamus-hippocampus circuit, improving the efficiency of information transmission from the hippocampus to the neocortex, and consolidating the neuroplasticity of declarative memory.

[0063] Step S5. Based on real-time electrode-skin impedance monitoring and post-stimulation micro-awakening event detection, a PID feedback control algorithm is used to adaptively adjust the current intensity at the microsecond level or trigger a safety fuse mechanism in case of abnormalities, ensuring the comfort and safety of the stimulation process. See Appendix. Figure 6 Safety monitoring and end-point feedback adjustment are achieved through the following steps: Step 501: Monitor electrode-skin impedance in real time and detect micro-awakening events after stimulation.

[0064] The hardware monitoring module utilizes a built-in impedance measurement circuit and employs a four-wire measurement method to inject a 1kHz frequency signal into the electrode circuit. Weak sinusoidal constant current carrier This formula defines the excitation signal used to detect the contact interface, where the formula sets... The design aims to ensure that the injected current is well below the neuronal activation threshold, and is used solely for physical impedance measurement without interfering with normal neurophysiological activity; the voltage response across the electrodes is acquired simultaneously. ; By using digital orthogonal demodulation technology, Each with local in-phase reference signal and orthogonal reference signal Multiply and pass through a low-pass filter with a cutoff frequency of 10Hz. Processing to filter out harmonic terms and extract in-phase components Orthogonal components Then, according to the formula... The complex impedance modulus of the electrode-skin interface is calculated in real time. Based on Ohm's law in the complex domain, the formula quantifies the total contact resistance and capacitive reactance of the electrode-skin interface by calculating the ratio of the voltage vector modulus to the constant current source amplitude. This directly reflects the fit of the wearer and provides a physical basis for subsequent judgment on whether there is a risk of electrode detachment.

[0065] The system is configured with three impedance safety thresholds: 1–10kΩ is the normal operating range; 10–20kΩ is the warning range, immediately prompting the user to adjust the electrode fit; impedance greater than 20kΩ is the fuse range, triggering an initial reduction in the current. Simultaneously, the data processing module continuously monitors changes in the EEG spectrum within a 3-second sliding window after the electrical stimulation output. It calculates the real-time power spectral density using short-time Fourier transform and integrates it to obtain the combined frequency band power of Alpha waves (8–13Hz) and Beta waves (13–30Hz), serving as a quantitative indicator of whether cortical overactivation has occurred due to stimulation.

[0066] System construction of micro wake-up determination function ,in This is an indicator function that outputs a binary state (0 or 1) by comparing the real-time high-frequency power with the baseline threshold. The average high-frequency power before stimulation at rest. To establish a wakefulness sensitivity threshold (set to 0.5), this formula creates a dynamic relative safety boundary for identifying abnormal EEG fluctuations that significantly deviate from the resting state. If A(t) = 1 is detected within N consecutive time windows and the duration is [not specified], then [the boundary is defined as follows]. If the event is detected, it is determined to be a transient micro-arousal event triggered by the stimulus. This helps to distinguish between a brief cortical startle response and a fully awake state, thereby triggering timely feedback regulation to maintain sleep continuity.

[0067] Step 502: The current intensity is adaptively adjusted at the microsecond level using a PID feedback control algorithm, or a safety fuse mechanism is triggered when an anomaly is detected.

[0068] A digital current closed-loop control loop based on a high-performance embedded processor is constructed, with a sampling period set to 50μs. Real-time reading of load current fed back by current detection circuit And calculate its relationship with the target stimulus waveform. Instantaneous tracking error This formula aims to quantify in real time the deviation of the actual output current from the ideal therapeutic waveform, serving as the sole input variable for subsequent feedback adjustment; subsequently, an incremental PID control algorithm is applied to calculate the adjustment increment of the DAC control word. In this algorithm structure, the proportional term Rapidly respond to current error changes to improve the system's dynamic tracking performance; integral term Used to accumulate historical deviations to eliminate steady-state errors, thereby ensuring the accuracy of current output, while the differential term This introduces the prediction of error change trends, effectively suppressing overshoot and oscillations in the system response process; then, through the accumulation update logic... ( As an anti-integral saturation limiting function, The output drive voltage of the digital-to-analog converter (DAC) is dynamically adjusted (to the full-scale value of the DAC). This accumulation operation realizes the conversion from differential increment to absolute control voltage. Combined with a limiting function, it prevents numerical overflow and protects the DAC device. Its physical essence is based on skin impedance. The nonlinear fluctuations are automatically adjusted to regulate the drive voltage amplitude, compensating for voltage drops with a microsecond-level response speed, ensuring the output possesses high internal resistance constant current source characteristics. Here, the current step size is strictly controlled within 0.05-0.1mA / cycle to ensure smooth current adjustment and avoid current surges caused by excessively large step sizes. Simultaneously, if the micro-wake-up event flag from step 501 is received... The algorithm immediately activates the adaptive negative feedback adjustment mechanism, introducing an exponential decay factor. According to the formula The stimulation intensity baseline is gradually lowered cyclically. This formula utilizes the smooth decay characteristic of an exponential function to gently reduce the stimulation intensity when cortical overactivation is detected, avoiding disturbing the user again due to sudden changes in electrical current. The aim is to quickly pull the brain state back to a low arousal level through a negative feedback mechanism, until the monitored high-frequency EEG power is reached. It falls back to the baseline range; in addition, the system is equipped with a hardware-level dual comparator circuit to monitor electrode impedance and loop current in real time, and when it detects... (Safety impedance threshold, such as 20kΩ) or instantaneous current (Hardware fuse limit, such as 3mA) The duration exceeds the debounce threshold At this time, the logic judgment aims to build the last line of defense at the physical level to prevent continuous overcurrent damage caused by software failure or component breakdown. The comparator directly triggers the processor's non-maskable interrupt, forcibly pulls down the control level of the output stage isolation relay or MOSFET, physically cuts off the stimulation output circuit and locks the system, and executes irreversible safety fuse protection.

[0069] Step 503 ensures the comfort and safety of the stimulation process, delivering a high-quality sleep-aid intervention with no side effects and no skin damage.

[0070] The data processing module is designed with a cutoff frequency of cascaded at the output of the PID controller. A first-order infinite impulse response (IIR) digital smoothing filter (set to 30Hz to match the sensory inertia of human skin) is used to perform iterative calculations. ,in Smoothing coefficient ( The system sampling period is The formula (which calculates the control increment for the PID algorithm at the current moment) constructs a low-pass digital filter by weighted averaging of historical output and current input. Its core purpose is to smooth the step changes in the PID controller output, mathematically limiting the spectral bandwidth of the control signal. Physically, this ensures that the slew rate of change of the drive current is strictly limited below the human sensory threshold, preventing the activation of subcutaneous pain nerve fibers (A) due to sudden current changes. (Type), thereby eliminating the stinging sensation during electrical stimulation and improving wearing comfort; at the same time, utilizing the impedance modulus value monitored in real time. With instantaneous current Construct a model for estimating subcutaneous tissue heat accumulation. ,in The effective contact area of ​​the electrode. The heat diffusion sliding window time (set to 60s) is used. This integral formula, based on Joule's law, simulates the cumulative thermal effect generated when current flows through the electrode-skin interface by integrating the instantaneous power density within the time window. Its physical meaning lies in quantifying the total heat energy absorbed by a unit area of ​​skin within a specific time period, thus serving as a direct basis for assessing the risk of thermal damage. The system monitors this indicator in real time; once the calculated energy density... Exceeding the safety threshold (Set according to IEC 60601-1 standard) This immediately triggers the highest priority hardware interrupt to cut off the MOSFET output circuit, fundamentally preventing low-temperature burns or electrochemical burns caused by prolonged stimulation; ultimately, the micro-wake-up detection results are... (Boolean value) is introduced as a penalty term in the maximum allowable current dynamic adjustment algorithm. ,in It is a rapid inhibitory factor (typical value 0.15). The natural recovery factor (typical value 0.005) is used. As a preset absolute safety baseline, this recursive formula constructs an asymmetric dynamic safety boundary adjustment mechanism: when a micro-wake-up event is detected ( When this occurs, the first part of the formula takes effect, utilizing the rapid inhibition factor. The purpose of causing the upper limit of the current to decay exponentially is to immediately reduce the intensity of the stimulus to eliminate the arousal source; when the sleep state is stable ( When this occurs, the second part of the formula takes effect, utilizing the natural recovery factor. Slowly bring the upper limit of current close to the preset safety baseline. The significance of this algorithm lies in simulating the adaptive regulation process of organisms, maximizing the therapeutic effect while ensuring safety, preventing treatment interruption due to mechanical constant flow restriction or disruption of sleep continuity due to excessive intervention, and thus outputting high-quality sleep-aid intervention signals that meet individual tolerance and have no side effects while strictly adhering to physiological safety limits.

[0071] Traditional transcranial microcurrent stimulation (CES) and other techniques generally employ open-loop control, applying stimulation at fixed frequencies and waveforms. This lack of real-time brain state perception and response often leads to mismatches between intervention timing and brainwave state. This invention constructs a complete closed-loop system of perception-decision-execution-feedback, capable of real-time acquisition and analysis of EEG and heart rate variability signals to achieve precise sleep staging and dynamically adjust stimulation parameters based on the staging results. Simultaneously, it introduces micro-awakening event detection as feedback; if stimulation causes an abnormal increase in cortical arousal, the system automatically reduces the stimulation intensity to avoid disrupting sleep continuity, achieving true adaptive closed-loop regulation.

[0072] Traditional techniques often set parameters based on the average effect of the population, ignoring individual differences among users in terms of skull thickness, neural excitability, and autonomic nervous system regulation. This "one-size-fits-all" approach to stimulation is ineffective. This invention constructs a sleep baseline model, using the Sigmoid function to map the individual's alpha wave peak frequency (IAF) to a cortical excitability benchmark, and calculates a specific neural excitability current threshold accordingly. Simultaneously, it establishes a sleep latency prediction function based on the heart rate variability (LF / HF) ratio, ensuring that key parameters such as initial stimulus intensity and frequency jump initiation are tailored to the user's individual physiological characteristics, achieving personalized and precise intervention.

[0073] Traditional techniques often employ a single stimulation modality, such as fixed-frequency tACS or tDCS, which struggle to cover the entire sleep cycle from sleep onset to deep sleep, resulting in a mismatch between the intervention method and the physiological needs of each sleep stage. This invention achieves a seamless integration of two modes: sleep onset guidance and deep sleep enhancement. During the awake or sleep-onset difficulty stage, a frequency-skipping strategy is employed, using Direct Digital Frequency Synthesis (DDS) technology to output a phase-continuous linear frequency-modulated signal, smoothly reducing the stimulation frequency from the individual's IAF to the Theta band, thus achieving brainwave entrainment. During the deep sleep stage, closed-loop phase-locked stimulation is used, predicting the endogenous slow-wave phase in real time through an autoregressive model and a digital phase-locked loop, and precisely applying so-tDCS stimulation at the peak position. The sub-millisecond prediction and locking capability of the slow-wave phase significantly improves the physiological adaptability and effectiveness of the intervention.

[0074] Traditional safety technologies often only include basic electrical isolation and current limit restrictions, lacking real-time monitoring of the biological effects of stimulation, resulting in insufficient comfort and safety during long-term use. This invention establishes a multi-dimensional, hardware-software co-operational safety system: PID feedback control and digital smoothing filtering ensure stable and gradual changes in output current, preventing stinging sensations at their source; micro-wake detection serves as a biosafety feedback indicator, automatically reducing stimulation intensity when abnormal activation occurs in the cortex; and a hardware dual comparator and skin heat accumulation estimation model trigger physical fuses in abnormal situations such as electrode detachment, instantaneous overcurrent, and excessive heat accumulation, extending safety protection from electrical safety to physiological and tissue safety levels.

[0075] The present invention is described below with reference to specific embodiments: The system constructs differential acquisition loops at the Fp1 and Fp2 positions on the forehead and the mastoid process behind the ear using flexible dry electrodes on the inside of the head-mounted device to acquire the user's resting-state electroencephalogram (EEG) and electrooculogram (EOG) signals; simultaneously, it acquires pulse data using a skin-mounted reflective photoplethysmography (PPG) sensor. The data processing module preprocesses the raw signal using a fourth-order Butterworth bandpass filter and a wavelet threshold denoising algorithm, and fits the spectral peak value in the 8–13 Hz frequency band using the Welch periodogram method with a Hanning window to determine the individual's Alpha peak frequency (IAF). The interval sequence extracted from the PPG signal is analyzed by Fast Fourier Transform (FFT) to obtain the low-frequency power (LF) and high-frequency power (HF), and the LF / HF ratio is calculated to quantify the autonomic nervous system balance state. The system maps the IAF frequency shift deviation to a neural excitability threshold using the Sigmoid function, substitutes the normalized LF / HF value into the exponential regression model to obtain the sleep latency weighting coefficient, and then fits it using the least squares method to finally construct a sleep baseline model containing individual-specific parameters.

[0076] The system performs bandpass filtering and artifact removal on real-time acquired physiological signals, extracts power spectral characteristics and heart rate variability indices using a sliding time window, compares the real-time feature vector with the sleep baseline model, and generates a standardized state difference tensor. This tensor is input into a lightweight convolutional neural network (CNN), which uses a three-level cascaded deep separable convolutional structure to extract temporal features. The Softmax function is used to calculate the probability distribution of the current sleep stage, N1 / N2 light sleep stage, N3 deep sleep stage, and REM sleep stage, and outputs the real-time sleep staging results. The system dynamically selects stimulation strategies based on the staging results: tACS stimulation with an IAF as the starting frequency is used during the wakefulness and light sleep stages; so-tDCS stimulation at 0.75Hz and 80% of the threshold intensity is used during the N3 deep sleep stage; stimulation is stopped during the REM sleep stage.

[0077] The data processing module reads sleep staging results in real time, processes the EEG signals with a Hanning window, and calculates the power proportion of the 13–30Hz Beta band using FFT. When the relative power of the Beta wave exceeds a preset threshold within three consecutive sliding windows, the user is determined to be in a state of difficulty falling asleep. The stimulation control module executes the tACS frequency glide strategy using direct digital frequency synthesis (DDS) technology, using the individual's IAF as the starting frequency and 6Hz as the target frequency, and outputs a sinusoidal stimulation signal with a linearly decreasing slope of 0.2Hz / s. The Arnold tongue nonlinear resonance mechanism is used to achieve brainwave entrainment, guiding the brain's dominant rhythm towards the low-arousal Theta band. The system monitors EEG changes in real time using short-time Fourier transform (STFT), and when a peak wave is detected and the Theta wave proportion stably exceeds 55%, the brain is confirmed to have smoothly entered the N1 sleep stage.

[0078] When the staging result is N2 or N3, the system extracts the slow wave component through a 0.5–4Hz bandpass filter. If the peak-to-peak value of the slow wave is greater than 75μV, the deep sleep enhancement process is initiated. The system uses the Burg algorithm to construct a 15th-order autoregressive (AR) model to predict the phase and amplitude of the slow wave in real time over the next 500ms, and uses a digital phase-locked loop (PLL) to lock the fundamental frequency of the slow wave. At the moment before the predicted positive peak of the slow wave, a 35ms hardware delay is compensated to trigger the stimulus output, producing a half-sine wave so-tDCS pulse with the same frequency and precise phase alignment as the endogenous slow wave. A positive bias is applied at the rising edge of the slow wave, using a stochastic resonance mechanism to increase the slow wave amplitude to above 95μV, inhibiting arousal center activity, prolonging deep sleep duration, and promoting hippocampal spike-wave ripple coupling to achieve memory consolidation.

[0079] The hardware component uses high-frequency carrier synchronous detection technology to monitor electrode-skin contact impedance in real time, while simultaneously monitoring the EEG spectrum to identify micro-awakening events induced by stimulation. The system employs a PID closed-loop control algorithm to compare the target current with the actual output current in real time, dynamically adjusting the DAC gain to compensate for impedance fluctuations and achieve microsecond-level constant current output. If impedance exceeds limits or micro-awakening is detected, the system automatically reduces the stimulation intensity or triggers a hardware interrupt to cut off the output. The system eliminates current step spikes through smoothing filtering and calculates current density in real time to avoid thermal accumulation damage. Under the premise of meeting physiological safety limits, it provides users with a stable sleep-aid intervention that is tailored to individual tolerance, painless, and without skin damage.

[0080] In the second aspect, as attached Figure 7The present invention provides an adaptive transcranial electrical stimulation (TCS) sleep aid system. The system includes a data acquisition module that collects physiological signals such as electroencephalogram (EEG), electrooculogram (EOG), and heart rate variability (HRV) during the user's resting state and sleep process. The sensor layer of the acquisition module can employ dry or wet electrode arrays, calibrated according to the international 10-20 EEG system, with Fp1 / Fp2 / F3 / F4 / Fz main stimulation sites, M1 / M2 reference sites, Oz grounding site, and Nz spare reference electrode. The effective contact area of ​​the electrodes is 1-3 cm², and the electrode spacing is 2-5 cm (adapted to the curvature of the prefrontal cortex). A PPG optical sensor is also integrated to acquire pulse wave data for subsequent HRV analysis. In the signal preprocessing stage, a built-in fourth-order Butterworth bandpass filter performs zero-phase bidirectional filtering on the raw EEG signal to remove baseline drift and high-frequency noise. Combined with db4 wavelet five-level decomposition and a soft thresholding denoising algorithm, eye movement and electromyography artifacts are effectively eliminated, ensuring the purity of the input signal.

[0081] The stimulation generation module is the core functional unit of the system, comprising two sub-units: frequency conversion induction and phase locking. It is responsible for generating appropriate transcranial electrical stimulation waveforms based on real-time brain states. The stimulation generation module executes differentiated stimulation strategies according to sleep stage results: In awake or sleep-disordered states, it generates linearly modulated transcranial alternating current (AC) stimulation waveforms using direct digital frequency synthesis (DFD). The stimulation frequency smoothly decreases from the individual's alpha wave peak frequency to the Theta band, simulating the brain wave decay pattern during natural sleep to induce cortical synchronization. In N2 or N3 stages, when real slow-wave activity is detected, it first analyzes the instantaneous phase of the slow waves using discrete Hilbert transform, then combines autoregressive model prediction with digital phase-locked loop (PDL) tracking. At the predicted peak phase, it applies synchronous slow-oscillating transcranial direct current (DC) stimulation, achieving precise phase locking with endogenous slow waves and enhancing slow-wave activity during deep sleep.

[0082] The stimulation generation module executes differentiated stimulation strategies and electrode site adaptation based on sleep stage results: (1) In the wakeful or sleep-inducing state, linear frequency modulated transcranial AC stimulation waveforms are generated through direct digital frequency synthesis technology. The stimulation frequency smoothly decreases from the individual Alpha wave peak frequency to the Theta band 4-6Hz. The electrode sites are Fp1 / Fp2 bilaterally, bipolar circuits, to adapt to the inhibition needs of bilateral prefrontal cortex overactivation; (2) In the N1 / N2 light sleep stage, weak stimulation in the Theta band or synchronous micro-stimulation with spindle waves is used. The electrode sites are gradually switched from Fp1 / Fp2 to Fz to prepare for the enhancement of slow waves in the deep sleep stage; (3) In the N2 or N3 stage and when real slow wave activity is detected, the instantaneous phase of the slow wave is first analyzed by discrete Hilbert transform, and then combined with autoregressive model prediction and digital phase-locked loop tracking. At the predicted peak phase time, the same frequency slow oscillation transcranial DC stimulation is applied. The electrode site is Fz. Midline, unipolar loop, precisely enhances midline cortical slow wave oscillations, achieving precise phase locking with endogenous slow waves.

[0083] The core algorithm of the baseline construction module revolves around individual-specific sleep characteristics: First, the peak frequency of individual alpha waves is extracted from the resting-state EEG signal by Welch power spectrum estimation combined with Gaussian fitting; then, the heart rate variability signal is integrated in the frequency domain to calculate the ratio of low-frequency to high-frequency power to quantify the balance state of the autonomic nervous system; finally, the above characteristics are transformed into personalized neural excitability thresholds and sleep latency prediction values ​​through Sigmoid mapping and exponential models, respectively, to construct a sleep baseline model that includes individual physiological boundaries and time responses.

[0084] The sleep staging module is implemented using a lightweight convolutional neural network. It takes real-time EEG and heart rate variability multimodal features as input and outputs five sleep stage discrimination results. The inference latency is controlled to sub-second levels to meet real-time closed-loop requirements. Specifically, when the user is detected to be awake, high-frequency arousal analysis is initiated. By calculating the relative power of the Beta band and the Beta / Alpha energy ratio, it determines whether there is difficulty falling asleep. When the user is detected to have entered N2 or N3 sleep stages, slow-wave feature tracking is initiated. Bandpass filtering and Hilbert transform are used to extract slow waves and analyze their phase and amplitude information.

[0085] The safety monitoring module is integrated into the processing module and consists of four sub-units: the impedance monitoring unit injects a high-frequency constant current carrier into the electrode circuit and performs digital quadrature demodulation to calculate the complex impedance modulus in real time to determine the electrode contact quality; the micro-wake-up detection unit analyzes the combined power of Alpha and Beta within a sliding window after stimulation, and if the power suddenly increases, it determines micro-wake-up and triggers an intensity reduction; the current closed-loop control unit uses an incremental PID algorithm to dynamically adjust the output current to compensate for the current deviation caused by skin impedance fluctuations, ensuring that the stimulation intensity remains stable within the safe threshold range; the fuse protection unit is a hardware-level interrupt design, which physically cuts off the stimulation output circuit when the electrode impedance exceeds the safe threshold or the instantaneous current exceeds the IEC safety limit to avoid the risk of electric shock.

[0086] The system as a whole forms a complete closed loop of "perception-decision-execution-feedback": First, the acquisition module obtains the user's resting-state physiological data, and the processing module constructs a personalized sleep baseline based on this data, including the individual's alpha wave peak frequency, neural excitability threshold, and sleep latency. Then, during sleep, the processing module completes sleep staging based on real-time physiological signals, and the stimulation generation module selects either frequency-skipping or phase-locking stimulation strategies based on the staging results. Finally, the safety monitoring module monitors electrode impedance and micro-awakening events in real time, adjusts the stimulation intensity through a PID closed loop, and triggers circuit breaker protection in abnormal states, achieving personalized, safe, and efficient sleep-aid intervention.

[0087] Those skilled in the art will recognize that the baseline construction module, sleep staging module, and security monitoring module can be integrated into a central processing unit or a microcontroller; see the appendix for details. Figure 7 .

[0088] The above description is merely a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural transformations made using the contents of the present invention's specification and drawings under the inventive concept of the present invention, or direct / indirect applications in other related technical fields, are included within the patent protection scope of the present invention.

[0089] A computer device according to embodiments of the present disclosure includes a memory and a processor. The memory is used to store non-transitory computer-readable instructions. Specifically, the memory may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may, for example, include random access memory (RAM) and / or cache memory. The non-volatile memory may, for example, include read-only memory (ROM), hard disk, flash memory, etc.

[0090] The processor may be a central processing unit (CPU) or other form of processing unit with data processing capabilities and / or instruction execution capabilities, and may control other components in the computer device to perform desired functions. In one embodiment of this disclosure, the processor is used to execute computer-readable instructions stored in the memory, causing the computer device to perform all or part of the steps of the learning outcome prediction method based on learning behavior data mining of the foregoing embodiments of this disclosure.

[0091] like Figure 8 This is a schematic diagram of a computer device provided for an embodiment of the present disclosure. It illustrates a structural schematic diagram suitable for implementing the computer device in the embodiments of the present disclosure. Figure 8 The computer device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0092] like Figure 8 As shown, a computer device may include a processor (such as a central processing unit, graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) or programs loaded from storage devices into random access memory (RAM). The RAM also stores various programs and data required for the operation of the computer device. The processor, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus.

[0093] Typically, the following devices can be connected to the I / O interface: input devices, such as sensors or visual information acquisition devices; output devices, such as displays; storage devices, such as magnetic tapes or hard drives; and communication devices. Communication devices allow the computer device to communicate wirelessly or wiredly with other devices (such as edge computing devices) to exchange data. Although a computer device with various devices is illustrated, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0094] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processor, all or part of the steps of the learning outcome prediction method based on learning behavior data mining according to embodiments of this disclosure are performed.

[0095] For a detailed description of this embodiment, please refer to the corresponding descriptions in the foregoing embodiments, which will not be repeated here.

Claims

1. A method of transcranial electrical stimulation for sleep aid, characterized by, Includes the following steps: Collect users' resting physiological signals, which include at least electroencephalogram (EEG) signals and heart rate variability signals. Use feature extraction to identify the individual's alpha wave peak frequency and autonomic nervous system balance. The peak frequency of an individual's alpha wave is mapped to a cortical excitability benchmark value using the Sigmoid function; this benchmark value is then mapped to a neural excitability current threshold; and a sleep latency prediction function is established based on heart rate variability characteristics. The calculated cortical excitability baseline value, neural excitability current threshold, and sleep latency prediction function value are combined into a feature vector to construct a sleep baseline model; The user's physiological signals collected in real time are compared with the sleep baseline model, and a convolutional neural network is used to determine sleep stages. The sleep stages include at least one or more of the following: wakefulness, light sleep, deep sleep, and REM sleep. Based on real-time sleep stage results, electrical stimulation parameter instructions adapted to the current brain state are dynamically generated. The instructions include stimulation mode, frequency, current intensity, and waveform. During stimulation, based on real-time electrode and skin impedance monitoring and micro-awakening event detection, the current intensity is adaptively adjusted through a feedback control algorithm or a safety fuse is triggered in case of an abnormality. The specific steps for constructing the sleep baseline model include: The Sigmoid function maps the peak frequency of an individual's alpha wave to a baseline value for cortical excitability. Based on the mapping of cortical excitability benchmark values ​​to neural excitability current thresholds; Establish a sleep latency prediction function based on heart rate variability characteristics; The calculated cortical excitability baseline value, the neural excitability current threshold value, and the sleep latency prediction function The encapsulation is a feature vector, and a sleep baseline model containing individual-specific neural excitability boundaries and time response curves is constructed.

2. The method of claim 1, wherein, The specific methods for identifying an individual's Alpha wave peak frequency and autonomic nervous system balance state through feature extraction include: The raw EEG signal is subjected to bidirectional zero-phase filtering using a bandpass filter; Discrete wavelet transform and soft thresholding are used to remove interference from eye movement and electromyography signals to obtain denoised EEG signals. The power spectral density of the denoised EEG signal was calculated, and the peak frequency of the Alpha wave of the individual user was determined by Gaussian fitting and nonlinear least squares method in the Alpha band. An adaptive dynamic threshold algorithm is used to extract the pulse wave peak value and RR interval from the photoplethysmography pulse signal. The heart rate variability frequency domain signal is obtained from the pulse wave peak value and RR interval. The low-frequency power and high-frequency power of the heart rate variability frequency domain signal are calculated, and the ratio of low-frequency power to high-frequency power is obtained. After smoothing by moving average, the balance state of the autonomic nervous system is obtained.

3. The method according to claim 2, characterized in that: The Sigmoid nonlinear transfer function is used to map the frequency shift deviation of an individual's Alpha wave peak frequency relative to the population mean into a baseline value for cortical excitability. Mapping the cortical excitability baseline value to the neural excitability current threshold; A sleep latency prediction function is established based on the frequency domain signal of heart rate variability.

4. The method of claim 1, wherein, The specific steps for comparing the real-time collected physiological signals of the user with the sleep baseline model include: Real-time physiological signals are preprocessed using filtering and wavelet denoising algorithms; A real-time time-frequency spectrum is constructed by using a sliding time window combined with short-time Fourier transform. Calculate the power ratio of the Beta to Alpha bands to obtain the cortical excitability deviation relative to the individual baseline, and calculate the low-to-high frequency ratio of heart rate variability. After calculating the frequency domain difference between the real-time alpha peak frequency and the baseline, the multidimensional features are fused to generate a state difference tensor.

5. The method according to claim 4, characterized in that, The specific steps of using a convolutional neural network for sleep staging include: The state difference tensor is input into the neural network model; The probability distribution of the current sleep stage is calculated using a flexible maximum value function, and the result with the highest probability is selected as the stage determination result.

6. The method according to claim 3, characterized in that, When the diagnosis indicates a state of wakefulness or difficulty falling asleep, a frequency glide strategy for transcranial alternating current stimulation is employed. The frequency skip strategy specifically includes: Set the initial frequency of the stimulus waveform to the individual's alpha peak frequency; The stimulation frequency is controlled to decrease linearly over time according to a preset slope until the target frequency drops to the Theta band. By utilizing the brainwave entrainment effect to inhibit excessive cortical arousal, the brain is guided smoothly into a light sleep stage, and stimulation is stopped once the frequency glide is completed.

7. The method according to claim 6, characterized in that, When the determination result is deep sleep and slow wave activity is detected, closed-loop phase-locked stimulation technology is used; The closed-loop phase-locked stimulation technique specifically includes: The slow wave component of the first frequency band is extracted using a bandpass filter, and the instantaneous phase of the slow wave component of the first frequency band is analyzed. Phase changes of endogenous slow waves were predicted using an autoregressive model and digital phase-locked loop technology. At the moment before the slow wave is predicted to reach the positive peak phase, a transcranial direct current stimulation of the same frequency slow oscillation is triggered, so that the external electric field and the endogenous nerve oscillation can be coherently superimposed in the time domain.

8. The method according to claim 1, characterized in that, The adaptive adjustment or the triggering of the circuit breaker mechanism in case of an anomaly specifically includes: A weak high-frequency carrier signal is injected into the electrode circuit to calculate the complex impedance modulus of the electrode-skin contact interface in real time; a current closed-loop control circuit is constructed, and an incremental feedback control algorithm is used to calculate the control increment and dynamically adjust the output voltage to compensate for impedance fluctuations. When a micro-awakening event triggered by a stimulus is detected, a negative gain coefficient is introduced to automatically reduce the target current intensity. When the impedance or current exceeds the safety threshold, an interrupt is triggered to cut off the output circuit.

9. An adaptive transcranial electrical stimulation sleep aid system, characterized in that, include: The signal acquisition module is used to acquire resting-state EEG signals, electrooculogram signals, and heart rate variability signals after the user wears the device, as well as real-time acquisition of physiological signals during sleep. The sensor of the signal acquisition module uses an electrode array to calibrate the left and right frontal poles, left and right frontal lobes and the main stimulation sites on the midline of the forehead, the left and right mastoid reference sites, the occipital lobe grounding site, and the nasal root position. The signal acquisition module includes a photoplethysmography (PPG) optical sensor to acquire pulse wave data. The baseline construction module is used to identify an individual's alpha wave peak frequency and autonomic nervous system balance state to build a sleep baseline model; The sleep staging module is used to perform real-time sleep staging discrimination based on the comparison between real-time collected physiological signals and the sleep baseline model, using a convolutional neural network. The stimulation generation module dynamically generates electrical stimulation parameters adapted to the current brain state based on sleep stage results. It executes a frequency-skipping strategy when the user is awake or has difficulty falling asleep, and performs closed-loop phase-locked stimulation when the user enters light or deep sleep and slow-wave activity is detected. When the user is awake or has difficulty falling asleep, the stimulation frequency smoothly decreases from the individual alpha wave peak frequency to the Theta band, with electrode sites on both sides of the left and right frontal poles. During the light transition period or light sleep, the electrode sites gradually switch from the left and right frontal poles to the midline of the forehead. When the user is in light or deep sleep and real slow-wave activity is detected, the electrode sites are on the midline of the forehead. The safety monitoring module is used to monitor the impedance between the electrode and the skin and micro-awakening events after stimulation in real time. It adaptively adjusts the current intensity through a feedback control algorithm and triggers a safety fuse mechanism in case of abnormality.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the transcranial electrical stimulation sleep aid method according to any one of claims 1-8.