Electroencephalogram signal basic model construction method and system based on discrete semantic modeling and space-time attention
By using discrete semantic modeling and spatiotemporal attention-based EEG signal fundamental model, the problems of insufficient generalization ability and biological interpretability of existing models are solved, achieving efficient EEG signal feature representation and cross-task adaptability, and improving decoding accuracy and the engineering practicality of the model.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TONGJI UNIV
- Filing Date
- 2026-02-13
- Publication Date
- 2026-06-05
AI Technical Summary
Existing EEG signal analysis models have shortcomings in generalization ability, robustness and biological interpretability. They are prone to overfitting, especially when dealing with long high-frequency EEG sequences, and cannot effectively utilize the optimization strategies of large language models.
We employ a basic model of EEG signals based on discrete semantic modeling and spatiotemporal attention. Through word segmentation, temporal encoding, spatiotemporal fusion and prediction modules, combined with rotational position encoding and cross-channel attention, we construct a feature representation of EEG signals that can adaptively learn.
It improves the model's generalization ability across subjects and devices, enhances decoding accuracy, aligns with the large language model ecosystem, reduces computational redundancy, and enhances biological interpretability and clinical scalability.
Smart Images

Figure CN122153389A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of brain-computer interfaces and deep learning in artificial intelligence, and in particular to a method and system for constructing a basic model of electroencephalogram (EEG) signals based on discrete semantic modeling and spatiotemporal attention. Background Technology
[0002] In recent years, the clinical scalability of brain-computer interfaces (BCIs) and neurodiagnostic systems has largely depended on the robust interpretation of brain dynamics. Electroencephalogram (EEG), due to its high temporal resolution, has become the primary neuro-monitoring modality. However, the current field of EEG signal analysis is trapped in two limited data representation paradigms: one is the specific-task models limited by finite generalization ability; the other is the vision-based fundamental models that regard dynamic signals as static images. The latter paradigm (such as pioneer works like LaBraM and CBraMod) is limited by the "sequence length explosion" problem inherent in high-frequency EEG, so it has to turn to the patch-based Vision Transformer (ViT) architecture to reduce computational complexity. Although this method is computationally efficient, processing brain signals as static image patches leads to spatiotemporal fragmentation, obscures fine-grained temporal evolution features, and makes the model prone to overfitting high-frequency artifacts. More critically, this reliance on visual proxies isolates neuroimaging from the rapidly developing natural language processing (NLP) ecosystem and hinders the direct utilization of complex architecture optimization strategies of modern large language models (LLMs). For example, existing models often show insufficient generalization ability when dealing with microsecond-level temporal dependencies or complex scenarios across subjects and devices. Patent application CN118606707A proposes a training method for an EEG signal enhancement model based on a diffusion model. The method includes: inputting the original EEG signal into the EEG signal enhancement model; using the diffusion model to perform t-step forward diffusion on the original EEG signal to obtain the enhanced result xt-1 of the (t-1)-step diffusion and the enhanced result xt of the t-step diffusion; inputting the enhanced result xt and the corresponding emotion label into the semantic segmentation model that controls the output, and outputting the specified EEG enhancement parameters through the semantic segmentation model; using the EEG enhancement parameters for resampling to obtain the mean, variance of the (t-1)-step diffusion, and the penalty term for controlling sampling, and estimating the enhanced result x't-1 of the (t-1)-step diffusion based on the mean, variance, and penalty term; training the EEG signal enhancement model based on the error loss between the enhanced result xt-1 and the enhanced result x't-1. However, this method still has defects such as being able to only achieve the generation and sample enhancement of EEG signals under specified emotion labels, being a single auxiliary data means, having no general representation learning ability, not capturing the core spatiotemporal features of EEG, not docking with the large model ecosystem, and having weak long-sequence processing and implementation adaptability, and being unable to solve the core pain points of existing EEG technologies.
[0003] Therefore, there is an urgent need to provide a new method that can improve the accuracy, robustness, and biological interpretability of EEG basic models in different downstream tasks. Summary of the Invention
[0004] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method and system for constructing a basic EEG signal model based on discrete semantic modeling and spatiotemporal attention. This method and system breaks through the paradigm defects of existing EEG models, achieves a comprehensive improvement in model generalization ability and decoding accuracy, and has strong clinical scalability, engineering applicability and biological interpretability.
[0005] The objective of this invention can be achieved through the following technical solutions: A method for constructing a basic model of EEG signals based on discrete semantic modeling and spatiotemporal attention includes the following steps: A large-scale pre-training corpus of EEG signals was acquired, and the original signals in the corpus were preprocessed to generate a data sample set. A basic model is constructed, which includes a word segmentation module, a time encoding module, a spatiotemporal fusion module, and a prediction module. The word segmentation module is used to perform neurosemantic word segmentation processing on the input data samples, converting continuous time series into discrete token sequences. The time encoding module is a Roformer model with rotational position encoding, which is used to capture the time dependency patterns within a single channel of the token sequence using a mask language modeling paradigm. The spatiotemporal fusion module is used to achieve feature fusion of local waveforms, global rhythm, and spatial topology features to obtain fused spatiotemporal features. The prediction module is used to perform classification prediction based on the fused spatiotemporal features. The base model is optimized and trained using the data sample set to obtain the final base model, wherein the Roformer model is obtained using a channel-independent pre-training strategy.
[0006] Furthermore, the preprocessing includes filtering, cleaning, and resampling the original signal.
[0007] Furthermore, the filtering includes bandpass filtering and notch filtering; The cleaning process includes short-duration record removal and boundary effect elimination; During resampling, the signal is segmented into non-overlapping segments, and artifact samples are removed.
[0008] Furthermore, the neural semantic segmentation process specifically includes: Perform channel-level adaptive normalization or standardization on each preprocessed channel signal; A predefined vocabulary is constructed, and discrete token sequences are obtained through linear transformation and floor function.
[0009] Furthermore, in the floor function, the range of integers is determined by the size of the predefined vocabulary.
[0010] Furthermore, in the time encoding module, the rotation position encoding transforms the Query vector and Key vector through a rotation matrix, so that the attention score depends only on the relative position information between the tokens. The rotation matrix is defined by preset parameters.
[0011] Furthermore, the spatiotemporal fusion module integrates a multi-scale feature fusion unit and a cross-channel attention unit, wherein, The multi-scale feature fusion unit is used to extract local features from the token sequence through an overlapping sliding window, and at the same time, it uses the global CLS token aggregation single-channel overall oscillation mode obtained by the Roformer model to extract global features, and fuses the local features and global features to obtain the fused features of each channel. The cross-channel attention unit is used to dynamically calculate the attention weights between different electrode positions, thereby achieving adaptive weighting and integration of multi-channel fusion features.
[0012] Furthermore, the local features are represented as follows: The global feature is represented as follows: in, For local features, it represents the local patch embedding representation after high-dimensional projection; It is a learnable linear projection weight matrix used to map low-dimensional local patches to a high-dimensional feature space; The local patch matrix is obtained after sliding window segmentation, which is the local signal representation obtained after dividing the EEG time series of each channel into overlapping segments according to a fixed patch length and step size; To and The corresponding learnable bias vector; is the hidden dimension after linear projection, i.e., the dimension of the target feature space; for The dimensional space in which it exists indicates It is a line number equal to the patch length. The number of columns is a hidden dimension. A real matrix is used to achieve a linear mapping from the patch dimension to the hidden dimension; The CLS classification label vector extracted by the pre-trained Roformer model for the c-th EEG channel fully encapsulates the inherent global temporal pattern features of this channel. It is a learnable projection matrix for the global representation between channels, and its role is to adaptively learn and encode the functional connection relationship between different electrode channels; for The dimensional space in which it exists indicates It is a row number The number of columns is A real matrix is used to project the CLS vectors of each channel from the Roformer hidden dimension to the local features. The same A 3D space is needed for subsequent additive feature fusion; This refers to the hidden layer dimension of the pre-trained Roformer model; for The vector space in which it exists, i.e. 3D real space; This represents the raw time series data for the c-th EEG channel; The complete output sequence obtained after inputting the data of the c-th channel into the pre-trained Roformer encoder contains token representations for all positions; To extract the vector at position 0 of the output sequence, i.e., the representation corresponding to the CLS tag, this vector is used as the global semantic summary for the entire channel and assigned to... .
[0013] Furthermore, when constructing the basic model, the Kaiming initialization method is used to dynamically adjust the weight variance based on the input dimension.
[0014] The present invention also provides a system for constructing a basic model of electroencephalogram (EEG) signals based on discrete semantic modeling and spatiotemporal attention, comprising one or more processors, a memory, and one or more programs stored in the memory, wherein the one or more programs include instructions for executing the method for constructing a basic model of EEG signals as described above.
[0015] Compared with the prior art, the present invention has the following beneficial effects: 1. Breakthrough in technical aspects: This invention avoids the problems of reduced time fidelity and spatiotemporal fragmentation of EEG signals caused by the visual paradigm through discrete semantic modeling. It solves the limitations of long sequence processing of high-frequency EEG by combining rotational position coding. At the same time, it achieves full-dimensional and accurate extraction of microscopic, macroscopic and spatial features of EEG signals, making feature representation more consistent with the real laws of brain neural activity.
[0016] 2. Comprehensive improvement in model performance: Based on massive pre-training of a huge EEG corpus, this invention significantly enhances the model’s generalization ability across subjects, devices, and tasks. In tasks such as EEG abnormality detection, the decoding accuracy is significantly better than traditional models. Moreover, it achieves structural alignment with the large language model ecosystem, and its mature architecture and optimization strategies can be directly reused, reducing R&D costs.
[0017] 3. High practical value in application and engineering: The basic model constructed by this invention can be seamlessly adapted to various downstream tasks such as motor imagery decoding and neurological disease diagnosis. The scalable tokenized representation learning framework improves the clinical scalability of brain-computer interfaces and neurodiagnostic systems. At the same time, the design of Kaiming initialization and subsequent spatiotemporal fusion not only ensures the numerical stability of large-scale pre-training, but also reduces computational redundancy and improves the efficiency of model training and inference. Moreover, the model learns general neural oscillation laws, which has stronger biological interpretability and is easier to implement in clinical applications. Attached Figure Description
[0018] Figure 1 This is a schematic diagram of the process of the present invention; Figure 2 This is a schematic diagram of the basic model structure for this invention. Detailed Implementation
[0019] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. These embodiments are based on the technical solution of the present invention and provide detailed implementation methods and specific operating procedures. However, the scope of protection of the present invention is not limited to the following embodiments.
[0020] Terminology Explanation EEG signals Visual Paradigm: Vision-based Neural Semantic Tokenization Neural Tokenizer: Amplitude-aware Tokenizer Binning Discretization Temporal Pretraining Temple University Hospital EEG Dataset: Temple University Hospital EEG Corpus, TUEG Rotary Position Embedding (RoPE) Masked Language Modeling (MLM) Multi-scale Feature Fusion Cross-channel Multi-head Attention Uniform Manifold Approximation and Projection (UMAP) Example 1 This embodiment provides a method for constructing a basic model of EEG signals based on discrete semantic modeling and spatiotemporal attention, including: acquiring a large-scale pre-training corpus of EEG signals; preprocessing the original signals in the corpus to generate a data sample set; and constructing a basic model, such as... Figure 2 As shown, the basic model includes a tokenization module, a temporal encoding module, a spatiotemporal fusion module, and a prediction module. The tokenization module performs neurosemantic tokenization on the input data samples, converting continuous time series into discrete token sequences. The temporal encoding module is a Roformer model with rotational position encoding, used to capture temporal dependency patterns within a single channel of the token sequence using a masking language modeling paradigm. The spatiotemporal fusion module fuses local waveform, global rhythm, and spatial topological features of the time series to obtain fused spatiotemporal features. The prediction module performs classification prediction based on the fused spatiotemporal features. The basic model is optimized and trained using a data sample set to obtain the final basic model. The Roformer model is obtained through pre-training. The EEG signal basic model constructed by the above method can comprehensively process the original signal, fusing the original signal, local waveform, global rhythm, and spatial topological features, making the feature representation more consistent with the real laws of brain neural activity and effectively improving the reliability of downstream task predictions.
[0021] The EEG signal baseline model constructed using the above method is an infrastructure aligned with the structure of the modern large language model ecosystem. It can dynamically synthesize local discrete streams and generate holistic neural representations, overcoming the temporal fidelity reduction and fragmentation problems caused by existing vision-based models. Through large-scale pre-training, this model significantly improves its performance on various downstream tasks.
[0022] like Figure 1 As shown, the process of constructing the above-mentioned basic model of EEG signals includes the following steps: Step S1: Data Preprocessing and Neural Semantic Tokenization This embodiment uses Temple University Hospital EEG Corpus (TUEG) as a large-scale EEG signal pre-training corpus, containing more than 27,000 hours of EEG recordings.
[0023] Specifically, the data preprocessing in this embodiment includes: 1) Perform 0.3-75Hz bandpass filtering on the original signals (EEG signals) in the TUEG corpus to remove extremely low frequency drift and high frequency noise, and use 60Hz notch filtering to suppress power frequency interference; 2) Clean and format the data, including: removing records with a duration of less than 5 minutes, removing the first and last 1 minute of data to eliminate boundary effects; resampling all data to 200Hz and dividing it into non-overlapping 30-second segments (Epochs), and removing artifact samples with an absolute amplitude exceeding 100μV.
[0024] The neural semantic segmentation in this embodiment specifically includes: 1) Perform channel-level Min-Max normalization or Z-score standardization on the preprocessed EEG signal of each channel to eliminate amplitude differences among subjects; 2) Construct a predefined vocabulary and set the vocabulary size V. Using linear transformation and a floor function, discretize the normalized continuous voltage values into an integer token sequence. In a specific implementation, the vocabulary size V can be set to V=2000. Using the predefined vocabulary size V, the normalized signal is mapped to a token sequence within the integer range [0, V-1] through linear transformation, preserving the temporal characteristics of the original signal.
[0025] This step designs an amplitude-aware tokenizer, abandoning traditional continuous waveform input or spectrogram conversion, and instead converting multi-channel EEG signals into discrete semantic sequences through high-resolution quantization. The "amplitude awareness" specifically refers to the fact that the neural tokenizer explicitly preserves and utilizes the amplitude information of the original signal during the discretization process of the EEG signal. Specifically, firstly, channel-by-channel min-max normalization is performed on the original EEG signal, adaptively scaling the data of each channel to a uniform numerical range to eliminate amplitude baseline differences between different subjects, while preserving the relative variation pattern of signal amplitude within each channel; then, the normalized values are mapped to a predefined vocabulary space through linear transformation, and the continuous amplitude values are discretized into integer tokens in the range [0, V-1] using a rounding function, where V is the preset vocabulary size. Through the above processing, a deterministic monotonic mapping relationship is formed between the generated discrete token sequence and the amplitude changes of the original signal. EEG signals at different amplitude levels are encoded into semantically distinguishable tokens, thereby enabling the subsequent language model to effectively perceive and model the amplitude dynamic features in the EEG signal.
[0026] In one specific embodiment, let the tensor of the input EEG signal data be X. Then, during neural semantic segmentation, the original signal of the c-th channel is first normalized to obtain: Subsequently, binning discretization is used to map continuous voltage values to the vocabulary space. It should be noted that binning discretization is a core execution step in the Neural Semantic Tokenization (NST) process. Specifically, NST is a complete tokenization method specifically designed for the characteristics of EEG signals, proposed in this invention. It aims to convert the original time-domain signal into a discrete token sequence compatible with the input format of a large language model. Its implementation includes two sequentially executed stages: the first stage is channel-by-channel min-max normalization, used to eliminate amplitude baseline differences between subjects and scale the signal to a uniform range; the second stage is binning discretization, which converts the normalized continuous values output from the first stage into discrete integer indices within the range [0, V-1] by linearly scaling them to a predefined vocabulary size V and then processing them using a rounding function. In other words, binning discretization undertakes the crucial mapping task from the continuous numerical domain to the discrete symbolic domain in NST, and is the core operational step in achieving alignment between EEG signals and natural language modalities. The specific process is as follows: Where V is the preset vocabulary size. This represents the floor function, ensuring that the data is discretized into integer indices.
[0027] This step converts micro-voltage fluctuations into symbolic language sequences, achieving input space regularization. This not only effectively filters high-frequency noise variance but also extracts chaotic electrophysiological activity as symbolic "neural vocabulary," achieving structural alignment with the input format of Large Language Models (LLMs). The final input tensor shape is: Batch Size × Number of Channels × Sequence Length, facilitating subsequent processing by the Transformer model.
[0028] Step S2: Temporal Pretraining This embodiment utilizes the Roformer model with Rotation Position Encoding (RoPE) as the encoder to construct an Encoder-Only architecture. It employs the Masked Language Modeling (MLM) paradigm to capture temporal dependency patterns within a single channel and uses a channel-independent pre-training strategy, treating the token sequence of each channel as an independent one-dimensional stream input encoder.
[0029] Specifically, the channel-independent pre-training strategy refers to treating the token sequences of each electrode channel in the multi-channel EEG signal as independent one-dimensional time series during the pre-training phase, and inputting them separately into the Roformer encoder for processing, rather than splicing or interleaving the multi-channel signals into a unified input sequence. Under this strategy, the encoder receives only the token sequence of a single channel in each forward propagation and performs a masked language modeling task on it, i.e., randomly masking 15% of the EEG segment in that channel sequence, requiring the model to reconstruct the original signal at the masked location based on the context, thereby forcing the model to learn the temporal representation pattern within a single channel. Since all channels share the same encoder parameters, after sufficient training on a large-scale corpus, the model can learn neural oscillation patterns that are universal across different cortical regions, rather than overfitting to spatial artifacts of a specific dataset, thus providing a generalizable temporal representation basis for downstream tasks. Unlike traditional absolute position encoding, this step uses rotational position encoding instead. By transforming the Query and Key vectors using a rotation matrix, the attention score depends only on the relative positions of the tokens. This captures the crucial phase relationships and long-range temporal dependencies in neural oscillations, thereby improving long sequence modeling capabilities. The relationship between the Query and Key vectors and the EEG signal is as follows: After neurosemantic segmentation in step S1, the original EEG signal is converted into a discrete token sequence and input into the Roformer encoder. In the encoder's self-attention layer, the embedding representation of each token is projected onto the Query vector through three sets of learnable linear transformations. Key vector and Value vector, where and These correspond to the EEG tokens at positions m and n in the sequence, respectively. Rotational position encoding utilizes position-related rotation matrices. and To each and Apply a rotational transformation so that the attention score calculated by the inner product of the two is... It depends only on the relative position mmn, not on the absolute position. This mechanism maintains the relative position invariance of the inner product operation while eliminating explicit position bias terms, enabling the model to effectively model the temporal dependencies of different time scales in EEG signals.
[0030] The Roformer model described above uses a channel-independent pre-training strategy to treat data from different electrodes as a unified one-dimensional stream. By using a large-scale corpus for MLM tasks, the model is forced to learn neural oscillation laws that are universal across cortical regions (such as phase-amplitude coupling), rather than simply memorizing spatial artifacts specific to a particular dataset.
[0031] In one specific embodiment, the pre-trained Roformer encoder uses a rotation matrix... Introduce relative position information. For the Query vector at position m Key vector at position n The inner product is calculated as follows: in, , For position-dependent rotation matrices, by The definition ensures that the attention score is only related to the relative distance mn, captures single-channel time-dependent patterns, and learns general neural oscillation laws based on the TUEG corpus.
[0032] Step S3: Multi-scale Feature Fusion This embodiment extracts local waveforms and global rhythms from the features. It constructs a feature vector containing both microscopic and macroscopic information through linear projection and additive fusion of local patch embedding and global CLS tokens. In this step, an overlapping sliding window strategy is used to segment the discrete token sequence into local patches, and the overall oscillation features of a single channel are aggregated using global CLS tokens. Finally, feature fusion is achieved through feature summation.
[0033] Specifically, in the multi-scale feature fusion framework of this step, local feature extraction and global feature extraction are two parallel processing paths: the local feature path directly performs overlapping sliding window segmentation on the token sequences of each channel output from step S1 and obtains the results through linear projection. The global feature path then inputs the token sequence of each channel into the Roformer encoder pre-trained in step S2 to extract the CLS token representation of each channel. And obtained through channel projection matrix After capturing local waveform details and global oscillation modes respectively through two paths, multi-scale features are collaboratively modeled by additive fusion.
[0034] In one specific embodiment, the fusion process includes local features. and global features Superposition: Among them, local features Obtained through overlapping slicing (Patch Embedding) and linear projection: Global features Obtained through Roformer's CLS token and channel projection matrix: in, For local features, it represents the local patch embedding representation after high-dimensional projection; It is a learnable linear projection weight matrix used to map low-dimensional local patches to a high-dimensional feature space; The local patch matrix is obtained after sliding window segmentation, which is the local signal representation obtained after dividing the EEG time series of each channel into overlapping segments according to a fixed patch length and step size; To and The corresponding learnable bias vector; is the hidden dimension after linear projection, i.e., the dimension of the target feature space; for The dimensional space in which it exists indicates It is a line number equal to the patch length. The number of columns is a hidden dimension. A real matrix is used to achieve a linear mapping from the patch dimension to the hidden dimension; The CLS classification label vector extracted by the pre-trained Roformer encoder for the c-th EEG channel fully encapsulates the inherent global temporal pattern features of this channel. It is a learnable projection matrix for the global representation between channels, and its role is to adaptively learn and encode the functional connection relationship between different electrode channels; for The dimensional space in which it exists indicates It is a row number The number of columns is A real matrix is used to project the CLS vectors of each channel from the Roformer hidden dimension to the local features. The same A 3D space is needed for subsequent additive feature fusion; This refers to the hidden layer dimension of the pre-trained Roformer model; for The vector space in which it exists, i.e. 3D real space; This represents the raw time series data for the c-th EEG channel; The complete output sequence obtained after inputting the data of the c-th channel into the pre-trained Roformer encoder contains token representations for all positions; To extract the vector at position 0 of the output sequence, i.e., the representation corresponding to the CLS tag, this vector is used as the global semantic summary for the entire channel and assigned to... .
[0035] Step S4: Modeling Cross-channel Multi-head Attention The fused feature vectors from all channels are collected to construct a cross-channel feature set. A scaled dot product self-attention mechanism for independent channels and multi-head attention integration are employed to calculate the attention weights of each channel with other channels, capturing the spatial dependencies between different electrode positions, and obtaining a global feature vector fused with spatiotemporal information. The specific calculation process of the cross-channel multi-head attention mechanism is as follows: The feature representation of the c-th channel after multi-scale feature fusion in step S3 The query matrix is projected onto the three sets of learnable linear transformation matrices respectively. Key matrix Sum matrix ,Right now: in , , This is the corresponding learnable linear transformation weight matrix. Based on this, the self-attention output of this channel is calculated according to the scaling dot product formula: in The dimension of the key vector, divided by To prevent the softmax function from entering the gradient saturation region due to excessively large inner product values, thus ensuring the numerical stability of the attention weight distribution, this embodiment executes the above attention calculations in parallel across h attention heads. The outputs of each head are then concatenated and integrated via a linear transformation. in , , These are the projection matrices corresponding to the i-th attention head. To output the linear transformation matrix.
[0036] While preserving the integrity of single-channel microdynamics, this mechanism automatically learns the functional connectivity patterns between electrodes through attention weights. Each attention head can focus on spatiotemporal features at different time scales, from millisecond-level transient events to continuous oscillatory activities, and synthesizes high-fidelity local representations into a coherent global neurophysiological model to meet the spatial reasoning needs of tasks such as motor imagery or pathological detection.
[0037] Step S5: Downstream Task Adaptation and Prediction The fused spatiotemporal features are input into task-specific classification heads to generate final prediction results for downstream tasks (such as motion imagery, emotion recognition, etc.).
[0038] Specifically, a linear classification head with a flattening layer is constructed. The global spatiotemporal feature vector is input into the flattening layer to eliminate dimensional differences, and then input into the classification head to generate prediction results to complete the detection (such as binary classification or multi-class classification).
[0039] When optimizing the basic model constructed above, Kaiming initialization, gradient clipping, and AdamW optimizer are used to ensure the numerical stability and convergence of large-scale pre-training.
[0040] In a specific embodiment, by visualizing the latent space using UMAP (Uniform Manifold Approximation and Projection), this invention demonstrates that the model can spontaneously separate pathological records from health records and perform semantic clustering of emotional states according to emotional valence, verifying that the model has learned real neurophysiological syntax rather than statistical artifacts.
[0041] Experiments have shown that this invention has significant technical advantages in improving the accuracy of EEG signal decoding, enhancing cross-task generalization ability, and achieving compatibility with NLP ecosystem technologies.
[0042] Specifically, to verify the performance of the model described in this invention, this embodiment comprehensively evaluated it on four downstream tasks covering physiological and cognitive domains, including: a motor imagery decoding task (BCIC-IV-2a dataset, 22 channels, 200Hz sampling rate, extracting 4-second segments from 2-6 seconds after cue presentation), an abnormal EEG detection task (TUAB dataset, converted to 16-lead bipolar reference, segmented into 10-second segments), a psychological stress assessment task (Mental Arithmetic dataset, selecting 20 standard channels, segmented into 5-second segments), and an emotion recognition task (FACED dataset, segmented into 3-second segments to match rapid emotional state transitions). All datasets underwent a unified preprocessing workflow, including resampling to 200Hz, 0.3-75Hz bandpass filtering, and 60Hz power frequency notch filtering.
[0043] The specific experimental process is as follows: The preprocessed dataset samples are input into the model described in this invention, and sequentially go through steps S1 (neural semantic segmentation), S2 (temporal representation pre-training, loading Roformer encoder weights pre-trained on the large-scale TUEG corpus), S3 (multi-scale feature fusion), S4 (cross-channel multi-head attention modeling), and S5 (downstream task adaptive classification head), outputting the prediction results for each task; in the evaluation phase, AUROC, AUPRC, balanced accuracy, and Kappa coefficient are calculated for each downstream task.
[0044] This embodiment compares the model with eleven representative baseline methods, which cover various paradigms of methodological evolution in this field, including efficient convolutional architectures (EEGNet, SPaRCNet, ContraWR, FFCL), composite Transformer architectures (EEGConformer, CNN-Transformer, ST-Transformer, BIOT, LaBraM), and the CBraMod base model, which was reimplemented and fine-tuned under the same standardized data preprocessing process and computational environment.
[0045] Experimental results show that in the motor imagery decoding task, the model described in this invention achieves an AUROC of 0.7724 and an AUPRC of 0.6055, significantly outperforming the retrained CBraMod baseline (AUROC of 0.5118). In the TUAB anomaly detection task in the clinical diagnostic field, the model described in this invention establishes a new performance ceiling with an AUPRC of 0.9425, surpassing the best baseline method's 0.9258. In the psychological stress assessment task, the model described in this invention achieves an AUPRC improvement of 85.4%. In the emotion recognition task, the model described in this invention outperforms dedicated architectures by more than 20% in balanced accuracy.
[0046] The experimental results above fully demonstrate that the collaborative mechanism of high-resolution word segmentation, channel-independent pre-training, and cross-channel attention fusion achieved by the discrete semantic modeling strategy of this invention has significant technical advantages in terms of EEG signal decoding accuracy and cross-task generalization ability. At the same time, this invention also has outstanding advantages in structural alignment with the natural language processing ecosystem. Specifically, the Roformer encoder architecture used in the model described in this invention is fully compatible with the standard interface of the HuggingFace Transformers library, which is currently the most widely used open-source model tool library in the field of natural language processing, providing unified interfaces for model loading, weight management, inference deployment, and fine-tuning training. Because this invention converts EEG signals into discrete sequences consistent with the natural language token format, the model's pre-training weights and word segmentation parameters can be directly hosted on the HuggingFace platform and loaded and called through the standard API, without the need for additional modality adapters or custom data interfaces. This structural alignment enables the model described in this invention to directly reuse mature parameter fine-tuning techniques, distributed training frameworks, and model compression deployment toolchains from the NLP community. At the same time, it provides a unified discrete token space foundation for the subsequent native fusion of EEG signals with multimodal data such as clinical text and visual stimuli, thus providing a scalable technical blueprint for building the next generation of brain-language models.
[0047] If the above methods are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0048] Example 2 This embodiment provides a system for constructing a basic model of EEG signals based on discrete semantic modeling and spatiotemporal attention, including a data acquisition and preprocessing device, a model construction device, and a model training device, wherein: The data acquisition and preprocessing device is used to acquire multi-channel EEG signals and perform preprocessing such as noise reduction and filtering; The model building device is used to build a basic model, which includes a word segmentation module, a time encoding module, a spatiotemporal fusion module, and a prediction module. The word segmentation module is used to perform neural semantic word segmentation processing on the input data samples, converting the continuous time series into discrete token sequences. The time encoding module is a Roformer model with rotational position encoding, which is used to capture the time dependency pattern within a single channel of the token sequence using a mask language modeling paradigm. The spatiotemporal fusion module is used to achieve feature fusion of local waveforms, global rhythm, and spatial topology features to obtain fused spatiotemporal features. The prediction module is used to perform classification prediction based on the fused spatiotemporal features. The model training device is used to optimize and train the constructed base model based on a preprocessed set of data samples.
[0049] Furthermore, the data acquisition and preprocessing device includes a multi-channel EEG acquisition device and a preprocessing unit. The multi-channel EEG acquisition device is used to acquire and convert EEG signals, and the preprocessing unit has built-in filtering, data cleaning and other functions to complete noise reduction, resampling, artifact removal and other tasks.
[0050] In a preferred embodiment, the system further includes a parameter initialization unit: using the Kaiming initialization method, the weight variance is adjusted according to the input dimension to ensure model convergence stability.
[0051] The rest is the same as in Example 1.
[0052] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. A method for constructing a basic model of EEG signals based on discrete semantic modeling and spatiotemporal attention, characterized in that, Includes the following steps: A large-scale pre-training corpus of EEG signals was acquired, and the original signals in the corpus were preprocessed to generate a data sample set. A basic model is constructed, which includes a word segmentation module, a time encoding module, a spatiotemporal fusion module, and a prediction module. The word segmentation module is used to perform neurosemantic word segmentation processing on the input data samples, converting continuous time series into discrete token sequences. The time encoding module is a Roformer model with rotational position encoding, which is used to capture the time dependency patterns within a single channel of the token sequence using a mask language modeling paradigm. The spatiotemporal fusion module is used to achieve feature fusion of local waveforms, global rhythm, and spatial topology features to obtain fused spatiotemporal features. The prediction module is used to perform classification prediction based on the fused spatiotemporal features. The base model is optimized and trained using the data sample set to obtain the final base model, wherein the Roformer model is obtained using a channel-independent pre-training strategy.
2. The method for constructing a basic model of EEG signals based on discrete semantic modeling and spatiotemporal attention as described in claim 1, characterized in that, The preprocessing includes filtering, cleaning, and resampling the original signal.
3. The method for constructing a basic model of EEG signals based on discrete semantic modeling and spatiotemporal attention according to claim 2, characterized in that, The filtering includes bandpass filtering and notch filtering; The cleaning process includes short-duration record removal and boundary effect elimination; During resampling, the signal is segmented into non-overlapping segments, and artifact samples are removed.
4. The method for constructing a basic model of EEG signals based on discrete semantic modeling and spatiotemporal attention as described in claim 1, characterized in that, The neural semantic segmentation process specifically involves: Perform channel-level adaptive normalization or standardization on each preprocessed channel signal; A predefined vocabulary is constructed, and discrete token sequences are obtained through linear transformation and floor function.
5. The method for constructing a basic model of EEG signals based on discrete semantic modeling and spatiotemporal attention according to claim 4, characterized in that, In the floor function, the range of integers is determined by the size of the predefined vocabulary.
6. The method for constructing a basic model of EEG signals based on discrete semantic modeling and spatiotemporal attention according to claim 1, characterized in that, In the time encoding module, the rotation position encoding transforms the Query vector and Key vector through a rotation matrix, so that the attention score depends only on the relative position information between the tokens. The rotation matrix is defined by preset parameters.
7. The method for constructing a basic model of EEG signals based on discrete semantic modeling and spatiotemporal attention according to claim 1, characterized in that, The spatiotemporal fusion module integrates a multi-scale feature fusion unit and a cross-channel attention unit, wherein... The multi-scale feature fusion unit is used to extract local features from the token sequence through an overlapping sliding window, and at the same time, it uses the global CLS token aggregation single-channel overall oscillation mode obtained by the Roformer model to extract global features, and fuses the local features and global features to obtain the fused features of each channel. The cross-channel attention unit is used to dynamically calculate the attention weights between different electrode positions, thereby achieving adaptive weighting and integration of multi-channel fusion features.
8. The method for constructing a basic model of EEG signals based on discrete semantic modeling and spatiotemporal attention according to claim 7, characterized in that, The local features are represented as follows: The global feature is represented as follows: in, For local features, The linear projection weight matrix is learnable. This is the local patch matrix after sliding window segmentation. To and The corresponding learnable bias vector, Hidden dimensions after linear projection for The dimensional space in which it exists No. c The CLS classification label vectors extracted from each channel by a pre-trained Roformer model. This is the learnable projection matrix for the global representation between channels. for The dimensional space in which it exists To determine the hidden layer dimension of the pre-trained Roformer model, for The vector space in which it exists For the first c The raw time series data of each channel, To make the first c The complete output sequence obtained after inputting data from each channel into a pre-trained Roformer model. Indicates taking the sequence The vector at position 0, which serves as the global semantic summary for the entire channel, is assigned to... .
9. The method for constructing a basic model of EEG signals based on discrete semantic modeling and spatiotemporal attention according to claim 1, characterized in that, When constructing the basic model, the Kaiming initialization method is used to dynamically adjust the weight variance based on the input dimension.
10. A system for constructing a basic model of electroencephalogram (EEG) signals based on discrete semantic modeling and spatiotemporal attention, characterized in that, It includes one or more processors, a memory, and one or more programs stored in the memory, said one or more programs including instructions for executing the method for constructing a basic model of electroencephalogram signals as described in any one of claims 1-9.