A lightweight eeg classification and reconstruction method based on multi-task learning

By constructing a lightweight shared encoder and a multi-task learning method for EEG classification and reconstruction, the accuracy fluctuation and deployment challenges of EEG decoding models in cross-sample and cross-subject scenarios were solved, enabling efficient and real-time EEG signal analysis on resource-constrained devices.

CN123179090APending Publication Date: 2026-11-27NORTH ELECTRON RES INST ANHUI CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611563459.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-10
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing EEG decoding models are prone to fluctuations in classification accuracy across samples and subjects, and are difficult to deploy in a lightweight and real-time manner on resource-constrained wearable devices. Existing multi-task methods have failed to effectively balance the computational complexity of the model with the real-time requirements.

Method used

A lightweight EEG classification and reconstruction method based on multi-task learning is adopted. A network architecture consisting of a lightweight shared encoder, a classification branch, and a reconstruction branch is constructed. Feature extraction is performed through one-dimensional temporal convolution and depthwise convolution. The MSSTMamba module and content-aware upsampling module are combined to realize feature extraction and signal reconstruction. A weighted joint loss function is used for training. During deployment, the reconstruction branch is removed and only the lightweight shared encoder and classification branch are retained on the terminal.

Benefits of technology

It achieves low-latency, high-precision EEG signal classification on resource-constrained devices, improves the model's cross-sample generalization ability and signal reconstruction fidelity, and meets the real-time interaction requirements of wearable devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure FT_1
    Figure FT_1
  • Figure FT_2
    Figure FT_2
  • Figure SMS_1
    Figure SMS_1
Patent Text Reader

Abstract

The application discloses a kind of based on multi-task learning's light weight electroencephalogram classification and reconstruction method, belongs to brain-computer interface and electroencephalogram signal processing technical field.The method constructs the network architecture consisting of light weight shared encoder, classification branch and reconstruction branch;When training, electroencephalogram signal is input into shared encoder to obtain hidden vector, and is sent into classification branch and reconstruction branch in parallel, to jointly train with classification loss and reconstruction loss weighting, utilize reconstruction task to constrain encoder to retain discriminative neural features;When deployment, peel off reconstruction branch, wearable terminal only deploys encoder and classification branch to realize real-time classification, and reconstruction branch is deployed in external computing power equipment to complete high-fidelity reconstruction.Reconstruction branch is provided with MSS Mamba module and content-aware upsampling module, respectively used for extracting multi-band space-time frequency features and dynamically generating adaptive convolution kernel.The terminal reasoning parameter quantity of the application is low, time delay is small, adapts resource limited wearable equipment, and improves electroencephalogram decoding generalization ability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the fields of brain-computer interface, EEG signal processing and artificial intelligence technology, and specifically relates to a lightweight EEG signal classification and reconstruction method based on multi-task learning. Background Technology

[0002] Electroencephalography (EEG) is a non-invasive neural signal acquisition technology that uses electrodes to collect the electrical activity of the brain's nerves. It is characterized by being non-invasive, real-time, and providing rich information. With the development of brain science, neural engineering, and artificial intelligence, brain-computer interfaces (BCIs) based on EEG signals are gradually becoming an important technological means to connect the human brain with external devices. Non-invasive BCIs collect and analyze neural signals such as EEG signals to extract information that reflects the user's intentions, cognitive state, or neural activity characteristics, and convert this information into control commands that can be recognized and executed by external systems such as computers, robots, and assistive devices. They have broad application prospects in areas such as motor function assistance, neurorehabilitation, human-computer interaction, and brain state detection.

[0003] Currently, the practical application performance of non-invasive brain-computer interfaces (BCIs) is mainly constrained by two core bottlenecks. First, the inherent temporal non-stationarity and low signal-to-noise ratio of EEG signals place stringent demands on the generalization and adaptation capabilities of EEG decoding models. When using lightweight, single-task networks, the model's classification accuracy is prone to fluctuations across different samples and subjects. Second, non-invasive BCIs are mostly deployed in wearable EEG devices and other terminals with limited computing power and power consumption. These systems have a strong real-time requirement, and model inference latency directly determines the smoothness of interaction and user experience. Therefore, the decoding network must achieve an extremely lightweight design. Thus, how to reduce model computational complexity while ensuring decoding performance, and achieve lightweight and real-time EEG signal analysis, has become a key issue driving the development of practical BCI applications.

[0004] In recent years, multi-task learning schemes have received increasing attention in the field of EEG decoding. By sharing feature representation spaces and jointly optimizing multiple related tasks, they can improve the model's feature extraction capabilities and cross-sample generalization performance. However, existing multi-task methods mainly focus on improving EEG feature representation capabilities and decoding performance through auxiliary tasks, with insufficient consideration for model lightweighting and practical deployment requirements. On the one hand, some methods emphasize performance improvement in classification tasks, introducing complex network structures that increase the number of parameters and computational overhead. On the other hand, some methods rely on complete multi-task frameworks, still requiring multiple task branches during the inference phase, consuming terminal computing power and limiting their application in resource-constrained and real-time-critical brain-computer interface devices. Current technology lacks an EEG decoding scheme that maintains the advantages of multi-task collaboration while achieving efficient and lightweight deployment through structural simplification and deployment decoupling. Summary of the Invention

[0005] The purpose of this invention is to provide a lightweight EEG classification and reconstruction method based on multi-task learning to solve the problems of insufficient generalization ability, computational complexity and difficulty in lightweight real-time deployment on resource-constrained wearable devices of existing EEG decoding models. At the same time, it also solves the problem of how to reduce the loss of detail in the signal reconstruction process and improve the reconstruction fidelity of compressed EEG signals after the information is compressed by the lightweight encoder.

[0006] To achieve the above objectives, the present invention adopts the following technical solution.

[0007] This invention provides a lightweight EEG classification and reconstruction method based on multi-task learning. The method constructs a network architecture consisting of a lightweight shared encoder, a classification branch, and a reconstruction branch. The lightweight shared encoder is connected to both the classification and reconstruction branches. The reconstruction branch includes an MSSTMamba module and a content-aware upsampling module. During training, EEG signals are input to the lightweight shared encoder for feature extraction and temporal compression, outputting latent vectors. These latent vectors are input in parallel to the classification and reconstruction branches, simultaneously executing classification and signal reconstruction tasks. A weighted joint loss function is used to jointly optimize and train the encoder, classification branch, and reconstruction branch, utilizing the reconstruction task to constrain the encoder to retain discriminative neural features. During deployment, the reconstruction branch is separated, and only the lightweight shared encoder and the classification branch are deployed on a wearable terminal to complete real-time EEG signal classification and inference. When signal reconstruction is required, the latent vectors are uploaded to an external computing device, and the independently deployed reconstruction branch is invoked to complete high-fidelity EEG signal reconstruction.

[0008] Based on the above technical solutions, the following further technical solutions are proposed: The lightweight shared encoder employs a lightweight design combining one-dimensional temporal convolution and depthwise convolution. First, one-dimensional temporal convolution extracts EEG temporal features. Then, depthwise convolution is used to perform independent spatial filtering on each electrode channel to learn frequency-related spatial patterns. Afterward, average pooling is used for temporal downsampling compression, followed by temporal convolution, batch normalization, ELU activation, and Dropout regularization to finally output a compact latent vector. This encoder structure achieves lightweight feature extraction by reducing the number of parameters and computational overhead.

[0009] In one implementation, the one-dimensional temporal convolution has a kernel size of (1, 65) and a stride of 2. This kernel length can cover the main μ rhythm (8-13Hz) and β rhythm (13-30Hz) information in the motor imagery task, and the number of output temporal feature channels is 64. The depthwise convolution has a kernel size of (Ch, 1), where Ch is the number of EEG channels, and the number of parameters is only 1 / Ch of the conventional convolution. The average pooling has a kernel size of 2 and a stride of 2. The feature refinement temporal convolution has a kernel size of 33, a stride of 2, and padding of 7, and the number of output temporal feature channels is compressed to 16.

[0010] The classification branch performs global average pooling on the latent vectors output by the encoder to compress the temporal and spatial dimensions to further reduce computational overhead; the pooled features are flattened into one-dimensional vectors and Dropout is applied to suppress overfitting caused by EEG noise; finally, the processed features are input into a fully connected layer to map the class prediction results of the EEG signals.

[0011] The MSSTMamba module integrates multi-scale modeling and channel attention mechanisms, and leverages Mamba's advantage in capturing long-range temporal dependencies to extract multi-scale spatiotemporal frequency features of EEG from latent vectors. The MSSTMamba module includes a multi-scale grouped convolutional unit, a Mamba temporal modeling unit, and a channel attention calibration unit. The multi-scale grouped convolutional unit divides the input features into multiple groups along the channel dimension. Each group uses one-dimensional convolution with different kernel sizes to extract EEG rhythm features of different frequency bands. Then, the features of each group are concatenated and fused. The Mamba temporal modeling unit expands the channel dimension of the concatenated and fused features through linear mapping, splitting them into feature branches and gated branches. The feature branches are input into the state space model after one-dimensional convolution and SiLU activation to capture long-range temporal dependencies. The gated branches are activated by SiLU to generate dynamic weights and multiplied element-wise with the output of the feature branches to achieve adaptive modulation. The original channel dimension is then restored through linear mapping. The channel attention calibration unit performs global average pooling on the Mamba output along the time dimension, generates channel weights through compression-expansion mapping, and calibrates the features channel by channel to compensate for the loss of cross-channel information interaction caused by grouped convolution.

[0012] In one implementation, for EEG signals with a sampling rate of 250Hz, multi-scale grouped convolutional units are divided into four groups with kernel sizes of 65, 33, 19 and 11, respectively, corresponding to low-frequency EEG rhythms (4-8Hz), μ rhythms (8-13Hz), low β rhythms (13-20Hz) and high β rhythms (20-30Hz), to extract temporal patterns in different frequency ranges in a hierarchical manner.

[0013] The content-aware upsampling module dynamically generates convolutional kernels based on input features, enabling the upsampling process to adaptively focus on information-rich regions. This module includes a dynamic kernel generation submodule and a feature reorganization submodule. The dynamic kernel generation submodule receives the input feature map, first performing channel compression through pointwise convolution to reduce the number of parameters and computational overhead, then expanding the channel dimension through one-dimensional convolution before reshaping and normalizing along the kernel dimension to obtain a content-adaptive upsampling convolutional kernel. The feature reorganization submodule performs bilinear interpolation on the input feature map to obtain preliminary upsampling features, extracts the local convolution weights corresponding to the upsampling convolutional kernel for each output position, and performs local weighted summation on the preliminary upsampling features, thereby integrating local contextual information while achieving upsampling and adaptively recovering fine-grained detailed features.

[0014] During the training phase, a weighted joint loss function is used. This joint loss is a weighted sum of the classification cross-entropy loss and the reconstruction mean squared error loss. The classification cross-entropy loss is used to constrain the classification task, while the reconstruction mean squared error loss is used to constrain the signal reconstruction task. The two are weighted by a balancing coefficient. Backpropagation is performed uniformly through the joint loss to synchronously update all parameters of the encoder, classification branch, and reconstruction branch.

[0015] This invention also provides a lightweight EEG classification and reconstruction system based on multi-task learning, comprising: a lightweight shared encoder for receiving EEG signals and performing feature extraction and temporal compression, outputting latent vectors; a classification branch connected to the output of the lightweight shared encoder for outputting classification and recognition results of the EEG signals based on the latent vectors; and a reconstruction branch connected to the output of the lightweight shared encoder, including an MSSTMamba module and a content-aware upsampling module for reconstructing high-fidelity EEG signals based on the latent vectors. During training, the classification branch and the reconstruction branch simultaneously participate in joint loss calculation. During deployment, the lightweight shared encoder and the classification branch are loaded onto a wearable terminal to complete real-time inference, while the reconstruction branch is independently deployed on an external computing device.

[0016] Due to the adoption of the above technical solution, the present invention has the following beneficial effects: 1. Lightweight real-time deployment advantages: The encoder and classification branches adopt a simplified structure of one-dimensional convolution + deep convolution, without complex temporal operations, which greatly reduces the number of parameters and computation, making it suitable for low-power, low-computing-power wearable EEG devices with extremely low inference latency; it adopts a joint training and decoupled deployment architecture, so the reconstruction branch does not occupy the terminal's computing power, taking into account both real-time interaction and signal reconstruction requirements.

[0017] 2. Higher accuracy and stronger generalization of EEG classification and recognition: Relying on the multi-task collaborative constraints of reconstruction auxiliary task and classification task, the encoder is guided to automatically filter out irrelevant redundant noise, fully retain the EEG feature representation with discriminative power, alleviate the performance fluctuation caused by individual differences and temporal drift of EEG signals, and improve the model's stable recognition ability across samples and subjects.

[0018] 3. Excellent EEG reconstruction fidelity: Based on MSST-Mamba multi-scale modeling combined with channel attention mechanism, it completely preserves the details of neural rhythms in different frequency bands; the module can adaptively adapt to the local oscillation changes of various EEG signals, while achieving efficient compression of EEG signals on the device side, reducing data transmission bandwidth and storage overhead, effectively reducing the loss of feature information, and significantly improving the fidelity of the compressed signal restoration, making it suitable for scenarios such as remote data backhaul of wearable terminals and cloud archiving of batch EEG data. Attached Figure Description

[0019] Figure 1 This is a diagram illustrating the overall architecture of the lightweight EEG classification and reconstruction method based on multi-task learning proposed in this invention. Figure 1 (a) is a schematic diagram of the encoder structure. Figure 1 (b) is a schematic diagram of the restructured branch structure. Figure 1 (c) is a schematic diagram of the classification branch structure. Figure 1 (d) is a schematic diagram of the internal structure of the MSSTMamba module; Figure 2 This is an architecture diagram of the content-aware upsampling module of this invention. Detailed Implementation

[0020] The present invention will be further described in detail below with reference to the accompanying drawings. It should be understood that the following embodiments are only used to illustrate the present invention and are not intended to limit the scope of protection of the present invention.

[0021] Example 1

[0022] like Figure 1As shown, the method proposed in this invention consists of three main components: an encoder (Fig. 1(a)), a reconstruction branch (Fig. 1(b)), and a classification branch (Fig. 1(c)). The encoder first extracts features and performs temporal compression on the input EEG signal to obtain a latent vector with compact representation capabilities. Subsequently, the latent vector is transmitted in parallel to the classification branch and the reconstruction branch, which are used for EEG task category prediction and high-fidelity EEG signal reconstruction, respectively. Considering that the deployment requirements of different components in actual brain-computer interface systems vary, the encoder is designed for resource-constrained wearable devices with limited memory and computing power, while the classification branch needs to meet strict real-time inference requirements. In contrast, the reconstruction branch can be deployed on external devices with sufficient computing resources. Therefore, this invention adopts an asymmetric architecture: the encoder and classification branch adopt a lightweight structure, while computationally intensive operations are mainly allocated to the reconstruction branch. To compensate for the potential loss of representation capabilities that may be caused by the lightweight encoder, the reconstruction branch integrates the proposed multi-scale spatiotemporal Mamba (MSSTMamba) module and content-aware upsampling module. These modules are designed to enhance the ability to extract and recover spatiotemporal frequency representations from compressed EEG features, thereby improving reconstruction fidelity while maintaining the overall lightweight deployment capability of the brain-computer interface system.

[0023] 1. Encoder and Classification Branches To reduce encoder complexity while maintaining effective feature extraction capabilities, this invention employs a lightweight design combining temporal convolution and depthwise convolution. First, a one-dimensional temporal convolution of size (1, 65) is used to extract EEG temporal features. This convolutional kernel length covers the main μ (8–13 Hz) and β (13–30 Hz) rhythmic information in motion visualization tasks. Subsequently, a depthwise convolution of size (Ch, 1) is used to perform independent spatial filtering on each temporal feature map (Ch is the number of channels), learning frequency-related spatial patterns while reducing the number of model parameters and computational overhead. After feature downsampling and temporal compression through average pooling, further feature refinement is achieved through temporal convolution, combined with batch normalization, ELU, and Dropout to improve model stability and generalization ability. Finally, the encoder maps the input EEG signal into a compact latent vector representation, providing shared features for subsequent classification and reconstruction tasks.

[0024] In the classification branch, considering the high real-time requirements of EEG classification tasks, this invention first performs pooling on the encoder output features to further reduce feature dimensionality and computational overhead. Subsequently, the pooled features are flattened, and a Dropout operation is introduced to effectively alleviate overfitting and improve the model's generalization ability. Finally, the processed features are input into a fully connected layer to achieve the final class prediction. 2. Refactor the branch The design of lightweight encoders can limit a model's ability to extract complex spatiotemporal frequency features from EEG signals. To address this issue, this invention introduces an enhanced decoder structure in the reconstruction branch. By providing auxiliary supervision through the reconstruction task, the proposed method enables the encoder to learn more comprehensive and discriminative EEG representations, while improving the reconstruction quality of compressed signals. Specifically, two key modules are introduced in the decoding stage. First, the proposed MSSTMamba module integrates multi-scale modeling and channel attention mechanisms, leveraging Mamba's strength in capturing long-range temporal dependencies to effectively extract spatiotemporal frequency features from the latent representation. Second, an adaptive upsampling module is proposed, which dynamically generates convolutional kernels based on input features to achieve more accurate feature recovery. Compared to traditional transposed convolution methods using fixed kernels and linear interpolation methods lacking learnable capabilities, the proposed strategy better adapts to local variations in EEG signals.

[0025] As shown in Figure 1(b), the reconstruction branch consists of two MSSTMamba modules and n alternating upsampling layers. Guided by global spatiotemporal frequency information, this branch gradually recovers the details of the EEG signal and promotes the encoder to learn more discriminative latent representations through multi-task joint optimization. Finally, channel convolutional layers are used to restore the output to the original EEG signal dimension.

[0026] 3. Introduction to the MSSTMamba Module The structure of the MSTMamba module is shown in Figure 1(d). To efficiently extract features from different rhythmic frequency bands, this invention employs multi-scale grouped convolution for feature modeling of the input feature tensor B × C × Ch × T (where B represents the batch size, C represents the number of feature channels, Ch represents the number of EEG electrode channels, and T represents the time length). Specifically, the features are first divided into four groups along the channel dimension, with each group having a size of B × C / 4 × Ch × T. Subsequently, based on the EEG sampling rate, one-dimensional convolution of different scales is used to perform temporal modeling on multiple groups of features to capture rhythmic features at different time scales. Taking a sampling rate of 250 Hz as an example, convolution kernels with sizes of (1×65), (1×33), (1×19), and (1×11) are used for feature extraction, corresponding to different temporal receptive fields, effectively covering relevant frequency band information such as low-frequency rhythms (4–8 Hz), μ rhythms (8–13 Hz), and β rhythms (13–30 Hz) in EEG tasks. This design reduces computational overhead while extracting temporal patterns across different frequency ranges in a hierarchical manner. The multi-scale features are then concatenated and input into a Mamba module for further modeling.

[0027] The Mamba module adopts the basic Mamba architecture with a lightweight gating structure. First, it expands the feature channel dimension through linear mapping and divides the features into two branches: Feature branch: Local temporal patterns are extracted through one-dimensional convolution, followed by SiLU activation and long-range temporal dependencies captured using a State Space Model (SSM). Gating branch: Features are directly processed through the SiLU activation function to generate dynamic weights. The outputs of the two branches are element-wise multiplied to achieve adaptive modulation based on contextual information, and finally restored to the original channel dimension through linear mapping.

[0028] Since grouped convolutions limit cross-channel information interaction, and the original Mamba module has limited sensitivity to channel-dimensional information, this invention further introduces a channel attention mechanism for enhancement. Specifically, firstly, global average pooling is performed on the feature map along the time dimension to obtain the initial channel response; then, two linear mapping layers W1 and W2 are used in a "compression-expansion" manner, combined with nonlinear functions δ1 and δ2 to generate channel importance weights. Finally, these weights are used to recalibrate the output features of the Mamba module channel by channel. The calculation process is as follows:

[0029] The MSSTMamba module enhances the modeling of EEG spatiotemporal frequency features while maintaining consistency in input and output dimensions. It can be easily integrated into existing frameworks without additional adjustments to the network dimensional structure.

[0030] 4. Content-aware upsampling Existing upsampling methods mainly include interpolation-based upsampling and transposed convolution. Interpolation methods typically rely on fixed mathematical rules for feature expansion, lacking the ability to adaptively model the input content, which may lead to the loss of key features during the detailed reconstruction of EEG signals. Although transposed convolution introduces learnable parameters, it uses a fixed convolution kernel for all samples, making it difficult to adapt to local differences between different EEG samples. To address these limitations, this patent proposes a content-aware upsampling module. This module dynamically generates convolution kernels based on input features, enabling the upsampling process to adaptively focus on information-rich regions, thereby achieving more accurate feature reconstruction. As shown in Figure 2, this module mainly consists of two parts: dynamic kernel generation and feature reorganization.

[0031] 1) Dynamic kernel generation Given a size of Input feature map First, pointwise convolution is applied to reduce the channel dimension to This reduces both the number of parameters and computational cost. A one-dimensional convolution is then used to expand the channel dimension to mk, where m represents the upsampling factor and k represents the kernel size of the dynamically generated convolution. The expanded feature map is then reshaped into k×Ch×(mT) and normalized along the k-dimensional plane to ensure that the sum of the kernel weights is 1, ultimately resulting in a content-adaptive upsampling convolution kernel. Where Ch×mT corresponds to the spatial resolution after upsampling, and k represents the size of the local neighborhood used when calculating each upsampling point.

[0032] 2) Feature recombination First of all Applying bilinear interpolation, we obtain a value of Preliminary upsampling features '.for Any spatial position (i, j) in ′, from Extract the corresponding k-dimensional convolution kernel as adaptive weights. Let Final output The calculation is as follows:

[0033] Where p is summed from -l to l, in this way, the module integrates local context information while performing upsampling, thereby enabling adaptive recovery of fine-grained detailed features.

[0034] Example 2: Specific application of the present invention: This embodiment is adapted to the 250Hz sampling scenario of conventional wearable EEG devices and is suitable for mainstream EEG tasks such as motor imagery, cognitive state recognition, and fatigue recognition.

[0035] like Figure 1 As shown, the overall architecture of the method of this invention consists of four core parts: an encoder, a reconstruction branch, a classification branch, and an MSSTMamba module. The encoder sequentially extracts temporal features and compresses the EEG input signal in the temporal domain, and outputs latent vectors. These latent vectors are then input into the reconstruction branch and the classification branch, respectively, to achieve the classification and high-fidelity reconstruction of the EEG signal.

[0036] (I) Basic Experimental Setup Data configuration: Publicly available EEG datasets and data collected by a self-developed wearable EEG device were used. The EEG sampling rate was fixed at 250Hz, the number of electrode channels Ch=32, and the single sample duration T=1000 points (4s). Data preprocessing only retained bandpass filtering (0.5-45Hz) and baseline drift removal, without any additional complex preprocessing, to fit the real-time acquisition scenario of the device.

[0037] Hardware and Environment: The training end uses GPU computing power, and the deployment end uses a low-computing-power embedded wearable terminal. The training framework uses PyTorch, the batch size is B=32, the optimizer is AdamW, the base learning rate is set to 1e-3, the weight decay is 1e-4, the number of training iterations is 100, and an early stopping strategy is used to prevent overfitting.

[0038] The main symbols involved in this embodiment are defined as follows: B For batch size, C The number of feature channels, Ch This refers to the number of EEG electrode channels. T For the length of time, Cm This represents the number of feature channels after channel compression. m This is the upsampling factor. k To dynamically generate the kernel size of the convolution, mT The time length after upsampling. Xin This is the input feature map for the content-aware upsampling module. Kup For content-adaptive upsampling convolution kernels, Xin' For preliminary upsampling features, XO' For upsampling output features, i The abscissa of the feature space location, j Let l be the ordinate of the feature space location, and l be the radius of the convolution kernel, and l equals ,p For the summation variable of locally weighted summation, Loss For joint losses, LossCE For classification cross-entropy loss, LossMSE This represents the mean square error loss during signal reconstruction.

[0039] Multi-task loss function: A weighted joint loss function is used, the specific formula of which is as follows: Loss = LossCE + λ × LossMSE ,in LossCE The cross-entropy loss is used to constrain the classification task. LossMSE The mean square error loss for signal reconstruction is used; the balance coefficient λ is fixed at 1 to stabilize the gradient update ratio of the two tasks and avoid single task dominating the optimization.

[0040] (ii) Lightweight shared encoder like Figure 1 As shown in (a), the encoder uses a lightweight combination of one-dimensional temporal convolution and depthwise convolution throughout, without fully connected dense computation or complex temporal iteration. The specific layer sequence configuration is as follows: The first step is input normalization, which normalizes the amplitude of the original EEG signal B×32×1000 to [-1,1]. The second step is to perform a one-dimensional temporal convolution (kernel=65, stride=2, padding=0), which outputs 64 temporal feature channels and extracts the core rhythm temporal features from 8-30Hz. The third step is depthwise convolution (kernel=32, stride=1, padding=0), channel-by-channel independent spatial filtering, learning the spatial feature patterns of each electrode, with only 1 / 32 of the parameters of conventional convolution. The fourth step is average pooling (kernel=2, stride=2), which completes time-domain downsampling and signal compression, reducing the time sequence length and the amount of subsequent computation. The fifth step is to refine the features through temporal convolution (kernel=33, stride=2, padding=7), compressing the number of output temporal feature channels to 16. This is combined with batch normalization (BN), ELU activation function, and Dropout=0.2 to complete feature smoothing and regularization constraints.

[0041] The encoder's final output latent vector has a dimension of B×16×100, achieving a compact and effective representation of the original EEG signal.

[0042] (III) Complete Implementation Structure of Classification Branches like Figure 1 As shown in (c), the classification branch is lightweight and computationally efficient throughout, adapting to real-time inference on the terminal. The specific process is as follows: Step 1: Perform global average pooling on the latent vectors output by the encoder to compress the temporal and spatial dimensions; Step 2: Flatten the pooled features into a one-dimensional vector and apply Dropout with a value of 0.3 to suppress overfitting caused by EEG noise; Step 3: Use a two-layer fully connected layer for progressive mapping. The first layer has 128 nodes, and the second layer outputs the corresponding task category (both 4 categories of motion imagination and 2 categories of fatigue state can be universally adapted). Step 4: In the inference stage, only the encoder and classification branches are retained, and no reconstruction branches are calculated. The single-sample inference latency is less than 8ms, which meets the real-time interaction requirements of wearable devices.

[0043] (iv) Reconstructing branches and content-aware upsampling modules like Figure 1 As shown in (b), the reconstruction branch is a computational enhancement branch, deployed in the cloud or on a host computer computing device, and does not occupy terminal resources. The reconstruction branch as a whole consists of two MSSTMamba modules and three content-aware upsampling layers stacked alternately (the number of upsampling layers is...). Figure 1The overall block diagram is marked with *n layers, which can be varied according to the specific compression ratio. Similarly, the upsampling factor is adjustable (the factor K in the upsampling module is adjustable), with upsampling factors of 5, 1, and 2 respectively. The end configuration channel convolutional layer restores the original signal dimension, and the final output reconstructed EEG signal dimension is completely consistent with the input original signal (B×32×1000).

[0044] like Figure 2 As shown, the content-aware upsampling module dynamically generates convolutional kernels based on input features, enabling the upsampling process to adaptively focus on information-rich regions, thereby achieving more accurate feature reconstruction. This module mainly consists of two parts: dynamic kernel generation and feature recombination.

[0045] Dynamic kernel generation: given size C×Ch×T Input feature map X in First, pointwise convolution is applied to reduce the channel dimension to C m ×Ch×T This reduces both the number of parameters and computational cost; subsequently, one-dimensional convolution is used to expand the channel dimension to... mk ,in m Indicates the upsampling factor. k This represents the kernel size for dynamically generated convolutions; subsequently, the expanded feature map is reshaped into... k×Ch ×(mT) The kernel weights are then normalized along the k-dimensional plane to ensure that the sum of the kernel weights is 1, ultimately resulting in a content-adaptive upsampling kernel. K up .in, Ch×mT Corresponding to the spatial resolution after upsampling, k This indicates the size of the local neighborhood used when calculating each upsampling point.

[0046] Feature recombination: First, for X in Applying bilinear interpolation, we obtain a value of k×Ch×(mT) Preliminary upsampling features X in ' ,for X in ' any spatial location (i,j) ,from K up Take the corresponding k The dimensional convolution kernel is used as adaptive weights, let Final output X O ' Calculated by locally weighted summation, where p Summing from -l to l,

[0047] In this way, the module integrates local contextual information while performing upsampling, thereby adaptively recovering fine-grained detailed features.

[0048] (v) MSSTMamba module The MSSTMamba module is the core module of this invention, such as... Figure 1 As shown in (d), this module has consistent input and output dimensions and can be arbitrarily embedded into the decoding network. This embodiment discloses its complete grouping, convolution, temporal modeling, and attention calibration details.

[0049] (1) Multi-scale grouped rhythmic convolution: The input feature B×16×32×T (T=100 in this embodiment, consistent with the temporal dimension of the encoder output latent vector) is equally divided into 4 groups along the channel dimension, with 4 channels in each group. The four groups of features are used for temporal modeling with convolution kernels of different scales to adapt to the full frequency band rhythms of EEG at a sampling rate of 250Hz: the first group of convolution kernels has a size of 65 (adapted to 4-8Hz low frequency rhythms), the second group of convolution kernels has a size of 33 (adapted to 8-13Hz μ rhythms), the third group of convolution kernels has a size of 19 (adapted to 13-20Hz low β rhythms), and the fourth group of convolution kernels has a size of 11 (adapted to 20-30Hz high β rhythms). The stride of each group of convolutions is 1, and the padding is half the kernel size to ensure that the temporal dimension remains unchanged. After single-scale feature extraction, the four groups of feature channels are spliced ​​and fused to achieve collaborative modeling of multi-frequency band rhythmic features.

[0050] (2) Lightweight Mamba dual-branch temporal modeling: The concatenated multi-scale features are extended to expand the channel dimension through linear mapping, and the feature branch and the gated branch are split. The feature branch extracts local temporal features through one-dimensional convolution, and after SiLU activation, it is input into the lightweight state-space model SSM to capture long-term temporal dependencies and adapt to the long-term non-stationary change characteristics of EEG signals; the gated branch is directly activated by SiLU to generate dynamic weights, and performs element-wise adaptive modulation on the output of the feature branch to enhance effective temporal features and suppress ineffective noise features; after the dual branches are fused, the original channel dimension is restored through linear mapping.

[0051] (3) Channel attention calibration: Global average pooling is performed on the Mamba output features along the time dimension to obtain the initial response value of each channel; channel weights are generated by compression-expansion bilinear mapping (W1 dimensionality reduction, W2 dimensionality increase) combined with nonlinear activation functions, and the features are calibrated by channel weight to make up for the problem of missing cross-channel information interaction caused by group convolution, strengthen effective feature channels and suppress redundant noise channels.

[0052] (vi) Decoupling process of training and deployment Training Phase: Raw EEG signals are input into a lightweight encoder to generate latent vectors. These latent vectors are then input in parallel into the classification and reconstruction branches. Classification cross-entropy loss and reconstruction mean squared error loss are calculated simultaneously. A unified backpropagation is performed using the joint loss to iteratively update all parameters of the encoder, classification branch, and reconstruction branch. Through strong supervised constraints on the reconstruction task, the lightweight encoder is forced to retain high-discrimination, high-fidelity neural features during signal compression, addressing the issue of insufficient representational capacity in lightweight models.

[0053] Deployment Phase: After model training converges, the reconstruction branch, MSSTMamba module, and content-aware upsampling module are permanently stripped away, leaving only the encoder and classification branch structures embedded in the wearable terminal. The terminal acquires EEG signals in real time, performs lightweight feature extraction by the encoder, and rapid inference by the classification branch, outputting EEG state recognition results in real time. The entire process involves no intensive computation or high-latency operations. For data archiving, signal replay, and offline analysis, the compressed latent vectors from the terminal can be uploaded to cloud computing devices, and the independently deployed reconstruction branch can be invoked to complete high-fidelity EEG signal reconstruction, achieving an asymmetric deployment architecture of lightweight inference on the terminal and heavy reconstruction in the cloud.

[0054] (vii) Experimental Results and Technical Effects Ablation experiments and comparative experiments were conducted under the same dataset and hardware conditions to quantitatively verify the technical effect of the present invention.

[0055] (1) Lightweight performance: The terminal inference model of this invention has only 0.21M parameters, which is 83.6% lower than the traditional CNN-LSTM model (1.28M) and 75.8% lower than the conventional Mamba EEG model (0.87M); the single-sample inference P99 latency is stable within 8ms, which is far below the 20ms real-time threshold of wearable devices, and the advantages of low power consumption and high real-time performance are significant.

[0056] (2) Classification generalization performance: Compared with the single-task lightweight baseline model, the average classification accuracy across subjects of this invention is improved by 4.2%, which effectively alleviates the performance fluctuations caused by individual differences in EEG, temporal drift and low signal-to-noise ratio, and significantly enhances the generalization ability.

[0057] (3) Signal reconstruction performance: The MSE error of the reconstructed signal of the present invention is reduced by 18.7% compared with the traditional interpolation and transposed convolution decoding methods. The multi-band rhythm details are restored more accurately, and the original brain electrical neural activity characteristics can be accurately restored, meeting the needs of cloud data archiving, signal analysis and fault review scenarios.

Claims

1. A lightweight EEG classification and reconstruction method based on multi-task learning, characterized in that, Includes the following steps: S1. Construct the overall network architecture, which includes a lightweight shared encoder, a classification branch, and a reconstruction branch. The lightweight shared encoder is connected to the classification branch and the reconstruction branch respectively. The reconstruction branch includes an MSSTMamba module and a content-aware upsampling module. S2. During the training phase, the EEG signal is input into the lightweight shared encoder for feature extraction and temporal compression, and the latent vector is output. The latent vector is input into the classification branch and the reconstruction branch in parallel, and the classification task and signal reconstruction task are performed simultaneously. The lightweight shared encoder, the classification branch and the reconstruction branch are jointly optimized and trained using a weighted joint loss function. S3. During the deployment phase, the reconstruction branch is stripped off, and only the lightweight shared encoder and the classification branch are deployed on the wearable terminal to complete the real-time classification and reasoning of EEG signals. When signal restoration is required, the latent vector is uploaded to an external computing device, and the independently deployed reconstruction branch is called to complete the high-fidelity reconstruction of EEG signals.

2. The lightweight EEG classification and reconstruction method based on multi-task learning according to claim 1, characterized in that, The lightweight shared encoder includes, in sequence: Temporal convolutional units use one-dimensional temporal convolution to extract EEG temporal features; Batch normalized units; The depthwise convolutional unit uses depthwise convolution to perform independent spatial filtering on each electrode channel; Batch normalization and ELU activation unit; The downsampling unit uses average pooling to perform temporal downsampling. Dropout regular expression processing unit; The unit consists of a temporal convolutional unit, a batch normalization unit, and an ELU activation unit, which output latent vectors.

3. The lightweight EEG classification and reconstruction method based on multi-task learning according to claim 2, characterized in that, The one-dimensional temporal convolution has a kernel size of (1, 65) and a stride of 2, outputting 64 temporal feature channels; the depthwise convolution has a kernel size of (Ch, 1), where Ch is the number of EEG channels; the average pooling convolution has a kernel size of 2 and a stride of 2; the temporal convolution has a kernel size of 33, a stride of 2, and padding of 7, outputting 16 temporal feature channels.

4. The lightweight EEG classification and reconstruction method based on multi-task learning according to claim 1, characterized in that, The processing procedure for the classification branch is as follows: global average pooling is performed on the latent vector to compress the temporal and spatial dimensions; the pooled features are flattened into a one-dimensional vector and Dropout is applied; the processed features are input into a fully connected layer, and the class prediction result of the EEG signal is mapped and output.

5. A lightweight EEG classification and reconstruction method based on multi-task learning according to claim 1, characterized in that, The MSSTMamba module includes a multi-scale grouped convolutional unit, a Mamba temporal modeling unit, and a channel attention calibration unit. The multi-scale grouped convolutional unit divides the input features into multiple groups along the channel dimension. Each group uses a one-dimensional convolution with different kernel sizes to extract EEG rhythm features of different frequency bands. Then, the features of each group are spliced ​​and fused together. The Mamba temporal modeling unit extends the channel dimension of the spliced ​​and fused features through linear mapping, splitting them into feature branches and gated branches. The feature branches are input into the state space model after one-dimensional convolution and SiLU activation to capture long-range temporal dependencies. The gated branches are activated by SiLU to generate dynamic weights and multiplied element-wise with the output of the feature branches, and then restored to the original channel dimension through linear mapping. The channel attention calibration unit performs global average pooling on the output of the Mamba temporal modeling unit along the time dimension, generates channel weights through compression-expansion mapping, and calibrates the features channel by channel.

6. A lightweight EEG classification and reconstruction method based on multi-task learning according to claim 5, characterized in that, For EEG signals with a sampling rate of 250Hz, the multi-scale grouped convolutional unit is divided into four groups, with kernel sizes of 1×65, 1×33, 1×19 and 1×11, respectively, corresponding to low-frequency EEG rhythms, μ rhythms, β rhythms and high β rhythms.

7. A lightweight EEG classification and reconstruction method based on multi-task learning according to claim 1, characterized in that, The content-aware upsampling module includes a dynamic kernel generation submodule and a feature recombination submodule; The dynamic kernel generation submodule receives the input feature map, performs channel compression through pointwise convolution, expands the channel dimension through one-dimensional convolution, reshapes it, and normalizes it along the convolution kernel dimension to obtain a content-adaptive upsampling convolution kernel. The feature reorganization submodule performs bilinear interpolation on the input feature map to obtain preliminary upsampled features. For each output position, it extracts the local convolution weights corresponding to the upsampled convolution kernel, performs local weighted summation on the preliminary upsampled features, and outputs upsampled features that restore details.

8. A lightweight EEG classification and reconstruction system based on multi-task learning, characterized in that, include: A lightweight shared encoder is used to receive EEG signals, perform feature extraction and temporal compression, and output latent vectors. The classification branch, connected to the output of the lightweight shared encoder, is used to output the classification and recognition results of the EEG signals based on the latent vectors; The reconstruction branch, connected to the output of the lightweight shared encoder, includes an MSSTMamba module and a content-aware upsampling module, used to reconstruct high-fidelity EEG signals based on the latent vectors. During training, the classification branch and the reconstruction branch participate in joint loss calculation simultaneously. When deployed, the lightweight shared encoder and the classification branch are loaded onto a wearable terminal to complete real-time inference, while the reconstruction branch is independently deployed on an external computing device.