Abnormal electroencephalogram wave detection method based on Mama attention optimization and related equipment

By combining wavelet convolution and the Mamba-optimized attention module for feature extraction and modeling, and suppressing feature redundancy, a highly efficient method for detecting abnormal EEG waves was developed, meeting the real-time and high-precision requirements of clinical practice.

CN122004901APending Publication Date: 2026-05-12SOUTH CHINA UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SOUTH CHINA UNIV OF TECH
Filing Date
2025-12-25
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing technologies for detecting abnormal EEG waves suffer from problems such as low efficiency in long-term modeling, insufficient control of feature redundancy, and insufficient millisecond-level temporal localization accuracy, making it difficult to meet the clinical requirements for real-time performance and high spatiotemporal resolution.

Method used

We employ a method for detecting abnormal EEG waves based on Mamba-optimized attention. This method uses a wavelet convolution module for multi-scale feature extraction, combines a Mamba-optimized attention module for long-term dependency modeling, and uses a spatial reconstruction module to suppress feature redundancy, thereby achieving point-by-point prediction.

Benefits of technology

It achieves efficient long-term modeling, powerful feature redundancy control, and millisecond-level temporal positioning accuracy, improving detection accuracy and practicality, and is suitable for embedded devices and clinical applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122004901A_ABST
    Figure CN122004901A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an electroencephalogram abnormal wave detection method based on Mama attention optimization and related equipment, and belongs to the technical field of artificial intelligence and biomedical signal processing. The method aims at solving the problems that in the prior art, long-time-sequence modeling efficiency is low, feature redundancy is serious, and time sequence positioning precision is insufficient. The method comprises the following steps: carrying out multi-scale wavelet convolution solution on a preprocessed electroencephalogram signal; the extracted features are input to a Mama optimization attention (MOA) module, the module fuses a gating mechanism of a coring linear attention and a selective state space model, and a long-time dependency relationship is modeled with linear complexity; then, feature decomposition and cross reconstruction are carried out based on channel importance through a spatial reconstruction (SD) module to suppress redundancy; and finally, outputting an abnormal wave positioning result by adopting point-by-point prediction. According to the method, efficient and accurate detection of the abnormal electroencephalogram waves is achieved, and the method is particularly suitable for clinical real-time monitoring and embedded equipment deployment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of artificial intelligence and biomedical signal processing technology, and in particular to a method and related equipment for detecting abnormal brain waves based on Mamba-optimized attention. Background Technology

[0002] Electroencephalography (EEG) is a key tool for the clinical diagnosis of neurological disorders such as epilepsy. Automated detection of abnormal brain waves (such as spikes and sharp waves) is of great significance for the early identification and treatment of these diseases.

[0003] Currently, methods for detecting abnormal EEG waves can be mainly divided into three categories: The first category is based on traditional machine learning methods, such as Support Vector Machines (SVM) and Random Forests. These rely on manually designed features (such as band power and waveform morphology), and their performance is limited by the expertise required for feature design, and their generalization ability is insufficient. The second category is based on deep learning methods, especially Convolutional Neural Networks (CNNs) and their combination with Long Short-Term Memory Networks (LSTMs) (CNN-LSTM). These methods can automatically learn features, but are limited by the receptive field of convolutions, making it difficult to effectively model long-term dependencies. The third category is based on Transformer methods, whose self-attention mechanism has global modeling capabilities, but their computational complexity is proportional to the square of the sequence length (O(N)). 2 When processing long-term, high-sampling-rate EEG signals, there are problems with excessive computation and memory overhead, making it difficult to meet the real-time requirements of clinical practice.

[0004] In recent years, state-space models (SSMs) such as Mamba have been proposed, and their selective state-space mechanism can theoretically model long sequences with linear complexity (O(N)). However, the standard Mamba model suffers from problems such as the difficulty in parallelizing recursive structures, insufficient ability to model local details, and lack of effective control over feature redundancy, which limit its direct application in EEG anomaly detection that requires high spatiotemporal resolution.

[0005] Therefore, existing technologies have significant shortcomings in terms of long-term modeling efficiency, feature redundancy control, and millisecond-level temporal positioning accuracy, and there is an urgent need for a new solution that can balance efficiency, accuracy, and practicality. Summary of the Invention

[0006] The main objective of this application is to propose a method, system, electronic device, storage medium, and program product for detecting abnormal EEG waves based on Mamba-optimized attention. This method can balance detection accuracy, computational efficiency, and temporal resolution in the analysis of long-term, high-sampling-rate EEG, thereby overcoming multiple limitations of traditional methods and providing a feasible, stable, and efficient technical path for the rapid detection and intelligent diagnosis of abnormal EEG waves.

[0007] To achieve the above objectives, one aspect of this application proposes a method for detecting abnormal brainwaves based on Mamba-optimized attention, the method comprising: Acquire multi-channel EEG signals and perform preprocessing; The preprocessed EEG signal is input into the wavelet convolution module for multi-scale feature extraction to obtain multi-scale feature representation; The multi-scale feature representation is input into the time-dependent modeling module, which is based on the Mamba-optimized attention mechanism to model the long-term dependency of the EEG signal with linear computational complexity and outputs global context embedding features. The global context embedding features are input to the spatial reconstruction module, which estimates channel importance, generates a binary mask, and decomposes and cross-reconstructs the features to suppress feature redundancy and output refined features. Based on the refined features, a sequence of output and input EEG signals of equal length is predicted point by point, where the output value at each time point represents the predicted probability of abnormal EEG waves occurring at that time.

[0008] In some embodiments, the wavelet convolution module performs multi-scale feature extraction, including: The input signal is subjected to first-order Haar wavelet decomposition to obtain low-frequency and high-frequency components; Learnable convolution kernels are applied to the low-frequency components and high-frequency components respectively. The processed low-frequency and high-frequency components are reconstructed using inverse wavelet transform. The reconstructed signal is then residually fused with the result of convolution processing of the original input signal. Multiple sets of features processed by convolutional kernels of different sizes are concatenated along the channel dimension to obtain the multi-scale feature representation.

[0009] In some embodiments, the time-dependent modeling module is a Mamba-optimized attention module, and its processing includes: The input features are layer normalized while retaining residual connections; The first activation feature and the second activation feature are extracted by using the first linear projection branch and the one-dimensional convolution branch set in parallel. Dynamic gating weights are generated based on the input features; After preprocessing the input features by linear projection and convolution, kernel function mapping and rearrangement of matrix multiplication order are used to calculate kernelized linear attention features, so that the computational complexity is linearly related to the sequence length. The dynamic gating weights, the kernelized linear attention features, the second activation features, and the first activation features are gating fusions. After adding the gated fusion result to the residual connection, the global context embedding feature is output by combining the learnable positional encoding and the multilayer perceptron.

[0010] In some embodiments, the formula for calculating the kernelized linear attention feature is:

[0011]

[0012] in, and The query matrix and key matrix are obtained by mapping the input features using the kernel function. These are the features after convolution preprocessing. The kernelized linear attention feature; This is a transpose.

[0013] In some embodiments, the processing procedure of the spatial reconstruction module includes: The input features are grouped and normalized, and the importance weight of each channel is calculated based on the scaling factor of the normalization layer. A binary mask is generated based on the aforementioned importance weights; Using the binary mask and its complementary mask, the input features are decomposed into informative subsets and redundant subsets; The informative subset and redundant subset are further subdivided and cross-combined to achieve feature reconstruction; The reconstructed features are concatenated and then passed through a lightweight convolutional layer to output the refined features.

[0014] In some embodiments, during the model training phase, a weighted Dice loss function is used as the optimization objective. The formula for calculating the weighted Dice loss function is as follows:

[0015] in, For the model's predicted output, For real labels, The weight matrix is ​​set according to class imbalance. This is the smoothing constant.

[0016] To achieve the above objectives, another aspect of this application proposes a brainwave abnormality detection system based on Mamba-optimized attention, comprising: The preprocessing module is used to acquire and preprocess multi-channel EEG signals; The wavelet convolution module is connected to the preprocessing module and is used to extract multi-scale features from the preprocessed EEG signal to obtain a multi-scale feature representation. A time-dependent modeling module is connected to the wavelet convolution module. The time-dependent modeling module is a Mamba-optimized attention module, which is used to model the long-term dependencies of the multi-scale feature representation with linear computational complexity and output global context embedding features. The spatial reconstruction module, connected to the time-dependent modeling module, is used to suppress redundancy in the global context embedded features through channel importance estimation and feature cross-reconstruction, and output refined features. The output module, connected to the spatial reconstruction module, is used to perform point-by-point prediction based on the refined features and output an abnormal wave detection sequence of the same length as the input EEG signal.

[0017] To achieve the above objectives, another aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described above.

[0018] To achieve the above objectives, another aspect of the embodiments of this application proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described above.

[0019] To achieve the above objectives, another aspect of the embodiments of this application proposes a computer program product, including a computer program that, when executed by a processor, implements the method described above.

[0020] Compared with the prior art, this application has the following significant advantages: 1) Highly efficient long-term modeling capability: Through the innovative MOA module, the modeling capability of global attention is combined with linear computational complexity. While ensuring effective modeling of long-term dependencies of EEG signals, the computational and memory overhead is greatly reduced, making it possible to perform real-time or near-real-time processing on embedded devices or clinical bedside systems.

[0021] 2) Strong feature redundancy control capability: Through the channel importance evaluation and cross-reconstruction mechanism of the SD module, redundant information in the feature map is adaptively suppressed, making the network representation more compact and efficient. This not only reduces unnecessary computation, but also helps to improve the model's discriminative performance and generalization ability.

[0022] 3) Millisecond-level high-precision time-series localization: Abandoning the traditional fixed-time-window classification strategy, it adopts an end-to-end point-by-point prediction mechanism to directly classify each sampling point. It can accurately mark the start and end times of abnormal waves with the time resolution of the original signal (usually at the millisecond level), providing more reliable technical support for clinical lesion localization and dynamic monitoring.

[0023] 4) Superior overall performance and practicality: Through the collaborative design and optimization of the three modules WTConv, MOA, and SD, this invention significantly outperforms traditional CNN, Transformer, and baseline Mamba models in detection accuracy (such as Dice coefficient and F1 score) on publicly available EEG datasets. Furthermore, the model is highly lightweight, compatible with GPUs and embedded AI chips, and has promising prospects for clinical application. Attached Figure Description

[0024] Figure 1 This is a flowchart of an EEG abnormality detection method based on Mamba-optimized attention in an embodiment of this application.

[0025] Figure 2 This is a schematic diagram of the overall process of the EEG abnormal wave detection method based on Mamba-optimized attention in the embodiments of this application.

[0026] Figure 3 This is a schematic diagram of the wavelet convolution module (WTConv) in the embodiments of this application.

[0027] Figure 4 This is a flowchart of the spatial reconstruction module (SD module) in the embodiments of this application.

[0028] Figure 5 This is a schematic diagram of the time-dependent modeling module (MOA attention module) and its sub-components in an embodiment of this application.

[0029] Figure 6 This is a schematic diagram of the hardware structure of the electronic device in the embodiments of this application. Detailed Implementation

[0030] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit it. In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with those of this application; they are merely examples of apparatuses and methods consistent with some aspects of the embodiments of this application as detailed in the appended claims.

[0031] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0032] Before providing a detailed description of the embodiments of this application, some of the nouns and terms involved in the embodiments of this application will be explained first. The nouns and terms involved in the embodiments of this application are subject to the following interpretations.

[0033] 1) Mamba is a novel sequence model based on the Selective StateSpace (SSM) architecture, designed to address the high computational complexity of traditional Transformer models when processing long sequences. Its core innovation lies in replacing the quadratic complexity of the Transformer with linear time complexity, significantly improving the efficiency of long sequence processing. For example, in tasks such as language modeling, Mamba achieves performance comparable to the Transformer while increasing inference throughput by approximately 5 times. This advancement stems from improvements to the StateSpace model (SSM), which was originally designed to address the limitations of RNN's hidden state mechanism. Mamba further introduces a selection mechanism, enabling the model to dynamically filter irrelevant information.

[0034] Electroencephalography (EEG) is an important tool for the clinical diagnosis of neurological diseases. In particular, the early detection of abnormal waveforms such as spikes and sharp waves commonly seen during epileptic seizures plays a crucial role in disease identification and treatment decisions. However, existing automated detection methods still have significant shortcomings in accuracy, computational efficiency, and cross-scenario generalization, limiting their large-scale clinical application.

[0035] Traditional methods often employ shallow classifiers such as Support Vector Machines (SVM) and Random Forests, relying on manually designed features such as band power and waveform morphology. While they offer some interpretability, they require strong professional knowledge and struggle to adapt to complex and variable EEG patterns.

[0036] With the development of deep learning, convolutional neural networks (CNNs) and their variants (such as SeizureNet, EEGNet, and CNN-LSTM) have been widely used in EEG signal analysis. These methods can capture spatial patterns and short-term temporal dependencies, but due to limited receptive fields, they are difficult to effectively model long-term dependencies, and deep stacking often leads to feature redundancy rather than performance improvement.

[0037] Transformer-based methods have achieved some improvements due to their global modeling capabilities, such as ScatterFormer, MEET, and pre-trained models like BioT, EEGPT, and LaBraM. These models can enhance generalization performance across subjects and datasets, but the complexity of the Transformer's attention mechanism is O(N). 2 The computational and memory overhead is too high when processing long-term EEG recordings, which is not conducive to real-time and resource-constrained clinical deployment.

[0038] To reduce complexity, linear attention mechanisms have been proposed, lowering computational complexity to O(n), but they fall short in fine-grained temporal modeling. The recently proposed Mamba method introduces a Selective State-Space Model (SelectiveSSM), capturing long-range dependencies through dynamic gating, demonstrating high efficiency in tasks such as vision. However, these methods suffer from difficulties in parallelizing recursive structures, insufficient modeling of local spatial details, and limited control over feature redundancy, thus failing to directly meet the requirements for high-resolution EEG anomaly detection.

[0039] In summary, existing technologies have shortcomings in terms of scalability, redundancy control, and temporal resolution. This application aims to overcome the above-mentioned deficiencies of existing technologies and solve the following technical problems: 1) How to efficiently model long-term dependencies in EEG signals with linear computational complexity without sacrificing detection accuracy; 2) How to effectively suppress feature redundancy generated in deep networks, reduce computational overhead, and improve feature discrimination power; 3) How to achieve millisecond-level high-precision localization of the start and end points of abnormal EEG waves to meet the needs of precise clinical diagnosis.

[0040] In view of this, this application provides a method, system, electronic device, storage medium, and program product for detecting abnormal EEG waves based on Mamba-optimized attention. The solution includes: 1) providing an efficient long-term modeling mechanism with linear complexity, significantly reducing computational latency while ensuring detection accuracy, enabling real-time or near-real-time processing of long-term EEG. 2) proposing an effective feature redundancy suppression mechanism, making the model's feature representation more compact and discriminative, reducing computational and storage overhead, and adapting to low-power medical devices. 3) constructing a detection framework based on point-by-point prediction, achieving millisecond-level precise localization of the start and end points of abnormal waves, enhancing the clinical practical value of the method. 4) comprehensively improving the performance of EEG abnormal wave detection in terms of accuracy, efficiency, and practicality through multi-module collaborative design, promoting its widespread application in clinical scenarios.

[0041] This application provides a method for detecting abnormal EEG waves based on Mamba-optimized attention, relating to the fields of artificial intelligence and biomedical signal processing technology. This method can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, or in-vehicle terminal, but is not limited to these. The server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network. The software can be an application implementing the Mamba-optimized attention-based method for detecting abnormal EEG waves, but is not limited to the above forms.

[0042] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0043] like Figure 1 and Figure 2 As shown, this embodiment provides a method for detecting abnormal EEG waves based on Mamba-optimized attention, including the following steps: S1: Signal preprocessing. Acquire multi-channel raw EEG signals, perform bandpass filtering (e.g., 0.5-70 Hz) and normalization (e.g., Z-score standardization) to obtain preprocessed signal sequences.

[0044] In one embodiment, 19-channel EEG records containing clearly defined epileptic spikes are selected from the TUEV dataset. The original signal sampling rate is 250 Hz. First, each channel signal is bandpass filtered from 0.5 to 70 Hz to remove low-frequency drift and high-frequency noise. Then, the filtered signal is Z-score normalized, i.e., the mean is subtracted and the standard deviation is divided to obtain an input sequence with zero mean and unit variance. .

[0045] S2: Multi-scale Feature Extraction. The preprocessed signal is input into the wavelet convolution module (WTConv). This module first performs a first-level Haar wavelet decomposition on the input signal to obtain low-frequency and high-frequency components; then, learnable convolution kernels are applied to each component for processing; next, inverse wavelet transform is used for reconstruction, and residual fusion is performed with the result of the original signal after convolution processing; finally, multiple sets of features extracted using convolution kernels of different sizes (e.g., 3, 5, 7) are concatenated along the channel dimension to form a feature representation containing multi-scale information. .

[0046] In one embodiment, the preprocessed signal Enter the WTConv module. The specific steps are as follows: A1: Use the Haar wavelet basis for first-order decomposition to obtain the low-frequency approximate components. and high-frequency detail components .

[0047] A2: Yes and Each of these layers is a learnable one-dimensional convolutional layer (kernel size = 3).

[0048] A3: Perform inverse Haar wavelet transform (IWT) on the two components after convolution to reconstruct the signal. .

[0049] A4: At the same time, another independent convolutional layer is applied to the original input x to obtain... .

[0050] A5: Perform residual fusion: .

[0051] A6: Will After passing through a convolutional layer, the output of this path is obtained using the Sigmoid activation function. .

[0052] A7: Repeat the above process, but use convolutional layers with kernel sizes of 5 and 7 respectively to process the wavelet components, and obtain... and .

[0053] A8: Finally, the three sets of features are concatenated along the channel dimension: .

[0054] S3: Long-running dependency modeling. The input is fed into the time-dependent modeling module (Mamba-OptimizedAttention, MOA). This module is one of the core innovations of this embodiment, integrating the gating mechanism of kernelized linear attention and selective state-space model (SSM). Specifically, the MOA module efficiently captures the global contextual information of the sequence and outputs global contextual embedding features by performing operations such as layer normalization, parallel feature extraction (linear projection and one-dimensional convolution), dynamic gating weight generation, kernelized linear attention computation (complexity O(N)), and gating feature fusion. .

[0055] S4: Spatial redundancy suppression and feature refinement. The input is fed into the Spatial Deconstructed Block (SD). This module first estimates the importance weights of each channel using a scaling factor derived from GroupNorm, and generates a binary mask accordingly. Then, it uses the mask to decompose the input features into informative and redundant subsets. Next, it reconstructs the features through further subdivision and cross-combination of these subsets. Finally, it outputs refined features via lightweight convolution. This process effectively suppresses redundant activation between channels.

[0056] S5: Point-by-point prediction output. The system takes a 1×1 convolutional layer as input and outputs a predicted sequence that corresponds one-to-one with the time points of the input EEG signal. The value at each position in the sequence represents the probability of an abnormal wave occurring at that moment, thus enabling millisecond-level start and end point location.

[0057] In some embodiments, model training uses a weighted Dice loss function, where the weights of the anomalous wave class (positive class) are set to 5 times the weights of the background class (negative class) to mitigate class imbalance. The optimizer uses AdamW with an initial learning rate of 1e-4 and a batch size of 32.

[0058] The solutions of the embodiments of this application will be described in detail below with reference to the accompanying drawings and specific application examples.

[0059] (1) Wavelet Convolution Module (WTConv) See Figure 3 The wavelet-transform convolution module (WTConv) is used to perform multi-scale decomposition of the raw EEG signal and capture features of different frequency bands. This application uses the input signal... The above employs a first-order Haar wavelet decomposition and utilizes a low-pass filter.

[0060] and high-pass filter

[0061] Obtain low-frequency and high-frequency components Then, learnable convolution kernels are applied to each component, and the signal is reconstructed using inverse wavelet transform (IWT) to form a multi-band fused signal.

[0062] To enhance expressive power, the WTConv module further employs a residual fusion strategy:

[0063] The output is obtained through convolutional layers and the sigmoid activation function:

[0064] In a preferred embodiment, three sets of WTConv layers with different kernel sizes are used and concatenated along the channel dimension:

[0065] This allows for a comprehensive representation that spans multiple frequency bands and scales.

[0066] (2) Time-dependent modeling module (MOA attention module) See Figure 5 To address the issues of O(N²) complexity of Transformer and parallel constraints of Mamba, this embodiment proposes Mamba-Optimized Attention (MOA) module, which is used to model long-term dependencies with linear complexity and extract global context embeddings.

[0067] 2.1) Module Structure MOA attention module receives input features The processing steps include: a) Preprocessing and normalization: Apply LayerNorm to the input and preserve the residuals. ; b) Parallel feature extraction: obtained through linear layers + SiLU activation. It is obtained through one-dimensional convolution + SiLU. ; c) Dynamic gating weight generation: Gating weights are obtained through a linear layer + Sigmoid function. ; d) Kernelized linear attention computation: After preprocessing the input through linear projection and convolution, the kernel function is used... Generate Q and K, and rearrange the matrix multiplication order:

[0068] Reduce the complexity to O(N); e) Gated feature fusion:

[0069] in This is element-wise multiplication; f) Residuals and Output: [This section appears to be incomplete and requires further context.] and The summation, followed by convolutional positional encoding and MLP, yields the final output. .

[0070] 2.2) Technical Effects The MOA attention module maintains O(N) complexity while ensuring global modeling capabilities, achieving efficient parallel training and inference, and is suitable for real-time processing of long-term EEG.

[0071] (3) Spatial Reconstruction Module (SD Module) See Figure 4 To reduce feature redundancy, this embodiment designs a Spatial Deconstructed Block (SD module) to suppress cross-channel redundancy and improve the compactness and discriminative power of the representation.

[0072] 3.1) Module Steps Input feature map The process involves the following steps: a) Channel importance estimation: Apply GroupNorm to Z, based on a scaling factor. Calculate channel weights: ; b) Binary mask generation: The weights are activated by Sigmoid and thresholded (threshold 0.5) to generate a binary mask W; c) Feature decomposition: Using masks and complementary masks, features are divided into informative subsets. With redundant subsets ; d) Cross-reconstruction: Further subdivide the subsets and cross-combine them to obtain reconstructed features. After being pieced together, they form a comprehensive feature. ; e) Lightweight convolution output: for Applying a lightweight convolution yields the final output. .

[0073] 3.2) Technical Effects By separating and cross-reconstructing information / redundancy channels, this module significantly reduces redundant computation, enhances feature discriminativeness, and improves the overall efficiency of the model.

[0074] (4) Loss function design To alleviate the imbalance in the proportion of EEG anomalous wave samples, this embodiment employs weighted Dice loss:

[0075] Where I is the predicted output, T is the true label, and W is the class weight. This is a stable term. This loss can improve the model's ability to detect minority classes (abnormal events), thereby improving the overall detection performance.

[0076] (5) Implementation methods and application scenarios In a preferred embodiment, the method of this embodiment runs on a GPU or embedded AI chip, inputs a multi-channel EEG (sampling rate 250 Hz–2 kHz), and can quickly output point-by-point prediction results to meet the real-time needs of bedside monitoring and wearable devices.

[0077] (6) Beneficial effects In summary, compared with the prior art, the method of this embodiment has the following significant advantages and beneficial effects: 6.1) Highly efficient long-term time-series modeling capability Technical features: In the time-dependent modeling stage, this embodiment uses the MOA-attention module, which combines kernelized linear attention with dynamic gating of the Selective State Space Model (SSM), reducing the computational complexity from O(N²) to O(N), while enhancing global modeling capabilities through the gating mechanism.

[0078] Technical benefits: It enables low-latency inference and parallel processing on long-term, high-sampling-rate EEG sequences, overcoming the problem of excessive computation and storage overhead of traditional Transformers under large-scale input.

[0079] Experimental support: On publicly available EEG datasets, this invention maintains detection accuracy while improving inference speed by approximately 2.3 times and reducing GPU memory usage by approximately 42% compared to the standard Transformer model.

[0080] 6.2) Effective Feature Redundancy Control Technical features: The introduction of the SD module effectively distinguishes and reconstructs informational channels and redundant channels through channel importance estimation, binary mask separation and cross-reconstruction mechanisms.

[0081] Technical effects: It reduces redundant activations in feature representation, making the network more compact and efficient, improving discriminative power, and reducing computational and storage consumption.

[0082] Experimental support: Ablation experiments show that removing the SD module reduces the model's Dice by approximately 3.7%, validating the necessity and effectiveness of redundancy suppression.

[0083] 6.3) Millisecond-level timing positioning accuracy Technical features: It adopts a point-by-point prediction mechanism to replace fixed window classification, so as to realize the time-by-time prediction of the start and end points of abnormal waves in EEG signals.

[0084] Technical effect: It can accurately mark the start and end positions of anomalous waves at millisecond-level resolution, which is significantly better than traditional methods with second-level resolution.

[0085] Experimental support: On a certain epilepsy monitoring dataset, the average localization error of this invention is less than 5 ms, while the error of the fixed-window CNN-LSTM method is between 50 and 100 ms.

[0086] 6.4) More suitable for clinical and embedded applications Technical features: The WTConv module enhances the representation of low-frequency features, and the lightweight MOA attention module and SD module are combined to significantly reduce the overall model size and energy consumption.

[0087] Technical benefits: It can be deployed on portable EEG acquisition devices and embedded medical terminals, supporting real-time monitoring, bedside diagnosis and mobile medical applications.

[0088] Experimental support: On an embedded GPU platform (NVIDIA Jetson Nano), the model of this invention can complete point-by-point prediction of a single EEG signal within 100ms, meeting the needs of real-time clinical applications.

[0089] 6.5) Overall performance improvement Technical features: A collaborative design combining multi-scale WTConv, MOA attention module, SD module, and weighted Dice loss.

[0090] Technical effect: While ensuring high efficiency and low latency, it improves the accuracy and robustness of abnormal wave detection.

[0091] Experimental support: Experimental results on multiple public EEG datasets show that: 1) the average Dice score is improved by approximately 3–5%; 2) the F1-score is improved by approximately 3%. This application also provides a brainwave abnormality detection system based on Mamba-optimized attention, which can implement the above-mentioned method. The system includes: The preprocessing module is used to acquire and preprocess multi-channel EEG signals; The wavelet convolution module is connected to the preprocessing module and is used to extract multi-scale features from the preprocessed EEG signal to obtain a multi-scale feature representation. A time-dependent modeling module is connected to the wavelet convolution module. The time-dependent modeling module is a Mamba-optimized attention module, which is used to model the long-term dependencies of the multi-scale feature representation with linear computational complexity and output global context embedding features. The spatial reconstruction module, connected to the time-dependent modeling module, is used to suppress redundancy in the global context embedded features through channel importance estimation and feature cross-reconstruction, and output refined features. The output module, connected to the spatial reconstruction module, is used to perform point-by-point prediction based on the refined features and output an abnormal wave detection sequence of the same length as the input EEG signal.

[0092] It is understood that the content of the above method embodiments is applicable to this system embodiment. The specific functions implemented in this system embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0093] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described method. This electronic device can be any smart terminal, including servers, tablets, smartphones, etc.

[0094] It is understood that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0095] Please see Figure 6 , Figure 6 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes: The processor 601 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application. The memory 602 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 602 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 602 and is called and executed by the processor 601 using the methods described in the embodiments of this application. The input / output interface 603 is used to implement information input and output; The communication interface 604 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). Bus 605 transmits information between various components of the device (e.g., processor 601, memory 602, input / output interface 603, and communication interface 604); The processor 601, memory 602, input / output interface 603, and communication interface 604 are connected to each other within the device via bus 605.

[0096] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method.

[0097] It is understood that the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0098] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0099] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.

[0100] It is understood that the content of the above method embodiments is applicable to the embodiments of this program product. The specific functions implemented in the embodiments of this program product are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments. The executable computer program code or "code" used to perform the various embodiments can be written in high-level programming languages ​​such as C, C++, Python, Smalltalk, Java, JavaScript, Visual Basic, Structured Query Language (e.g., Transact-SQL), Perl, or in various other programming languages.

[0101] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

[0102] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.

[0103] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0104] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0105] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0106] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0107] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0108] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0109] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0110] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0111] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.

Claims

1. A method for detecting abnormal EEG waves based on Mamba-optimized attention, characterized in that, The method includes the following steps: Acquire multi-channel EEG signals and perform preprocessing; The preprocessed EEG signal is input into the wavelet convolution module for multi-scale feature extraction to obtain multi-scale feature representation; The multi-scale feature representation is input into the time-dependent modeling module, which is based on the Mamba-optimized attention mechanism to model the long-term dependency of the EEG signal with linear computational complexity and outputs global context embedding features. The global context embedding features are input to the spatial reconstruction module, which estimates channel importance, generates a binary mask, and decomposes and cross-reconstructs the features to suppress feature redundancy and output refined features. Based on the refined features, a sequence of output and input EEG signals of equal length is predicted point by point, where the output value at each time point represents the predicted probability of abnormal EEG waves occurring at that time.

2. The method according to claim 1, characterized in that, The steps for multi-scale feature extraction by the wavelet convolution module include: The input signal is subjected to first-order Haar wavelet decomposition to obtain low-frequency and high-frequency components; Learnable convolution kernels are applied to the low-frequency components and high-frequency components respectively. The processed low-frequency and high-frequency components are reconstructed using inverse wavelet transform. The reconstructed signal is then residually fused with the result of convolution processing of the original input signal. Multiple sets of features processed by convolutional kernels of different sizes are concatenated along the channel dimension to obtain the multi-scale feature representation.

3. The method according to claim 1, characterized in that, The time-dependent modeling module is a Mamba-optimized attention module, and its processing includes: The input features are layer normalized while retaining residual connections; The first activation feature and the second activation feature are extracted by using the first linear projection branch and the one-dimensional convolution branch set in parallel. Dynamic gating weights are generated based on the input features; After preprocessing the input features by linear projection and convolution, kernel function mapping and rearrangement of matrix multiplication order are used to calculate kernelized linear attention features, so that the computational complexity is linearly related to the sequence length. The dynamic gating weights, the kernelized linear attention features, the second activation features, and the first activation features are gating fusions. After adding the gated fusion result to the residual connection, the global context embedding feature is output by combining the learnable positional encoding and the multilayer perceptron.

4. The method according to claim 3, characterized in that, The formula for calculating the kernelized linear attention feature is as follows: in, and The query matrix and key matrix are obtained by mapping the input features using the kernel function. These are the features after convolution preprocessing. The kernelized linear attention feature; This is a transpose.

5. The method according to claim 1, characterized in that, The processing steps of the spatial reconstruction module include: The input features are grouped and normalized, and the importance weight of each channel is calculated based on the scaling factor of the normalization layer. A binary mask is generated based on the aforementioned importance weights; Using the binary mask and its complementary mask, the input features are decomposed into informative subsets and redundant subsets; The informative subset and redundant subset are further subdivided and cross-combined to achieve feature reconstruction; The reconstructed features are concatenated and then passed through a lightweight convolutional layer to output the refined features.

6. The method according to claims 1 to 5, characterized in that, During the model training phase, a weighted Dice loss function is used as the optimization objective. The formula for calculating the weighted Dice loss function is as follows: in, For the model's predicted output, For real labels, The weight matrix is ​​set according to class imbalance. This is the smoothing constant.

7. A system for detecting abnormal brainwaves based on Mamba-optimized attention, characterized in that, include: The preprocessing module is used to acquire and preprocess multi-channel EEG signals; The wavelet convolution module is connected to the preprocessing module and is used to extract multi-scale features from the preprocessed EEG signal to obtain a multi-scale feature representation. A time-dependent modeling module is connected to the wavelet convolution module. The time-dependent modeling module is a Mamba-optimized attention module, which is used to model the long-term dependencies of the multi-scale feature representation with linear computational complexity and output global context embedding features. The spatial reconstruction module, connected to the time-dependent modeling module, is used to suppress redundancy in the global context embedded features through channel importance estimation and feature cross-reconstruction, and output refined features. The output module, connected to the spatial reconstruction module, is used to perform point-by-point prediction based on the refined features and output an abnormal wave detection sequence of the same length as the input EEG signal.

8. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method according to any one of claims 1 to 6.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 6.