Electroencephalogram signal classification method and system
By constructing structured prompts and purity guidance mechanisms, the problems of training complexity and universality in existing EEG signal classification methods are solved, achieving efficient and multi-task applicable EEG signal classification. The context learning capability of large language models is utilized to reduce computational costs.
Patent Information
- Application Number
- CN202511717455.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-21
- Publication Date
- 2026-02-24
AI Technical Summary
Existing EEG signal classification methods based on large language models rely on model parameter updates, which are complex and costly to train, lack multi-task validation, and have poor versatility.
By extracting features from the EEG signals to be classified, structured cue information is constructed, including features, cue examples, and instruction information, to guide the large language model in classification. A purity-guided mechanism is used to select the most representative sample examples without updating the model parameters.
It achieves efficient EEG signal classification for multiple tasks without adjusting model parameters, maximizes the use of large language models, reduces computational costs and deployment costs, and improves generalization and classification accuracy.
Smart Images

Figure CN121561518A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of electroencephalogram (EEG) classification technology, and more specifically, relates to an EEG signal classification method and system. Background Technology
[0002] Brain-computer interfaces (BCIs) enable direct communication between the brain and external devices, allowing users to interact with their environment through brain signals that reflect cognitive states or intentions. Among various BCI modalities, electroencephalograms (EEGs) are widely used due to their low cost, non-invasiveness, and ease of acquisition. However, achieving efficient and accurate EEG signal classification remains a significant challenge due to the individual variability and non-stationarity of EEG signals.
[0003] Large Language Models (LLMs) have made significant progress in a wide range of natural language processing tasks. As the model size increases, LLMs exhibit powerful in-context learning (ICL) capabilities, enabling them to complete downstream tasks during inference with a small number of example samples without requiring gradient-based parameter updates.
[0004] In existing research on EEG signal classification based on large language models, most methods still rely on updating model parameters, including adjusting the model by introducing additional adapter layers or classification heads. This makes training complex and costly, and these methods are only applicable to open-source large language models. Furthermore, some studies only conduct experiments on single-task or task-specific datasets, lacking validation across multiple tasks and failing to adequately demonstrate the generalization ability of their methods, resulting in poor versatility. Summary of the Invention
[0005] In view of the above-mentioned defects or improvement needs of the existing technology, the present invention provides a method and system for classifying electroencephalogram (EEG) signals, the purpose of which is to achieve more general and efficient EEG signal classification that supports multiple tasks without updating model parameters.
[0006] To achieve the above objectives, in a first aspect, the present invention provides a method for classifying electroencephalogram (EEG) signals, comprising: Feature extraction of EEG signals to be classified; Structured prompts are constructed and input into a large language model to obtain the classification results of the EEG signals to be classified. The structured cue information includes: features of the EEG signal to be classified, cue examples, and instruction information; the instruction information is used to guide the large language model to refer to the cue examples and determine the classification result of the EEG signal to be classified. The above example prompt was obtained in the following way: EEG signals under different categories are acquired, and feature extraction is performed on each to form a sample pool carrying category labels. The sample pool was divided according to category labels to obtain candidate sample sets under different EEG signal categories; Under each EEG signal category: For each sample in the corresponding candidate sample set, select the K most similar samples from the sample pool to form the corresponding nearest neighbor set, and calculate the proportion of samples in the nearest neighbor set that have the same category label as the sample, as the purity value of the sample; For each EEG signal category, select the N samples with the highest purity values from its candidate sample set as the example sample set for that EEG signal category; K≥1; N≥1; The sample sets under each category of EEG signal are combined to form the prompt example.
[0007] More preferably, when the EEG signal is a signal collected during a motor imagery task, a common spatial pattern algorithm is used to extract features from the EEG signal; When the EEG signal is a signal collected during a sleep stage classification task, the energy spectral density of the EEG signal is used as its characteristic.
[0008] More preferably, the structured prompt information further includes: professional knowledge in the field of electroencephalography (EEG); the prompt information is used to guide the large language model to determine the classification result of the EEG signal to be classified based on the professional knowledge in the field of EEG and with reference to the prompt example.
[0009] More preferably, the content of each part in the structured prompt information is structurally divided into pairs using separators.
[0010] More preferably, K is 1 / 16 of the number of samples in the sample pool.
[0011] More preferably, N=2.
[0012] In a second aspect, the present invention provides an electroencephalogram (EEG) signal classification system, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor executes the EEG signal classification method provided in the first aspect of the present invention when executing the computer program.
[0013] Thirdly, the present invention also provides a computer-readable storage medium comprising a stored computer program, wherein the computer program, when executed by a processor, controls the device containing the storage medium to perform the electroencephalogram (EEG) signal classification method provided in the first aspect of the present invention.
[0014] Fourthly, the invention also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the EEG signal classification method provided in the first aspect of the invention.
[0015] In summary, the above-described technical solutions conceived in this invention can achieve the following beneficial effects: This invention provides a method for classifying electroencephalogram (EEG) signals. First, features are extracted from the EEG signals to be classified, resulting in a compact and discriminative feature representation. Then, a structured cue information system is constructed, including the features of the EEG signals to be classified and cue examples. This system is input into a large language model to obtain the signal classification result. This invention innovatively overcomes the limitation of existing technologies where a single model can only handle a single paradigm or task. Through a purity-guided mechanism, the most representative cue examples are selected. These examples contain the most typical and representative samples within each classification category, facilitating the large language model's differentiation between different categories and maximizing its contextual learning capabilities. It is applicable to various tasks, exhibits strong generalization, and achieves efficient and universal classification of EEG signals. Simultaneously, this invention does not require adjusting the parameters of the large model and is compatible with both open-source and closed-source large language models, maximizing the powerful capabilities of large language models while minimizing computational costs and training and deployment costs. Attached Figure Description
[0016] Figure 1 This is a flowchart illustrating the electroencephalogram (EEG) signal classification method provided in an embodiment of the present invention. Figure 2 This is a schematic diagram of the format of the structured prompt information provided in an embodiment of the present invention; Figure 3a A comparison chart of token consumption between the EEG signal classification method provided by this invention and the traditional method of EEG signal classification using a large language model; Figure 3b A comparison chart of query counts between the EEG signal classification method provided by this invention and the traditional method of classifying EEG signals using a large language model; Figure 3c The figure shown is a comparison of the computational costs of the EEG signal classification method provided by this invention and the traditional method of classifying EEG signals using a large language model. Figure 4 This includes all dataset information involved in the experiments of this invention; Figure 5 The average classification accuracy (%) of the EEG signal classification method provided in this invention compared with five baselines on the BNCI2014001 dataset; Figure 6 The average classification accuracy (%) of the EEG signal classification method provided by this invention is compared with that of three CNN architecture models and two CNN-Transformer architecture models. Detailed Implementation
[0017] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.
[0018] To achieve the above objectives, in a first aspect, the present invention provides a method for classifying electroencephalogram (EEG) signals, comprising: Feature extraction of EEG signals to be classified; Structured prompts are constructed and input into a large language model to obtain the classification results of the EEG signals to be classified. The structured cue information includes: features of the EEG signal to be classified, cue examples, and instruction information; the instruction information is used to guide the large language model to refer to the cue examples and determine the classification result of the EEG signal to be classified. The above example prompt was obtained in the following way: EEG signals under different categories are acquired, and feature extraction is performed on each to form a sample pool carrying category labels. The sample pool was divided according to category labels to obtain candidate sample sets under different EEG signal categories; Under each EEG signal category: For each sample in the corresponding candidate sample set, select the K most similar samples from the sample pool to form the corresponding nearest neighbor set, and calculate the proportion of samples in the nearest neighbor set that have the same category label as the sample, as the purity value of the sample; For each EEG signal category, select the N samples with the highest purity values from its candidate sample set as the example sample set for that EEG signal category; K≥1; N≥1; The sample sets under each category of EEG signal are combined to form the prompt example.
[0019] It should be noted that any existing feature extraction method can be used when extracting EEG signals, such as CNN, DNN, etc., and there is no limitation here.
[0020] Preferably, a task-related feature extraction method is used to extract features from the signal. For example, when the EEG signal is collected during a motor imagery task, the Common Spatial Pattern Algorithm (CSP algorithm) is used to extract features from the EEG signal. When the EEG signal is collected during a sleep stage classification task, the energy spectral density of the EEG signal is used as its feature.
[0021] It should be noted that there are various methods for measuring sample similarity, such as calculating the Euclidean distance or cosine similarity between samples, and no limitation is made here; the method of calculating the Euclidean distance between samples is preferred.
[0022] Preferably, in an optional implementation, the structured prompt information further includes: professional knowledge in the field of electroencephalography (EEG); the prompt information is used to guide the large language model to determine the classification result of the EEG signal to be classified based on the professional knowledge in the field of EEG and with reference to the prompt example.
[0023] In one alternative implementation, the components of the structured prompt information (characteristics of the EEG signal to be classified, prompt examples, professional knowledge in the field of EEG, and instruction information) are structurally divided into pairs using separators or special symbols.
[0024] It should be noted that K and N can be determined based on experience according to the specific task and sample pool size. Preferably, in one optional implementation, K is 1 / 16 of the number of samples in the sample pool and N=2.
[0025] It should be noted that the above-mentioned large language model can be any existing large language model, such as DeepSeek series models, GPT series models, LLaMA, Qwen, T5, etc., without any limitation.
[0026] In summary, this invention provides a large-model-based EEG signal classification method that can efficiently adapt to multiple paradigm tasks. This method innovatively overcomes the limitation of existing technologies where a single model can only handle a single paradigm or task. Through a purity-guided mechanism, it selects the most representative sample examples, maximizing the contextual learning ability of the large model, thereby achieving efficient decoding and classification of downstream tasks. This invention does not require adjustment of the large model parameters, is compatible with both open-source and closed-source models, and achieves maximum utilization of the powerful capabilities of large language models while minimizing computational costs and training and deployment costs.
[0027] To further illustrate the electroencephalogram (EEG) signal classification method provided by this invention, a specific embodiment is described in detail below: It should be noted that how to efficiently embed high-dimensional physiological signals into text prompts suitable for LLM processing is one of the key issues in realizing LLM-based EEG signal decoding.
[0028] Existing literature has explored methods for combining numerical information with language models, where numerical values typically possess clear semantic meaning and are therefore easily expressed in language. However, EEG signals lack this inherent semantic characteristic. For example, in clinical records, "16" might represent a patient's age, while in EEG data, it might simply represent the voltage amplitude at a specific time point, lacking a clear semantic meaning.
[0029] Furthermore, EEG signals have high temporal density and high dimensionality. Directly inputting this dense and unstructured data into LLM will lead to excessive token consumption, thus limiting the model's ability to extract effective features. At the same time, EEG signals also have problems such as non-stationarity, significant inter-subject differences, and low signal-to-noise ratio, further increasing the difficulty of direct analysis based on LLM.
[0030] In addition, without updating the model parameters, if existing large language models are used directly for EEG signal classification, examples often need to be selected independently, resulting in high computational overhead and high inference latency.
[0031] To solve the above problems, such as Figure 1 As shown, this embodiment provides a brainwave signal classification method (denoted as PGAP), which utilizes the context learning capability of LLM to achieve efficient classification of EEG signals without gradient updates. This method mainly consists of three core modules: a feature extraction module, a purity-guided sample selection module, and a prompt construction and reasoning module.
[0032] 1. The raw EEG signal is high-dimensional, noisy, and lacks obvious semantic structure, therefore, domain feature extraction is required before inputting it into the LLM. This embodiment defines feature extraction methods suitable for different brain-computer interface paradigms (motor imagery, sleep staging, epilepsy detection) according to their respective paradigms (i.e., tasks).
[0033] (1) Motion visualization: Given a multi-channel EEG signal sample ,in It is a category index. It is a sample index within the same type of data. It refers to the number of channels. This represents the number of time points in the sample. An 8–24Hz bandpass filter is used, and the frequency range is divided into four sub-bands. The signal in each sub-band is obtained by bandpass filtering.
[0034] in, This represents the range of the kth frequency band.
[0035] Then, the spatial filtering matrix is obtained by maximizing / minimizing the following objective function. :
[0036] in, and These are the mean spatial covariance matrices of all EEG samples from the two classes, respectively. Then, a spatial filtering matrix can be used... Projecting the original samples yields the common spatial pattern (CSP) features of the sub-bands:
[0037] Finally, by summarizing the CSP features of the four sub-bands and each sub-band, all feature values are obtained.
[0038] (2) Sleep stage classification: Multi-band power spectral density (PSD) characteristics were used. The average power spectrum of each channel was calculated in the following five typical frequency bands:
[0039] The first EEG signal sample The first channel and the first The power spectral density characteristics of each frequency band are defined as follows:
[0040] in, The first EEG signal sample Each channel at frequency The power spectral density estimate at that location, Indicates the frequency band range. Frequency band range The number of frequency points within the range. Concatenating all channels and frequency bands yields the complete feature vector:
[0041] Used for selecting subsequent prompt examples.
[0042] (3) Epilepsy detection: The EEG signal is first decomposed into five standard frequency bands by digital bandpass filtering:
[0043] For the Class, No. Next test, next channel and frequency band The signal after bandpass filtering is defined as Then the instantaneous power of the channel in this frequency band is:
[0044] Its time-average power is:
[0045] The total power of each frequency band is obtained by averaging across all channels:
[0046] Ultimately, each trial The eigenvectors are defined as follows:
[0047] This representation can concisely describe the energy variation characteristics of different frequency bands and effectively characterize the dynamic energy distribution of epileptic seizures.
[0048] 2. Purity-Guided Sample Selection Module The goal of this module is to select a set of the most representative "prototype samples" from the entire labeled sample pool as cue example input LLMs to activate their few-shot reasoning capabilities. In this embodiment, a total of M samples are selected as example input LLMs, and there are a total of C categories to be classified.
[0049] (1) For each sample In the sample pool, the proportion of samples of the same type among its K nearest neighbors is calculated using Euclidean distance, and this proportion is defined as the local homolabel purity.
[0050] in, Indicates sample The set of K Euclidean nearest neighbors; This is an indicator function that takes the value when the condition is true. Otherwise take ; and Samples and his neighbors Category tags.
[0051] (2) Sort by purity fraction in descending order, and select the top in each category. The final hint example is composed of several samples. .
[0052] 3. Hint Construction and Reasoning Module The goal of this module is to transform selected typical samples into text templates (i.e., structured prompts) that conform to the understanding of a large language model by embedding text. This information is then input into the large language model to maximize its comprehension capabilities and guide it through downstream tasks according to the instructions in the prompts, returning output results in the required format. The prompt text should include the following parts: (1) Task description: Clearly define the model objective and describe it in detail, such as "Given an EEG feature vector, determine its category"; (2) Contextual information: Provides the task context, a description of the data (i.e., the characteristics of the EEG signals to be classified), and suggested alternative methods; (3) Example prompt: It consists of high-purity samples selected by the purity-guided sample selection module mentioned above, and contains several "feature-label" pairs; (4) Prediction instructions: Specify the output format (such as a JSON list) and syntax constraints, requiring the model to output in a strict format.
[0053] like Figure 2 The image shown is a schematic diagram of the structured prompt information format constructed in this embodiment.
[0054] In summary, this embodiment aims to address the shortcomings of existing LLM-based EEG signal decoding methods in terms of high-dimensional physiological data representation, context-learning sample selection, and computational efficiency. Considering the high temporal density, low semantic content, and cross-subject variability of EEG signals, a purity-guided large language model-based active cue EEG signal decoding method is proposed. This method can achieve general and efficient EEG signal classification across multiple paradigms and tasks without updating model parameters.
[0055] To further verify the performance of the EEG signal classification method provided in this embodiment, the following detailed description is provided in conjunction with specific experiments: The computational performance of the electroencephalogram signal classification method (PGAP) provided by this invention is compared with that of traditional methods using large language models for electroencephalogram signal classification; specifically, for example... Figure 3a The image shows a comparison of token consumption between the EEG signal classification method provided by this invention and the traditional method using a large language model for EEG signal classification; as shown... Figure 3b The image shows a comparison of query counts between the EEG signal classification method provided by this invention and the traditional method using a large language model for EEG signal classification; as shown in the figure. Figure 3c The figure shown is a comparison of the computational costs of the EEG signal classification method provided by this invention and the traditional method using a large language model for EEG signal classification. It is a comprehensive comparison. Figure 3a and Figure 3bThe results show that, for batches of EEG signal test samples, this invention only requires obtaining one prompt instance (i.e., one-time example selection), denoted as one-time selection. Traditional methods for EEG signal classification using large language models require selecting an example for each test sample when dealing with batches of EEG signal samples, denoted as per-instance selection. As can be seen from the figure, the computational performance of the EEG signal classification method provided by this invention is far superior to that of traditional methods using large language models for EEG signal classification.
[0056] Furthermore, the present invention was experimentally validated on seven datasets across three paradigms: motor imagery, sleep staging, and epilepsy detection; among which... Figure 4 It displays all the dataset information involved in the experiment. Figure 5 The average classification accuracy (%) of the EEG signal classification method provided in this invention is shown in comparison with five baselines on the BNCI2014001 dataset. Figure 6 The figure shows a comparison of the average classification accuracy (%) of the EEG signal classification method provided by this invention with three CNN architecture models and two CNN-Transformer architecture models. As can be seen from the figure, the EEG signal classification method provided by this invention outperforms the five existing baseline methods in both signal classification accuracy and robustness.
[0057] In a second aspect, the present invention provides an electroencephalogram (EEG) signal classification system, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor executes the EEG signal classification method provided in the first aspect of the present invention when executing the computer program.
[0058] The related technical solutions are the same as the EEG signal classification method provided in the first aspect of this invention, and are not limited here.
[0059] Thirdly, the present invention also provides a computer-readable storage medium comprising a stored computer program, wherein the computer program, when executed by a processor, controls the device containing the storage medium to perform the electroencephalogram (EEG) signal classification method provided in the first aspect of the present invention.
[0060] The related technical solutions are the same as the EEG signal classification method provided in the first aspect of this invention, and are not limited here.
[0061] Fourthly, the invention also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the EEG signal classification method provided in the first aspect of the invention.
[0062] The related technical solutions are the same as the EEG signal classification method provided in the first aspect of this invention, and are not limited here.
[0063] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for classifying electroencephalogram (EEG) signals, characterized in that, include: Feature extraction of EEG signals to be classified; Structured prompts are constructed and input into a large language model to obtain the classification results of the EEG signals to be classified. The structured prompt information includes: features of the EEG signal to be classified, prompt examples, and instruction information; the instruction information is used to guide the large language model to determine the classification result of the EEG signal to be classified by referring to the prompt examples. The example prompt is obtained in the following way: EEG signals under different categories are acquired, and feature extraction is performed on each to form a sample pool carrying category labels. The sample pool is divided according to category labels to obtain candidate sample sets under different EEG signal categories; Under each EEG signal category: for each sample in the corresponding candidate sample set, select the K most similar samples from the sample pool to form the corresponding nearest neighbor set, and calculate the proportion of samples in the nearest neighbor set that have the same category label as the sample, as the purity value of the sample; For each EEG signal category, select the N samples with the highest purity values from its candidate sample set as the example sample set for that EEG signal category; K≥1; N≥1; The example prompts are composed of sample sets from each category of EEG signals.
2. The EEG signal classification method according to claim 1, characterized in that, When the EEG signal is collected during a motor imagery task, the common spatial pattern algorithm is used to extract features from the EEG signal. When the EEG signal is a signal collected during a sleep stage classification task, the energy spectral density of the EEG signal is used as its characteristic.
3. The EEG signal classification method according to claim 1, characterized in that, The structured prompt information also includes: professional knowledge in the field of electroencephalography (EEG); the instruction information is used to guide the large language model to determine the classification result of the EEG signal to be classified based on the professional knowledge in the field of EEG and with reference to the prompt example.
4. The EEG signal classification method according to any one of claims 1-3, characterized in that, The structured prompt information is structurally divided into pairs of parts using separators.
5. The EEG signal classification method according to any one of claims 1-3, characterized in that, K is 1 / 16 of the number of samples in the sample pool.
6. The EEG signal classification method according to any one of claims 1-3, characterized in that, N=2。 7. A brainwave signal classification system, characterized in that, include: A memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the EEG signal classification method according to any one of claims 1-6.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein when the computer program is run by a processor, it controls the device containing the storage medium to perform the electroencephalogram (EEG) signal classification method according to any one of claims 1-6.
9. A computer program product, characterized in that, It includes a computer program / instruction that, when executed by a processor, implements the EEG signal classification method according to any one of claims 1-6.