An electroencephalogram classification method based on pre-training-fine-tuning and space-time topology decoupling
Patent Information
- Application Number
- CN202611507208.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-28
- Publication Date
- 2026-10-30
AI Technical Summary
[0006]本申请实施例提供了一种基于预训练-微调和时空拓扑解耦的脑电分类方法,可以解决脑电分类准确性低的问题
在本申请的实施例中,通过在锚点时间的不同电极之间进行同步编码,再对锚点时间前后的跨时间、跨电极连接进行异步编码,并融合两类编码特征,使模型构建过程具有明确、连续的时空拓扑编码关系;且模型的预训练为自监督预训练,使模型能够从无类别标签的脑电数据中学习同步和异步拓扑编码参数,得到可迁移至不同脑电分类任务的模型;同时,在预训练后,根据临床信息对微调脑电样本进行域划分,并基于划分的样本域对预训练模型进行微调,从而使得最终的脑电分类模型能够降低年龄、性别和采集属性等非目标因素造成的表征偏差,提升脑电分类准确性。
Smart Images

Figure CN123012736A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of EEG signal processing technology, and in particular relates to an EEG classification method based on pre-training-fine-tuning and spatiotemporal topological decoupling. Background Technology
[0002] Electroencephalography (EEG) signals record neural electrical activity using electrodes distributed at different locations on the scalp, offering advantages such as high temporal resolution and flexible acquisition methods. Coordinated changes between different electrodes at the same time point can reflect spatial synchronization, while delayed changes between different time points and electrodes can reflect the propagation of neural activity. Therefore, jointly modeling the spatial connectivity and temporal propagation in EEG signals is an important approach to forming effective EEG representations.
[0003] Existing EEG classification methods typically employ convolutional, graph learning, or attention structures designed for a single dataset or task. These methods rely on a limited amount of labeled data, and the learned features are easily coupled with the acquisition conditions of the specific dataset, making them difficult to transfer to EEG data with different electrode configurations or classification systems. To improve transferability, some methods utilize large-scale unlabeled EEG data for self-supervised pre-training, and then transfer the pre-trained model to downstream classification tasks.
[0004] However, existing EEG pre-training methods mostly divide continuous signals into segments or patches and learn features through mask reconstruction, context prediction, or general attention mechanisms. Segment-level processing weakens the one-to-one correspondence between individual time-electrode points, and the attention weights or implicit associations within the model cannot directly represent synchronous connections at the same time or asynchronous propagation connections across time points. As a result, the pre-trained representations obtained are difficult to explicitly preserve the spatiotemporal topology between points of the EEG signal.
[0005] Furthermore, EEG topology is not only related to the target category but also varies with non-target factors such as age, gender, acquisition equipment, and acquisition conditions. When fine-tuning directly using labeled data, the model may use changes related to non-target factors as the basis for category discrimination, leading to biased classification representations and low EEG classification accuracy. Summary of the Invention
[0006] This application provides an EEG classification method based on pre-training-fine-tuning and spatiotemporal topological decoupling, which can solve the problem of low EEG classification accuracy.
[0007] This application provides an EEG classification method based on pre-training-fine-tuning and spatiotemporal topological decoupling, including: EEG data was acquired and preprocessed to obtain multiple raw EEG samples; For each raw EEG sample, the raw EEG sample is input into the EEG encoder for processing to obtain a topologically aware EEG representation for each raw EEG sample. In each network layer of the EEG encoder, the input features of the network layer are divided into multiple local time neighborhoods. For each local time neighborhood, an anchor time is selected within the local time neighborhood. A synchronous topological connection matrix is constructed between different electrodes at the anchor time. The electrode features at the anchor time are synchronously encoded using the synchronous topological connection matrix to obtain synchronous encoded features. Asynchronous encoded features before the anchor time are set according to the offset between the time point before the anchor time and the anchor time, and asynchronous encoded features after the anchor time are set according to the offset between the time point after the anchor time and the anchor time. The synchronous encoded features, the asynchronous encoded features before the anchor time, and the asynchronous encoded features after the anchor time are fused to obtain the topologically aware EEG representation of the local time neighborhood. The output of each network layer consists of the topologically aware EEG representations of all local time neighborhoods corresponding to that network layer. The output of the last network layer of the EEG encoder is the output of the EEG encoder. Based on the topologically sensed EEG representation of each original EEG sample, the EEG encoder and EEG decoder are self-supervised pre-trained to obtain the pre-trained EEG encoder. Multiple fine-tuned EEG samples with category labels and corresponding clinical information for each fine-tuned EEG sample are obtained. Based on the clinical information, the multiple fine-tuned EEG samples are divided into domains to obtain multiple sample domains. A classification model is constructed based on the pre-trained EEG encoder, and the classification model is fine-tuned using multiple sample domains to obtain the EEG classification model. The EEG classification model is used to classify the EEG data to be classified, and the EEG category results are obtained.
[0008] Optionally, the input features of the network layer can be divided into multiple local temporal neighborhoods, including: Using a sliding time window of odd length, the input features of the network layer are divided into multiple local temporal neighborhoods.
[0009] Optionally, the anchor time can be selected within the local time neighborhood, including: Use the center time point of the local time neighborhood as the anchor time.
[0010] Optionally, the electrode features of the anchor point time are synchronously encoded using the synchronization topology connection matrix to obtain synchronization encoded features, including: The synchronization coding features are calculated using the following formula: ; ; in, Indicates the first The first layer of the network Synchronization coding features corresponding to local temporal neighborhoods Indicates the original EEG sample number. Indicates synchronous encoding. Indicates the first Layer network layer, first The synchronization topology connection matrix corresponding to each time offset. , This represents the subspace embedding matrix obtained based on the current electrode position. express The transpose of the matrix, Indicates the first The first layer of the network The first original EEG sample was in the... Within a local time neighborhood, the first Electrode features corresponding to each time offset Indicates the first Learnable feature transformation parameters of layer network layers This represents the length of the local time neighborhood.
[0011] Optionally, the asynchronous encoding feature before the anchor point is: ; in, Indicates the first The first layer of the network The anchor point asynchronous encoding features corresponding to each local temporal neighborhood This indicates asynchronous encoding before the anchor point; The asynchronous encoding feature after the anchor point is: ; in, Indicates the first The first layer of the network Asynchronous encoding features are then performed on anchor points corresponding to local temporal neighborhoods. This indicates asynchronous encoding after the anchor point.
[0012] Optionally, the synchronous coding features, pre-anchor asynchronous coding features, and post-anchor asynchronous coding features are fused to obtain a topologically aware EEG representation of the local temporal neighborhood, including: The topological sensing EEG representation of the local temporal neighborhood is calculated using the following formula: ; in, Indicates the first The first layer of the network Topologically-aware EEG representations of local temporal neighborhoods.
[0013] Optionally, multiple fine-tuned EEG samples can be domain-divided based on clinical information to obtain multiple sample domains, including: The domain partitioning model was trained using clinical information corresponding to multiple fine-tuned EEG samples to obtain the trained domain partitioning model. For each fine-tuned EEG sample, the probability of the fine-tuned EEG sample belonging to different sample domains is calculated using the trained domain partitioning model, and the fine-tuned EEG sample is partitioned into the sample domain corresponding to the highest probability.
[0014] Optionally, the domain partitioning model includes a clinical information encoder and a domain partitioning head; Loss function when training a domain partitioning model for: ; in, Represents conditional entropy. This represents the sample domain probability distribution for predicting branching clinical information. This represents clinical information within a batch. This indicates the sample domain category derived from clinical information. The marginal entropy represents the average sample domain distribution. This represents the average distribution of the predicted probability of the sample domain within a batch. ; Indicates the number of samples in the batch. Indicates the first A fine-tuned EEG sample belongs to the sample domain. The probability, , Indicates the first Clinical information corresponding to each fine-tuned EEG sample Indicates a clinical information encoder. Represents the field partition header.
[0015] Optionally, the classification model includes a pre-trained EEG encoder and a classification head, with the output of the pre-trained EEG encoder connected to the input of the classification head. Loss function when fine-tuning the classification model for: ; ; ; ; in, This represents the classification loss between the EEG category result and the category label. , , All represent weights. Represents the domain-adaptive loss. Indicates the sample domain partitioning loss. This indicates the prediction loss for clinical information categories. This represents the cross-sample domain distribution alignment loss. Indicates the number of sample domains. Indicates belonging to the sample domain Topologically perceptual EEG representation of fine-tuned EEG samples Indicates belonging to the sample domain Topologically perceptual EEG representation of fine-tuned EEG samples Indicates the Sinkhorn divergence. This indicates the optimal transmission distance for entropy regularization.
[0016] Optionally, based on the topologically-aware EEG representation of each original EEG sample, the EEG encoder and EEG decoder are self-supervised pre-trained to obtain a pre-trained EEG encoder, including: The topologically-aware EEG representation of each original EEG sample is input into the EEG decoder to reconstruct the EEG sample; Using the reconstruction loss between the original EEG sample and the reconstructed EEG sample as the pre-training target, the EEG encoder and EEG decoder are self-supervised pre-trained to obtain the pre-trained EEG encoder.
[0017] The above-mentioned solution in this application has the following beneficial effects: In the embodiments of this application, synchronous encoding is performed between different electrodes at the anchor time, and asynchronous encoding is performed on the cross-time and cross-electrode connections before and after the anchor time. The two types of encoding features are then fused to give the model construction process a clear and continuous spatiotemporal topological encoding relationship. Furthermore, the model pre-training is self-supervised pre-training, which enables the model to learn synchronous and asynchronous topological encoding parameters from EEG data without class labels, resulting in a model that can be transferred to different EEG classification tasks. At the same time, after pre-training, the fine-tuned EEG samples are divided into domains based on clinical information, and the pre-trained model is fine-tuned based on the divided sample domains. This allows the final EEG classification model to reduce the representation bias caused by non-target factors such as age, gender, and acquisition attributes, thereby improving the accuracy of EEG classification.
[0018] Other beneficial effects of this application will be described in detail in the following detailed description section. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 A flowchart of an EEG classification method based on pre-training-fine-tuning and spatiotemporal topological decoupling provided in an embodiment of this application. Detailed Implementation
[0021] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0022] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0023] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0024] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0025] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0026] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0027] To address the issue of low accuracy in current EEG classification, this application provides an EEG classification method based on pre-training-fine-tuning and spatiotemporal topological decoupling. This method synchronously encodes connections between different electrodes at anchor times, then asynchronously encodes connections across time and electrodes before and after the anchor times, fusing these two types of encoding features to create a clear and continuous spatiotemporal topological encoding relationship in the model construction process. Furthermore, the model's pre-training is self-supervised, enabling the model to learn synchronous and asynchronous topological encoding parameters from unlabeled EEG data, resulting in a model transferable to different EEG classification tasks. Simultaneously, after pre-training, the fine-tuned EEG samples are divided into domains based on clinical information, and the pre-trained model is fine-tuned based on these domain divisions. This allows the final EEG classification model to reduce representational biases caused by non-target factors such as age, gender, and acquisition attributes, thereby improving EEG classification accuracy.
[0028] The following specific embodiments illustrate the EEG classification method based on pre-training-fine-tuning and spatiotemporal topological decoupling provided in this application.
[0029] like Figure 1 As shown, the EEG classification method based on pre-training-fine-tuning and spatiotemporal topological decoupling provided in this application includes the following steps: Step 11: Acquire EEG data and preprocess the EEG data to obtain multiple raw EEG samples.
[0030] Specifically, the process involves reading raw EEG recordings and converting each recording into a channel-time matrix; removing pre-defined duration signals from the beginning and end of the recording based on its length; performing bandpass filtering and channel normalization on the EEG signals; dividing continuous signals into fixed-time windows and using resampling, truncation, or zero-padding to ensure a uniform duration for each EEG sample. The preprocessed data is then used to... Each EEG sample (i.e., the raw EEG sample) is represented as: ; in, For the number of time points, This refers to the number of electrode channels. The feature dimension for each time-electrode point; when directly using time-domain amplitude. Raw EEG recordings can be in EDF, BDF, or other data formats capable of storing multi-channel EEG signals. EDF and BDF are both EEG file formats.
[0031] Step 12: For each original EEG sample, input the original EEG sample into the EEG encoder for processing to obtain the topological sensing EEG representation of each original EEG sample.
[0032] For example, the above-mentioned EEG encoder can be an EEG network (EEGNet).
[0033] Specifically, in each network layer of the EEG encoder, the input features of the network layer are divided into multiple local temporal neighborhoods. For each local temporal neighborhood, an anchor time is selected within that neighborhood. A synchronous topological connection matrix is constructed between different electrodes at the anchor time. The electrode features at the anchor time are synchronously encoded using the synchronous topological connection matrix to obtain synchronous encoded features. Asynchronous encoded features before the anchor time are set according to the offset between the time point before the anchor time and the anchor time, and asynchronous encoded features after the anchor time are set according to the offset between the time point after the anchor time and the anchor time. The synchronous encoded features, the asynchronous encoded features before the anchor time, and the asynchronous encoded features after the anchor time are fused to obtain the topologically aware EEG representation of the local temporal neighborhood. The output of each network layer consists of the topologically aware EEG representations of all local temporal neighborhoods corresponding to that network layer. The output of the last network layer of the EEG encoder is the output of the EEG encoder.
[0034] The aforementioned synchronization coding features are used to describe the synchronization response relationship and spatial topological dependence relationship between different electrodes at the same anchor point time, so as to characterize the cross-electrode cooperative activity features of EEG signals at that anchor point time.
[0035] In some embodiments of this application, an odd-length sliding time window can be used to divide the input features of the network layer into multiple local temporal neighborhoods. The aforementioned sliding time window is used to define the temporal range of the topology connections, where each time-electrode point still serves as a topology node. The center time point of each local temporal neighborhood can be used as the anchor time, and at the anchor time, the point-level features of each electrode can be used as nodes. Specifically, the synchronization coding features can be calculated using the following formula: ; ; in, Indicates the first The first layer of the network Synchronization coding features corresponding to local temporal neighborhoods Indicates the original EEG sample number. Indicates synchronous encoding. Indicates the first Layer network layer, first The synchronization topology connection matrix corresponding to each time offset.
[0036] , This represents the subspace embedding matrix obtained based on the current electrode position. express The transpose of the matrix, Indicates the first The first layer of the network The first original EEG sample was in the... Within a local time neighborhood, the first Electrode features corresponding to each time offset Indicates the first Learnable feature transformation parameters of layer network layers This represents the length of the local time neighborhood.
[0037] Among them, the synchronization topology connection matrix The construction process is as follows: To address the differences in the number and location of electrodes in various EEG data sets, a globally learnable spatial embedding matrix is established for each network layer and each time offset. The globally learnable spatial embedding matrix is interpolated based on the electrode locations in the current EEG data to obtain a subspace embedding matrix corresponding to the current electrode configuration. The synchronization topology connection matrix is then generated using the following formula: ; Therefore, while embedding parameters in a shared space, a synchronous topology connection matrix of appropriate size can be generated for different numbers and layouts of electrodes.
[0038] In some embodiments of this application, for asynchronous encoding, the asynchronous topology connection matrix can be set according to its offset from the anchor time for each time point before and after the anchor time.
[0039] Specifically, the asynchronous encoding features before the anchor point are: ; in, Indicates the first The first layer of the network The anchor point asynchronous encoding features corresponding to each local temporal neighborhood This indicates asynchronous encoding before the anchor point.
[0040] The asynchronous encoding feature after the anchor point is: ; in, Indicates the first The first layer of the network Asynchronous encoding features are then performed on anchor points corresponding to local temporal neighborhoods. This indicates asynchronous encoding after the anchor point.
[0041] The pre-anchor asynchronous coding features describe the propagation relationship of electrode activity from previous time points to the anchor time, while the post-anchor asynchronous coding features describe the continuation relationship of electrode activity from the anchor time to subsequent time points. Different topology connectivity matrices are used for different time offsets to preserve the inter-point connectivity that varies with propagation delay.
[0042] For each local temporal neighborhood, the topologically sensed EEG representation of that local temporal neighborhood can be calculated using the following formula: ; in, Indicates the first The first layer of the network Topologically-aware EEG representations of local temporal neighborhoods.
[0043] It should be noted that after obtaining the topologically aware EEG representations of all local temporal neighborhoods in the network layer, the topologically aware EEG representations of each local temporal neighborhood can be combined in chronological order to form the output of the current network layer and input into the next network layer. Each network layer of the EEG encoder sequentially performs synchronous encoding, asynchronous encoding, and feature fusion to obtain hierarchical topologically aware EEG representations, thus completing the construction of the EEG coding model.
[0044] Step 13: Based on the topological perception EEG representation of each original EEG sample, perform self-supervised pre-training on the EEG encoder and EEG decoder to obtain the pre-trained EEG encoder.
[0045] In some embodiments of this application, the topologically perceived EEG representation of each original EEG sample can be input into the EEG decoder to reconstruct the EEG sample, thereby obtaining a reconstructed EEG sample; then, the reconstruction loss between the original EEG sample and the reconstructed EEG sample can be used as a pre-training target to perform self-supervised pre-training on the EEG encoder and the EEG decoder, thereby obtaining a pre-trained EEG encoder.
[0046] For example, the above-mentioned EEG decoder can be a Long Short-Term Memory (LSTM) decoder.
[0047] Specifically, the topologically-aware EEG representation output from the EEG encoder is input into the EEG decoder to reconstruct an EEG sample with the same shape as the original EEG sample. The reconstruction process and pre-training objective are represented as follows: ; ; in, and These represent the EEG encoder and EEG decoder, respectively. and These represent the original EEG sample and the reconstructed EEG sample, respectively. This indicates the number of pre-training EEG samples. The loss function is used for self-supervised pre-training. The reconstruction loss is minimized using unlabeled EEG samples until the pre-training objective converges. After pre-training, the parameters of the EEG encoding model are saved to obtain the pre-training weights for fine-tuning, thus obtaining the pre-trained EEG encoder.
[0048] Step 14: Obtain multiple fine-tuned EEG samples with category labels and the corresponding clinical information for each fine-tuned EEG sample, and divide the multiple fine-tuned EEG samples into domains based on the clinical information to obtain multiple sample domains.
[0049] The process for acquiring the fine-tuned EEG samples is the same as that for acquiring the original EEG samples, and will not be repeated here. The category labels for the fine-tuned EEG samples can be patient EEG signals, normal EEG signals, etc. It is understood that, for ease of data processing, each category label can be coded; for example, patient EEG signals are coded as 0, and normal EEG signals are coded as 1. The aforementioned clinical information includes at least one of the following: age, gender, acquisition device, acquisition location, and acquisition batch.
[0050] In some embodiments of this application, the domain partitioning model can be trained using clinical information corresponding to multiple fine-tuned EEG samples to obtain the trained domain partitioning model; then, for each fine-tuned EEG sample, the probability of the fine-tuned EEG sample belonging to different sample domains is calculated using the trained domain partitioning model, and the fine-tuned EEG sample is partitioned into the sample domain corresponding to the highest probability.
[0051] The aforementioned sample domains are used to describe differences in EEG representations caused by non-target factors in clinical information. Generally, sample domains can include those induced by clinical information such as different age groups, genders, acquisition devices, acquisition locations, or acquisition batches; when multiple clinical information items are used, sample domains can also include those induced by combined differences in multiple clinical information items. These sample domains are adaptively determined by the domain partitioning model based on clinical information, and are not pre-set with fixed domain labels.
[0052] In some embodiments of this application, the domain partitioning model includes a clinical information encoder and a domain partitioning head. For example, the clinical information encoder may be a Transformer encoder, and the domain partitioning head may be a Multilayer Perceptron (MLP).
[0053] While unsupervised training methods commonly used in deep learning models can be employed to train domain partitioning models, this application uses an information maximization approach for sample domain partitioning instead of pre-setting explicit domain labels. The loss function used when training the domain partitioning model is different. for: ; in, This represents the conditional entropy (i.e., the conditional entropy of the probability of a single sample domain), which is the mean of the prediction entropy of each sample domain within a batch. Minimizing this term can make the prediction of each sample domain more certain. This represents the sample domain probability distribution for predicting branching clinical information. This indicates clinical information within a batch, such as age and gender. This indicates the sample domain category derived from clinical information. Indicates from clinical information To the sample domain The mapping. Marginal entropy, representing the average sample domain distribution (i.e., the marginal entropy of the batch aggregation domain probability), maximizes this term to maintain a relative balance of samples across different sample domains, preventing all samples from being assigned to the same domain. This represents the average distribution of the predicted probability of the sample domain within a batch.
[0054] ; This indicates the number of samples in the batch (i.e., the amount of clinical information). Indicates the first A fine-tuned EEG sample belongs to the sample domain. The probability, , Indicates the first Clinical information corresponding to each fine-tuned EEG sample Indicates a clinical information encoder. Represents the field partition header.
[0055] The specific calculation process for the aforementioned sample domain probability distribution, batch average sample domain probability, conditional entropy, and marginal entropy is as follows. First, the sample domain probability distribution is calculated using a normalization (Softmax) method. The domain partitioning head is based on the... The clinical information of each fine-tuned EEG sample is output as a score for each sample domain. The scores are then normalized using the Softmax function to obtain the sample domain probability distribution of the fine-tuned EEG sample. The calculation formula is as follows: ; in, For matrix The Middle Line 1 Column elements, The output of the domain partitioning header is the first The fine-tuned EEG sample corresponds to the first The score of each sample domain, The output of the domain partitioning header is the first The fine-tuned EEG sample corresponds to the first The score of each sample domain, This indicates fine-tuning of the EEG sample index. Indicates the sample field index. This represents the number of sample domains. After obtaining the sample domain probabilities for each fine-tuned EEG sample, the batch average sample domain probability is obtained according to the aforementioned batch average formula, and then the conditional entropy and marginal entropy are further calculated. The formula for calculating the conditional entropy is: ; The formula for calculating edge entropy is: ; in, This represents a very small positive number set to prevent the logarithm from being zero.
[0056] During the training of the domain partitioning model, the confidence of domain assignment is increased by reducing conditional entropy, and the balance of samples across different domains is maintained by increasing marginal entropy. Based on the domain probability of each sample, fine-tuned EEG samples are pre-partitioned into their respective sample domains. The loss is minimized by maximizing information (i.e., the loss function). This can simultaneously improve the certainty of prediction for a single sample domain while maintaining the diversity and balance of sample domain partitioning at the batch level.
[0057] It should be noted that after obtaining the trained domain partitioning model, it can be used through the above formula. Calculate the probability that each fine-tuned EEG sample belongs to a different sample domain in order to perform domain division of the fine-tuned EEG samples.
[0058] Step 15: Construct a classification model based on the pre-trained EEG encoder, and fine-tune the classification model using multiple sample domains to obtain the EEG classification model.
[0059] In some embodiments of this application, the classification model includes a pre-trained EEG encoder and a classification head, with the output of the pre-trained EEG encoder connected to the input of the classification head. For example, the classification head may be a multilayer perceptron.
[0060] The fine-tuning training described above can be carried out using training methods commonly used in deep learning models. However, the loss function in this application is constructed based on sample domain partitioning loss, meta-information category prediction loss after gradient inversion, and cross-sample domain distribution alignment loss.
[0061] Specifically, the loss function when fine-tuning the classification model. for: ; ; ; ; in, This represents the classification loss between the EEG category result and the category label. , , All of these represent weights; the specific values can be set according to the actual situation. Represents the domain-adaptive loss. Indicates the sample domain partitioning loss. This indicates the prediction loss for clinical information categories. This represents the cross-sample domain distribution alignment loss. Indicates the number of sample domains. Indicates belonging to the sample domain Topologically perceptual EEG representation of fine-tuned EEG samples Indicates belonging to the sample domain Topologically perceptual EEG representation of fine-tuned EEG samples Indicates the Sinkhorn divergence. This represents the optimal transmission distance using entropy regularization. The method for obtaining the topologically-aware EEG representation of the fine-tuned EEG sample is the same as that for obtaining the topologically-aware EEG representation of the original EEG sample, and will not be elaborated upon here.
[0062] It should be noted that, to calculate the domain-adaptive loss, a preset number of topologically sensed EEG representations with the highest domain probability are selected as representative samples in each sample domain. Entropy-normalized optimal transmission is used to calculate the distance between the distributions of representative samples in different sample domains, and Sinkhorn divergence is used to subtract the transmission cost of the distribution of each sample domain itself.
[0063] To reduce the impact of the correlation between clinical information (also known as meta-information) and category labels on sample domain partitioning, a gradient inversion layer and a clinical information category prediction head are added after the clinical information encoder. This allows the clinical information encoder to reduce the category information contained in the sample domain representation. The sample domain partitioning loss, the gradient-inverted clinical information category prediction loss, and the cross-sample domain distribution alignment loss are combined into a domain adaptive loss, which is then jointly optimized with the EEG classification loss.
[0064] In the above loss function In the middle, classification loss and clinical information category prediction loss Both are calculated using the cross-entropy loss function, and the sample domain partitioning loss is... The above information is used to maximize the loss calculation, which is to calculate the difference between the mean of the prediction entropy of each sample domain within a batch and the marginal entropy of the batch aggregate domain probability.
[0065] Step 16: Use the EEG classification model to classify the EEG data to be classified and obtain the EEG category results.
[0066] In some embodiments of this application, the EEG data to be classified can be input into an EEG classification model for processing. First, the EEG encoder encodes the EEG data to be classified into a topologically sensed EEG representation. Then, the classification head processes the topologically sensed EEG representation and outputs the probability that the EEG data to be classified belongs to different EEG categories (such as patient EEG signals and normal EEG signals). The EEG category corresponding to the highest probability is taken as the EEG category result of the EEG data to be classified.
[0067] The following examples illustrate the EEG classification method of this application.
[0068] Specifically, the EEG classification method of this application includes the following steps: Step 1) Preprocess EEG data. Read the raw EEG recordings and arrange the signals into a channel-time matrix. As one implementation, if the recording length allows, remove the first and last 10 seconds of signal. Use a fourth-order Butterworth bandpass filter to retain signals from 0.5 Hz to 40 Hz. Standardize each electrode channel using a z-score, and then divide the continuous signal into 10-second time windows. Resample, truncate, or zero-padded time windows within each window to include 800 time points. The specific duration, frequency band, and number of time points can be adjusted according to the sampling rate and the EEG classification task.
[0069] Step 2) Perform synchronous encoding of EEG data. In each network layer of the EEG encoder, multiple local temporal neighborhoods are formed using odd-length sliding time windows, with the central time point as the anchor time. At the anchor time, each electrode feature is used as a node, and a synchronous topology connection matrix is generated according to the current electrode configuration. The synchronous topology connection matrix is then used to complete feature propagation between different electrodes at the same time point, resulting in synchronously encoded features.
[0070] Step 3) Perform asynchronous encoding and feature fusion of EEG data. For each time offset before the anchor point, an asynchronous topological connection matrix is set up; for each time offset after the anchor point, an asynchronous topological connection matrix is set up. Electrode features at the corresponding time points are propagated using these asynchronous topological connection matrices to obtain asynchronous encoded features before and after the anchor point. The asynchronous encoded features before, simultaneously encoded, and asynchronous encoded features after the anchor point are fused, and then the fused features from each local time neighborhood are combined in chronological order to form the topologically aware EEG representation of the current network layer. Each network layer performs the above encoding operations sequentially, thus completing the construction of the EEG encoding model.
[0071] Step 4) Self-supervised pre-training using EEG sample reconstruction. The topologically-aware EEG representation output by the EEG coding model is input into the EEG decoder, which outputs reconstructed EEG samples with the same shape as the original EEG samples. The difference between the original and reconstructed EEG samples is used as the reconstruction loss, and this reconstruction loss is used as the pre-training objective. Optimization is performed using unlabeled EEG samples until the pre-training objective converges. The EEG coding model parameters are then saved, yielding the pre-training weights.
[0072] Step 5) Pre-classify samples based on clinical information. Obtain information such as age, gender, acquisition device, acquisition location, or acquisition batch for each fine-tuned EEG sample. Input this information into the clinical information encoder and domain division head to obtain the sample domain probability. Utilize the information to maximize the confidence of individual sample domain allocation while maintaining balance between different sample domains. Then, pre-classify the fine-tuned EEG samples into multiple sample domains based on the sample domain probability.
[0073] Step 6) Fine-tune the model by combining the domain adaptation loss and classification loss. Load the pre-trained weights obtained in Step 4 into the fine-tuned model. Calculate the cross-sample domain distribution alignment loss based on the sample domain obtained in Step 5, and reduce the category information in the sample domain representation by gradient inversion. Combine the sample pre-splitting loss, the gradient-inverted meta-information category prediction loss, and the cross-sample domain distribution alignment loss into the domain adaptation loss. Simultaneously, calculate the classification loss based on the EEG category results and category labels output by the fine-tuned model. Update the pre-trained weights by combining the domain adaptation loss and classification loss to obtain the fine-tuned model, and use this model to output the category results of the EEG data to be classified.
[0074] Through the above steps, EEG data undergoes preprocessing, synchronous encoding, asynchronous encoding and fusion, reconstruction pre-training, sample pre-segmentation based on clinical information or meta-information, and joint fine-tuning, thus forming a continuous pre-training-fine-tuning EEG classification process.
[0075] In summary, the EEG classification method provided in this application has the following advantages: I. This application achieves synchronous encoding between different electrodes at the anchor time, and asynchronous encoding of cross-time and cross-electrode connections before and after the anchor time, and integrates the two types of encoding features, so that the model construction process has a clear and continuous spatiotemporal topological encoding relationship.
[0076] Second, this application utilizes EEG sample reconstruction as a self-supervised pre-training target, which can learn synchronous and asynchronous topological coding parameters from unlabeled EEG data and obtain pre-training weights that can be transferred to different EEG classification tasks.
[0077] Third, this application generates a topological connectivity matrix by globally learnable spatial embedding and electrode position-based interpolation, enabling shared parameters to adapt to different numbers and layouts of electrodes, thereby improving the applicability of the pre-trained model to heterogeneous EEG data.
[0078] Fourth, this application divides the fine-tuned EEG samples into domains based on clinical information and fine-tunes the pre-training weights by combining domain adaptive loss and classification loss. This can reduce the representation bias caused by non-target factors such as age, gender and acquisition attributes, thereby improving the accuracy of EEG classification.
[0079] The above description is the preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principles described in this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A brainwave classification method based on pre-training-fine-tuning and spatiotemporal topological decoupling, characterized in that, include: EEG data is acquired and preprocessed to obtain multiple raw EEG samples; For each of the original EEG samples, the original EEG sample is input into an EEG encoder for processing to obtain a topologically aware EEG representation for each original EEG sample. In each network layer of the EEG encoder, the input features of the network layer are divided into multiple local time neighborhoods. For each local time neighborhood, an anchor time is selected within the local time neighborhood. A synchronous topological connection matrix is constructed between different electrodes at the anchor time. The electrode features at the anchor time are synchronously encoded using the synchronous topological connection matrix to obtain synchronous encoded features. Asynchronous encoded features before the anchor time are set according to the offset between the time point before the anchor time and the anchor time, and asynchronous encoded features after the anchor time are set according to the offset between the time point after the anchor time and the anchor time. The synchronous encoded features, the asynchronous encoded features before the anchor time, and the asynchronous encoded features after the anchor time are fused to obtain the topologically aware EEG representation of the local time neighborhood. The output of each network layer consists of the topologically aware EEG representations of all local time neighborhoods corresponding to that network layer. The output of the last network layer of the EEG encoder is the output of the EEG encoder. Based on the topologically sensed EEG representation of each original EEG sample, the EEG encoder and EEG decoder are self-supervised pre-trained to obtain the pre-trained EEG encoder. Multiple fine-tuned EEG samples with category labels and corresponding clinical information for each fine-tuned EEG sample are obtained. Based on the clinical information, the multiple fine-tuned EEG samples are divided into domains to obtain multiple sample domains. A classification model is constructed based on the pre-trained EEG encoder, and the classification model is fine-tuned using the multiple sample domains to obtain the EEG classification model. The EEG classification model is used to classify the EEG data to be classified, and the EEG category results are obtained.
2. The EEG classification method according to claim 1, characterized in that, The process of dividing the input features of the network layer into multiple local temporal neighborhoods includes: Using a sliding time window of odd length, the input features of the network layer are divided into multiple local temporal neighborhoods.
3. The EEG classification method according to claim 2, characterized in that, Selecting the anchor time within the local time neighborhood includes: The center time point of the local time neighborhood is used as the anchor time.
4. The EEG classification method according to claim 1, characterized in that, The method of synchronously encoding the electrode features of the anchor point time using the synchronous topology connection matrix to obtain synchronous encoded features includes: The synchronization coding features are calculated using the following formula: ; ; in, Indicates the first The first layer of the network Synchronization coding features corresponding to local temporal neighborhoods Indicates the original EEG sample number. Indicates synchronous encoding. Indicates the first Layer network layer, first The synchronization topology connection matrix corresponding to each time offset. , This represents the subspace embedding matrix obtained based on the current electrode position. express The transpose of the matrix, Indicates the first The first layer of the network The first original EEG sample was in the... Within a local time neighborhood, the first Electrode features corresponding to each time offset Indicates the first Learnable feature transformation parameters of layer network layers This represents the length of the local time neighborhood.
5. The EEG classification method according to claim 4, characterized in that, The asynchronous encoding feature before the anchor point is: ; in, Indicates the first The first layer of the network The anchor point asynchronous encoding features corresponding to each local temporal neighborhood This indicates asynchronous encoding before the anchor point; The asynchronous encoding feature after the anchor point is: ; in, Indicates the first The first layer of the network Asynchronous encoding features are then performed on anchor points corresponding to local temporal neighborhoods. This indicates asynchronous encoding after the anchor point.
6. The EEG classification method according to claim 5, characterized in that, The process of fusing the synchronous coding features, the pre-anchor asynchronous coding features, and the post-anchor asynchronous coding features to obtain the topologically sensed EEG representation of the local temporal neighborhood includes: The topological sensing EEG representation of the local temporal neighborhood is calculated using the following formula: ; in, Indicates the first The first layer of the network Topologically-aware EEG representations of local temporal neighborhoods.
7. The EEG classification method according to claim 1, characterized in that, The process involves dividing multiple fine-tuned EEG samples into domains based on clinical information, resulting in multiple sample domains, including: The domain partitioning model was trained using clinical information corresponding to multiple fine-tuned EEG samples to obtain the trained domain partitioning model. For each fine-tuned EEG sample, the probability of the fine-tuned EEG sample belonging to different sample domains is calculated using the trained domain partitioning model, and the fine-tuned EEG sample is partitioned into the sample domain corresponding to the highest probability.
8. The EEG classification method according to claim 7, characterized in that, The domain partitioning model includes a clinical information encoder and a domain partitioning head; Loss function when training a domain partitioning model for: ; in, Represents conditional entropy. This represents the sample domain probability distribution for predicting branching clinical information. This represents clinical information within a batch. This indicates the sample domain category derived from clinical information. The marginal entropy represents the average sample domain distribution. This represents the average distribution of the predicted probability of the sample domain within a batch. ; Indicates the number of samples in the batch. Indicates the first A fine-tuned EEG sample belongs to the sample domain. The probability, , Indicates the first Clinical information corresponding to each fine-tuned EEG sample Indicates a clinical information encoder. Represents the field partition header.
9. The EEG classification method according to claim 1, characterized in that, The classification model includes a pre-trained EEG encoder and a classification head, with the output of the pre-trained EEG encoder connected to the input of the classification head; Loss function during fine-tuning training of the classification model for: ; ; ; ; in, This represents the classification loss between the EEG category result and the category label. , , All represent weights. Represents the domain-adaptive loss. Indicates the sample domain partitioning loss. This indicates the prediction loss for clinical information categories. This represents the cross-sample domain distribution alignment loss. Indicates the number of sample domains. Indicates belonging to the sample domain Topologically perceptual EEG representation of fine-tuned EEG samples Indicates belonging to the sample domain Topologically perceptual EEG representation of fine-tuned EEG samples Indicates the Sinkhorn divergence. This indicates the optimal transmission distance for entropy regularization.
10. The EEG classification method according to claim 1, characterized in that, The topologically-aware EEG representation based on each of the original EEG samples is used to perform self-supervised pre-training on the EEG encoder and EEG decoder to obtain the pre-trained EEG encoder, including: The topologically-aware EEG representation of each of the original EEG samples is input into the EEG decoder to reconstruct the EEG samples; Using the reconstruction loss between the original EEG sample and the reconstructed EEG sample as the pre-training target, the EEG encoder and EEG decoder are self-supervised pre-trained to obtain the pre-trained EEG encoder.