Deep learning-based electroencephalogram slow wave real-time feedback transcranial electrical stimulation method and system
By integrating self-predictive representation, unsupervised target conditional reinforcement learning, and inverse dynamics modeling through a deep learning model, a lightweight end-to-end system is constructed, which solves the problems of low representation efficiency and imbalance between safety and real-time performance in EEG slow wave modulation, and achieves precise and safe modulation of EEG slow waves.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ACADEMY OF MILITARY MEDICAL SCIENCES
- Filing Date
- 2026-02-28
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies for slow-wave EEG modulation suffer from problems such as low representation efficiency, poor parameter matching, lack of multi-target coordination, and imbalance between safety and real-time performance, making it difficult to achieve precise and safe closed-loop modulation.
By employing a deep learning-based approach, a lightweight end-to-end model is constructed by integrating self-predictive representation, unsupervised target-conditional reinforcement learning, and inverse dynamics modeling. This model monitors EEG signals in real time and optimizes transcranial electrical stimulation parameters, including stimulation type, intensity, and frequency. Combined with individual safety protection mechanisms, it achieves precise control of slow EEG waves.
It improves the efficiency of representation learning in low-data scenarios, enables real-time adaptation to slow-wave dynamic changes, ensures the safety and tolerance of stimuli, and meets the needs of real-time, accurate, and safe closed-loop regulation.
Smart Images

Figure CN121731667B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of interdisciplinary technology of neuromodulation and deep learning, and in particular to a method and system for real-time feedback transcranial electrical stimulation of slow brain waves based on deep learning. Background Technology
[0002] Slow brainwaves (including) Wavelength 0.5-4Hz and Slow-wave activity (4-8 Hz) is a core biomarker for deep sleep (N3 stage), and its density, amplitude, and rhythm stability are directly related to sleep quality and neurological function. Transcranial electrical stimulation (tDCS / tACS), as a non-invasive neuromodulation technique, has been shown to improve slow-wave brain activity by modulating cortical excitability or rhythm; however, current technology still has significant limitations, including the following:
[0003] Low representation learning efficiency: Traditional models rely on a large amount of labeled clinical data for training, while EEG data collection is costly and has large individual differences, resulting in poor generalization ability of the model in low data scenarios and difficulty in adapting to the slow wave characteristics of different subjects.
[0004] Staticized control parameters: Existing systems mostly use fixed stimulus parameters or simple rule adjustments, which do not fully explore the temporal evolution of slow waves, cannot adapt to the dynamic changes of slow waves in real time, and have insufficient control precision.
[0005] Lack of multi-objective coordination: A single self-supervised objective (such as relying solely on inverse dynamics modeling) is insufficient to fully capture the spatial characteristics, temporal dependence, and action correlations of slow waves, which can easily lead to representation collapse and affect the control effect;
[0006] Imbalance between safety and real-time performance: Some systems prioritize control precision over real-time performance or sacrifice parameter optimization to ensure speed, and lack personalized safety mechanisms for individual tolerance, limiting clinical application scenarios.
[0007] Although existing technologies attempt to introduce deep learning and reinforcement learning to improve the intelligence of regulation, they have not yet achieved the synergistic integration of multi-dimensional self-supervised objectives, making it difficult to efficiently learn slow wave representations in low-data scenarios and failing to meet the needs of real-time, accurate, and safe closed-loop regulation. Summary of the Invention
[0008] This invention aims to address the problems of low efficiency in slow-wave EEG modulation representation, poor parameter adaptation, lack of multi-target coordination, and imbalance between safety and real-time performance in existing technologies. It provides a deep learning-based method and system for real-time feedback transcranial electrical stimulation of slow-wave EEG. By monitoring the slow-wave characteristics of EEG in real time and combining deep learning algorithms to dynamically optimize the parameters of transcranial electrical stimulation (tDCS / tACS), it achieves precise modulation of slow-wave sleep during sleep, ultimately improving sleep quality.
[0009] In a first aspect, embodiments of the present invention provide a method for real-time feedback transcranial electrical stimulation of slow-wave EEG based on deep learning, comprising:
[0010] Collect the electroencephalogram (EEG) signals of the target object and preprocess the EEG signals to obtain preprocessed EEG signals;
[0011] The preprocessed EEG signal is input into a pre-constructed deep learning model for analysis to obtain a latent representation of the slow-wave dynamic state of the EEG; wherein, the deep learning model is obtained by fusion of three types of self-supervised target collaborative training: self-predictive representation, unsupervised target conditional reinforcement learning, and inverse dynamics modeling;
[0012] Transcranial electrical stimulation parameters are generated based on the latent characterization decision, wherein the stimulation parameters include at least stimulation type, stimulation intensity, and stimulation frequency;
[0013] Based on the transcranial electrical stimulation parameters, corresponding transcranial direct current stimulation or transcranial alternating current stimulation is output to specific brain regions of the target subject.
[0014] In a preferred embodiment, the deep learning model adopts a lightweight end-to-end architecture, comprising the following modules connected in sequence:
[0015] The input layer is used to receive preprocessed EEG signals;
[0016] The feature extraction module uses a convolutional neural network to extract local spatial features of slow brain waves.
[0017] The temporal modeling module employs a bidirectional long short-term memory network to perform temporal modeling on the local spatial features, thereby mining the temporal dependencies of slow brain waves and outputting latent representations.
[0018] The self-supervised pre-training fusion module trains the model by fusing three types of self-supervised objectives: self-predictive representation, unsupervised objective conditional reinforcement learning, and inverse dynamics modeling, in order to optimize the encoding ability of the latent representation for slow-wave dynamics and control actions.
[0019] The output layer includes a stimulation type subheader, a stimulation intensity subheader, and a stimulation frequency subheader set in parallel, which are used to output the corresponding stimulation type, stimulation intensity, and stimulation frequency based on the latent characterization, respectively.
[0020] As a preferred embodiment, the self-predictive representation objective of the deep learning model is achieved as follows:
[0021] The latent representation at the current moment and the corresponding regulatory action are input into a pre-built transition model to iteratively generate predicted latent representations for multiple future time steps.
[0022] The parameters of the deep learning model are optimized by maximizing the cosine similarity between the predicted latent representation and the corresponding real latent representation at each time step. The real latent representation is obtained by the target encoder encoding the real EEG signal at the corresponding time. The target encoder is an auxiliary encoder independent of the main encoder of the deep learning model, and its parameters are updated according to the parameters of the main encoder in the deep learning model using an exponential moving average method.
[0023] As a preferred embodiment, the unsupervised objective conditional reinforcement learning objective of the deep learning model is implemented as follows:
[0024] Based on the preprocessed EEG signals, a state sequence consisting of latent representations at multiple consecutive time points is extracted;
[0025] Sample the latent representation of future time moments from the state sequence as the target state;
[0026] Random noise is added to the target state to expand the target distribution, and the reduction in distance between the current latent representation and the target state is used as the synthetic reward.
[0027] Based on the synthetic reward training objective conditional value function, a representation space that guides slow-wave state transitions is constructed, wherein the objective conditional value function is used to evaluate the expected value of performing a regulatory action in a given objective state.
[0028] As a preferred embodiment, the inverse dynamics modeling objective of the deep learning model is achieved as follows:
[0029] Using the current latent representation and the next latent representation as input, a multilayer perceptron network is used to predict the discrete control actions that cause the slow wave state change.
[0030] By modeling inverse dynamics, a mapping relationship between slow wave state changes and discrete control actions is established, providing a supervisory signal for feature learning that is independent of the self-predictive representation and the unsupervised target conditional reinforcement learning objective.
[0031] In a preferred embodiment, after completing the collaborative training of three types of self-supervised objectives—fusion of self-predictive representations, unsupervised objective conditional reinforcement learning, and inverse dynamics modeling—the deep learning model further includes a fine-tuning stage:
[0032] During the fine-tuning phase, the deep learning model is optimized using the following external reward function:
[0033] ;
[0034] in, : No. Instant reward value at any given moment; : Slow wave density change; : Change in slow wave amplitude; : No. The intensity of transcranial electrical stimulation at any given time.
[0035] In a preferred embodiment, transcranial electrical stimulation parameters are generated based on the latent characterization decision, wherein the stimulation parameters include at least stimulation type, stimulation intensity, and stimulation frequency, including:
[0036] The latent characterization is input into the stimulus type subheader, stimulus intensity subheader, and stimulus frequency subheader of the output layer;
[0037] The stimulation type subhead outputs the stimulation type decision result based on the slow wave spectrum concentration and amplitude stability reflected by the latent characterization: if the spectrum is concentrated and the amplitude is stable, the transcranial direct current stimulation type is output; otherwise, the transcranial alternating current stimulation type is output.
[0038] The stimulation intensity subhead outputs a first normalized value based on the latent characterization, and maps the first normalized value to a preset current intensity range;
[0039] The stimulation frequency subheader outputs a second normalized value based on the latent characterization, and maps the second normalized value to a preset frequency range.
[0040] In a preferred embodiment, the method further includes the following real-time security protection steps:
[0041] Set dual-strength safety thresholds, including a general safety current threshold and an individual calibration current threshold;
[0042] When the real-time stimulus intensity reaches any of the aforementioned safety thresholds, an alarm is triggered and the stimulus output is stopped.
[0043] Real-time monitoring of EEG signals and cutting off stimulation output within a preset time when predefined abnormal discharge characteristics are detected;
[0044] The contact impedance of the stimulation electrode is monitored in real time. When the impedance exceeds a preset impedance threshold, it is determined that the electrode contact is abnormal and the corresponding adjustment mechanism is triggered.
[0045] In a preferred embodiment, the method for setting the individual calibration current threshold includes:
[0046] Test transcranial electrical stimulation is applied to the target subject starting from a safe initial value and increasing in fixed steps, while simultaneously acquiring its physiological feedback signals;
[0047] The intensity of stimulation that first elicits subjective feedback of discomfort or abnormal features in EEG signals is defined as the stimulation tolerance intensity.
[0048] The individual calibration current threshold is calculated based on the stimulation tolerance intensity and the preset safety factor.
[0049] Secondly, embodiments of the present invention also provide a deep learning-based EEG slow-wave real-time feedback transcranial electrical stimulation system, comprising:
[0050] The signal acquisition and preprocessing unit is used to acquire the electroencephalogram (EEG) signals of the target object and preprocess the EEG signals to obtain preprocessed EEG signals.
[0051] The signal processing and analysis unit is used to input the preprocessed EEG signal into a pre-constructed deep learning model for analysis to obtain a latent representation of the dynamic state of slow-wave EEG; wherein, the deep learning model is obtained by fusion of three types of self-supervised target collaborative training: self-predictive representation, unsupervised target conditional reinforcement learning, and inverse dynamics modeling.
[0052] A transcranial electrical stimulation parameter generation unit is used to generate transcranial electrical stimulation parameters based on the latent characterization decision, wherein the stimulation parameters include at least stimulation type, stimulation intensity, and stimulation frequency;
[0053] The transcranial electrical stimulation output unit is used to output corresponding transcranial direct current stimulation or transcranial alternating current stimulation to a specific brain region of the target subject according to the transcranial electrical stimulation parameters.
[0054] Thirdly, embodiments of the present invention also provide an electronic device, the electronic device comprising:
[0055] One or more processors;
[0056] Storage device for storing one or more programs;
[0057] When the one or more programs are executed by the one or more processors, the one or more processors implement the deep learning-based EEG slow-wave real-time feedback transcranial electrical stimulation method described in any embodiment of the present invention.
[0058] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the deep learning-based EEG slow-wave real-time feedback transcranial electrical stimulation method described in any embodiment of the present invention.
[0059] Compared with existing technologies, the present invention achieves the following beneficial effects:
[0060] (1) This invention integrates three types of self-supervised target collaborative optimization feature representation: self-predictive representation (SPR), unsupervised target conditional RL, and inverse dynamics modeling. SPR is used to learn the slow wave time series evolution law, unsupervised target conditional RL is used to construct the state transition representation space, and inverse dynamics modeling is used to establish the "slow wave change-regulation action" association. The three work together to avoid representation collapse and improve the representation learning efficiency in low data scenarios.
[0061] (2) The present invention constructs a lightweight CNN-BiLSTM end-to-end model and combines it with a sliding window inference mechanism. Under the premise of ensuring that the model parameters are ≤5 million, the inference delay is controlled to ≤50ms, and the slow wave density, amplitude and rhythm abnormalities are accurately identified.
[0062] (3) Dynamically optimize stimulation regulation parameters: Based on the output of stimulation type, intensity and frequency of deep learning model, the parameters are updated every 50ms through closed-loop feedback mechanism to adapt to slow wave dynamic changes and realize personalized rhythm entrainment or excitability regulation.
[0063] (4) The present invention combines general threshold and individual calibration threshold, and integrates signal anomaly monitoring, electrode contact detection and emergency intervention mechanism to ensure stimulation safety and tolerance while ensuring the end-to-end delay is ≤100ms. Attached Figure Description
[0064] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings. The drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0065] Figure 1 This is a flowchart of the deep learning-based real-time feedback transcranial electrical stimulation method for slow-wave EEG provided in an embodiment of the present invention;
[0066] Figure 2 This is a system architecture diagram of a deep learning model provided in an embodiment of the present invention;
[0067] Figure 3 This is a flowchart of the security monitoring and intervention process provided in the embodiments of the present invention;
[0068] Figure 4This is a human-computer interaction visualization diagram provided in an embodiment of the present invention;
[0069] Figure 5 This is a performance comparison chart of different algorithms provided in the embodiments of the present invention;
[0070] Figure 6 This is a block diagram of a deep learning-based real-time feedback transcranial electrical stimulation system for slow-wave EEG provided in an embodiment of the present invention.
[0071] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0072] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.
[0073] Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe operations (or steps) as being processed sequentially, many of these operations (or steps) may be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations may be rearranged. The process may be terminated when its operation is completed, but may also have additional steps not included in the figures. The process may correspond to a method, function, procedure, subroutine, subroutine, etc.
[0074] Example 1:
[0075] like Figure 1 The diagram shows a flowchart of a deep learning-based real-time feedback transcranial electrical stimulation method for slow-wave EEG provided in Embodiment 1 of the present invention. The method 100 specifically includes the following steps:
[0076] S110. Collect the EEG signal of the target object and preprocess the EEG signal to obtain the preprocessed EEG signal.
[0077] As a preferred embodiment, the hardware configuration for acquiring the electroencephalogram (EEG) signals of the target object is as follows:
[0078] A 16 / 32-channel high-precision EEG acquisition device with a sampling rate ≥1000Hz and a resolution ≤16bit is used to ensure complete acquisition of slow-wave signals. A 0.1-30Hz bandpass filter is configured to retain high-frequency information (such as EMG artifacts >30Hz) required for artifact identification in Independent Component Analysis (ICA) while effectively suppressing high-frequency noise interference. This design covers the core slow-wave frequency band (0.5-8Hz) and provides data support for accurate noise reduction in the software. The electrode layout of the international 10-20 system for scalp EEG is adopted, focusing on acquiring signals from slow-wave active areas such as the prefrontal cortex (Fp1 / Fp2) and central region (C3 / C4).
[0079] In a preferred embodiment, the preprocessing of the acquired EEG signals includes the following steps:
[0080] First, the acquired EEG signals were subjected to a 0.5-8Hz digital bandpass filter to extract the slow-wave core components; simultaneously, the original unfiltered data was retained for artifact identification and removal. Independent component analysis (ICA) was used to separate electrooculography (EOG), electromyography (EMG), and electrocardiogram (ECG) artifacts, and a threshold method was used to remove abnormal signal segments (such as signal amplitudes exceeding ±100μV).
[0081] Next, the processed signal is subjected to Z-score normalization to eliminate signal amplitude fluctuations caused by individual differences, and the one-dimensional EEG signal is reshaped into a two-dimensional feature map (number of channels C, time point T), where T=500 (corresponding to a 500ms data window) to adapt to the input of the deep learning model.
[0082] Finally, to ensure data consistency, when using public datasets (such as Sleep-EDF, CAP SleepDatabase, etc.) for pre-training, the raw data undergoes preprocessing with 0.1-30Hz hardware filtering + 0.5-8Hz software digital filtering, identical to the real-time process. This ensures complete frequency band matching between the subsequent pre-training and fine-tuning stages, avoiding representation transfer bias caused by 8-10Hz frequency band differences. A timestamp synchronization mechanism is employed to ensure temporal consistency between EEG acquisition, model inference, and stimulus output, with a synchronization error ≤1ms.
[0083] S120. The preprocessed EEG signal is input into a pre-constructed deep learning model for analysis to obtain a latent representation of the slow-wave dynamic state of the EEG; wherein the deep learning model is obtained by integrating three types of self-supervised target collaborative training: self-predictive representation, unsupervised target conditional reinforcement learning, and inverse dynamics modeling.
[0084] As a preferred embodiment, such as Figure 2As shown, the pre-built deep learning model adopts an end-to-end architecture of "feature extraction - temporal modeling - self-supervised fusion - decision output", balancing accuracy and lightweight requirements. Specifically, it includes an input layer, a feature extraction module, a temporal modeling module, a self-supervised pre-training fusion module, and an output layer. The functions of each module / structure are as follows:
[0085] Input layer: Used to receive preprocessed EEG signals, which have dimensions of (batch_size, C, T), where C = 16 / 32 channels and T = 500 time points (500ms window).
[0086] Feature extraction module: Contains a multi-layer one-dimensional convolutional neural network for extracting spatial features layer by layer. In this embodiment, a 3-layer CNN network is selected, consisting of (1,20) convolutional kernels (64 channels), (1,10) convolutional kernels (128 channels), and (1,5) convolutional kernels (256 channels). Each layer is followed by BatchNorm and ReLU activation. Global average pooling is used to compress the spatial dimension (output dimension: batch_size, 256, time step) to capture slow-wave local spatial features.
[0087] Temporal modeling module: In this embodiment, a two-layer BiLSTM network (128 hidden dimensions per layer) is selected to mine long-term dependencies (such as the periodic evolution of delta waves). The last time step feature concatenation strategy is adopted to output a flattened feature vector of (batch_size, 512) (each bidirectional LSTM outputs 256 dimensions, which are concatenated to 512 dimensions).
[0088] Self-supervised pre-training fusion module: embeds three types of self-supervised objectives to improve representation learning capabilities in low-data scenarios. The three types of self-supervised objectives include self-predictive representation (SPR), unsupervised objective conditional (RL) reinforcement learning, and inverse dynamics modeling.
[0089] Output layer: Consists of the following three parallel sub-headers to ensure precise matching between output and control requirements:
[0090] (1) Stimulus type head: Softmax layer, outputs the probability distribution of [tDCS,tACS], and selects the final stimulus mode through argmax;
[0091] (2) Stimulus intensity head: a linear layer activated by Sigmoid, outputting a normalized intensity value of 0-1, which is then converted into a physical range of 0-2.5mA (step size 0.1mA) through linear mapping.
[0092] (3) Stimulation frequency head: a linear layer activated by Sigmoid, outputting a normalized frequency value of 0-1, which is then mapped to a physical range of 0.5-8Hz (step size 0.1Hz). This output is ignored in tDCS mode.
[0093] As a preferred embodiment, this deep learning model directly serves the needs of slow-wave modulation by integrating three types of self-supervised objective training: self-predictive representation (SPR), unsupervised objective conditional (RL) reinforcement learning, and inverse dynamics modeling. Specifically, it includes the following three aspects:
[0094] (a) Self-predictive representation (SPR)
[0095] The principle of Self-Predictive Representations (SPR) is to force the model to learn the temporal evolution of slow waves (such as the rise-peak-fall cycle of delta waves), allowing the representation to naturally contain dynamic environmental information without relying on reconstruction of the original signal or negative sample comparison. Its core is to construct a transitional model. The system obtains the latent representation at the current moment through the master encoder. Based on the current latent representation and the current control action input transition model, iteratively predicts the latent representation for the next multiple steps (e.g., 5 steps, 50ms each). It calculates the cosine similarity between the predicted latent representation and the true latent representation, and then applies a loss function... Calculate the loss value, and then perform a weighted summation with the inverse dynamics modeling loss, etc., to obtain the total loss. Then, perform backpropagation to update the parameters of the master encoder, transition model, and prediction head.
[0096] The aforementioned real latent representation is obtained by encoding the real EEG signal at the corresponding time by the target encoder. The target encoder is an auxiliary encoder independent of the main encoder of the deep learning model, and its parameters are updated according to the parameters of the main encoder in the deep learning model by exponential moving average.
[0097] Among them, the loss function of the aforementioned self-predictive representation (SPR) The formula is:
[0098] ;
[0099] ;
[0100] in, : Future prediction step index, with a value range of 1 to 5; The prediction head is a linear layer structure that receives the projected features from the main encoder and outputs a prediction vector with the same dimension as the output of the target projection head, which is used to match the true representation dimension. The main encoder, consisting of a linear projection layer after CNN+BiLSTM, has the core function of mapping EEG signal features to a high-dimensional latent space and extracting representations rich in slow-wave temporal information. : No. The latent representation of the time-prospective model is derived from the transition model. Based on the predicted representation and corresponding action generated at the previous moment, it reflects the model's prediction of the future slow wave state; Target projection head, and main encoder The structures are exactly the same, and their parameters vary depending on the target encoder. Synchronous updates are used to project the true latent representation and adapt it to the dimension of loss calculation. : No. The true latent representation of time is obtained by the target encoder. For the first The EEG signals at each moment are processed and generated, serving as a benchmark for predictive representation; The Euclidean norm calculation operator is used to normalize the predicted vector and the true vector to avoid the interference of magnitude differences on the loss calculation. : The formula for generating the predicted representation, where For the first Latent representation of time prediction For the first The timing of the adjustment actions (virtual actions during the pre-training phase, and real adjustment parameters during the fine-tuning phase); Transitional model: used to iteratively predict the latent representation of the next time step based on the latent representation and corresponding action of the previous time step; : The formula for generating the true representation, where For the first Preprocessed EEG signals at all times For the target encoder; The target encoder, whose parameters are those of the main encoder. The exponential moving average (EMA) of the parameters, without gradient updates, is used to generate stable, true latent representations, avoiding model oscillations caused by target fluctuations during training. : No. EEG signals at any time, via Hardware filtering The effective signal after preprocessing steps such as software filtering, artifact removal, and normalization is the original input for generating the latent representation; EMA (Exponential Moving Average): a parameter update strategy that adjusts the master encoder... The parameters are weighted and averaged to update the target encoder. The parameters are adjusted to make the target representation more stable and improve the convergence of model training.
[0101] (b) Unsupervised objective condition RL
[0102] Unsupervised target-conditional reinforcement learning (RL) draws on the idea of post-experience replay. Its principle is to guide the model to learn smooth and coherent slow-wave state transition paths without external rewards, and to construct a representation space with regulatory guidance.
[0103] Specifically, firstly, a state sequence consisting of latent representations at multiple consecutive time points is extracted from the preprocessed EEG signal, and then the state for the next 100-200ms is sampled from this state sequence as the target state. The target state is as described. Random noise is added to expand the target distribution, and the distance change to the target represented by the current latency is used as the synthetic reward to train the target conditional value function, wherein the target conditional value function is used to evaluate the expected value of performing a control action in a given target state.
[0104] Among them, the synthesis reward Used to train the objective conditional value function .
[0105] in, : Distance calculation function, used to measure two latent representations ( and and The similarity between states is such that the smaller the distance, the closer the state is to the target. : No. Latent representation of EEG signals at a given moment; : No. Latent representation of EEG signals at a given moment; : Objective conditional value function, used to estimate the value at the th... Moment State Next, execute the action. Approaching the target Expected cumulative reward; : No. The effective EEG signal after preprocessing is used to generate latent representations. The original input; Action variables in unsupervised objective conditional RL are discrete pseudo-actions in the virtual action space during the pre-training phase and are mapped to real tES control parameters during the fine-tuning phase.
[0106] (c) Inverse dynamics modeling
[0107] The core role of inverse dynamics modeling is to establish the correlation between slow wave changes and regulatory actions, provide independent supervision signals, prevent representation collapse, simplify the complexity of pre-training tasks, and enhance the model's sensitivity to regulatory feedback.
[0108] Specifically, inverse dynamics modeling takes the current latent representation and the next latent representation as input, and predicts the intermediate discrete control actions through a two-layer multilayer perceptron (MLP). The actions include categories such as {intensity+, intensity-, frequency+, frequency-, mode switching, and maintenance}. The principle is to establish a mapping relationship between "slow wave state change and regulation action", providing a supervision signal independent of other targets. This avoids representation collapse, enhances the model's sensitivity to regulation feedback, and simplifies the complexity of pre-training tasks.
[0109] It is important to note that in the subsequent fine-tuning phase of the model, the above action categories are mapped to the gradient adjustment direction of the continuous output parameters (such as "intensity+" corresponding to an increase of 0.1mA in the intensity head output value, and "switching mode" corresponding to an update of the type head probability distribution), further transferring the "change-action" association learned in the pre-training to the fine-tuning task.
[0110] In a preferred embodiment, after completing the collaborative training of three types of self-supervised objectives—integrated self-predictive representation, unsupervised target conditional reinforcement learning, and inverse dynamics modeling—the process enters the fine-tuning stage. The optimization objective in this stage focuses on improving slow-wave characteristics, quantifying the stimulus effect into an external reward, and optimizing the control strategy. The reward function formula is as follows:
[0111] ;
[0112] in This represents a change in slow wave density (positive when approaching healthy standards). This represents the change in slow wave amplitude (positive if it increases within the healthy range). The current stimulus intensity (punishment for overstimulation); and The calculation is based on the moving average of the slow wave characteristics between the current moment and the previous 5-second baseline period. The inference mechanism adopts a 50ms sliding window mode, updating the input data every 50ms (taking the latest 500ms signal) to ensure that the control parameters adapt to the dynamic changes of the slow wave in real time. : No. The immediate reward value at any given moment is determined by both the improvement effect of slow-wave characteristics and the penalty for stimulus intensity; a higher value indicates a better current control strategy. 5-second baseline period: Calculation and The reference time period is taken as the moving average of slow wave features 5 seconds before the current moment to reduce the impact of instantaneous fluctuations; Moving average: The moving average of slow wave density and amplitude features within the 5-second baseline period is calculated to smooth data fluctuations and improve the stability of reward calculation; 50ms sliding window mode: The inference mechanism in the fine-tuning stage updates the model input data every 50ms to ensure that the adjustment parameters adapt to the dynamic changes of slow waves in real time; Latest 500ms signal: The input data window at each inference time takes the latest 500ms EEG signal (including 10 50ms sliding window data) to ensure that the model captures the temporal features of slow waves.
[0113] As a preferred embodiment, the deep learning model also needs to be lightweighted and optimized for deployment, including the following aspects:
[0114] Hardware deployment: Prioritize edge computing GPUs (NVIDIA Jetson Xavier NX) or dedicated neural processing chips (Intel Movidius NCS2) to balance inference speed and deployment cost;
[0115] Model compression: If deployed on a general-purpose CPU, pruning (removing 30%-50% of redundant connections) + 8-bit quantization technology is used to ensure that the accuracy loss is ≤5% while keeping the inference latency ≤50ms.
[0116] Real-time performance guarantee: Through engineering techniques such as batch size = 1 and layer fusion optimization, the forward propagation time is further reduced to meet the requirement of end-to-end latency ≤ 100ms.
[0117] S130. Based on the latent characterization decision, transcranial electrical stimulation parameters are generated, wherein the stimulation parameters include at least stimulation type, stimulation intensity, and stimulation frequency.
[0118] In a preferred embodiment, the latent characterization is input into the output layer of the model as the stimulus type subheader, stimulus intensity subheader, and stimulus frequency subheader:
[0119] The stimulation type subheading outputs the stimulation type decision result based on the slow wave spectrum concentration and amplitude stability reflected by the latent characterization: if the spectrum is concentrated and the amplitude is stable, the transcranial direct current stimulation type is output; otherwise, the transcranial alternating current stimulation type is output. Among them, spectrum flatness represents the spectrum characteristic index of the slow wave signal, which is used to judge the degree of slow wave rhythm concentration. The more concentrated the spectrum, the more stable the rhythm. Amplitude stability represents the amplitude fluctuation characteristic index of the slow wave signal, which is used to judge whether the slow wave amplitude is stable. The smaller the fluctuation, the higher the stability.
[0120] The stimulus intensity is obtained by outputting a first normalized value based on the latent representation from the stimulus intensity subheading and mapping the first normalized value to a preset physical range.
[0121] The stimulation frequency subheader outputs a second normalized value based on the latent characterization, and maps the second normalized value to a preset physical range to obtain the stimulation frequency;
[0122] Among them, the stimulation type supports two modes: tDCS (transcranial direct current stimulation) and tACS (transcranial alternating current stimulation), which can be selected to adapt to different slow wave abnormality scenarios. If the spectrum is concentrated, the amplitude is low and stable, it is suspected that the neuronal excitability is insufficient, and tDCS is selected first for cortical excitability regulation. If the spectrum is dispersed and the amplitude fluctuates greatly, it is suspected that the rhythm is disordered, and the same frequency tACS is selected first for rhythm entrainment.
[0123] Stimulation intensity: The value ranges from 0 to 2.5 mA with a step size of 0.1 mA. It is used to adjust the current magnitude of the stimulation signal and directly affects the control effect and safety.
[0124] Stimulation frequency: The value ranges from 0.5 to 8 Hz, with a step size of 0.1 Hz. It is only effective in tACS mode and is matched with the slow wave core frequency band to achieve rhythm entrainment. It is automatically disabled in tDCS mode.
[0125] As a preferred embodiment, the stimulation signal generation adopts direct digital synthesis (DDS) technology to generate a high-precision constant current stimulation signal with a ripple coefficient ≤0.5%; the tDCS mode outputs constant DC current, and the tACS mode outputs sinusoidal AC current, with a switching response time of ≤10ms between the two modes; the total time from receiving the model command to applying the stimulation signal is ≤30ms, ensuring the continuity of the closed-loop timing.
[0126] As a preferred embodiment, combined with Figure 4 As shown, the system completes a closed loop of signal acquisition, model inference, parameter update, and stimulus output every 50ms, tracking slow wave changes in real time. By comparing the current slow wave characteristics (density, amplitude) with the target threshold for N3 slow waves in healthy individuals, if the slow wave characteristics remain below the target threshold or show a downward trend for 10 consecutive regulation cycles (500ms), the stimulus parameters are adjusted according to the reward function (e.g., moderately increasing intensity or optimizing frequency); if the target has been reached, the current parameters are maintained or the intensity is gradually reduced to avoid overstimulation.
[0127] Among them, the target threshold for slow waves in N3 stage of healthy individuals is set based on the statistical values of slow wave density and amplitude during deep sleep (N3 stage) in healthy individuals, serving as the basis for judging whether slow waves meet the standard.
[0128] S140. Based on the transcranial electrical stimulation parameters, output corresponding transcranial direct current stimulation or transcranial alternating current stimulation to a specific brain region of the target subject.
[0129] As a preferred embodiment, such as Figure 3 As shown, the above model also includes a multi-layered security monitoring mechanism:
[0130] Set dual safety thresholds (general safety current threshold and individual calibration current threshold). When the stimulus intensity is ≥2.5mA or exceeds the individual calibration threshold, trigger an alarm and stop the output.
[0131] It can detect abnormal discharge characteristics (such as epileptiform discharges and other dangerous characteristics) in EEG signals in real time, and cut off the stimulation output within a preset time (e.g., 10ms) after detecting abnormalities;
[0132] The electrode contact status is monitored in real time. When the impedance exceeds the preset impedance threshold (for example, when the impedance is ≥50kΩ, it indicates that the electrode has fallen off), it is determined to be an abnormal electrode contact and the corresponding adjustment mechanism is triggered.
[0133] The individual calibration threshold is a safe upper limit for stimulus intensity set based on individual differences among subjects. It is determined by the calibration process during initial use and is adapted to the tolerance of different individuals. Specifically, it includes:
[0134] When used for the first time, the system applies a set of short test stimuli starting from 0.5mA and increasing in increments of 0.2mA (each stimulus lasts for 1 second, with a 5-second interval), while simultaneously monitoring abnormal EEG signals and the subject's subjective reports (via button feedback). The intensity value at which discomfort or EEG abnormality first occurs is set as the individual safety limit for the subject.
[0135] During the regulation process, the scalp impedance changes are monitored in real time. If the impedance fluctuation exceeds 30%, the stimulation current is automatically adjusted to maintain the effective stimulation intensity while avoiding the risk of skin irritation.
[0136] The individual safety upper limit is a customized safety threshold for stimulation intensity for each subject, equal to 80% of the intensity value at which discomfort or EEG abnormality first occurs during the initial calibration, ensuring individual safety. Short-duration test stimuli are experimental stimuli applied during the initial calibration phase, starting at 0.5 mA and increasing in 0.2 mA increments, with each stimulus lasting 1 second and a 5-second interval, used to assess individual tolerance.
[0137] Subjective reports are the feedback method during the initial calibration phase. Subjects report their discomfort during the stimulation process via buttons, which serves as the basis for setting individual safety limits. Changes in scalp impedance reflect the fluctuations in impedance between the scalp and electrodes during the adjustment process, used to determine whether the stimulation conduction environment is stable.
[0138] As a preferred embodiment, such as Figure 3 The following emergency intervention mechanisms are also included:
[0139] Manual control: Equipped with an emergency stop button, allowing subjects to trigger a stop at any time;
[0140] Software redundancy: The system has a built-in independent safety controller that runs in parallel with the main control module, ensuring that safety logic can still be executed when the main module fails.
[0141] Emergency stop button: A manual safety control component that the subject can trigger at any time to cut off the stimulus output, providing proactive safety assurance.
[0142] Independent safety controller: The system has a built-in redundant safety module that runs in parallel with the main control module to ensure that safety logic (such as cutting off stimuli or triggering warnings) can still be executed when the main module fails.
[0143] Based on the above embodiments, the present invention achieves the following beneficial effects:
[0144] (1) This invention integrates three types of self-supervised target collaborative optimization feature representations: self-predictive representation (SPR), unsupervised target conditional RL, and inverse dynamics modeling, directly serving the needs of slow wave regulation: learning the evolution law of slow wave time series through SPR, constructing the state transition representation space through unsupervised target conditional RL, and establishing the "slow wave change-regulation action" association through inverse dynamics modeling. The three work together to avoid representation collapse and improve the representation learning efficiency in low data scenarios.
[0145] (2) The present invention constructs a lightweight CNN-BiLSTM end-to-end model and combines it with a sliding window inference mechanism. Under the premise of ensuring that the model parameters are ≤5 million, the inference delay is controlled to ≤50ms, and the slow wave density, amplitude and rhythm abnormalities are accurately identified.
[0146] (3) Dynamically optimize stimulation regulation parameters: Based on the deep learning model, the stimulation type (tDCS / tACS), intensity (0-2.5mA), and frequency (0.5-8Hz) are output. The parameters are updated every 50ms through a closed-loop feedback mechanism to adapt to the slow wave dynamic changes and realize personalized rhythm entrainment or excitability regulation.
[0147] (4) The present invention combines general threshold and individual calibration threshold, and integrates signal anomaly monitoring, electrode contact detection and emergency intervention mechanism to ensure stimulation safety and tolerance while ensuring the end-to-end delay is ≤100ms.
[0148] Example 2:
[0149] To further verify the superiority of this algorithm in EEG slow-wave representation learning and control decision-making, this embodiment designed and conducted a multi-dimensional comparative verification experiment. The experiment used Root Mean Square Error (RMSE) as the core evaluation metric, comparing the performance of the algorithm with four mainstream baseline algorithms throughout the entire process. The four baseline algorithms were: a sequential combination of Convolutional Neural Network (CNN) and Long Short-Term Memory (LSTM) (CNN+LSTM), a combination of CNN and Bidirectional Long Short-Term Memory (BiLSTM) (CNN+BiLSTM), and a composite model that adds a Multi-Layer Perceptron (MLP) decision layer to these two combinations (CNN+LSTM+MLP, CNN+BiLSTM+MLP). All models were tested on the same dataset and under the same training conditions.
[0150] Experimental results are as follows Figure 5 As shown, the algorithm of this invention exhibits significantly better RMSE reduction trend and final convergence performance than all baseline algorithms throughout the entire training process, specifically in the following two stages:
[0151] In the early training phase (rounds 0-10): the RMSE of the algorithm of this invention dropped rapidly from 0.85 to 0.42, a decrease of 50.6%, while the RMSE of the four baseline algorithms only decreased by 29.3%-35.9%, demonstrating the efficient empowerment of multi-self-supervised target collaborative representation learning for initial feature extraction;
[0152] During the later stages of training (10-50 rounds), the algorithm of this invention maintained stable and rapid error convergence. Finally, at 50 rounds, the RMSE dropped to 0.06 (<0.1), which is 75% lower than the best-performing baseline algorithm (CNN+BiLSTM, RMSE=0.24) and 81.25% lower than the worst-performing baseline algorithm (CNN+LSTM+MLP, RMSE=0.32). This fully verifies the synergistic advantages formed by SPR's accurate modeling of the evolution of slow wave time series, the effective construction of the state transition representation space by unsupervised objective conditional RL, and the reliable establishment of the correlation between "slow wave change and regulation action" by inverse dynamics modeling. These three factors not only effectively avoid the representation collapse problem that is easily caused by a single self-supervised objective, but also improve the model's generalization ability and feature recognition accuracy in low-data scenarios.
[0153] In contrast, the four baseline algorithms, limited by single or simple network structures, failed to fully capture the spatial features, temporal dependencies, and action associations of slow EEG waves, resulting in slow RMSE convergence speed and high final values. Among them, the composite baseline algorithms integrating MLP (CNN+LSTM+MLP, CNN+BiLSTM+MLP) did not show the expected performance gain, but instead experienced convergence delay due to increased network complexity. This further highlights the advantages of the algorithm in this invention in balancing representation learning efficiency, feature adaptability, and model lightweighting, providing technical support that combines performance and practicality for real-time and accurate modulation of slow EEG waves.
[0154] Example 3:
[0155] Figure 6 This is a block diagram of a deep learning-based slow-wave transcranial electrical stimulation system provided in Embodiment 3 of the present invention. Figure 6 As shown, the device includes:
[0156] The signal acquisition and preprocessing unit 610 is used to acquire the electroencephalogram (EEG) signals of the target object and preprocess the EEG signals to obtain preprocessed EEG signals.
[0157] The signal processing and analysis unit 620 is used to input the preprocessed EEG signal into a pre-constructed deep learning model for analysis to obtain a latent representation of the dynamic state of slow-wave EEG; wherein, the deep learning model is obtained by integrating three types of self-supervised target collaborative training: self-predictive representation, unsupervised target conditional reinforcement learning, and inverse dynamics modeling.
[0158] The transcranial electrical stimulation parameter generation unit 630 is used to generate transcranial electrical stimulation parameters based on the latent characterization decision, wherein the stimulation parameters include at least stimulation type, stimulation intensity and stimulation frequency;
[0159] The transcranial electrical stimulation output unit 640 is used to output corresponding transcranial direct current stimulation or transcranial alternating current stimulation to a specific brain region of the target subject according to the transcranial electrical stimulation parameters.
[0160] The deep learning-based slow-wave real-time feedback transcranial electrical stimulation system provided in this embodiment of the invention can execute the deep learning-based slow-wave real-time feedback transcranial electrical stimulation method provided in any of the above embodiments of the invention. It has the corresponding functions and beneficial effects of executing the deep learning-based slow-wave real-time feedback transcranial electrical stimulation method. For detailed process, please refer to the relevant operations of the deep learning-based slow-wave real-time feedback transcranial electrical stimulation method in the foregoing embodiments.
[0161] Example 4:
[0162] Figure 7This is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention. The electronic device 10 is intended to represent various forms of digital computers, and may also represent various forms of mobile devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the invention described and / or claimed herein.
[0163] like Figure 7 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded into the RAM 13 from storage unit 18. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0164] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0165] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, central processing unit (CPU), graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the deep learning-based slow-wave EEG real-time feedback transcranial electrical stimulation method described above.
[0166] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0167] The above embodiments are merely illustrative examples and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.
Claims
1. A deep learning-based EEG slow-wave real-time feedback transcranial electrical stimulation system, characterized in that, include: The signal acquisition and preprocessing unit is used to acquire the electroencephalogram (EEG) signals of the target object and preprocess the EEG signals to obtain preprocessed EEG signals. The signal processing and analysis unit is used to input the preprocessed EEG signal into a pre-constructed deep learning model for analysis, obtaining a latent representation of the dynamic state of slow-wave EEG. The deep learning model is obtained through collaborative training of three types of self-supervised objectives: self-predictive representation, unsupervised objective-based reinforcement learning, and inverse dynamics modeling. The self-predictive representation objective of the deep learning model is implemented as follows: The latent representation at the current moment and the corresponding regulatory action are input into a pre-constructed transition model to iteratively generate predicted latent representations for multiple future time steps. The parameters of the deep learning model are optimized by maximizing the cosine similarity between the predicted latent representations at each time step and the corresponding true latent representations. The true latent representation is obtained by encoding the true EEG signal at the corresponding moment by the target encoder. The target encoder is an auxiliary encoder independent of the main encoder of the deep learning model, and its parameters are updated according to the parameters of the main encoder in the deep learning model using an exponential moving average method. A transcranial electrical stimulation parameter generation unit is used to generate transcranial electrical stimulation parameters based on the latent characterization decision, wherein the stimulation parameters include at least stimulation type, stimulation intensity, and stimulation frequency; The transcranial electrical stimulation output unit is used to output corresponding transcranial direct current stimulation or transcranial alternating current stimulation to a specific brain region of the target subject according to the transcranial electrical stimulation parameters.
2. The system according to claim 1, characterized in that, The deep learning model adopts a lightweight end-to-end architecture, comprising the following modules connected in sequence: The input layer is used to receive preprocessed EEG signals; The feature extraction module uses a convolutional neural network to extract local spatial features of slow brain waves. The temporal modeling module employs a bidirectional long short-term memory network to perform temporal modeling on the local spatial features, thereby mining the temporal dependencies of slow brain waves and outputting latent representations. The self-supervised pre-training fusion module trains the model by fusing three types of self-supervised objectives: self-predictive representation, unsupervised objective conditional reinforcement learning, and inverse dynamics modeling, in order to optimize the encoding ability of the latent representation for slow-wave dynamics and control actions. The output layer includes a stimulation type subheader, a stimulation intensity subheader, and a stimulation frequency subheader set in parallel, which are used to output the corresponding stimulation type, stimulation intensity, and stimulation frequency based on the latent characterization, respectively.
3. The system according to claim 2, characterized in that, The unsupervised objective conditional reinforcement learning objective of the deep learning model is achieved as follows: Based on the preprocessed EEG signals, a state sequence consisting of latent representations at multiple consecutive time points is extracted; Sample the latent representation of future time moments from the state sequence as the target state; Random noise is added to the target state to expand the target distribution, and the reduction in distance between the current latent representation and the target state is used as the synthetic reward. Based on the synthetic reward training objective conditional value function, a representation space that guides slow-wave state transitions is constructed, wherein the objective conditional value function is used to evaluate the expected value of performing a regulatory action in a given objective state.
4. The system according to claim 2, characterized in that, The inverse dynamics modeling objective of the deep learning model is achieved as follows: Using the current latent representation and the next latent representation as input, a multilayer perceptron network is used to predict discrete control actions that lead to changes in the slow wave state. By modeling inverse dynamics, a mapping relationship between slow wave state changes and discrete control actions is established, providing a supervisory signal for feature learning that is independent of the self-predictive representation and the unsupervised target conditional reinforcement learning objective.
5. The system according to claim 2, characterized in that, After completing the collaborative training of three types of self-supervised objectives—fusion of self-predictive representations, unsupervised objective conditional reinforcement learning, and inverse dynamics modeling—the deep learning model also includes a fine-tuning stage: During the fine-tuning phase, the deep learning model is optimized using the following external reward function: ; in, The instantaneous reward value at time t; : Slow wave density change; : Change in slow wave amplitude; : The intensity of transcranial electrical stimulation at time t.
6. The system according to claim 2, characterized in that, Transcranial electrical stimulation parameters are generated based on the latent characterization decision, wherein the stimulation parameters include at least stimulation type, stimulation intensity, and stimulation frequency, including: The latent characterization is input into the stimulus type subheader, stimulus intensity subheader, and stimulus frequency subheader of the output layer; The stimulation type subhead outputs the stimulation type decision result based on the slow wave spectrum concentration and amplitude stability reflected by the latent characterization: if the spectrum is concentrated and the amplitude is stable, the transcranial direct current stimulation type is output; otherwise, the transcranial alternating current stimulation type is output. The stimulation intensity subhead outputs a first normalized value based on the latent characterization, and maps the first normalized value to a preset current intensity range; The stimulation frequency subheader outputs a second normalized value based on the latent characterization, and maps the second normalized value to a preset frequency range.
7. The system according to claim 1, characterized in that, The system also includes the following real-time security protection steps: Set dual-strength safety thresholds, including a general safety current threshold and an individual calibration current threshold; When the real-time stimulus intensity reaches any of the aforementioned safety thresholds, an alarm is triggered and the stimulus output is stopped. Real-time monitoring of EEG signals and cutting off stimulation output within a preset time when predefined abnormal discharge characteristics are detected; The contact impedance of the stimulation electrode is monitored in real time. When the impedance exceeds a preset impedance threshold, it is determined that the electrode contact is abnormal and the corresponding adjustment mechanism is triggered.
8. The system according to claim 7, characterized in that, The method for setting the individual calibration current threshold includes: Test transcranial electrical stimulation is applied to the target subject starting from a safe initial value and increasing in fixed steps, while simultaneously acquiring its physiological feedback signals; The intensity of stimulation that first elicits subjective feedback of discomfort or abnormal features in EEG signals is defined as the stimulation tolerance intensity. The individual calibration current threshold is calculated based on the stimulation tolerance intensity and the preset safety factor.