Seizure multi-stage recognition method, device, system and storage medium
A lightweight multi-stage epileptic seizure recognition model combining multi-scale parallel convolution with a Transformer encoder and a depthwise separable convolutional residual structure solves the problems of insufficient multi-scale feature extraction and high computational complexity in existing technologies, achieving stability and robustness across patients for multi-stage recognition of the entire course of epileptic seizures.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XIJING UNIV
- Filing Date
- 2026-03-12
- Publication Date
- 2026-06-26
AI Technical Summary
Existing epilepsy detection methods are unable to fully capture multi-scale EEG signal features. The models have a large computational load and a high number of parameters, making it difficult to achieve multi-stage state recognition throughout the entire course of the seizure and stable recognition across patient scenarios.
A lightweight multi-stage epileptic seizure recognition model is constructed by fusing spatiotemporal features with multi-scale parallel convolution and Transformer encoder, and combining it with depthwise separable convolutional residual structure. Multi-stage recognition is achieved through a global adaptive average pooling classifier.
It achieves automatic identification of the entire course of epileptic seizures, supports four-class classification of normal state, pre-seizure, seizure, and post-seizure, reduces model computational complexity, improves stability and robustness for cross-patient applications, and is suitable for portable monitoring devices.
Smart Images

Figure CN122271933A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of information processing technology, specifically relating to a method, device, system, and storage medium for multi-stage identification of epileptic seizures. Background Technology
[0002] Current methods for detecting epilepsy still have the following shortcomings: (1) Some methods use a single-scale convolution structure with a fixed receptive field, which makes it difficult to fully capture the multi-scale features of epileptic EEG signals; (2) Some methods introduce structures such as recurrent neural networks or multi-layer Transformers, which can extract temporal information, but the model has a large amount of computation and a large number of parameters, making it difficult to meet the requirements of lightweight deployment. (3) Most existing studies only target the binary classification task of normal and epileptic phases, lacking the ability to accurately identify multiple stages such as pre-epidemic and post-epidemic states, making it difficult to provide a reference for diagnosis of the entire course of the disease. (4) Existing models have insufficient generalization ability in cross-patient scenarios. When faced with clinical data with large differences between patients and complex signal and noise, the recognition performance is prone to fluctuation. Summary of the Invention
[0003] To address the shortcomings of existing technologies, such as insufficient multi-scale feature extraction of epileptic EEG signals, large model parameters and high computational complexity, difficulty in recognizing multiple stages of seizures throughout the entire course of the disease, and insufficient generalization ability across patient scenarios, this invention provides a method, device, system, and storage medium for multi-stage epileptic seizure recognition. By fusing spatiotemporal features through multi-scale parallel convolution and a Transformer encoder, and combining a depthwise separable convolutional residual structure to reduce model complexity, this invention improves the stability and robustness of cross-patient applications while ensuring recognition performance.
[0004] To achieve the above objectives, the present invention provides the following solution: A multi-stage method for identifying epileptic seizures includes: Step S1: Select key lead channels of EEG signals from epilepsy patients, slice them according to fixed window length and sliding step size, and generate time-limited sequence fragments; classify them into four categories according to clinical labels: pre-ictal, ictal, post-ictal and normal state, and sample samples from the non-ictal state to balance the category distribution. Step S2: Construct a lightweight multi-stage epileptic seizure identification model that integrates spatiotemporal features; Step S3: Based on the preprocessed samples, train a multi-stage recognition model for mild epileptic seizures; Step S4: Input the EEG signal to be detected into the trained lightweight multi-stage epileptic seizure recognition model, and output the classification result through the global adaptive average pooling classifier to realize multi-stage epileptic seizure recognition.
[0005] As a preferred option, a lightweight multi-stage epileptic seizure recognition model that integrates spatiotemporal features includes sequentially connected input convolutional layers, multi-scale parallel convolutional modules, depthwise separable convolutional residual modules, Transformer encoders, and global adaptive average pooling classifiers. The input convolutional layer is used to perform preliminary dimensionality upscaling on the multi-channel raw EEG signals and map them to a feature space of a preset dimension to extract basic local features; The multi-scale parallel convolution module employs three independent convolution branches. By configuring different convolution kernel sizes and dilation rates, it captures the evolution patterns of EEG signals at different time scales in parallel. The outputs of each branch are concatenated along the channel dimension and then compressed and fused through convolution to form a joint feature space. The depthwise separable convolutional residual module consists of multiple layers of cascaded depthwise separable convolutional residual blocks (DSCBlock). Each layer adopts a depthwise separable convolutional structure with a different dilation rate, and combined with the residual connection mechanism, it alleviates gradient vanishing and maintains high-level semantic consistency. The Transformer encoder includes a multi-head self-attention mechanism and a feedforward network, introduces learnable positional encoding, and models the medium- and long-range dependencies and global temporal structure of EEG sequences. The global adaptive average pooling classifier compresses the time dimension through adaptive global average pooling, and combines Dropout regularization with a fully connected layer to achieve multi-stage classification output of epileptic seizures.
[0006] As a preferred option, in step S3, the preprocessed samples are divided into training set, validation set and test set according to the proportion, or cross-patient validation is used to divide the data; the training set is input into a lightweight multi-stage epileptic seizure recognition model that integrates spatiotemporal features, and trained using the Adam optimizer and cross-entropy loss function, and the hyperparameters are adjusted through the validation set to suppress overfitting.
[0007] Preferably, in step S1, the key lead channel is a preset set of multi-channel EEG signal channels; the fixed window length and sliding step size are preset parameters set according to the sampling frequency and detection requirements; the pre-ictal period is defined as a preset time range before the onset of the attack, and the post-ictal period is defined as a preset time range after the onset of the attack.
[0008] Preferably, in step S3, the hyperparameters for model training are configured as follows: 100 training rounds (to be increased appropriately in cross-patient experiments), learning rate 0.001, batch size 64, activation function ReLU, and normalization BatchNorm1d. The specific method for cross-patient validation is as follows: in each round of experiment, all data of one patient are selected as the test set, and the data of the remaining patients are selected as the training set. The test is repeated for all patients to evaluate the generalization performance of the model on unknown individuals.
[0009] Preferably, in step S1, the EEG signal is derived from monitoring data under clinical no-drug intervention conditions, with a sampling frequency of 256Hz, a file format of EDF standard format, and data annotation is completed by experienced neurologists based on synchronous analysis of EEG waveforms and video.
[0010] The present invention also provides a multi-stage epileptic seizure recognition device, comprising: The first processing module is used to select key lead channels of the EEG signals of epilepsy patients, slice them according to a fixed window length and sliding step size, and generate time-long sequence fragments; according to clinical annotations, it divides the signals into four categories: pre-ictal, ictal, post-ictal and normal state, and samples the non-ictal state to balance the category distribution. The second processing module is used to construct a lightweight multi-stage epileptic seizure recognition model that integrates spatiotemporal features; The third processing module is used to train a multi-stage recognition model for mild epileptic seizures based on the preprocessed samples. The fourth processing module is used to input the EEG signal to be detected into the trained lightweight multi-stage epileptic seizure recognition model, and output the classification result through a global adaptive average pooling classifier to realize multi-stage epileptic seizure recognition.
[0011] As a preferred option, a lightweight multi-stage epileptic seizure recognition model that integrates spatiotemporal features includes sequentially connected input convolutional layers, multi-scale parallel convolutional modules, depthwise separable convolutional residual modules, Transformer encoders, and global adaptive average pooling classifiers. The input convolutional layer is used to perform preliminary dimensionality upscaling on the multi-channel raw EEG signals and map them to a feature space of a preset dimension to extract basic local features; The multi-scale parallel convolution module employs three independent convolution branches. By configuring different convolution kernel sizes and dilation rates, it captures the evolution patterns of EEG signals at different time scales in parallel. The outputs of each branch are concatenated along the channel dimension and then compressed and fused through convolution to form a joint feature space. The depthwise separable convolutional residual module consists of multiple layers of cascaded depthwise separable convolutional residual blocks (DSCBlock). Each layer adopts a depthwise separable convolutional structure with a different dilation rate, and combined with the residual connection mechanism, it alleviates gradient vanishing and maintains high-level semantic consistency. The Transformer encoder includes a multi-head self-attention mechanism and a feedforward network, introduces learnable positional encoding, and models the medium- and long-range dependencies and global temporal structure of EEG sequences. The global adaptive average pooling classifier compresses the time dimension through adaptive global average pooling, and combines Dropout regularization with a fully connected layer to achieve multi-stage classification output of epileptic seizures.
[0012] As a preferred option, the third processing module divides the preprocessed samples into training set, validation set and test set according to the proportion, or adopts cross-patient validation to divide the data; the training set is input into a lightweight multi-stage epileptic seizure recognition model that integrates spatiotemporal features, and trained using the Adam optimizer and cross-entropy loss function, and the hyperparameters are adjusted through the validation set to suppress overfitting.
[0013] The present invention also provides a multi-stage epileptic seizure recognition system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes a multi-stage epileptic seizure recognition method when executed by the processor.
[0014] The present invention also provides a storage medium storing a computer program that executes a multi-stage epileptic seizure identification method when running.
[0015] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention captures local features at different time scales through a multi-scale parallel convolution module and combines it with a Transformer encoder to model long-distance temporal dependencies, thereby achieving comprehensive fusion of spatiotemporal features and solving the problem of insufficient feature extraction at a single scale. The depthwise separable convolution significantly reduces the number of parameters compared to standard convolution, resulting in high overall computational efficiency of the model. It can be deployed in portable monitoring devices to meet the needs of real-time clinical monitoring. 2. This invention can automatically identify the entire course of epileptic seizures, supporting four-class classification: normal state, pre-ictal state, ictal state, and post-ictal state. It can be extended to binary classification tasks according to clinical needs. Repeated validation results across multiple datasets demonstrate that this invention achieves stable and high recognition accuracy in both binary and four-class classification tasks, while effectively reducing missed detections. This provides a more complete and reliable reference for epilepsy monitoring, diagnostic assessment, and early warning intervention throughout the entire course of the disease. 3. This invention is trained and validated based on real clinical EEG data. Through end-to-end modeling and multi-scale spatiotemporal feature fusion, the model output results are consistent and stable, thereby improving the reliability of multi-stage epileptic seizure identification and having application value in assisting clinical decision-making. Attached Figure Description
[0016] To more clearly illustrate the technical solution of the present invention, the drawings used in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart of the multi-stage epileptic seizure identification method according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the epilepsy detection model structure of the multi-scale depth-separable convolution and Transformer of the present invention. Figure 3 This is a flowchart of the multi-scale convolution process of the present invention; Figure 4 This is a structural diagram of the Transformer encoder of the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0020] Example 1 like Figure 1 As shown, the present invention provides a method for multi-stage identification of epileptic seizures, including: Step S1: Data preprocessing: Select key lead channels of EEG signals from epilepsy patients, slice them according to fixed window length and sliding step size, and generate time-limited sequence fragments; classify them into four categories according to clinical labels: pre-ictal, ictal, post-ictal and normal state, and sample samples from the non-ictal state to balance the category distribution. Step S2, Model Construction: Construct a lightweight multi-stage epileptic seizure recognition model that integrates spatiotemporal features; Step S3, Model Training: Divide the preprocessed samples into training set, validation set and test set according to the proportion, or use cross-patient validation (Leave-One-Subject-Out, LOSO) to divide the data; input the training set into the mild epileptic seizure multi-stage recognition model, use Adam optimizer and cross-entropy loss function for training, and adjust hyperparameters through the validation set to suppress overfitting; Step S4, Multi-stage detection: The EEG signal to be detected is preprocessed according to step S1, input into the trained lightweight epileptic seizure multi-stage recognition model, and the classification result is output through the global adaptive average pooling classifier to realize the multi-stage recognition of epileptic seizures.
[0021] As one embodiment of the present invention, step S1 includes: S11: Channel Selection: 19 key lead channels (Fp1-Ref, Fp2-Ref, F3-Ref, F4-Ref, F7-Ref, F8-Ref, T3-Ref, T4-Ref, T5-Ref, T6-Ref, C3-Ref, C4-Ref, P3-Ref, P4-Ref, Fz-Ref, Cz-Ref, Pz-Ref, O1-Ref, O2-Ref) were selected to cover major brain regions; S12: Signal Slicing: Slice the continuous EEG signal into equal-length sequence fragments by using a window length of 4 seconds and a sliding step of 2 seconds. S13: Label mapping: Based on clinical labels, the samples are divided into four categories: pre-ictal, ictal, post-ictal, and normal state; S14: Sample Balancing: Samples are taken from the non-symptomatic state to control the balance of class distribution, and finally a sample set that can be set according to training needs is generated for model training and validation. As one embodiment of the present invention, in step S2, as follows: Figures 2 to 4 As shown, the lightweight multi-stage epileptic seizure recognition model integrating spatiotemporal features adopts an end-to-end architecture, which includes an input convolutional layer, a multi-scale parallel convolutional module, a depthwise separable convolutional residual module, a Transformer encoder, and a global adaptive average pooling classifier. These modules work together to achieve efficient extraction of multi-scale spatiotemporal features and accurate multi-stage classification. 1) Input Convolutional Layer The system receives raw EEG signals from multiple channels and maps the signals from 1 channel to a 32-channel feature space through a 1×3 one-dimensional convolution. Combined with BatchNorm1d batch normalization and ReLU activation function, the system enhances the expressive power of the raw signals and provides low-level semantic support for subsequent multi-scale modeling. 2) Multi-scale parallel convolution module Three parallel convolutional branches are employed, and multi-scale feature collaborative extraction is achieved through differentiated configuration: Branch 1: Convolution kernel parameters are 32→64×3, dilation rate d=1, padding=1, focusing on high-frequency, local short-term burst features (such as spikes, spikes). Branch 2: Convolution kernel parameters are 32→64×5, dilation rate d=1, padding=2, to enhance the perception of rhythmic changes of moderate duration; Branch 3: The convolution kernel parameters are 32→64×3, the dilation rate d=2, and the padding=2. The receptive field is expanded through dilated convolution to capture long-term dependent features (such as slow waves and background rhythms). The outputs of each branch are concatenated in the channel dimension (dimension 192) by the concatenation operation, and then compressed to 128 channels by 1×1 convolution, realizing multi-scale information fusion and dimensional control. The multi-scale parallel convolution module employs a multi-scale convolutional neural network with a parallel multi-path structure. Each branch uses a different kernel size or dilation rate to process the same input sequence. Assume the input EEG segment is... Where C represents the number of EEG channels and T is the length of the time dimension. i The convolution output of the path branch can be expressed as the formula: in W i These are the kernel weights, where * indicates a one-dimensional convolution operation. b i For bias terms, For non-linear activation functions such as ReLU. The kernel size used in each branch... k i The receptive fields of these branches differ, and their temporal ranges also vary, enabling the models to perceive both localized, sudden activity and long-term, slowly evolving rhythmic changes in parallel. The outputs of all branches... The data will be concatenated along the channel dimension to form a joint multi-scale feature tensor, represented by the formula: Its feature tensor dimension is .
[0022] To further integrate feature information across different scales and control channel dimension expansion, multi-scale convolutional neural networks typically introduce... Convolution performs channel compression and information mapping. This operation can be expressed by the formula: in Here, BN stands for batch normalization, and the activation function is used. This structure not only preserves the effective information of the original signal at multiple scales at the feature fusion level, but also significantly reduces computational complexity, improving the network's scalability and engineering deployment friendliness.
[0023] To further extend the temporal awareness range of the model, dilated convolution mechanisms can also be introduced into some paths of multi-scale convolutional neural networks. This mechanism increases the receptive field by inserting holes while keeping the number of convolution kernel parameters constant. Its convolution operation can be expressed by the following formula: in r For expansion rate, k The kernel length is 1. x ( t ) represents the input signal. w ( i ) represents the weights of the convolution kernel. By introducing dilated convolution, the model can perceive a wider range of temporal dependencies without increasing computational cost, making it particularly suitable for capturing latent low-frequency abnormalities in the pre-ictal phase and slow-wave recovery processes in the post-ictal phase.
[0024] The multi-scale convolution module employs a three-parallel convolutional branch structure, each with different kernel sizes and dilation rates, to achieve comprehensive perception of multi-frequency and multi-timescale features in epileptic EEG signals. Branch 1 uses a standard kernel size of 3 and a dilation rate of 1, responsible for extracting short-term burst features such as high-frequency and local spikes and spiking waves; Branch 2 uses a larger kernel (size 5) with a dilation rate of 1 to enhance the perception of rhythmic changes of moderate duration; Branch 3 combines an expanded convolutional operation with a kernel size of 3 and a dilation rate of 2 to expand the receptive field while maintaining the same computational cost, enabling the modeling of long-term dependent features such as slow waves and background rhythms.
[0025] 3) Depthwise separable convolutional residual module It consists of four cascaded depthwise separable convolutional blocks, each layer employing a structure combining depthwise separable convolutions and residual connections: Depthwise separable convolution breaks down the standard convolution operation into two steps: depthwise convolution and pointwise convolution. Depthwise convolution performs a one-dimensional convolution operation independently on each channel, without cross-channel feature fusion, focusing on extracting local temporal patterns. Pointwise convolution, on the other hand, uses a 1×1 kernel to linearly combine features across channels, achieving information integration and cross-channel modeling. One-dimensional depthwise separable convolution assumes the input feature map has a dimension of... ,in C in Input the number of channels. T The length is the time dimension, and the number of output channels is... Cout The number of parameters in a standard one-dimensional convolution is calculated using the following formula: Depthwise separable convolutions are decomposed according to formula (4.6): This process can be formalized as two steps. In the depthwise convolution stage, each channel is convolved using a separate kernel to obtain intermediate feature maps. Y d : in It is an independent convolution kernel for each input channel.
[0026] In the pointwise convolution stage, 1×1 convolutions are used to fuse the channels to obtain the final output feature map. Y : in yes The pointwise convolution kernel.
[0027] 3) Transformer encoder Employing a lightweight design, it includes a single layer of multi-head self-attention mechanism and a feedforward network: The core of Transformer lies in its self-attention mechanism, which calculates the correlation between any two positions in a sequence, thus enabling effective modeling of long-distance dependencies. For the input sequence... ,in L For sequence length, d As a feature dimension, the self-attention mechanism generates a matrix of query Q, key K, and value V through linear transformation, as shown in the following formula: in, dk is the learnable weight matrix, and dk is the dimension of the attention head.
[0028] Attention weights are derived using the dot product formula between the query and the key: Wherein, scaling factor This mechanism is used to prevent the softmax function from entering the saturation region due to excessively large dot product results. This allows the model to dynamically focus on important information within the sequence, regardless of positional distance.
[0029] To enhance the model's representational ability, this invention employs a multi-head attention mechanism, which captures feature relationships in different subspaces by computing multiple attention heads in parallel. The calculation formula for multi-head attention is as follows: Among them, the i An attention head is defined as: h For the number of attention heads, For the first i Weight matrix of the size, This is for outputting the projection matrix.
[0030] In this model, the number of attention heads is set to h=8, and the feature dimension is d=128, so the dimension of each attention head is dk=16. The multi-head mechanism allows the model to learn different types of dependencies in different representation subspaces, thereby improving the ability to recognize complex patterns. Each head focuses on different aspects of the sequence, and finally, the outputs of all heads are fused through a linear transformation WO.
[0031] Since the self-attention mechanism itself does not contain positional information, and the temporal characteristics of EEG signals are crucial for epilepsy detection, positional encoding needs to be incorporated into the input. Considering the continuous nature of EEG signals, this invention employs a learnable positional encoding method, automatically learning the optimal positional representation through a training process.
[0032] The Transformer encoder also includes a Position-wise Feed-Forward Network (FFN) to enhance the model's non-linear expressive power. FFN is calculated according to the formula: in, , This is the weight matrix. b 1. b 2 is the bias vector. d ff This represents the hidden layer dimension of the feedforward network. In this model, it is set to... d ff =256.
[0033] To mitigate the vanishing gradient problem in deep networks and accelerate training convergence, the Transformer encoder employs residual connections and layer normalization around the multi-head attention and feedforward networks. The output of this ensemble sublayer is defined as: in, This represents the output of a multi-head attention or feedforward network. The formula for calculating layer normalization is: in, and These are the mean and standard deviation of the input, respectively. and These are learnable scaling and translation parameters.
[0034] While depthwise separable convolutions significantly reduce computational burden, they are prone to gradient vanishing or feature degradation in deep networks, especially when processing complex EEG data with high signal noise. Therefore, this invention further integrates residual connections into the depthwise separable convolution module, constructing a residual separable convolution block that is more effective in expressing depth and gradient propagation. This structure allows input features to bypass an identity mapping path and be directly passed to the output outside the main convolutional path, effectively mitigating information loss during deep network training. Let the input be... X The output of the residual module is Y : When the input and output dimensions are inconsistent, it can be done through... Convolutional layers are matched to meet dimension alignment requirements. This structure not only enhances the network's non-linear expressive power but also accelerates convergence and improves training stability.
[0035] As one embodiment of the present invention, step S3 includes: S31: Data partitioning: Two partitioning methods are used: ① Single validation: 70% training set, 15% test set, and 15% validation set; ② Cross-patient validation (LOSO): In each round, data from one patient is selected as the test set, and the rest are used as the training set. S32: Hyperparameter settings: 100 training epochs (increase appropriately for cross-patient experiments), learning rate 0.001, batch size 64, optimizer is Adam, loss function is CrossEntropyLoss; S33: Model Training: Input the training set into the model, update the parameters through backpropagation, monitor the performance using the validation set, adjust the hyperparameters to suppress overfitting, until the model converges. As one embodiment of the present invention, step S4 includes: S41: Data preprocessing: Preprocess the clinically collected EEG signals according to steps S11-S13 to generate standard input samples; S42: Model Inference: Input the preprocessed samples into the trained model, and output the predicted labels through the classifier; S43: Output Results: Output the results of epileptic seizure stage identification (normal state / pre-seizure / seizure period / post-seizure), providing a basis for clinical diagnosis and intervention.
[0036] Example: (I) Experimental Data The XJCEpilepsy dataset, a self-built dataset from the neurosurgery department of a municipal children's hospital, was used. It contains clinical EEG data from 20 children with epilepsy (aged 8–14). The data sampling frequency was 256 Hz, and the format was EDF standard. The seizure stages were labeled by neurologists. (II) Data Preprocessing Implementation Channel selection: 19 key lead channels were selected, covering the frontal lobe, temporal lobe, parietal lobe, central lobe, and occipital lobe regions; Signal slicing: Window length 4 seconds, sliding step 2 seconds, generating equal-length sequence segments, each segment containing 19 channels × 1024 sampling points (256Hz × 4s). Label mapping: Four categories of labels are divided according to clinical annotations. The pre-onset period is a preset time range before the onset, and the post-onset period is a preset time range after the onset. For example, the preset time range can be selected as 3 minutes before the onset and 3 minutes after the onset. Sample balance: Sampling is performed on samples in the non-seizure state to maintain a balanced distribution of samples in the four categories of normal state, pre-seizure state, seizure state, and post-seizure state. (III) Model Parameter Settings The parameters of each module of the model are shown in Table 1: Table 1 (iv) Model training and testing implementation Single verification experiment: Data partitioning: 70% training set, 15% test set, 15% validation set; Training process: Iterate for 100 rounds, recording the training loss and validation accuracy in each round. Stop training when the validation accuracy does not improve for 10 consecutive rounds. Test results: Through testing on binary and four-class classification tasks, the method of this invention showed good classification performance under different task settings, achieving high recognition accuracy and stable evaluation index performance, with few missed detections, thus meeting the application requirements for the recognition of the entire course of epilepsy. Cross-patient validation trial: Data partitioning: In each round, data from one patient is selected as the test set, and data from the remaining 19 patients are selected as the training set, for a total of 20 rounds; Test results: Under cross-patient validation conditions, the model of this invention still maintains high and stable recognition performance on unknown patient data. The comprehensive evaluation index of binary and four-class classification tasks is consistent, the model has good generalization ability, and can adapt to clinical application scenarios with large differences in signals among different patients. Ablation experiments verified: Comparative experiments were conducted by removing the multi-scale convolution module (A), the depthwise separable convolution residual module (B), and the Transformer encoder (C) respectively. The results show that all three modules can significantly improve model performance, and the combined use of all three modules yields the best performance, thus verifying the necessity and synergistic effect of each module. (V) Implementation process of testing methods Clinical data acquisition: EEG monitoring equipment with a 10-20 electrode system was used to acquire patients' EEG signals at a sampling frequency of 256Hz and saved in EDF format; Preprocessing: Follow the steps above to filter 19 channels, slice in a 4-second window, and generate the input sample; Model inference: The sample is input into the deployed model, and the inference latency is low, which can meet the requirements of real-time detection; Results output: The identification results (normal state / pre-attack / attack period / post-attack) are displayed in real time on the monitoring device interface, and the attack time and duration are recorded. This embodiment verifies the effectiveness of the model and method of the present invention. Through training and testing with clinical data, the model has the characteristics of high accuracy, strong generalization and lightweight, which can meet the needs of real-time detection of multiple stages of clinical epilepsy seizures.
[0037] Example 2 The present invention also provides a multi-stage epileptic seizure recognition device, comprising: The first processing module is used to select key lead channels of the EEG signals of epilepsy patients, slice them according to a fixed window length and sliding step size, and generate time-long sequence fragments; according to clinical annotations, it divides the signals into four categories: pre-ictal, ictal, post-ictal and normal state, and samples the non-ictal state to balance the category distribution. The second processing module is used to construct a lightweight multi-stage epileptic seizure recognition model that integrates spatiotemporal features; The third processing module is used to train a multi-stage recognition model for mild epileptic seizures based on the preprocessed samples. The fourth processing module is used to input the EEG signal to be detected into the trained lightweight multi-stage epileptic seizure recognition model, and output the classification result through a global adaptive average pooling classifier to realize multi-stage epileptic seizure recognition.
[0038] As one embodiment of the present invention, a lightweight multi-stage epileptic seizure recognition model that integrates spatiotemporal features includes an input convolutional layer, a multi-scale parallel convolutional module, a depthwise separable convolutional residual module, a Transformer encoder, and a global adaptive average pooling classifier connected in sequence. The input convolutional layer is used to perform preliminary dimensionality upscaling on the multi-channel raw EEG signals and map them to a feature space of a preset dimension to extract basic local features; The multi-scale parallel convolution module employs three independent convolution branches. By configuring different convolution kernel sizes and dilation rates, it captures the evolution patterns of EEG signals at different time scales in parallel. The outputs of each branch are concatenated along the channel dimension and then compressed and fused through convolution to form a joint feature space. The depthwise separable convolutional residual module consists of multiple layers of cascaded depthwise separable convolutional residual blocks (DSCBlock). Each layer adopts a depthwise separable convolutional structure with a different dilation rate, and combined with the residual connection mechanism, it alleviates gradient vanishing and maintains high-level semantic consistency. The Transformer encoder includes a multi-head self-attention mechanism and a feedforward network, introduces learnable positional encoding, and models the medium- and long-range dependencies and global temporal structure of EEG sequences. The global adaptive average pooling classifier compresses the time dimension through adaptive global average pooling, and combines Dropout regularization with a fully connected layer to achieve multi-stage classification output of epileptic seizures.
[0039] As one embodiment of the present invention, the third processing module divides the preprocessed samples into a training set, a validation set, and a test set according to a certain ratio, or adopts cross-patient validation to divide the data; the training set is input into a lightweight multi-stage epileptic seizure recognition model that integrates spatiotemporal features, and is trained using the Adam optimizer and cross-entropy loss function; the hyperparameters are adjusted through the validation set to suppress overfitting.
[0040] Example 3 The present invention also provides a multi-stage epileptic seizure recognition system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes a multi-stage epileptic seizure recognition method when executed by the processor.
[0041] Example 4 The present invention also provides a storage medium storing a computer program that executes a multi-stage epileptic seizure identification method when running.
[0042] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made to the technical solutions of the present invention by those skilled in the art without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.
Claims
1. A method for multi-stage identification of epileptic seizures, characterized in that, include: Step S1: Select key lead channels of the EEG signal of epilepsy patients, slice them according to fixed window length and sliding step size, and generate time-limited sequence fragments; Based on clinical labels, four categories were defined: pre-seizure, seizure, post-seizure, and normal state. Samples of the non-seizure state were sampled to balance the category distribution. Step S2: Construct a lightweight multi-stage epileptic seizure identification model that integrates spatiotemporal features; Step S3: Based on the preprocessed samples, train a multi-stage recognition model for mild epileptic seizures; Step S4: Input the EEG signal to be detected into the trained lightweight multi-stage epileptic seizure recognition model, and output the classification result through the global adaptive average pooling classifier to realize multi-stage epileptic seizure recognition.
2. The multi-stage epileptic seizure identification method as described in claim 1, characterized in that, A lightweight multi-stage epileptic seizure recognition model that integrates spatiotemporal features includes a sequentially connected input convolutional layer, a multi-scale parallel convolutional module, a depthwise separable convolutional residual module, a Transformer encoder, and a global adaptive average pooling classifier. The input convolutional layer is used to perform preliminary dimensionality upscaling on the multi-channel raw EEG signals and map them to a feature space of a preset dimension to extract basic local features; The multi-scale parallel convolution module employs three independent convolution branches. By configuring different convolution kernel sizes and dilation rates, it captures the evolution patterns of EEG signals at different time scales in parallel. The outputs of each branch are concatenated along the channel dimension and then compressed and fused through convolution to form a joint feature space. The depthwise separable convolutional residual module consists of multiple layers of cascaded depthwise separable convolutional residual blocks (DSCBlock). Each layer adopts a depthwise separable convolutional structure with a different dilation rate, and combined with the residual connection mechanism, it alleviates gradient vanishing and maintains high-level semantic consistency. The Transformer encoder includes a multi-head self-attention mechanism and a feedforward network, introduces learnable positional encoding, and models the medium- and long-range dependencies and global temporal structure of EEG sequences. The global adaptive average pooling classifier compresses the time dimension through adaptive global average pooling, and combines Dropout regularization with a fully connected layer to achieve multi-stage classification output of epileptic seizures.
3. The multi-stage epileptic seizure identification method as described in claim 2, characterized in that, In step S3, the preprocessed samples are divided into training set, validation set and test set according to the proportion, or the data is divided by cross-patient validation. The training set is input into the lightweight multi-stage epileptic seizure recognition model that integrates spatiotemporal features. The model is trained using the Adam optimizer and cross-entropy loss function. The hyperparameters are adjusted through the validation set to suppress overfitting.
4. A multi-stage epileptic seizure recognition device, characterized in that, include: The first processing module is used to select key lead channels of the EEG signal of epilepsy patients, slice them according to a fixed window length and sliding step size, and generate time-limited sequence fragments. Based on clinical labels, four categories were defined: pre-seizure, seizure, post-seizure, and normal state. Samples of the non-seizure state were sampled to balance the category distribution. The second processing module is used to construct a lightweight multi-stage epileptic seizure recognition model that integrates spatiotemporal features; The third processing module is used to train a multi-stage recognition model for mild epileptic seizures based on the preprocessed samples. The fourth processing module is used to input the EEG signal to be detected into the trained lightweight multi-stage epileptic seizure recognition model, and output the classification result through a global adaptive average pooling classifier to realize multi-stage epileptic seizure recognition.
5. The multi-stage epileptic seizure recognition device as described in claim 4, characterized in that, A lightweight multi-stage epileptic seizure recognition model that integrates spatiotemporal features includes a sequentially connected input convolutional layer, a multi-scale parallel convolutional module, a depthwise separable convolutional residual module, a Transformer encoder, and a global adaptive average pooling classifier. The input convolutional layer is used to perform preliminary dimensionality upscaling on the multi-channel raw EEG signals and map them to a feature space of a preset dimension to extract basic local features; The multi-scale parallel convolution module employs three independent convolution branches. By configuring different convolution kernel sizes and dilation rates, it captures the evolution patterns of EEG signals at different time scales in parallel. The outputs of each branch are concatenated along the channel dimension and then compressed and fused through convolution to form a joint feature space. The depthwise separable convolutional residual module consists of multiple layers of cascaded depthwise separable convolutional residual blocks (DSCBlock). Each layer adopts a depthwise separable convolutional structure with a different dilation rate, and combined with the residual connection mechanism, it alleviates gradient vanishing and maintains high-level semantic consistency. The Transformer encoder includes a multi-head self-attention mechanism and a feedforward network, introduces learnable positional encoding, and models the medium- and long-range dependencies and global temporal structure of EEG sequences. The global adaptive average pooling classifier compresses the time dimension through adaptive global average pooling, and combines Dropout regularization with a fully connected layer to achieve multi-stage classification output of epileptic seizures.
6. The multi-stage epileptic seizure recognition device as described in claim 5, characterized in that, The third processing module divides the preprocessed samples into training, validation, and test sets proportionally, or uses cross-patient validation to divide the data. The training set is input into a lightweight multi-stage epileptic seizure recognition model that integrates spatiotemporal features. The model is trained using the Adam optimizer and cross-entropy loss function. The hyperparameters are adjusted through the validation set to suppress overfitting.
7. A multi-stage epileptic seizure recognition system, characterized in that, include: A memory and a processor, wherein the memory stores a computer program executed by the processor, the computer program performing the multi-stage epileptic seizure identification method as described in any one of claims 1-3 when executed by the processor.
8. A storage medium, characterized in that, The storage medium stores a computer program that, when executed, performs the multi-stage epileptic seizure identification method as described in any one of claims 1-3.