Pre-cueing brain-computer interface decoding method for sensory-motor electrostimulation rehabilitation training

CN122964670APending Publication Date: 2026-10-23BEIJING NAOLI TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611272197.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-20
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

由于模型无法区分感觉电刺激阶段、运动想象阶段和运动执行阶段脑电的不同作用,极易将刺激伪迹、肌电残留或个体化幅值差异当作分类捷径,导致在跨被试或跨天评估时性能急剧下降

Benefits of technology

本发明提供的解码方法及装置,通过将SMES前提示窗口与主任务窗口按真实时间边界分离,并利用分段注意力池化生成具有阶段语义的前提示表示,构建了可学习的前提示条件记忆;在此基础上,通过两级门控机制动态调节不同前提示阶段及整体前提示的参与强度,并以主任务时序表示作为查询、经门控调节的前提示表示作为键值执行条件注意力解码,使得主任务脑电能够主动读取前提示条件记忆,而前提示信息不会重排或拉长主任务时间轴,从而在保持主任务时序完整性的前提下,将触发前的体感先验安全、可控地转化为对运动意图解码的增强条件。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122964670A_ABST
    Figure CN122964670A_ABST
Patent Text Reader

Abstract

The application provides a sensory muscle electrical stimulation pre-cue brain-computer interface decoding method for rehabilitation training, comprising: acquiring electroencephalogram data, performing feature extraction on the electroencephalogram data of a SMES pre-cue window, generating at least a plurality of pre-cue representations with stage semantics, and the plurality of pre-cue representations constitute a pre-cue condition memory; performing feature extraction on the electroencephalogram data of a main task window, and generating a main task time sequence representation; adjusting the pre-cue condition memory through a learnable gating mechanism, determining the participation intensity of different pre-cue representations and overall pre-cue information; taking the main task time sequence representation as a query, taking the pre-cue representation and / or main task representation after gating adjustment as a key and a value, performing conditional attention decoding, and outputting a movement intention classification result; the conditional attention decoding does not change the time axis length of the main task time sequence representation. The method can be more in line with the basic process of guiding central movement intention by peripheral sensation in rehabilitation training.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of brain-computer interface technology, and in particular to a brain-computer interface decoding method and apparatus for sensory muscle electrical stimulation pre-stimulation cues in rehabilitation training. Background Technology

[0002] Neurological disorders such as stroke, spinal cord injury, and peripheral nerve injury often lead to motor dysfunction in the upper or lower limbs, severely impacting patients' daily living abilities. In the field of neurorehabilitation, motor imagery (MI) brain-computer interfaces collect and decode the electroencephalogram (EEG) signals of patients during motor imagery, enabling them to participate in active rehabilitation training even when their actual limb movement abilities are limited. Motor execution (ME) EEG decoding can further be used to assess patients' residual motor control abilities. These technologies have significant application prospects in functional electrical stimulation (FES) control, exoskeleton training, soft rehabilitation robots, and remote rehabilitation assessment. Their core objective is to establish a closed-loop neuroplasticity training process: "intention generation—brain signal recognition—external feedback—sensory feedback—reinforcement of intention."

[0003] However, existing motor imagery brain-computer interface systems face numerous challenges in practical applications. Firstly, traditional systems typically rely on visual arrows, on-screen action videos, or audio cues to induce subjects to imagine specific movements, then extract μ-rhythms, β-rhythms, or deep network features from the EEG during the motor imagery phase for classification. These cues remain at the audiovisual level and differ significantly from the patient's actual proprioception of the affected limb. For rehabilitation patients with hemiplegia after stroke or traumatic brain injury, who often experience sensory impairment, difficulty maintaining attention, and decreased motor imagery abilities, visual or auditory cues alone are often insufficient to induce a stable, clear, and repeatable state of motor readiness in the sensorimotor cortex. This results in low signal-to-noise ratios, significant individual variability, and marked drift across training days in the motor imagery EEG, ultimately leading to insufficient classification accuracy and online control stability.

[0004] Secondly, while peripheral sensory-muscle electrical stimulation (SMES) can provide somatosensory input and motor side-awareness related to the target limb, and is closer to the sensorimotor closed-loop process in rehabilitation training than visual cues alone, current technologies have significant limitations in their application of SMES. Most approaches use SMES as feedback stimulation after motor imagery, triggering electrical stimulation only after the model decodes the motor intention to elicit muscle contraction or limb movement feedback, failing to fully utilize the crucial temporal structure that "stimulation occurs before the main task." Another approach, while using both pre-trigger SMES EEG and main task EEG as input, often employs a simple concatenation method to feed them into the classifier (such as CNN, Transformer, etc.). This confuses the different semantics of "cue prior" and "motor intention response," and may even disrupt the natural temporal sequence from cue to action. Because the model cannot distinguish the different roles of EEG during the sensory-muscle electrical stimulation phase, the motor imagery phase, and the motor execution phase, it is highly susceptible to treating stimulus artifacts, residual EEG, or individualized amplitude differences as classification shortcuts, leading to a sharp decline in performance during cross-subject or cross-day assessments.

[0005] Third, existing EEG decoding models lack robustness against cross-subject and cross-day drift. The amplitude, spectrum, and spatial distribution of EEG values ​​vary significantly among patients or rehabilitation training users. Simply relying on deep convolutional networks or traditional spatial filtering algorithms can easily lead to the learning of incidental features relevant to the subjects, making stability difficult to guarantee in online applications. Although transfer learning or domain generalization methods (such as MMD and CORAL) have been introduced into EEG classification, these methods typically do not consider the actual stimulus timing and cueing phases present in rehabilitation equipment, and lack a mechanism to transform pre-trigger SMES cues into learnable conditional priors.

[0006] Fourth, existing systems lack interpretable diagnostic mechanisms for pre-cue usage. Clinicians and rehabilitation therapists are not only concerned with whether the algorithm outputs the correct category, but also with whether the patient produces a stable EEG response to the pre-cues, whether the model truly utilizes the pre-cues information, and whether the intensity of pre-cues engagement collapses or over-relies on training domain shortcuts. Traditional black-box classifiers struggle to provide such diagnostic indicators, resulting in a lack of objective evidence when adjusting stimulus parameters, optimizing cue rhythm, or performing individualized calibration.

[0007] Fifth, the need for small-sample calibration in rehabilitation scenarios is mismatched with existing calibration methods. In clinical training, it is impossible to collect a large number of labeled trials before each training session, and patients cannot tolerate a long calibration process without feedback. If the algorithm must rely on large-sample individual training, or directly update all model parameters during calibration, it is easy to cause negative transfer or perturb the established discrimination boundary, reducing its practical value. Summary of the Invention

[0008] This invention provides a brain-computer interface decoding method and apparatus for sensory muscle electrical stimulation pre-stimulation cueing in rehabilitation training, in order to solve at least one of the above-mentioned technical problems.

[0009] To solve the above-mentioned technical problems, the present invention adopts the following technical means: A brain-computer interface decoding method for sensory muscle electrical stimulation pre-stimulation cues in rehabilitation training, the method comprising: Acquire EEG data, including EEG data in the SMES pre-prompt window before the start of the main task of motor imagery or motor execution, and EEG data in the main task window after the start of the main task. Feature extraction is performed on the EEG data of the SMES pre-cue window to generate multiple pre-cue representations with stage semantics, and the multiple pre-cue representations constitute pre-cue conditioned memory; Feature extraction is performed on the EEG data of the main task window to generate a temporal representation of the main task; The pre-cue conditional memory is adjusted through a learnable gating mechanism to determine the participation intensity of different pre-cue representations and the overall pre-cue information; Using the main task temporal representation as the query, and the gated pre-cue representation and / or the main task representation as the key and value, conditional attention decoding is performed, and the motion intent classification result is output; wherein, the conditional attention decoding does not change the time axis length of the main task temporal representation.

[0010] In some embodiments, feature extraction is performed on the EEG data of the SMES pre-cue window to generate multiple pre-cue representations with stage semantics, specifically including: The SMES pre-notification window is divided into at least two consecutive sub-stages; The EEG features of each sub-stage are extracted separately, and the corresponding pre-cue representations of each sub-stage are generated by segmented attention pooling or weighted average pooling. Each preceding prompt represents an overlay stage embedding to distinguish the semantics of different sub-stages.

[0011] In some embodiments, feature extraction is performed on the EEG data of the main task window to generate a temporal representation of the main task, specifically including: A multi-scale temporal convolutional network is used to perform preliminary feature extraction on the EEG data of the main task window to obtain multi-scale spatiotemporal features; The multi-scale spatiotemporal features are subjected to channel mixing and dimensionality transformation to generate a patch embedding sequence; The patch embedding sequence is input into a Transformer encoder or a temporal convolutional network for deep temporal modeling, and the temporal representation of the main task is output.

[0012] In some embodiments, the SMES pre-timing window is divided into an early stimulus timing stage and a late timing stage near the main task trigger, and a first pre-timing representation p1 and a second pre-timing representation p2 are generated accordingly. The learnable gating mechanism includes stage-level gating and global strength gating. The stage-level gating is used to output the relative participation weights between p1 and p2, and the global strength gating is used to output the strength of the overall cue path participation in the main task decoding.

[0013] In some embodiments, the method includes the following steps during the model training phase: Construct a pre-cue auxiliary supervision path, and input the pre-cue representation into a weak auxiliary classification head after independent projection; Calculate the weak classification loss between the pre-completion auxiliary output and the task label, and / or calculate the KL divergence alignment loss between the pre-completion auxiliary output and the main task branch output; Construct a pre-cue domain alignment path by projecting the pre-cue representation through another independent projection and calculating the conditional maximum mean difference loss by grouping pre-cue stages and categories to align the conditional distributions between different domains.

[0014] In some embodiments, the method further includes the following during the model training phase: Main protection steps: Using the main task branch output without pre-injection as the anchor point, apply KL divergence protection or distillation protection to the fused output with pre-injection condition memory, and constrain the offset of the fused output distribution relative to the anchor point output. The steps for gating anti-collapse constraints and consistency constraints are as follows: For the same sample's pre-cue window, generate two slightly perturbed views that do not disrupt the stage order. The distribution of the pre-cue auxiliary outputs of the two views must be consistent, and the gating weights of the two views must remain stable. Apply anti-collapse loss to the gating weights to prevent the gating output from degenerating into a fixed constant.

[0015] In some embodiments, the method includes the following steps during the model calibration phase: A small number of labeled trials were collected on the target subjects, most of the parameters of the main task backbone were frozen, and only some parameters in the pre-cue stage embedding, gating network, normalized statistics, lightweight adaptation layer or classification head were updated. The calibration loss includes the target sample cross-entropy, the model output distillation loss before calibration, and the parameter drift constraint loss.

[0016] In some embodiments, the method includes the following steps in the model prediction phase: In online applications, if the maximum prediction probability is lower than the threshold, the prediction entropy is too high, the difference between the main branch output and the fused output is too large, or the quality abnormality is indicated before the gating diagnosis is displayed, strong feedback is suppressed and weak feedback or recalibration prompts are given. If the output is stable, then generate and output feedback control instructions.

[0017] The present invention also provides a brain-computer interface decoding device for sensory muscle electrical stimulation pre-stimulation cueing in rehabilitation training, the device comprising: The EEG acquisition module is used to acquire EEG data, which includes EEG data in the SMES pre-prompt window before the start of the main task of motor imagery or motor execution, and EEG data in the main task window after the start of the main task. The pre-cue representation generation module is used to extract features from the EEG data of the SMES pre-cue window and generate multiple pre-cue representations with stage semantics. The multiple pre-cue representations constitute pre-cue conditional memory. The main task representation generation module is used to extract features from the EEG data of the main task window and generate a temporal representation of the main task. The gating adjustment module is used to adjust the pre-cue condition memory through a learnable gating mechanism to determine the participation intensity of different pre-cue representations and the overall pre-cue information; The conditional decoding module is used to perform conditional attention decoding with the main task temporal representation as the query, and the gated pre-cue representation and / or main task representation as the key and value, and output the motion intent classification result; wherein the conditional attention decoding does not change the time axis length of the main task temporal representation.

[0018] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the method described above.

[0019] In one or more of the above specific embodiments, the brain-computer interface decoding method and apparatus for sensory muscle electrical stimulation pre-stimulation cueing in rehabilitation training provided by the present invention has at least the following technical effects: The decoding method and apparatus provided by this invention separate the SMES pre-cue window and the main task window according to the real time boundary, and use segmented attention pooling to generate a pre-cue representation with stage semantics to construct a learnable pre-cue conditional memory. On this basis, a two-level gating mechanism is used to dynamically adjust the participation intensity of different pre-cue stages and the overall pre-cue. The main task temporal representation is used as the query, and the gated pre-cue representation is used as the key value to perform conditional attention decoding. This allows the main task EEG to actively read the pre-cue conditional memory, and the pre-cue information will not be rearranged or lengthened on the main task time axis. Thus, while maintaining the integrity of the main task temporal sequence, the pre-trigger somatosensory prior is safely and controllably transformed into an enhanced condition for decoding motor intention.

[0020] Meanwhile, through a series of training strategies such as pre-cue-assisted alignment training (weak classification and KL alignment), conditional distribution alignment grouped by stage and category, backbone anchor protection, gating to prevent collapse, and consistency constraints, the model effectively prevents shortcuts or over-independent classification in the training domain of pre-cue branch learning, avoids interference from pre-cue artifacts or differences in stimulus amplitude on the decoding results, and significantly improves the generalization stability and robustness of the model in cross-subject and cross-day evaluation.

[0021] Furthermore, the few-sample calibration step allows for updating only lightweight parameters related to the pre-cautions while freezing most of the parameters of the main task backbone. This enables a limited number of trials to be used to adjust "how to use the cue" rather than relearning the entire classifier, significantly reducing the time cost and miscalibration risk of individualized adaptation for rehabilitation patients. The online inference and feedback control steps combine gating diagnosis, predictive entropy, and the differences between the main branch and the fusion output to suppress strong feedback when the model confidence is insufficient. Once the output is stable, the FES or exoskeleton is then driven to perform actions. This reduces the risk of online false triggering and creates a tight closed loop between the patient's sensory input, motor intention, and external feedback, improving long-term training compliance. Attached Figure Description

[0022] Embodiments of the invention will now be described by way of example only, with reference to the accompanying schematic diagrams, wherein: Figure 1 A flowchart of the brain-computer interface decoding method for sensory muscle electrical stimulation pre-stimulation cueing in rehabilitation training provided by the present invention; Figure 2 The flowchart in this example illustrates the temporal relationship between the resting period, task prompting period, SMES pre-prompt period, and MI / ME main task period in the experimental paradigm. Figure 3 The diagram shown in this embodiment illustrates the overall architecture of the SMES_MI model, including the SMES pre-hint branch, the MI / ME main task branch, the gating fusion module, the Transformer temporal modeling module, the TCN feature extraction module, and the classification output module. Figure 4 The experimental metrics comparison chart in the embodiment is used to show the accuracy comparison results between the algorithm of this application and the control algorithm in four binary classification tasks, and the significant differences are marked. Figure 5 The comparison graph in the embodiment shows the accuracy difference between the algorithm of this application and the pure MI / ME main task TCFormer decoding algorithm, the pure SMES pre-cue algorithm and the CSP-SVM algorithm, and marks the significant differences. Figure 6The example plot shows the average key performance indicators (KPIs) for the four tasks, which are used to display the average results of accuracy, F1 score and Kappa coefficient for the four tasks, and provide explanations of the corresponding significant differences. Figure 7 The t-SNE feature visualization diagram in the example is used to show the t-SNE dimensionality reduction visualization results of the features extracted by the SMES_MI algorithm, reflecting the distribution of different categories of samples in the low-dimensional feature space; Figure 8 The confusion matrix diagram in this embodiment is used to show the classification results of task category and rest category in the test data, reflecting the model's ability to distinguish samples of different categories; where the significance indicators are explained as follows: * indicates p<0.05, ** indicates p<0.01, *** indicates p<0.001, and ns indicates no significant difference; Figure 9 This is a schematic diagram of the electronic device of the present invention. Detailed Implementation

[0023] 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.

[0024] First, the technical terms used in this invention will be explained as follows: MI: Motor imagery, refers to the mental imagery of a specified limb movement by a subject without any visible physical action output.

[0025] ME: Motor execution, refers to the subject performing specified limb movements according to task requirements.

[0026] SMES: Sensory muscle electrical stimulation refers to the application of low-intensity, perceptible, but not intended to induce forced movement, peripheral electrical stimulation to target muscle groups before the start of motor imagination or motor execution tasks, in order to provide somatosensory and motor sequence priors.

[0027] SMES_MI: Sensory electrical stimulation pre-stimulation cue motor imagery / motor execution algorithm, which refers to a complete algorithm that simultaneously utilizes the pre-trigger sensory muscle electrical stimulation cue path and the post-trigger MI / ME main task path, and outputs motor intention through gating condition decoding.

[0028] Pure sensory electrical stimulation algorithm: refers to a control algorithm that uses only the EEG or its features during the pre-trigger SMES cue period for classification, and is used to verify that relying solely on pre-cue information cannot replace the subsequent MI / ME main task decoding.

[0029] Pure motor imagery algorithm: refers to a control algorithm that uses only EEG data from the motor imagery stage or motor execution stage for decoding and does not introduce SMES pre-cue conditional path, and is used to evaluate the difference between pre-cue condition injection and conventional main task decoding.

[0030] Sensory electrical stimulation phase: refers to the SMES cue window before the start of the motor imagery phase or motor execution phase, encoding the stimulation side, stimulation sequence and somatosensory afferent state.

[0031] Motor imagery / motor execution phase: This refers to the main task window where the subject performs MI or ME according to the task requirements, and is used to collect EEG responses related to motor intentions.

[0032] Pre-cueing representation: A small number of semantic vectors obtained from the EEG features of the pre-cueing period through segmented attention pooling, preferably including two phases, p1 and p2.

[0033] Pre-cue gating: A learnable module used to adjust the intensity of different pre-cue representations and the overall pre-cue information participating in the main task decoding.

[0034] DG: Domain generalization evaluation across subjects or days, trained without using target subject test data and labels.

[0035] LOSO: Leave-one-out cross-validation, used to evaluate the algorithm's generalization ability on subjects not yet seen.

[0036] MMD: Maximum Mean Difference, used to measure the distance between two distributions, is a commonly used loss function in transfer learning.

[0037] Motor imagery is not a naturally stable physiological behavior. Different subjects exhibit significant differences in their understanding of instructions such as "imagine grasping with the left hand" or "imagine dorsiflexion of the ankle." Even the same subject may experience EEG rhythm drift when fatigued, experiencing changes in attention, taking medication, or during training. In particular, rehabilitation patients often experience sensory impairment, difficulty maintaining attention, and decreased motor imagery abilities. If the algorithm relies solely on visual arrows or textual cues, patients may understand the task requirements but struggle to form a clear and repeatable state of readiness in the sensorimotor cortex. Sensorimotor electrical stimulation (EMS) holds unique significance in this context: firstly, the stimulation directly acts on the target muscle group or related neural pathways, providing somatosensory cues related to lateralization, location, and direction of movement; secondly, the stimulation occurs before motor imagery or execution, naturally possessing a "pre-cue" attribute; and thirdly, the stimulation intensity can be below a significant motor threshold, not aiming to replace the patient's active intention, but rather helping the patient establish a bodily sensory entry point related to the target movement.

[0038] This application does not simply treat electrical stimulation as an additional input, nor as feedback after motor imagery, but rather considers "pre-triggered sensory-muscle electrical stimulation and its induced EEG response" as a cue condition preceding the main task decoding. This condition includes target lateralization, stimulation phase, sensory afferent state, and the subject's immediate response to the stimulus. If this condition can be injected into the subsequent MI / ME decoding backbone in a small, controllable, and diagnostic manner, it is hoped that the stability of intention decoding can be improved without disrupting the main task's EEG temporal structure.

[0039] From the perspective of industrial and medical rehabilitation applications, this technology is applicable to rehabilitation training equipment, intelligent FES systems, soft hand function trainers, lower limb gait induction devices, exoskeleton-assisted training systems, virtual reality rehabilitation systems, and outpatient remote training platforms. Its core value lies in lowering the barrier to entry for patients, improving the efficiency of individualized adaptation with few samples, and ensuring that the algorithm output aligns with real rehabilitation stimulus paradigms. This application should focus not on protecting a single network layer or a set of fixed parameters, but rather on the continuous technical route of "SMES pre-cue—pre-cue representation construction—gated condition injection—MI / ME decoding—assisted alignment training—rehabilitation feedback application."

[0040] Based on publicly available technical approaches and clinical rehabilitation equipment, existing solutions can generally be categorized into four types. The first type uses visual arrows, screen motion videos, auditory cues, or rhythmic cues to induce motor imagery, followed by EEG classification using CSP, FBCSP, SVM, LDA, CNN, or Transformer. This method is simple to implement, but the cues primarily remain at the visual or auditory level, insufficiently activating the patient's body perception on the affected side. The second type uses functional electrical stimulation as feedback after motor imagery, allowing the patient to receive muscle contraction or limb movement feedback after the model determines the target intention. This method emphasizes closed-loop training, but electrical stimulation often occurs after decoding, failing to fully utilize the pre-trigger stimulus as a conditional prior. The third type enhances the patient's motor imagery ability through kinetic hallucinations, passive movement, robotic traction, or multimodal induction. Its advantage is rehabilitation friendliness, but at the algorithm level, it usually still treats the enhancing signal as external induction, without forming a learnable pre-cue path. The fourth category focuses on improving EEG classification models using deep learning, transfer learning, or domain generalization as the core, enhancing cross-subject performance through network structure or training objectives, but rarely considers the actual stimulus timing and cueing phases present in rehabilitation devices.

[0041] Therefore, although existing technologies cover aspects such as motor imagery brain-computer interfaces, peripheral stimulation feedback, movement induction, deep learning classification, and cross-domain training, these aspects are often separate from each other. For the rehabilitation training process of "stimulus first, intention later, and feedback then return," there is still a lack of a complete algorithm that can convert pre-trigger SMES cues into learnable conditioned memories and retrieve these conditioned memories in a constrained manner during subsequent MI / ME decoding.

[0042] Existing rehabilitation training algorithms only emphasize classification accuracy, easily overlooking the true temporal relationships between stimuli, cues, intentions, and feedback. Clinical equipment is not an offline dataset; stimulators, EEG amplifiers, display cues, feedback actuators, and patient behavior together constitute a continuous system. If the algorithm does not treat pre-trigger cues as an independent path, even if the system achieves high accuracy in offline experiments, it may produce unstable outputs in online use due to stimulus synchronization errors, fluctuations in patient state, or cross-day drift.

[0043] This application extracts the pre-cue path from the main task path and re-injects it into the main task decoding through pre-cue representation, gating, and conditioned attention. This transforms the "cue before action" clinical process into a structural constraint within the model. This structural constraint allows the model to not only focus on EEG waveforms during the motor imagery or motor execution phases but also utilize the cueing context provided by pre-triggered sensory afferents, thus better aligning with the fundamental process in rehabilitation training where peripheral sensation guides central motor intention.

[0044] In one specific implementation, such as Figure 1 As shown, the brain-computer interface decoding method for sensory muscle electrical stimulation pre-stimulation cues in rehabilitation training provided by this invention includes the following steps: S110: Acquire EEG data, the EEG data including the EEG data of the SMES pre-prompt window located before the start of the main task of motor imagery or motor execution, and the EEG data of the main task window after the start of the main task. S120: Extract features from the EEG data of the SMES pre-cue window to generate multiple (preferably at least two) pre-cue representations with stage semantics, and the multiple pre-cue representations constitute pre-cue conditional memory; S130: Extract features from the EEG data of the main task window to generate a temporal representation of the main task; S140: Adjust the pre-cue conditional memory through a learnable gating mechanism to determine the participation intensity of different pre-cue representations and the overall pre-cue information; S150: Using the main task temporal representation as the query, and the gated pre-cue representation and / or main task representation as the key and value, perform conditional attention decoding and output the motion intent classification result; wherein, the conditional attention decoding does not change the time axis length of the main task temporal representation.

[0045] The method provided by this invention acquires EEG data from the SMES pre-cue window before the start of motor imagery or motor execution main task and EEG data from the main task window after the start of the main task. This clearly separates the pre-trigger somatosensory stimulation cue from the subsequent motor intention EEG response at the data acquisition level, avoiding semantic confusion caused by the indiscriminate splicing of the stimulation period and the main task period in traditional methods.

[0046] Building upon this foundation, feature extraction is performed on the pre-cue window EEG to generate a pre-cue representation with stage semantics, which constitutes the pre-cue conditioned memory, providing learnable prior conditions for main task decoding. Simultaneously, the main task temporal representation is extracted from the main task window EEG, preserving the complete temporal structure of the motor intention response. A learnable gating mechanism dynamically adjusts the pre-cue conditioned memory, adaptively determining the participation intensity of different pre-cue representations and overall pre-cue information, preventing uncontrollable pre-cue contributions or excessive suppression of the main task EEG. Finally, using the main task temporal representation as the query, and the gated pre-cue representation and / or the main task representation as the key and value for conditional attention decoding, the main task EEG can actively read the pre-cue conditioned memory. The pre-cue information only participates in the calculation as an external condition and does not change the time axis length of the main task temporal representation. Thus, while maintaining the integrity of the main task's temporal structure, it safely and controllably utilizes pre-trigger somatosensory priors to enhance motor intention decoding, significantly improving the accuracy and robustness of EEG decoding in rehabilitation training scenarios.

[0047] In step S120 above, feature extraction is performed on the EEG data of the SMES pre-cue window to generate multiple pre-cue representations with stage semantics, specifically including: The SMES pre-notification window is divided into at least two consecutive sub-stages; The EEG features of each sub-stage are extracted separately, and the corresponding pre-cue representations of each sub-stage are generated by segmented attention pooling or weighted average pooling. Each preceding prompt represents an overlay stage embedding to distinguish the semantics of different sub-stages.

[0048] Thus, the feature extraction method provided by this invention can fully exploit the differences in somatosensory information at different time stages within the pre-cueing period. For example, the early stimulus cueing stage mainly carries stimulus onset and lateral priming information, while the later cueing stage includes compound sensory input and motor preparation states related to the imminent start of the task. By segmented pooling, the long pre-cueing EEG is compressed into a small number of representation vectors with clear stage semantics, which not only preserves key temporal sequence information but also avoids the problem of losing dynamic changes in stages by treating the entire pre-cueing window as a single feature. The superimposed stage embedding further enhances the model's ability to distinguish the semantics of different sub-stages, enabling subsequent gating mechanisms to more accurately allocate the participation weights of different pre-cueing representations, thereby improving the representational quality and decoding performance of conditioned memory.

[0049] Furthermore, the process of extracting features from the EEG data of the main task window to generate a temporal representation of the main task also includes: A multi-scale temporal convolutional network is used to perform preliminary feature extraction on the EEG data of the main task window to obtain multi-scale spatiotemporal features; The multi-scale spatiotemporal features are subjected to channel mixing and dimensionality transformation to generate a patch embedding sequence; The patch embedding sequence is input into a Transformer encoder or a temporal convolutional network for deep temporal modeling, and the temporal representation of the main task is output.

[0050] Thus, the method provided by this invention can take into account both local details and global context through multi-scale convolution, patch embedding realizes the transition from raw EEG to high-level semantic representation, and deep temporal modeling of Transformer or TCN can capture long-distance temporal dependencies during the main task period, thereby generating temporal representations rich in discriminative information, providing high-quality query input for subsequent conditional attention decoding, and further improving the accuracy of motion intent classification.

[0051] The aforementioned SMES pre-cue window is divided into an early stimulus cue stage and a late cue stage that is close to the main task trigger, and a first pre-cue representation p1 and a second pre-cue representation p2 are generated accordingly. The learnable gating mechanism includes stage-level gating and global strength gating. The stage-level gating is used to output the relative participation weights between p1 and p2, and the global strength gating is used to output the strength of the overall cue path participation in the main task decoding.

[0052] Understandably, p1 and p2 carry different semantics for early somatosensory priming and later action preparation, respectively. Stage-level gating outputs the relative participation weights between p1 and p2, allowing the model to adaptively emphasize more informative pre-cue stages based on the current subject state, stimulus quality, or task type. Global strength gating outputs the intensity of the overall pre-cue path's participation in the main task decoding. When the pre-cue quality is poor, stimulus artifacts are too strong, or the main task information is sufficiently stable, it can reduce the overall pre-cue participation intensity to avoid introducing noise. This two-level gating structure achieves fine-grained control over pre-cue information from within a stage to the global level. It enhances the model's flexibility in utilizing pre-cue conditions and prevents excessive or insufficient participation of pre-cues, significantly improving the stability and generalization ability of the decoding system.

[0053] Furthermore, during the model training phase, the method provided by this invention includes the following steps: Construct a pre-cue auxiliary supervision path, and input the pre-cue representation into a weak auxiliary classification head after independent projection; Calculate the weak classification loss between the pre-completion auxiliary output and the task label, and / or calculate the KL divergence alignment loss between the pre-completion auxiliary output and the main task branch output; Construct a pre-cue domain alignment path by projecting the pre-cue representation through another independent projection and calculating the conditional maximum mean difference loss by grouping pre-cue stages and categories to align the conditional distributions between different domains.

[0054] This approach ensures that the pre-cue representation maintains its relevance to the main task category while avoiding training into an independent hard classifier. This prevents the pre-cue branch from becoming excessively detached from the main task or learning domain shortcuts unrelated to the main task. The KL alignment loss further constrains the consistency between the pre-cue auxiliary output and the main task branch output distribution, promoting the orderly transfer of pre-cue information to the main task decoding. The domain alignment path, after another independent projection of the pre-cue representation, calculates the conditional maximum mean difference loss by grouping pre-cue stages and categories. This aligns the conditional distribution of pre-cue features across different domains (e.g., different subjects, different sessions), preventing the model from misinterpreting category differences as domain differences, while preserving the stage semantics of p1 and p2. This step effectively improves the cross-domain generalization ability of the pre-cue branch, enabling the model to stably utilize pre-cue information even on unseen subjects or training days.

[0055] In some embodiments, the method provided by the present invention further includes the following during the model training phase: Main protection steps: Using the main task branch output without pre-injection as the anchor point, apply KL divergence protection or distillation protection to the fused output with pre-injection condition memory, and constrain the offset of the fused output distribution relative to the anchor point output. The steps for gating anti-collapse constraints and consistency constraints are as follows: For the same sample's pre-cue window, generate two slightly perturbed views that do not disrupt the stage order. The distribution of the pre-cue auxiliary outputs of the two views must be consistent, and the gating weights of the two views must remain stable. Apply anti-collapse loss to the gating weights to prevent the gating output from degenerating into a fixed constant.

[0056] In this way, the backbone protection step limits the perturbation of the stable discrimination boundary already formed by the main task by the pre-cue injection, preventing the pre-cue branch from undermining the discrimination ability of the main task backbone in the later stages of training, and ensuring that the enhancement effect of the pre-cue is always within a safe range. The gating anti-collapse constraint and consistency constraint steps generate two slightly perturbed views of the same sample's pre-cue window without disrupting the stage order. These require that the distribution of the pre-cue auxiliary outputs in the two views be consistent and that the gating weights remain stable. At the same time, an anti-collapse loss is applied to the gating weights, reducing the sensitivity of the pre-cue path to random noise, individual amplitude fluctuations, or stimulus artifacts, preventing the gating output from degenerating into a fixed constant and losing its regulatory ability, thereby enhancing the robustness and interpretability of the gating mechanism. These constraints together ensure the reliable learning and safe injection of pre-cue conditional memory.

[0057] During the model calibration phase, the method provided by this invention includes the following steps: A small number of labeled trials were collected on the target subjects, most of the parameters of the main task backbone were frozen, and only some parameters in the pre-cue stage embedding, gating network, normalized statistics, lightweight adaptation layer or classification head were updated. The calibration loss includes the target sample cross-entropy, the model output distillation loss before calibration, and the parameter drift constraint loss.

[0058] Thus, after the conditional attention decoding outputs the motor intent classification result, a few-sample calibration step is added. This step collects a small number of labeled trials on the target subject, freezes most of the parameters of the main task backbone, and only updates some parameters in the pre-cue stage embedding, gating network, normalized statistics, lightweight adaptation layer, or classifier head. The calibration loss simultaneously includes the target sample cross-entropy, the pre-calibration model output distillation loss, and the parameter drift constraint loss. By freezing the backbone network, overfitting or negative transfer that might occur from relearning the complete EEG classifier on a small amount of calibration data is avoided, protecting the universal discriminative boundary formed by source domain training. Updating only lightweight parameters related to the pre-cue allows the calibration process to focus on adjusting how to utilize the SMES pre-cue conditional prior, thereby achieving rapid model adaptation to the individual characteristics of the target subject with very few labeled trials. The distillation loss and parameter drift constraint in the calibration loss further prevent drastic parameter changes during the calibration process, ensuring the stability and reliability of the model output after calibration, and significantly reducing the time cost and clinical difficulty of individualized calibration for rehabilitation patients.

[0059] Furthermore, in the model prediction stage, the method provided by this invention includes the following steps: In online applications, if the maximum prediction probability is lower than the threshold, the prediction entropy is too high, the difference between the main branch output and the fused output is too large, or the quality abnormality is indicated before the gating diagnosis is displayed, strong feedback is suppressed and weak feedback or recalibration prompts are given. If the output is stable, then generate and output feedback control instructions.

[0060] Thus, following the few-sample calibration step, an online inference and feedback control step is added. In online applications, the system monitors the maximum predicted probability, prediction entropy, the difference between the main branch output and the fusion output, and gating diagnostic indicators in real time. When these indicators show insufficient model confidence or abnormal pre-cue quality, strong feedback is suppressed and weak feedback or recalibration prompts are given to avoid erroneous triggering of FES or exoskeleton movements that could cause discomfort or safety risks to patients. When the output is stable, functional electrical stimulation, exoskeleton, rehabilitation robot, or virtual reality training system is driven to perform corresponding action feedback. By closely integrating the decoding algorithm with the actual workflow of clinical rehabilitation equipment, safe and intelligent feedback control is achieved through multi-dimensional confidence assessment and gating diagnosis. This reduces the risk of online false triggering and ensures timely and effective action feedback when the model is confident, thus forming a closed-loop training of "sensory input - intention decoding - safety feedback," improving the active participation, compliance, and safety of rehabilitation training.

[0061] In addition to the methods described above, the present invention also provides a brain-computer interface decoding device for sensory muscle electrical stimulation pre-stimulation cueing in rehabilitation training, the device comprising: The EEG acquisition module is used to acquire EEG data, which includes EEG data in the SMES pre-prompt window before the start of the main task of motor imagery or motor execution, and EEG data in the main task window after the start of the main task. The pre-cue representation generation module is used to extract features from the EEG data of the SMES pre-cue window and generate multiple pre-cue representations with stage semantics. The multiple pre-cue representations constitute pre-cue conditional memory. The main task representation generation module is used to extract features from the EEG data of the main task window and generate a temporal representation of the main task. The gating adjustment module is used to adjust the pre-cue condition memory through a learnable gating mechanism to determine the participation intensity of different pre-cue representations and the overall pre-cue information; The conditional decoding module is used to perform conditional attention decoding with the main task temporal representation as the query, and the gated pre-cue representation and / or main task representation as the key and value, and output the motion intent classification result; wherein the conditional attention decoding does not change the time axis length of the main task temporal representation.

[0062] In one or more of the above specific embodiments, the brain-computer interface decoding method and apparatus for sensory muscle electrical stimulation pre-stimulation cueing in rehabilitation training provided by the present invention has at least the following technical effects: The decoding method and apparatus provided by this invention separate the SMES pre-cue window and the main task window according to the real time boundary, and use segmented attention pooling to generate a pre-cue representation with stage semantics to construct a learnable pre-cue conditional memory. On this basis, a two-level gating mechanism is used to dynamically adjust the participation intensity of different pre-cue stages and the overall pre-cue. The main task temporal representation is used as the query, and the gated pre-cue representation is used as the key value to perform conditional attention decoding. This allows the main task EEG to actively read the pre-cue conditional memory, and the pre-cue information will not be rearranged or lengthened on the main task time axis. Thus, while maintaining the integrity of the main task temporal sequence, the pre-trigger somatosensory prior is safely and controllably transformed into an enhanced condition for decoding motor intention.

[0063] Meanwhile, through a series of training strategies such as pre-cue-assisted alignment training (weak classification and KL alignment), conditional distribution alignment grouped by stage and category, backbone anchor protection, gating to prevent collapse, and consistency constraints, the model effectively prevents shortcuts or over-independent classification in the training domain of pre-cue branch learning, avoids interference from pre-cue artifacts or differences in stimulus amplitude on the decoding results, and significantly improves the generalization stability and robustness of the model in cross-subject and cross-day evaluation.

[0064] Furthermore, the few-sample calibration step allows for updating only lightweight parameters related to the pre-cautions while freezing most of the parameters of the main task backbone. This enables a limited number of trials to be used to adjust "how to use the cue" rather than relearning the entire classifier, significantly reducing the time cost and miscalibration risk of individualized adaptation for rehabilitation patients. The online inference and feedback control steps combine gating diagnosis, predictive entropy, and the differences between the main branch and the fusion output to suppress strong feedback when the model confidence is insufficient. Once the output is stable, the FES or exoskeleton is then driven to perform actions. This reduces the risk of online false triggering and creates a tight closed loop between the patient's sensory input, motor intention, and external feedback, improving long-term training compliance.

[0065] It needs to be emphasized again that the technical problem to be solved by this application is to provide an algorithmic method and system that can stably utilize the prior information of the pre-cue sequence and improve the robustness of EEG decoding in a continuous rehabilitation paradigm of sensory muscle electrical stimulation pre-cue, motor imagery and motor execution.

[0066] Specifically, it includes: 1. How to model the pre-trigger SMES cue period and the post-trigger MI / ME main task period separately, so that the pre-cues participate in decoding as a conditional prior, instead of splicing it together indiscriminately with the main task EEG.

[0067] 2. How to compress long pre-cue EEGs into a small number of pre-cue representations with stage semantics, respectively representing early stimulus cues, late stimulus cues near the start of the task, and possible multi-muscle group stimulation sequences.

[0068] 3. How to determine the participation mode of the before hints under different stages and task conditions through learnable gating, conditional modulation or equivalent adjustment mechanisms, so as to avoid the uncontrollable or unstable contribution of the before hints due to the use of fixed weight fusion.

[0069] 4. How to ensure that the main task represents the read of the pre-cue condition memory in the timing decoding process, while keeping the timeline of the motion imagination stage or motion execution stage from being stretched, disrupted, or replaced by the pre-cue representation.

[0070] 5. How to enable the pre-cue branch to learn effective stimulus priors without learning training subjects, training dates, or stimulus artifact shortcuts through auxiliary alignment, conditional distribution alignment, gating to prevent collapse, backbone protection, and consistency constraints.

[0071] 6. How to limit the update range and loss intensity in low-trial calibration scenarios to make the algorithm applicable to the actual training process of rehabilitation patients with stroke, spinal cord injury, peripheral nerve injury, etc.

[0072] Furthermore, this application can also address the following engineering and clinical translation issues: 7. How to use SMES pre-procedures as an input condition that can be stably triggered by the device, observed by EEG, and learned by the model, so that the algorithm matches the actual rehabilitation device process.

[0073] 8. How to keep the meaning of variables clear within a deep network, so that the pre-cue representation, main task representation, gating weights, attention relationships, classification output, and feedback decision all have traceable intermediate states.

[0074] 9. How to avoid suppressing the main task EEG when the pre-cue branch is too strong, so that the model output only reflects whether the stimulus occurs, and does not reflect whether the patient actually performs motor imagery or motor execution.

[0075] 10. How to reuse the same decoding framework across different rehabilitation stages, for example, transitioning from "motor imagery only" to "mild motor execution" and then to "combined training of imagery and actual movement".

[0076] 11. How to make the algorithm compatible with online real-time systems, including stimulus triggering, EEG caching, windowing, low-latency inference, feedback execution, anomaly suppression, and logging.

[0077] 12. How to integrate pre-stimulation prompts, EEG window segmentation, conditional decoding, model training, individualized calibration, diagnostic recording, and feedback control into a continuous operating method while ensuring the feasibility of clinical procedures.

[0078] The following is combined with Figures 2-8 This paper describes the complete implementation and effects of the present invention.

[0079] I. Experimental System, Data Acquisition Paradigm, and Task Organization This application can be implemented in a system consisting of an EEG acquisition device, an EEG electrode cap or other EEG sensing device, a sensory muscle electrical stimulation device, a visual task presentation device, a trigger synchronization device, an algorithm calculation unit, and a feedback execution unit. In a preferred embodiment, EEG data is acquired by a multi-channel EEG acquisition system, with electrodes placed according to the international 10-20 or extended 10-10 system, covering at least the sensorimotor cortex-related channels such as C3, C4, Cz, FC3, FC4, FCz, CP3, and CP4, and may also include adjacent channels in the frontal, parietal, temporal, and central lobes. In actual modeling, full-lead EEG can be used, or several channels can be selected based on the relevance of the motor cortex, device complexity, or online usage requirements. During acquisition, EEG data, task labels, SMES stimulus trigger codes, stimulus parameters, visual cue events, run and session numbers, subject numbers, and necessary feedback execution status are recorded simultaneously.

[0080] Before the experiment began, subjects underwent adaptive calibration of the SMES stimulus intensity based on the standard of "just being able to perceive the stimulus." Specifically, the system gradually increased the stimulus current or pulse width, starting from a low intensity. The threshold at which subjects reported the first clear perception of the stimulus without significant discomfort or involuntary large-amplitude movements was used as the stimulus intensity for the formal experiment. The calibration results were saved separately for the left and right sides, recording the stimulus channel, current intensity range, pulse width range, frequency range, duration, stimulus sequence, and subjective sensory level. This calibration method allows the SMES to primarily serve as a proprioceptive cue in this application, rather than a forced motor output that replaces the subject's active movement; at the same time, it is closer to the peripheral sensory input in rehabilitation training than a simple visual arrow, helping subjects establish a somatosensory entry point for the target limb and target movement.

[0081] This experiment includes two experimental conditions: video-guided motor imagery and motor execution. Under the motor imagery condition, subjects watch visual task cues and motion animations, and imagine extending or grasping with their left or right arm without any obvious limb movement output, or remain at rest. Under the motor execution condition, subjects actually perform the corresponding left or right arm extension or grasping action based on the cues, or remain at rest. Controlled SMES electrical stimulation cues are applied beforehand in each experimental condition, and three types of tasks are used: visually evoked left-hand extension / grasping, right-hand extension / grasping, and resting. The experimental objective can be described as the EEG classification between unilateral limb motor imagery and resting, and between unilateral limb motor execution and resting, or it can be extended to a three-class classification of left-hand, right-hand, and resting. The preferred verification method in this application is to construct binary classification models for left-hand versus resting and right-hand versus resting, and evaluate them separately under both the motor imagery and motor execution conditions.

[0082] II. Trial Sequence, SMES Pre-Trial Cueing, and Stimulus Intensity Calibration In each trial, the start of the task execution phase serves as the time reference point. A complete trial may include a resting preparation phase, a task prompting phase, a SMES electrical stimulation prompting phase, and a task execution phase. The resting preparation phase guides the subject to relax and stabilize their gaze on the screen; the task prompting phase displays directional instructions; the SMES electrical stimulation prompting phase allows the subject to experience weak electrical stimulation related to the task side and target muscle group; and the task execution phase involves corresponding motor imagery, motor execution, or resting maintenance.

[0083] SMES electrical stimulation is used to provide directional, lateral, and somatosensory pre-cues before the initiation of motor imagery or motor execution. The preferred stimulation sequence is to first stimulate one target muscle group or proximal stimulation site, followed by another target muscle group, distal stimulation site, or a combination of sites, creating at least two phases of somatosensory input throughout the pre-cues period. This sequence corresponds to the pre-cues representation, where the earlier phase characterizes the initial stimulus and lateral initiation information, while the subsequent phase characterizes the compound sensory input and the preparatory state for the upcoming task. Stimulation sites can be located in the upper arm or forearm muscles or their proximal / distal tendon regions associated with the target movement, such as muscle groups related to arm extension and grasping, wrist extension, wrist flexion, forearm pronation and supination, or finger grasping; in lower limb rehabilitation scenarios, these can be replaced with ankle dorsiflexion, plantar flexion, knee extension, or hip flexion muscles.

[0084] III. EEG Preprocessing, Window Segmentation, and Sample Construction The raw EEG data can be first subjected to bandpass filtering, power frequency notch filtering, bad sector detection, rereference, artifact labeling, amplitude clipping, standardization, and online Euclidean space alignment. If the online system's computing power is limited, downsampling can also be performed after filtering. Regardless of downsampling, window segmentation is based on the true time boundary corresponding to the event code. For each trial, the complete behavioral time sequence is preserved for quality checks and baseline analysis. The preferred analysis windows for decoding the algorithm in this application are the SMES pre-cue window and the main task window, where the SMES pre-cue window is located before the task starts, and the motor imagery or motor execution main task window is located after the task starts. Under different device sampling rates and different window lengths, sampling point indices can be mapped according to a unified time boundary, and half-open interval truncation can be used to ensure that the boundaries of the pre-cue window and the main task window are consistent.

[0085] The training samples consist of a pre-cue window, a main task window, task labels, domain labels, stimulus parameters, and necessary quality control markers. Domain labels can represent the subject, session, collection date, run, or other training domain sources. For the main task window, augmentations such as time pruning, time flipping, fragment recombination, noise injection, frequency band perturbation, mixup, and time shifting can be used to improve the model's robustness to variations across subjects and days. For the SMES pre-cue window, augmentations should be more cautious, such as weak Gaussian noise, small amplitude scaling, local channel dropout, or short-term masks within the same pre-cue phase; pruning, swapping, or recombination should not cross pre-cue boundaries, nor should the true temporal order of stimulus phases be disrupted.

[0086] IV. Two-branch decoding algorithm based on SMES pre-cue condition memory The core of this algorithm is to treat the SMES pre-cue phase and the main task phase of motor imagery / motor execution as two branches with different semantics. The algorithm first divides the timeframe according to the real-time boundary to obtain the pre-cue window and the main task window. The pre-cue window inputs the pre-cue branch, and the main task window inputs the main task branch. The pre-cue branch can use lightweight multi-kernel temporal convolution, channel convolution, batch normalization, nonlinear activation, pooling, and channel mixing layers to obtain the pre-cue temporal features; the main task branch can use multi-scale temporal convolution, channel mixing, patch embedding, Transformer, TCN, or equivalent temporal structures to obtain the main task temporal representation. To preserve the real stimulus statistics and stage semantics of the pre-cue phase, it is preferable not to apply strong enhancements to the mixing domain statistics to the pre-cue branch, but to mainly apply generalization enhancements such as MixStyle to the main task branch.

[0087] The pre-cue branch compresses the SMES cue period into a small number of pre-cue representations with stage meaning. Preferably, the pre-cue period is divided into an early stimulus cue stage and a late cue stage triggered near the main task, and p1 and p2 are constructed respectively. The construction method can employ stage attention pooling, weighted average pooling, gated convergence, or other representation generation methods that can preserve stage semantics. p1 and p2 are stacked as pre-cue conditional memories, and stage embeddings are superimposed, enabling the model to distinguish between early stimulus cues and late composite cues. If the actual paradigm includes more stimulus stages, more muscle groups, or different stimulus frequencies, it can also be extended to more pre-cue representations; however, in the preferred embodiment, a small number of staged representations are retained to balance algorithm interpretability, computational efficiency, and online deployment stability.

[0088] After obtaining the pre-cue conditional memory, the algorithm applies two levels of pre-cue gating. The first level is a stage-level gating, used to output the relative participation weights between different pre-cue stages; the second level is a global strength gating, used to output the strength of the entire SMES pre-cue path's participation in the main task decoding. This structure allows the model to determine which pre-cue stage is more useful and to reduce the overall pre-cue participation strength when the pre-cue quality is poor, the stimulus artifacts are too strong, or the main task information is sufficiently stable. The gating can be implemented by a small neural network, a conditional modulation module, a confidence estimation module, or an equivalent learnable regulator, or it can be constrained by online quality metrics.

[0089] To avoid conflicts between different training objectives of the pre-cue branches, this application preferably splits the pre-cue representation into three paths with different purposes. The first path is the main injection path, which injects the gated pre-cue representation as conditional memory into the main task temporal decoder. The second path is the pre-cue auxiliary supervision path, which inputs the pre-cue representation into a weak auxiliary classifier head after independent projection, so that the pre-cue representation has a certain class correlation but does not classify too independently. The third path is the pre-cue domain alignment path, which uses the pre-cue representation for class-conditional domain alignment after another independent projection. The three paths share the basic temporal source of the pre-cue, but assume different responsibilities through different projections and constraints, thereby reducing the potential target conflicts when the same pre-cue representation is used for injection, classification, and domain alignment at the same time.

[0090] The main task branch is processed using pre-cue conditional attention or equivalent conditional temporal decoding. Preferably, the main task representation primarily serves as the query, while the gated pre-cue representation and the main task representation together serve as readable key-value memories. Since the query originates from the main task representation, the output time length remains equal to the number of temporal representations in the main task window, and p1 and p2 are not inserted as ordinary time slices into the main task timeline. This differs from the scheme of simply concatenating the SMES period and the task period and inputting them into a regular Transformer: in this application, the main task EEG actively reads the pre-cue conditional memory, and the pre-cue does not change the physical temporal structure of the main task EEG. The network can also use group query attention, multi-head attention, rotational position encoding, residual connections, feedforward networks, or low-rank adaptation structures to improve temporal modeling capabilities and computational efficiency.

[0091] At the output, the fused temporal features of the main task can be concatenated with the convolutional features of the main task and fed into a temporal convolutional classification head or a fully connected classification head to output the probabilities of left-handed, right-handed, resting, or binary classification tasks. Preferably, a main task backbone path without pre-cues is retained to obtain the main branch output; simultaneously, a path with pre-cues is used to obtain the fused output. The main branch output reflects the stable discrimination boundary formed solely by the main task's EEG, while the fused output is enhanced based on this boundary using SMES pre-cues. During online inference, the fused output can be used directly, or it can be weighted with confidence by combining the main branch output, the fused output, gating strength, and prediction entropy.

[0092] V. Model Training, Domain Generalization Constraints, and Few-Sample Calibration During training, the source domain and target validation domain are constructed according to the subject, session, or collection date. Leave-one-out-of-subject or cross-day validation is preferred to evaluate generalization ability on subjects or sessions not yet seen. The main task loss uses labeled smoothed cross-entropy. The backbone domain generalization can retain MMD, CORAL, or other distribution distance constraints to make the main task features more consistent across different subjects or sessions; simultaneously, conditional distribution constraints such as Dist loss can be used to improve intra-class compactness and inter-class separability. The above loss names and combinations can be adjusted according to the device, data scale, and target task, and are not limited to a single fixed implementation.

[0093] For the pre-cue side, instead of using a simple marginal distribution MMD or directly averaging and aligning p1 and p2, a conditional MMD grouped by pre-cue stage and category is preferred. Specifically, aligned projection features are obtained separately for each pre-cue stage. Within each category, the distribution differences between different domains are compared, and the effective categories and stages are summarized. If a category has insufficient samples in a certain domain, that group is skipped or its influence is reduced to avoid unstable gradients caused by small batches. This design prevents category differences from being mistaken for domain differences and preserves the stage semantics of p1 and p2.

[0094] The pre-cue auxiliary supervision uses weak classification instead of hard classification. The pre-cue auxiliary head output can be used to calculate the label smoothing CE with the task label, or the pre-cue auxiliary output can be aligned with the main branch output using KL divergence. This allows the pre-cue branch to learn a category-related auxiliary direction, but it is not trained as a classifier that independently replaces the main task branch. Furthermore, two slightly perturbed views without disrupting the stage order can be generated for the same SMES pre-cue window. The distribution of the pre-cue auxiliary output in the two views must be consistent, for example, using JS divergence or KL divergence; simultaneously, the pre-cue gating weights in the two views must remain stable, for example, using gating consistency constraints. This consistency constraint reduces the sensitivity of the pre-cue path to random noise, individual amplitudes, or stimulus artifacts.

[0095] To protect the main task's discrimination boundary, this application introduces main branch anchor point protection. During training, the main branch output is first obtained from the main path without pre-cue injection, and then the fused output is obtained from the path with pre-cue conditional memory. Using the main branch distribution that stops updating as the anchor point, KL protection, distillation protection, or other output distribution protection are applied to the fused output. This ensures that pre-cues can provide limited enhancement, but cannot significantly degrade the discrimination boundary already formed by the main task in the later stages of training. This protection mechanism is more stable than simply reducing the pre-cue injection strength because it directly constrains the offset of the final output distribution.

[0096] The overall training objectives may include the main task classification loss, marginal distribution MMD loss, CORAL loss, conditional distribution Dist loss, weak auxiliary classification loss with foreshadowing, foreshadowing KL alignment loss, conditional distribution MMD loss, foreshadowing consistency loss, gated consistency loss, gated anti-collapse loss, foreshadowing representation decorrelation loss, and main branch anchor point protection loss. During training, the main task backbone can first form a basic discrimination boundary, then foreshadowing can be safely injected with a small intensity or by stopping gradients, and finally the influence of foreshadowing conditional alignment and consistency constraints can be gradually increased. In this way, foreshadowing is not necessarily better the stronger it is, but rather trained to be a clean, controllable, and transferable conditional memory.

[0097] In few-sample calibration, a small number of short trials can be collected for each class of target patients or subjects. Ideally, most parameters of the main task backbone should be frozen, updating only a small portion of the parameters in the pre-cause embedding, gating network, normalized statistics, lightweight adapter, or classifier head. The calibration loss can simultaneously include target sample cross-entropy, pre-calibration model output distillation, and parameter drift constraints, ensuring that the small amount of calibration data is primarily used to adjust "how to utilize SMES pre-cause" rather than relearning the complete EEG classifier. For rehabilitation scenarios, this calibration approach can shorten the feedback-free waiting time before patient training and reduce the risk of false feedback due to few-sample overfitting.

[0098] VI. Online Closed-Loop Applications, Diagnostic Indicators, and Alternative Implementation Methods In online applications, the system continuously caches EEG data before each trial begins. The task system first presents resting and task cues, followed by the stimulator outputting SMES pre-cues according to the target side and target muscle group, and simultaneously sending trigger codes. After the main task phase ends, the algorithm module generates a pre-cue window and a main task window according to the same preprocessing and window segmentation rules, constructs p1, p2, or more staged pre-cue representations, applies pre-cue gating, performs conditional temporal decoding, and outputs class probabilities. If the maximum probability is below the threshold, the prediction entropy is too high, the difference between the main branch output and the fusion output is too large, or the gating diagnosis shows abnormal pre-cue quality, the system may not trigger strong feedback, but instead provide weak feedback, prompt for retry, or enter a recalibration process. If the output is stable, it can drive FES feedback, exoskeleton motion assistance, soft rehabilitation robots, hand function trainers, virtual reality tasks, or remote rehabilitation platforms to perform corresponding motion feedback.

[0099] This application can also output various interpretable diagnostic indicators, including p1-stage attention, p2-stage attention, p1 / p2 gating weights, global pre-cue intensity, gating entropy, gating standard deviation, pre-cue auxiliary classification loss, pre-cue KL alignment loss, pre-cue consistency loss, gating consistency loss, conditional MMD loss, KL difference between main branch output and fusion output, and predictive entropy. Clinicians or engineers can use these to determine whether subjects produce stable EEG responses to SMES pre-cues, whether the model truly utilizes pre-cues, whether pre-cues collapse into fixed weights, whether there is excessive reliance on stimulus artifacts, and whether adjustments to stimulus location, stimulus intensity, visual cue rhythm, or calibration trial count are necessary.

[0100] In one specific embodiment, multichannel EEG data from healthy subjects were collected according to a paradigm that included multiple sessions and multiple runs. Each trial included three random conditions: left-hand extension grasp, right-hand extension grasp, and resting. During modeling, left-hand versus resting and right-hand versus resting binary classification tasks were constructed under video-guided motor imagery and video-guided motor execution conditions, respectively, and cross-subject and cross-day evaluations were conducted. Experimental results show that the optimized model using the pre-cue conditional decoding algorithm of this application exhibits stable cross-subject performance in the motor imagery left-hand versus resting, motor imagery right-hand versus resting, motor execution left-hand versus resting, and motor execution right-hand versus resting tasks. Furthermore, the gating, conditional alignment, and main branch protection mechanisms of the pre-cue branch enable the algorithm to not only output the category but also provide pre-cue usage and failure reason analysis.

[0101] Alternative implementations of this application include, but are not limited to: the SMES stimulation location can be expanded from the upper limb to the lower limb or trunk-related muscle groups; the stimulation sequence can be expanded from two stages to multiple stages; p1 and p2 can be expanded to more pre-cue tokens; the pre-cue encoder can be replaced with EEGNet, TCN, lightweight Transformer, graph convolution, or bandgap attention network; the main task decoder can be replaced with EEGConformer, ATCNet, CSPNet, or other EEG models; conditioned attention can be replaced with cross-attention, FiLM modulation, Adapter modulation, conditioned normalization, or low-rank attention; and the feedback end can be connected to FES, exoskeleton, robot, virtual reality, or evaluation platform. As long as it retains the core idea of ​​"modeling the pre-trigger SMES cue period and the post-trigger MI / ME main task period separately according to the real time boundary, compressing the SMES cue period into a staged conditioned memory, controlling its contribution to the main task decoding through gating and training constraints, and outputting the motor intention without changing the main task time axis," it belongs to the alternative implementations of the technical solution of this application.

[0102] This application has the following beneficial technical effects: 1. Make fuller use of sensory a priori input in the rehabilitation paradigm. Explicitly encode the SMES pre-cue period as two pre-cue representations, p1 and p2, so that the triggering pre-somatosensory stimulus is no longer regarded as noise or ordinary spliced ​​input, but becomes the conditioned memory for subsequent MI / ME decoding.

[0103] 2. Maintain the temporal integrity of the main task EEG decoding. In conditioned attention, queries only come from the main task representation during the motor imagery or motor execution phases. Pre-cues only participate as key / value conditioned memories and do not change the length of the main task timeline, which helps to maintain the interpretability of the motor imagery and motor execution EEG responses.

[0104] 3. Improve generalization stability across subjects and days. By employing pre-cue gating, conditional distribution alignment, auxiliary alignment, and backbone protection, the model's dependence on training subjects, training dates, or fixed stimulus artifacts can be reduced, making it more suitable for rehabilitation patients.

[0105] 4. Provide a diagnostic pre-cue usage mechanism. Indicators such as gating standard deviation, pre-cue-assisted generalization gap, gating weight norm, p1 / p2 attention, t-SNE feature distribution, and confusion matrix can be used to determine whether pre-cues are effective, whether they collapse, and whether they overfit, thereby improving the engineering interpretability of medical rehabilitation products during implementation.

[0106] 5. Supports unified decoding of motor imagery and motor execution. The pre-cue branch is not dependent on a single task and can be used for different task combinations such as MI, ME, left hand / right hand / resting, providing a unified algorithmic framework for progressive training from imagery to execution in rehabilitation training.

[0107] 6. For example Figures 4-8 As shown in the experimental results, the SMES_MI algorithm of this application has significant advantages over the pure MI / ME main task TCFormer decoding algorithm without SMES pre-cue conditional memory, the pure SMES pre-cue algorithm, and the traditional CSP-SVM feature classification algorithm. In the four tasks of MI left-hand to rest, MI right-hand to rest, ME left-hand to rest, and ME right-hand to rest, the cross-subject accuracy of the SMES_MI algorithm of this application are 0.7448±0.0762, 0.7329±0.0720, 0.8416±0.0600, and 0.8504±0.0749, respectively; while the corresponding accuracy of the pure MI / ME main task TCFormer decoding algorithm are 0.6966±0.1126 and 0.6924±0. The values ​​were 0.0939, 0.8079±0.0921, and 0.8314±0.0623; the values ​​for the pure SMES pre-hint algorithm were 0.5908±0.0498, 0.5722±0.0675, 0.6253±0.0612, and 0.6081±0.0893; and the values ​​for CSP-SVM were 0.5877±0.0513, 0.5882±0.0571, 0.6254±0.1088, and 0.6082±0.1301.

[0108] 7. The accuracy difference between the SMES_MI algorithm and the pure MI / ME main task TCFormer decoding algorithm in this application is approximately +0.0482, +0.0405, +0.0337, and +0.0190, respectively, with the significance markers for paired-subjects tests being *, **, and ***, respectively; the accuracy difference between the SMES_MI algorithm and the pure SMES pre-cue algorithm is approximately +0.1540, +0.1607, +0.2163, and +0.2423; and the accuracy difference between the SMES_MI algorithm and CSP-SVM algorithm is approximately +0.1571, +0.1447, +0.2162, and +0.2422. The above results show that using only the pure MI / ME main task EEG after triggering, only recognizing the SMES cue before triggering, or using traditional CSP-SVM feature classification cannot fully utilize the temporal coupling relationship between the SMES pre-cues and the motor imagery / motor execution main task. This application improves the ability to distinguish between unilateral motor intention and resting state in rehabilitation training scenarios through the combined structure of "SMES pre-cues conditioned memory + MI / ME main task decoding".

[0109] Furthermore, the technical effects of this application also include: 8. Enhance active participation in rehabilitation training. SMES pre-cues provide patients with sensory information, and the model uses these cues as the basis for conditional decoding, creating a tighter closed loop between the patient's sensory input, motor intention, and external feedback, which is beneficial for long-term training adherence.

[0110] 9. Reduce the risk of false triggering online. The system can combine gating strength, prediction entropy, the difference between the main task output and the fusion output, and the results of the pre-caution quality judgment to reduce the feedback intensity when the model confidence is insufficient, so as to avoid discomfort to patients caused by erroneous FES or exoskeleton movements.

[0111] 10. It has good scalability. The same structure can be extended to different movements such as left / right hand, wrist extension / flexion, ankle dorsiflexion / plantar flexion, and upper limb grasping / releasing, as well as rehabilitation tasks such as motor execution, passive motor observation, and movement attempt. As long as there are synchronous somatosensory cues before triggering and main task EEG after triggering, the pre-cue condition decoding framework of this application can be transferred and used.

[0112] 11. It helps protect the end-to-end technical approach. This application simultaneously covers pre-stimulus cues, EEG window segmentation, pre-cue representation construction, gated conditional attention, assisted training constraints, diagnostic indicators, and feedback interfaces, thus avoiding the avoidance risks caused by protecting only a single network structure.

[0113] The following alternatives or improvements may also be adopted for this application: 1. The length of the pre-cue window can be adjusted to [-2 seconds, 0 seconds], [-4 seconds, 0 seconds] or multiple pre-cues according to the stimulation paradigm; the number of pre-cues can be expanded from 2 to 3 or more to represent different stimulation stages, different muscle groups or different stimulation frequencies.

[0114] 2. The pre-cue encoder can be replaced with EEGNet, TCN, Lightweight Transformer, Graph Convolutional Network, or Bandwidth Attention Network; the main task decoder can be replaced with EEGConformer, ATCNet, CSPNet, or other EEG decoding models.

[0115] 3. The gating method can be replaced by channel-level gating, band-level gating, FiLM modulation, Adapter modulation, LoRA modulation, or confidence gating. The core is still the contribution of constraint pre-indication to the main decoding path.

[0116] 4. Auxiliary alignment can be achieved using KL distillation, label smoothing cross-entropy, supervised contrastive learning, consistency regularization, or uncertainty-weighted loss; cross-domain constraints can be achieved using MMD, CMMD, CORAL, adversarial domain classification, or subject / training day robust objectives.

[0117] 5. During the calibration phase, gated updates, pre-caution branch updates, aptamer layer updates, or lightweight classification head updates can be used. Alternatively, the main trunk can be frozen and only pre-caution related parameters can be updated as needed for clinical applications.

[0118] 6. The output end can be connected to FES stimulators, exoskeletons, rehabilitation robots, virtual reality training systems, hand function trainers, or remote rehabilitation assessment platforms.

[0119] Further alternative implementations include: 7. The preceding information indicates that it may not only be based on EEG, but may also incorporate stimulator current amplitude, pulse width, frequency, stimulation channel, target muscle group, patient subjective feeling score or electromyographic response. This information is then embedded in the layer and spliced ​​or added to p1 and p2.

[0120] 8. When multiple muscle groups are sequentially stimulated during the current cueing phase, an independent phase representation can be set for each muscle group, and its participation intensity can be controlled by shared gating or group gating.

[0121] 9. Conditional attention can be replaced by cross attention, key-value matching, FiLM conditional modulation, or conditional normalization, as long as it maintains the core idea that "the main task reads the preceding prompt conditions and the preceding prompts do not rearrange the main task timeline".

[0122] 10. When the computing power of edge devices is limited, the conditional Transformer can be replaced with a lightweight gated TCN or low-rank attention; when the computing power of hospital workstations is sufficient, multi-band branching and cross-channel graph attention can be added.

[0123] 11. In clinical systems, a priori diagnostic indicators can be used to adjust stimulus parameters. For example, when the a priori gating is consistently low, the stimulus intensity can be reduced or the stimulus location can be changed. When the a priori aid generalization gap is too large, the weight of the stimulus artifact sensitive channel can be reduced.

[0124] The key technical points of this invention include: 1. An EEG decoding process that divides the sensory electrical stimulation phase and the main task phase of motor imagery / motor execution according to real time boundaries, preferably using the sensory electrical stimulation phase as a pre-cue window and the motor imagery phase or motor execution phase as the main task window.

[0125] 2. A method for generating pre-cue representations from pre-cue EEG, wherein p1 and p2 are constructed separately by segmented attention pooling, and stage embedding representations of early and late stimulus cues are superimposed.

[0126] 3. A two-level gating method for pre-clipping, which determines the participation intensity of different pre-clipping representations and the overall pre-clipping through stage-level normalization allocation and global intensity gating, solves the problem of instability in fixed fusion or simple splicing.

[0127] 4. A pre-cue conditional Transformer decoding method, in which the main task MI / ME representation is used as the query, and the gated pre-cue representation and the main task representation are used together as the key / value, thereby utilizing the pre-cue conditional memorization without changing the length of the main task timeline.

[0128] 5. An auxiliary alignment training method for cue-oriented branches, using the logits of the uncued backbone as the teacher, and constraining the cue auxiliary head with KL divergence and weakly labeled smoothing CE to reduce the risk of negative transfer caused by learning training domain shortcuts.

[0129] 6. A training strategy that includes conditional distribution alignment, gating to prevent collapse, decorrelation of pre-cue representation, backbone protection, and few-sample calibration constraints, making pre-cues learnable, diagnostic, and without compromising the main decoding boundary.

[0130] 7. A unified intention decoding system for MI / ME suitable for neurorehabilitation, which can use the decoding results for FES feedback, exoskeleton assistance, soft rehabilitation robot control or virtual training task adjustment.

[0131] The following points require further emphasis and protection: 8. The pre-cues are not ordinary multimodal inputs, but rather stimulus-induced EEG information that precedes the main MI / ME task in time and provides conditional a priori information for the main task in semantics.

[0132] 9. The number of pre-cues is relatively small and has stage semantics. P1 is preferably used to represent early stimulus cues and P2 is used to represent late-stage cues triggered by nearby tasks. This structure balances interpretability and computational efficiency.

[0133] 10. Gating weights include both inter-stage relative allocation and overall pre-cue strength, enabling stable regulation as subjects, training days, stimulus quality, and task status change.

[0134] 11. Conditional attention queries are derived solely from the main task representation, which is a key technical feature distinguishing this application from simple splicing Transformers; its purpose is to enable the main task EEG to actively read pre-cue memories, rather than treating pre-cues as part of the main task time sequence.

[0135] 12. By using KL-assisted alignment, weak label smoothing, gating to prevent collapse, decorrelation of pre-cue representation, and few-sample calibration constraints, the pre-cue path is restricted to helping the main task decode, rather than replacing the main task or memorizing shortcuts in the training domain.

[0136] 13. The scope of protection of this application can cover scenarios such as motor imagery, motor execution, movement attempt and rehabilitation feedback control. The pre-cue stimulus can be low-intensity sensory muscle electrical stimulation, or it can be replaced by other synchronous peripheral sensory cues.

[0137] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 9 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and model predictions. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The model predictions of the computer device store static and dynamic information data. The network interface of the computer device is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements the steps in the above method embodiments.

[0138] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present invention and does not constitute a limitation on the computer device to which the present invention is applied. A specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0139] Corresponding to the above embodiments, this invention also provides a computer storage medium containing one or more program instructions. These one or more program instructions are used to execute the method described above.

[0140] The present invention also provides a computer program product, the computer program product including a computer program, the computer program being stored on a non-transitory computer-readable storage medium, and the computer being able to perform the above-described method when the computer program is executed by a processor.

[0141] In this embodiment of the invention, the processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0142] The various methods, steps, and logic diagrams disclosed in the embodiments of this invention can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The processor reads information from the storage medium and, in conjunction with its hardware, completes the steps of the above methods.

[0143] The storage medium can be memory, such as volatile memory or non-volatile memory, or may include both volatile and non-volatile memory.

[0144] Among them, non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory.

[0145] Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (Synchlink DRAM, SLDRAM), and direct memory bus RAM (DRRAM).

[0146] The storage media described in the embodiments of the present invention are intended to include, but are not limited to, these and any other suitable types of memory.

[0147] Those skilled in the art will recognize that, in one or more of the examples above, the functions described in this invention can be implemented using a combination of hardware and software. When applied as software, the corresponding functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transmission of computer programs from one place to another. Storage media can be any available medium that can be accessed by a general-purpose or special-purpose computer.

[0148] The above specific embodiments further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solution of the present invention should be included within the scope of protection of the present invention.

Claims

1. A brain-computer interface decoding method for sensory muscle electrical stimulation pre-stimulation cues in rehabilitation training, characterized in that, The method includes: Acquire EEG data, including EEG data in the SMES pre-prompt window before the start of the main task of motor imagery or motor execution, and EEG data in the main task window after the start of the main task. Feature extraction is performed on the EEG data of the SMES pre-cue window to generate multiple pre-cue representations with stage semantics, and the multiple pre-cue representations constitute pre-cue conditioned memory; Feature extraction is performed on the EEG data of the main task window to generate a temporal representation of the main task; The pre-cue conditional memory is adjusted through a learnable gating mechanism to determine the participation intensity of different pre-cue representations and the overall pre-cue information; Using the main task temporal representation as the query, and the gated pre-cue representation and / or the main task representation as the key and value, conditional attention decoding is performed, and the motion intent classification result is output; wherein, the conditional attention decoding does not change the time axis length of the main task temporal representation.

2. The decoding method according to claim 1, characterized in that, Feature extraction is performed on the EEG data of the SMES pre-cue window to generate multiple pre-cue representations with stage semantics, specifically including: The SMES pre-notification window is divided into at least two consecutive sub-stages; The EEG features of each sub-stage are extracted separately, and the corresponding pre-cue representations of each sub-stage are generated by segmented attention pooling or weighted average pooling. Each preceding prompt represents an overlay stage embedding to distinguish the semantics of different sub-stages.

3. The decoding method according to claim 2, characterized in that, Feature extraction is performed on the EEG data of the main task window to generate a temporal representation of the main task, specifically including: A multi-scale temporal convolutional network is used to perform preliminary feature extraction on the EEG data of the main task window to obtain multi-scale spatiotemporal features; The multi-scale spatiotemporal features are subjected to channel mixing and dimensionality transformation to generate a patch embedding sequence; The patch embedding sequence is input into a Transformer encoder or a temporal convolutional network for deep temporal modeling, and the temporal representation of the main task is output.

4. The decoding method according to claim 2, characterized in that, The SMES pre-timing window is divided into an early stimulus prompting stage and a late prompting stage near the main task trigger, and a first pre-timing representation p1 and a second pre-timing representation p2 are generated accordingly. The learnable gating mechanism includes stage-level gating and global strength gating. The stage-level gating is used to output the relative participation weights between p1 and p2, and the global strength gating is used to output the strength of the overall cue path participation in the main task decoding.

5. The decoding method according to claim 4, characterized in that, The method includes the following steps during the model training phase: Construct a pre-cue auxiliary supervision path, and input the pre-cue representation into a weak auxiliary classification head after independent projection; Calculate the weak classification loss between the pre-completion hints and the task labels, and / or calculate the KL divergence alignment loss between the pre-completion hints and the main task branch output; Construct a pre-cue domain alignment path by projecting the pre-cue representation through another independent projection and calculating the conditional maximum mean difference loss by grouping it by pre-cue stage and category, in order to align the conditional distributions between different domains.

6. The decoding method according to claim 5, characterized in that, The method further includes the following during the model training phase: Main protection steps: Using the main task branch output without pre-injection as the anchor point, apply KL divergence protection or distillation protection to the fused output with pre-injection condition memory, and constrain the offset of the fused output distribution relative to the anchor point output. The steps for gating anti-collapse constraints and consistency constraints are as follows: For the same sample's pre-cue window, generate two slightly perturbed views that do not disrupt the stage order. The distribution of the pre-cue auxiliary outputs of the two views must be consistent, and the gating weights of the two views must remain stable. Apply anti-collapse loss to the gating weights to prevent the gating output from degenerating into a fixed constant.

7. The decoding method according to any one of claims 1 to 6, characterized in that, The method includes the following steps in the model calibration phase: A small number of labeled trials were collected on the target subjects, most of the parameters of the main task backbone were frozen, and only some parameters in the pre-cue stage embedding, gating network, normalized statistics, lightweight adaptation layer or classification head were updated. The calibration loss includes the target sample cross-entropy, the model output distillation loss before calibration, and the parameter drift constraint loss.

8. The decoding method according to claim 7, characterized in that, The method includes the following steps in the model prediction stage: In online applications, if the maximum prediction probability is lower than the threshold, the prediction entropy is too high, the difference between the main branch output and the fused output is too large, or the quality abnormality is indicated before the gating diagnosis is displayed, strong feedback is suppressed and weak feedback or recalibration prompts are given. If the output is stable, then generate and output feedback control instructions.

9. A brain-computer interface decoding device for sensory muscle electrical stimulation pre-stimulation cueing in rehabilitation training, characterized in that, The device includes: The EEG acquisition module is used to acquire EEG data, which includes EEG data in the SMES pre-prompt window before the start of the main task of motor imagery or motor execution, and EEG data in the main task window after the start of the main task. The pre-cue representation generation module is used to extract features from the EEG data of the SMES pre-cue window and generate multiple pre-cue representations with stage semantics. The multiple pre-cue representations constitute pre-cue conditional memory. The main task representation generation module is used to extract features from the EEG data of the main task window and generate a temporal representation of the main task. The gating adjustment module is used to adjust the pre-cue condition memory through a learnable gating mechanism to determine the participation intensity of different pre-cue representations and the overall pre-cue information; The conditional decoding module is used to perform conditional attention decoding with the main task temporal representation as the query, and the gated pre-cue representation and / or main task representation as the key and value, and output the motion intent classification result; wherein the conditional attention decoding does not change the time axis length of the main task temporal representation.

10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method as described in any one of claims 1-8.