EEG signal ratchet wave detection method and system based on KAN feature fusion
Through the KAN feature fusion method, the KAN network with multi-base function and self-attention mechanism are used to solve the problem of artificial feature dependence and insufficient accuracy in the detection of EEG signal spike waves, and achieve higher detection accuracy and adaptive feature fusion.
Patent Information
- Application Number
- CN202510917986.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-03
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2045-07-03
AI Technical Summary
The existing EEG signal sphincter wave detection methods rely on artificial feature engineering and are difficult to adapt to the complexity and individual differences of EEG signals. In addition, deep learning methods have poor accuracy and weak generalization performance when detecting artifacts and atypical sphincter waves.
Using a KAN feature fusion method, parallel feature extraction and splicing is performed through KAN networks with multiple basis functions, combining gating dynamic selection and dual attention mechanism, long-term dependence and compression timing dimensions are captured, feature fusion is used by self-attention mechanism, and finally input classifiers for training.
It significantly improves the accuracy of spike wave detection, reduces the dependence of artificial feature design, and improves the adaptive feature fusion capability in noise environments.
Smart Images

Figure CN120408385A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent analysis and processing of EEG signals, and particularly to a method and system for detecting spikes in EEG signals based on KAN feature fusion. Background Art
[0002] Epilepsy is a common neurological disorder characterized by symptoms such as convulsions and loss of consciousness caused by abnormal discharges of brain neurons. Currently, the diagnosis and treatment of epilepsy mainly rely on electroencephalogram (EEG) examinations. EEG can record the electrophysiological signals on the scalp surface, helping doctors observe the electrical activities of brain neurons, especially the interictal epileptic discharges (IEDs) that occur during the interictal period of epilepsy. Among these discharges, spikes in particular are important physiological markers of epilepsy. The detection of spikes is a key step in non-invasive epileptogenic focus localization, but there are still huge challenges in existing clinical practices, mainly manifested in low efficiency and strong subjectivity of manual annotation. Especially when the EEG data volume is large and the time is long (from several hours to several days), doctors need to observe and annotate spikes frame by frame, which not only consumes time and effort but also leads to large subjective differences in the annotation results.
[0003] To solve this problem, current research mainly relies on methods based on traditional machine learning and methods based on deep learning. Traditional machine learning methods usually require manual feature design. By reducing the dimension and characterizing EEG signals, and then combining with a classifier for spike detection. Although these methods are highly interpretable and convenient for doctors to understand algorithm decisions, they rely on manual feature engineering, are difficult to adapt to the complexity and individual differences of EEG signals, have poor detection accuracy for situations such as artifacts and atypical spikes, and have weak generalization performance. In recent years, methods based on deep learning have achieved end-to-end training for spike detection by using convolutional neural networks (CNNs), recurrent neural networks (RNNs) or hybrid architectures, and can automatically learn features while reducing the dependence on manual feature design. Although deep learning methods show great potential in capturing complex features, how to improve their ability to comprehensively capture the complex features of EEG signals remains an urgent problem to be solved. Summary of the Invention
[0004] The object of the present invention is to overcome the deficiencies of the prior art. To achieve the above object, a method and system for detecting spikes in EEG signals based on KAN feature fusion are adopted to solve the problems raised in the above background art.
[0005] The technical solution provided in the first aspect: A method for detecting spikes in EEG signals based on KAN feature fusion, comprising the following steps: S1. Preprocess and partition the electroencephalogram (EEG) data sampled during the interictal period of epileptic patients to obtain the training set and test set of segmented EEG; S2. After performing parallel feature extraction on the obtained training set based on the KAN network with multiple basis functions, obtain multi-KAN parallel features, then splice and reduce the dimension to obtain hybrid features; S3. Perform gated dynamic selection on the obtained hybrid features to obtain the fusion features of the comprehensive multi-scale analysis of EEG signals; S4. Based on the dual attention mechanism, use multi-head self-attention to capture long-term dependencies and learnable attention to compress the temporal dimension to focus on key period features, and obtain weight fusion features; S5. Input the obtained weight fusion features into a classifier and train a prediction model based on the cross-entropy loss function; S6. Finally, use the test set to evaluate the model performance and output the classification results.
[0006] As a further solution of the present invention: The specific steps in S1 include: S11. Perform band-pass filtering processing on the collected EEG data during the interictal period of epileptic patients through and notch filtering processing through ; S12. Perform heartbeat artifact removal processing on the data after band-pass filtering through the ICA decomposition to remove artifact components algorithm; S13. Slice the obtained preprocessed data according to the doctor's annotation, set the batch size to , and obtain the input data , where represents the slice time length, corresponding to the time dimension, and represents the number of channels.
[0007] As a further solution of the present invention: The specific steps in S2 include: S21. Perform parallel feature extraction calculations on the obtained training set based on the KAN network layer with seven orthogonal basis functions, and respectively obtain seven different parallel features of the data, where the seven orthogonal basis functions include basis function,[[]] basis function,[[]] basis function,[[]] basis function,[[]] basis function,[[]] basis function, and basis function; S22. Splice and reduce the dimension of the obtained seven parallel features to obtain hybrid features.
[0008] As a further solution of the present invention: The specific steps in S21 include: Project the original signal into a specific feature space, and utilize the non-linear fitting ability of the learnable activation function to extract time-frequency or spatial features. The formula is:
[0009] Among them, the subscript represents the KAN network with the th basis function as the underlying fitting function of the learnable activation function. takes values of , , , , , , ; represents the preprocessed signal; represents the preliminary characterization obtained after passing through each KAN network. is the data dimension. represents the batch size. represents the time step. represents the feature dimension extracted by the KAN network.
[0010] As a further solution of the present invention: the basis function performs local smoothing on the EEG signal through piecewise low-order polynomials. The formula is:
[0011] Among them, represents the default activation function. represents the base weight, and the two multiplied together obtain the base output; represents the output of the B-spline function. represents the spline function coefficient. represents the fitting bias term. represents the feature extracted by the KAN network after ; The basis function captures the global periodic characteristics of the signal through frequency-domain energy analysis. The formula is:
[0012] Among them, represents the highest expansion order in the basis function. represents the current order. and represent the corresponding sine and cosine term coefficients; represents the feature extracted by the KAN network after ; The basis function eliminates the trend term through high - order polynomial fitting while retaining the relative waveform characteristics of the spike. The formula is:
[0013]
[0014]
[0015] Among them, represents the highest order of the polynomial, represents the current order of the polynomial, represents the coefficient corresponding to the polynomial, represents the -order Chebyshev polynomial, is the bias term; for is the input after compressed to the effective representation interval of the Chebyshev polynomial; represents the feature extracted by the KAN network after ; The basis function accurately captures the transient rising edge of the spike through the high - order derivative sensitivity characteristic. The formula is:
[0016] Among them, represents the highest expansion degree, represents the current series number, represents the coefficient of the -th term, represents the -th power of the input represents the feature extracted by the KAN network after ; The basis function optimizes the multi - lead signals for joint analysis through orthogonal weight distribution. The formula is:
[0017] Among them, represents the highest degree of the polynomial, represents the currently accumulated polynomial degree, represents the recursive formula of the -order Jacobi polynomial, which can be derived successively from the first two terms, represents the coefficient of the and is a key hyperparameter of the Jacobi polynomial, which controls the model's adaptability to different input distributions by adjusting the shape and orthogonality weights of the basis functions; denotes the features extracted by the KAN network after ; The basis function is highly matched with the spike morphology of the spiking wave through the combination of high-order derivatives and Gaussian functions. The formula is:
[0018]
[0019]
[0020]
[0021] where denotes the highest degree of the polynomial, denotes the currently accumulated degree of the polynomial, denotes the recurrence formula of the -th order Hermite polynomial, which can also be derived sequentially from the first two terms, denotes the coefficient of the -th order polynomial; denotes the normalization factor; denotes the features extracted by the KAN network after ; The basis function balances the local details and global trends of the signal through multi-scale time-frequency analysis. The formula is:
[0022]
[0023] where denotes the main process of wavelet transform, denotes the input feature dimension, which is the number of channels of the last dimension of the input here, , denotes the wavelet weight corresponding to the -th input feature, denotes the wavelet function acting on the input feature; and denotes the learnable scale and translation parameters corresponding to the -th feature, which adjusts the morphology of the wavelet function; denotes the features extracted by the KAN network after ; <9000192>As a further solution of the present invention: The specific steps in S22 include: The seven parallel features obtained are concatenated and dimensionally reduced to obtain a mixed feature, and the formula is:
[0025]
[0026]
[0027]
[0028] Wherein, represents the feature extracted by the KAN network after , represents the feature extracted by the KAN network after , represents the feature extracted by the KAN network with the basis function, represents the feature extracted by the KAN network with the basis function, represents the feature extracted by the KAN network with the basis function, represents the feature extracted by the KAN network with the basis function, represents the feature extracted by the KAN network with the basis function, represents the feature dimension after KAN, represents concatenation in the time dimension, and the concatenated feature is then dimensionally reduced through one-dimensional convolution to obtain a mixed feature, represents the dimension of the mixed feature after dimensional reduction.
[0029] As a further solution of the present invention: The specific steps in S3 include: S31. The obtained mixed feature calculates the dynamic fusion weights of the seven KAN network features through a multi-head self-attention mechanism to obtain the self-attention weights of the KAN network at each time step; The mixed feature performs dynamic weight calculation based on the self-attention mechanism, and the formula is:
[0030]
[0031]
[0032]
[0033] Among them, represents the seven dynamic weights of the KAN network obtained by self-attention calculation of the data; is an activation function, is the mixed feature Three different embedding vectors generated by mapping, are the corresponding three different mapping matrices, is the feature dimension in the attention mechanism; S32. Use the self-attention weights to weightedly fuse the mixed feature in time steps to obtain the fused feature , and the formula is:
[0034]
[0035] Among them, represents the KAN network with the th basis function as the underlying fitting function of the learnable activation function, takes values of , , , , , , ; represents the time step, represents the data at the time step under the th dynamic weight of the KAN network; represents the data after passing through the th KAN network and at the time step under the -dimensional feature; represents the weighted fusion feature of the 7 KAN networks of the data at the time step t, represents the concatenation operation in the time dimension.
[0036] As a further solution of the present invention: The specific steps in S4 include: S41. Use the multi-head self-attention mechanism to capture long-term dependencies for the obtained fused feature , and the formula is:
[0037]
[0038]
[0039]
[0040]
[0041]
[0042] where the subscript represents the th attention head of the multi-head attention mechanism, represents the total number of multi-head attentions; is an activation function, is the fused feature three different embedding vectors generated by mapping, are the corresponding three different mapping matrices; (∙) represents the concatenation operation; is a learnable linear transformation coefficient matrix; is the residual connection and normalization; is the preliminary weight fused feature to be normalized and residually connected; is the preliminary weight fused feature; S42. Perform time-dimensional fixed compression on the obtained preliminary weight fused feature through a learnable attention mechanism, dynamically focus on the key time period, and finally obtain the final weight fused feature , and the formula is:
[0043]
[0044]
[0045]
[0046] where is an activation function, is the preliminary weight fused feature two different embedding vectors generated by mapping, are the corresponding two different mapping matrices, is a learnable query vector, and by setting the fixed dimension to the purpose of compressing the time dimension is achieved, and it can be optimized by backpropagation learning.
[0047] As a further solution of the present invention: The specific steps in S5 include: Send the finally output weight fused feature into the classifier to obtain the predicted probability finally output by the model; Then, based on the predicted probability, construct the binary cross-entropy loss function of the model for backpropagation to update the model parameters and train the model. The formula is as follows:
[0048]
[0049] where the subscript represents the th electroencephalogram data input into the model; represents the predicted result output by the model, represents an activation function, represents a linear layer; represents the true label of the electroencephalogram data, represents the total number of electroencephalogram data samples, represents the mean of the loss function of all samples on this model.
[0050] The technical solution provided in the second aspect: A detection system adopting a method for detecting sharp waves of EEG signals based on KAN feature fusion as described in any one of the above, including: A data preprocessing module for preprocessing and partitioning the electroencephalogram data sampled during the interictal period of epileptic patients to obtain a training set and a test set of segmented electroencephalograms; A multi-KAN parallel feature extraction module for performing parallel feature extraction based on the KAN network of multiple basis functions according to the obtained training set, then splicing and dimension reduction of the multi-KAN parallel features to obtain hybrid features; A gated dynamic selection module for performing gated dynamic selection on the obtained hybrid features to obtain the fusion features of the comprehensive multi-scale analysis of EEG signals; A dual attention time series compression module for, based on the dual attention mechanism, using multi-head self-attention to capture long-term dependencies and learnable attention to compress the time series dimension to focus on key period features to obtain weight fusion features; A classification prediction module for inputting the obtained weight fusion features into a classifier and training a prediction model based on the cross-entropy loss function; A test evaluation module for evaluating the performance of the model using the test set and outputting the classification result.
[0051] Compared with the prior art, the present invention has the following technical effects: Adopting the above technical solution, by utilizing the characteristics of the learnable activation function of the KAN network, using the KAN network of seven different basis functions to cover the time-frequency, anti-noise and transient characteristics of EEG signals, and using the self-attention mechanism to dynamically generate a gated weight matrix, adaptive feature fusion in a noisy environment is realized. Compared with the time series sharp wave detection model in the prior art, the accuracy of the model is significantly improved. Brief Description of the Drawings
[0052] The following will describe in detail the specific embodiments of the present invention in conjunction with the accompanying drawings: Figure 1 It is a schematic diagram of the steps of the spike detection method for the disclosed embodiment of the present application; Figure 2 It is an example of electroencephalogram slice data for the disclosed embodiment of the present application; Figure 3 It is a schematic diagram of the basic model of the KAN network in one dimension for the disclosed embodiment of the present application; Figure 4 It is a diagram of the multi-KAN parallel feature extraction network model for the disclosed embodiment of the present application; Figure 5 It is a diagram of the self-attention gating enhanced feature fusion model for the disclosed embodiment of the present application; Figure 6 It is a diagram of the multi-head attention long-term dependence capture and learnable attention feature dimensionality reduction model for the disclosed embodiment of the present application. Specific Embodiments
[0053] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of the present invention.
[0054] Please refer to Figure 1 , in the embodiments of the present invention, the technical solution provided in the first aspect: a method for detecting spikes in EEG signals based on KAN feature fusion, including the following steps: S1. Preprocess and partition the electroencephalogram data sampled during the interictal period of epileptic patients to obtain a training set and a test set of segmented electroencephalograms. The specific steps include: In this embodiment, the preprocessing includes band-pass filtering, removing electrocardiogram artifacts, resampling, and normalization. Specifically: S11. Perform band-pass filtering processing on the collected electroencephalogram data during the interictal period of epileptic patients through band-pass filtering and notch filtering; S12. Perform artifact removal processing on the data after band-pass filtering through the ICA decomposition to remove artifact component algorithm; Among them, based on the reference electrocardiogram (abbreviation: ECG) and electrooculogram (abbreviation: EOG) channels, perform artifact removal processing on the data after band-pass filtering through the ICA decomposition to remove artifact vector algorithm for removing heartbeat artifacts and eye movement artifacts; Perform Z-score normalization on the data after artifact removal channel by channel to obtain the preprocessed electroencephalogram data.
[0055] S13. Slice the obtained preprocessed data according to the doctor's annotation, and set the batch size to , to obtain the input data , where represents the slice time length, corresponding to the time dimension, represents the number of channels.
[0056] As Figure 2 shown, the figure shows an example of electroencephalogram slice data; In this embodiment, slice the preprocessed electroencephalogram data 200 ms before and after the annotation point according to the doctor's annotation, and set the batch size to 32. After slicing each annotation point, a [[ID=2a]] dimensional data will be obtained. After batching, the final input data will be obtained, where 32 corresponds to the batch size and 400 corresponds to the time step and 19 corresponds to the number of lead channels , and the subscript represents the current electroencephalogram data sequence number.
[0057] Divide the sliced data, randomly select of the data as the test set, and the remaining data as the training set. In this embodiment, a total of 6540 ( ) data slices out of 22980 data slices are selected as the test set , and the remaining data is used as the training set data ; S2. After performing parallel feature extraction on the obtained training set based on the KAN network with multiple basis functions, obtain the multi-KAN parallel features and then perform splicing and dimensionality reduction to obtain the hybrid features. The specific steps include: S21. Perform parallel feature extraction calculations on the obtained training set based on the KAN network layer with seven orthogonal basis functions, and respectively obtain seven different parallel features of the data. The seven orthogonal basis functions include basis function, basis function, basis function, [[ID=,58]] basis function, basis function, basis function, and basis function; the specific steps include: The original signal is projected into a specific feature space, and the nonlinear fitting ability of the learnable activation function is used to extract the time-frequency or spatial features. The formula is:
[0058] Among them, the subscript Indicates the The seed function is the KAN network with the underlying fitting function of the learnable activation function, and the value of k is 、 、 、 、 、 、 ; represents the preprocessed signal; It represents the preliminary representation obtained after each KAN network, is the data dimension, represents the batch size, represents the time step, Represents the feature dimension extracted by the KAN network.
[0059] In this embodiment, each KAN network adopts a three-layer network architecture, with the network dimensions being , here The number of lead channels representing EEG signals , Represents the feature dimension after KAN, and performs feature extraction on the channel information at the same time step, such as Figure 3 As shown, the figure shows a A network diagram with a hidden layer dimension of 3. Specifically:
[0060] Among them, the original data After feature extraction, we get , the time dimension does not change, and the feature dimension of the same time step is adjusted to the feature dimension through the network The basis function learning and fitting process in each layer of KAN will not be described here.
[0061] In this embodiment, Figure 4 As shown, the diagram shows a multi-KAN parallel feature extraction network model diagram; according to the original data , , so the KAN network dimension is , the features output by each KAN network are .
[0062] Regarding the seven orthogonal basis functions, specifically: The basis function performs local smoothing on the EEG signal through piecewise low-order polynomials, and the formula is:
[0063] where represents the default activation function, represents the basic weight, and the product of the two gives the basic output; represents the output of the B-spline function, represents the spline function coefficient, represents the fitting bias term, represents after the features extracted by the KAN network; The basis function captures the global periodic characteristics of the signal through frequency-domain energy analysis, and the formula is:
[0064] where represents at the highest expansion order in the basis function, represents the current order, and represent the corresponding sine and cosine term coefficients; represents after the features extracted by the KAN network; The basis function eliminates the trend term through high-order polynomial fitting while retaining the relative waveform characteristics of the spikes, and the formula is:
[0065]
[0066]
[0067] where represents the highest order of the polynomial, represents the current order of the polynomial, represents the corresponding coefficient of the polynomial, represents the th-order Chebyshev polynomial, is the bias term; for is the input after compressed to the effective representation interval of the Chebyshev polynomial result; represents after the features extracted by the KAN network; The The basis function accurately captures the transient rising edge of the spike wave through the high-order derivative sensitivity characteristics. The formula is:
[0068] in, Indicates the maximum number of expansions, Indicates the current level, express The coefficient of the second term, Represents input of power; Indicates passing Features extracted by the KAN network; described The basis function optimizes the multi-lead signal through orthogonal weight distribution for joint analysis. The formula is:
[0069] in, represents the highest degree of the polynomial, Indicates the degree of the currently accumulated polynomial, Indicates the The recursive formula of the Jacobi polynomial of order can be derived by sequentially deducing the first two terms. Indicates the The coefficients of the polynomial of order, and It is a key hyperparameter of the Jacobi polynomial, which controls the adaptability of the model to different input distributions by adjusting the shape and orthogonality weight of the basis function; Indicates passing Features extracted by the KAN network; described The basis function is highly matched with the spike shape of the spike wave through the combination of high-order derivatives and Gaussian functions. The formula is:
[0070]
[0071]
[0072]
[0073] in, represents the highest degree of the polynomial, Indicates the degree of the currently accumulated polynomial, Indicates the The recursive formula of the Hermite polynomial of order can also be derived by sequentially deducing the first two terms. Indicates the Coefficients of the polynomial of order Denote the normalization factor; Denote the features extracted by the KAN network after ; The basis function balances the local details and global trends of the signal through multi-scale time-frequency analysis. The formula is:
[0074]
[0075] Where Denote the main process of wavelet transform, Denote the input feature dimension, which is the number of channels of the last dimension of the input here; , Denote the wavelet weights corresponding to the th input feature, Denote the wavelet function acting on the input feature; And Denote the learnable scale and translation parameters corresponding to the th feature, adjusting the shape of the wavelet function; Denote the features extracted by the KAN network after ;
[0076] In this embodiment, regarding the wavelet function, five wavelet functions are adopted. A brief description is given below. The following denote the general input, and the dimension description will not be carried out anymore: Mexican hat wavelet, the second derivative of the Gaussian function (negative normalization), with a shape similar to a Mexican hat.
[0077]
[0078] The wavelet (also known as the
[0079]
[0080] wavelet) is a complex-valued wavelet widely used in time-frequency analysis. Its core idea is to modulate the complex exponential signal with a Gaussian window function to achieve accurate analysis of the local frequency characteristics of the signal. is the center frequency, and the default value is adopted here.
[0081] The Gaussian reciprocal wavelet ( ) is the first derivative of the Gaussian function.
[0082]
[0083] Among them, is the scale parameter that controls the width of the wavelet. Here, the default value is taken .
[0084] The wavelet is a wavelet with compact support in the frequency domain and infinite smoothness.
[0085]
[0086]
[0087]
[0088] Among them, and are auxiliary functions for implementing this wavelet in the code. The branch corresponds to the low-frequency band in the frequency domain. At this time, the wavelet has no energy outside this interval; The branch corresponds to the transition region in the frequency domain. A smooth transition is achieved through another auxiliary function .
[0089] The construction of the auxiliary function needs to meet two conditions: smoothness, where all derivatives are 0 at and to ensure high-order continuity in the transition interval; normalization, .
[0090] The wavelet (also known as wavelet) is an ideal band-pass filter.
[0091]
[0092]
[0093] Among them, represents the standard wavelet function. Here, the with Hamming window processing is used. Through the window smooth truncation function, its effective range is restricted, the edge effect is reduced, the numerical problem caused by infinite oscillation is avoided, and the numerical stability is enhanced.
[0094] S22. Concatenate and reduce the dimension of the obtained seven parallel features to obtain the hybrid features. The specific steps include: Concatenate and reduce the dimension of the seven parallel features extracted by the KAN network layer based on seven basis functions. The formula is:
[0095]
[0096]
[0097]
[0098] Among them, represents the features extracted by the KAN network after ; represents the features extracted by the KAN network after ; represents the features extracted by the KAN network with basis functions after ; represents the features extracted by the KAN network with basis functions after ; represents the features extracted by the KAN network with basis functions after ; represents the features extracted by the KAN network with basis functions after ; represents the features extracted by the KAN network with basis functions after ; represents the feature dimension after KAN; represents concatenation in the time dimension. After concatenation, the features are further reduced in dimension through one-dimensional convolution to obtain the mixed features. represents the dimension of the mixed features after dimensionality reduction.
[0099] Specifically, the above are concatenated in the feature dimension to obtain the preliminary mixed features ; the preliminary mixed features are and then fed into one-dimensional convolution for feature compression while maintaining the time resolution unchanged. represents the dimension of the mixed features after dimensionality reduction. Here , and finally the compressed mixed features are obtained, which are specifically .
[0100] S3. Perform gated dynamic selection on the obtained mixed features to obtain the fused features of the comprehensive multi-scale analysis of the EEG signal. The specific steps include: As Figure 5 shown, the figure shows the self-attention gated enhanced feature fusion model diagram; S31. The obtained mixed features calculate the dynamic fusion weights of the seven KAN network features through the multi-head self-attention mechanism to obtain the KAN network self-attention weights at each time step; Fuse the features Based on the self-attention mechanism, calculate the dynamic weights. The formula is as follows:
[0101]
[0102]
[0103]
[0104] Among them, represents the seven dynamic weights of the KAN network obtained by self-attention calculation of the data; is an activation function, is the mixed feature Three different embedding vectors generated by mapping, are the corresponding three different mapping matrices, is the feature dimension in the attention mechanism; In this embodiment, the three embedding vectors are , and the corresponding three different mapping matrices are . Here ; The electroencephalogram mixed feature After passing through the above self-attention mechanism, a weight coefficient matrix based on time steps will be obtained , specifically .
[0105] S32. Use the self-attention weights to perform weighted fusion on the mixed feature to obtain the fused feature . The formula is as follows:
[0106]
[0107] Among them, represents the KAN network with the th basis function as the underlying fitting function of the learnable activation function, takes values of , , , , , , ; represents the time step, represents the data at the time step the th dynamic weight of the KAN network; represents the data after passing through the The features at time step after the KAN network under dimensional features; represents the weighted fusion features of 7 KAN networks for the data at time step t, indicating a concatenation operation in the time dimension.
[0108] In this embodiment, the feature is a 64-dimensional feature at time , is its corresponding weight coefficient. After the multiplication operation, the features at the same time are added up to obtain the fusion feature at time ; finally, a concatenation is performed in the time dimension to obtain the fusion feature with unchanged time resolution .
[0109] S4. Based on the dual attention mechanism, use multi-head self-attention to capture long-term dependencies and learnable attention to compress the time dimension to focus on key time period features, and obtain the weight fusion feature. The specific steps include: As Figure 6 shown, the figure is a multi-head attention long-term dependency capture and learnable attention feature dimensionality reduction model diagram; S41. Use the multi-head self-attention mechanism to capture long-term dependencies for the obtained fusion feature , and the formula is:
[0110]
[0111]
[0112]
[0113]
[0114]
[0115] Among them, the subscript represents the th attention head of the multi-head attention mechanism, represents the total number of multi-head attention; is an activation function, is the weighted fusion feature mapped to generate three different embedding vectors, are the corresponding three different mapping matrices; (∙) represents a concatenation operation; is a learnable linear transformation coefficient matrix; is for residual connection and normalization; is the preliminary weight fusion feature for normalization and residual connection; is the preliminary weight fusion feature; In this embodiment, the fusion feature captures long-term dependencies after passing through the four-head self-attention mechanism ( , the three embedding vectors are , and the corresponding three different mapping matrices are , the output of each attention head is , the multi-head output after splicing is , and then it is projected back to the original dimension by calculating with the learnable weight matrix to obtain the preliminary weight fusion feature for normalization and residual connection ; finally, the initial fusion feature is introduced through the residual connection and normalized to obtain the preliminary weight fusion feature , preventing the deep features from being overly smoothed.
[0116] S42. Perform time dimension fixed compression on the obtained preliminary weight fusion feature through the learnable attention mechanism, dynamically focus on the key time periods, and finally obtain the final weight fusion feature , and the formula is:
[0117]
[0118]
[0119]
[0120] where, is an activation function, are two different embedding vectors mapped from the preliminary weight fusion feature , are the corresponding two different mapping matrices, is the learnable query vector, and by setting the fixed dimension to the purpose of compressing the time dimension is achieved, and it can be optimized through backpropagation learning.
[0121] In this embodiment, the preliminary weight fusion feature obtained in step S41 has completed the basic process of multi-KAN feature fusion under the condition of unchanged time resolution. Finally, it is necessary to perform feature dimensionality reduction in the time dimension through the learnable attention module. By setting the learnable query vector , the preliminary weight fusion feature The two embedding vectors are , and the corresponding two mapping matrices are , which is the feature dimension in the attention mechanism. The final weighted fusion feature obtained through the learnable attention mechanism is , and the time length is reduced to .
[0122] In summary, an original electroencephalogram slice data can learn a weighted fusion feature of dimensions through steps S2, S3, and S4 .
[0123] S5. Input the obtained weighted fusion feature into the classifier and train the prediction model based on the cross-entropy loss function. The specific steps include: Send the finally output weighted fusion feature into the classifier to obtain the prediction probability finally output by the model; Then construct the binary cross-entropy loss function of the model based on the prediction probability for backpropagation to update the model parameters and train the model. The formula is:
[0124]
[0125] where the subscript represents the th electroencephalogram data input into the model; represents the prediction result output by the model, represents an activation function, represents a linear layer; represents the true label of the electroencephalogram data, represents the total number of electroencephalogram data samples, represents the mean of the loss function of all samples on this model.
[0126] After the training is completed, the entire prediction model and all the model parameters are obtained.
[0127] S6. Finally, use the test set to evaluate the performance of the model and output the classification result. The specific steps are:
[0128] where is the prediction result of the test set data on the model .
[0129] Technical solution provided by the second aspect: A detection system adopting a detection method for EEG signal sharp waves based on KAN feature fusion as described in any one of the above, comprising: A data preprocessing module, configured to preprocess and partition the electroencephalogram data sampled during the interictal period of epileptic patients to obtain a training set and a test set of segmented electroencephalograms; A multi-KAN parallel feature extraction module, configured to perform parallel feature extraction based on the KAN network of multiple basis functions according to the obtained training set, and then splice and reduce the dimension of the multi-KAN parallel features to obtain mixed features; A gated dynamic selection module, configured to perform gated dynamic selection on the obtained mixed features to obtain fusion features for comprehensive multi-scale analysis of EEG signals; A dual attention time series compression module, configured to, based on the dual attention mechanism, use multi-head self-attention to capture long-term dependencies and learnable attention to compress the time series dimension to focus on key period features, thereby obtaining weighted fusion features; A classification prediction module, configured to input the obtained weighted fusion features into a classifier and train a prediction model based on the cross-entropy loss function; A test evaluation module, configured to evaluate the performance of the model using the test set and output a classification result.
[0130] Although the embodiments of the present invention have been shown and described, for those of ordinary skill in the art, it can be understood that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents, and all should be included within the protection scope of the present invention.
Claims
1. An EEG signal spike detection method based on KAN feature fusion, characterized in that, It includes the following steps: S1. Preprocess and partition the electroencephalogram (EEG) data sampled during the interictal period of epileptic patients to obtain the training set and test set of segmented EEG; S2. After parallel feature extraction based on the KAN network with multiple basis functions according to the obtained training set, splice and reduce the dimensions of the multi-KAN parallel features to obtain hybrid features; S3. Perform gated dynamic selection on the obtained hybrid features to obtain the fusion features of the comprehensive multi-scale analysis of EEG signals; S4. Based on the dual attention mechanism, use multi-head self-attention to capture long-term dependencies and learnable attention to compress the temporal dimension to focus on key period features, and obtain weighted fusion features; S5. Input the obtained weighted fusion features into a classifier and train the prediction model based on the cross-entropy loss function; S6. Finally, use the test set to evaluate the model performance and output the classification result.
2. The EEG signal spike detection method based on KAN feature fusion according to claim 1, characterized in that The specific steps in S1 include: S11. Perform band-pass filtering on the EEG data collected during the interictal period of epileptic patients through and notch filtering through ; S12. Perform heartbeat artifact removal on the data after band-pass filtering through the ICA decomposition-based algorithm for removing artifact components; S13. Slice the obtained preprocessed data according to the doctor's annotation, and set the batch size to , to obtain the input data , where represents the slice time step, corresponding to the time dimension, represents the number of channels.
3. The EEG signal spike detection method based on KAN feature fusion according to claim 1, wherein The specific steps in S2 include: S21. The KAN network layer based on seven orthogonal basis functions performs parallel feature extraction calculations on the obtained training set, and respectively obtains seven different parallel features of the data, where the seven orthogonal basis functions include basis function, basis function, basis function, basis function, basis function, basis function, and basis function; S22. Splice and reduce the dimensions of the obtained seven parallel features to obtain hybrid features.
4. The EEG signal spike detection method based on KAN feature fusion according to claim 3, characterized in that, The specific steps in S21 include: Project the original signal into a specific feature space, and utilize the non-linear fitting ability of the learnable activation function to extract time-frequency or spatial features. The formula is: Among them, the subscript represents the KAN network with the th basis function as the underlying fitting function of the learnable activation function. takes values of , , , , , , ; represents the preprocessed signal; represents the preliminary representation obtained after passing through each KAN network. is the data dimension, represents the batch size, represents the time step, represents the feature dimension extracted by the KAN network.
5. The method for detecting EEG signal spikes based on KAN feature fusion according to claim 3, wherein The basis function performs local smoothing on the EEG signal through piecewise low-order polynomials, and the formula is: Among them, represents the default activation function, represents the basic weight, and the product of the two gives the basic output; represents the output of the B-spline function, represents the spline function coefficient, represents the fitting bias term, represents after the features extracted by the KAN network; The above-mentioned The basis function captures the global periodic characteristics of the signal through frequency-domain energy analysis, and the formula is: Among them, represents the highest expansion series in the basis function, represents the current series, and represent the corresponding sine and cosine term coefficients; represents the features extracted by the KAN network after ; The said The basis function eliminates the trend term through high-order polynomial fitting while retaining the relative waveform characteristics of the spike. The formula is as follows: Among them, represents the highest order of the polynomial, represents the current order of the polynomial, represents the corresponding coefficient of the polynomial, represents the -th order Chebyshev polynomial, is the bias term; for is the input after being compressed to the effective representation interval of the Chebyshev polynomial ; represents the features extracted by the KAN network after ; The above-mentioned The basis function accurately captures the transient rising edge of the spike through the high-order derivative sensitivity characteristic, and the formula is: Among them, represents the highest expansion order, represents the current series number, represents the coefficient of the th term, represents the input to the power of features extracted by the KAN network after The basis function optimizes the joint analysis of multi-lead signals through orthogonal weight distribution, and the formula is: Among them, represents the highest degree of the polynomial, represents the currently accumulated polynomial degree, represents the recurrence formula of the Jacobi polynomial of order which can be derived successively from the first two terms, represents the coefficient of the polynomial of order and are the key hyperparameters of the Jacobi polynomial, which control the adaptability of the model to different input distributions by adjusting the shape and orthogonality weights of the basis functions; represents the features extracted by the KAN network after ; The said The basis function combines the high-order derivative with the Gaussian function and highly matches the spike morphology of the sharp wave. The formula is as follows: Among them, represents the highest degree of the polynomial, represents the currently accumulated polynomial degree, represents the recursive formula of the Hermite polynomial of order, which can also be sequentially derived from the first two terms, represents the coefficient of the polynomial of order; represents the normalization factor; represents the features extracted by the KAN network after ; The basis function balances the local details and global trends of the signal through multi-scale time-frequency analysis, and the formula is: Among them, represents the main process of wavelet transform, represents the input feature dimension, which is the number of channels of the last dimension of the input here ; , represents the wavelet weight corresponding to the th input feature, represents the wavelet function acting on the input feature; and represent the learnable scale and translation parameters corresponding to the th feature, adjusting the shape of the wavelet function; represents the feature extracted by the KAN network after .
6. The EEG signal spike detection method based on KAN feature fusion according to claim 5, characterized in that, The specific steps in S22 include: Splice and reduce the dimensions of the obtained seven parallel features to obtain hybrid features. The formula is: Among them, represents the features extracted by the KAN network passing through . represents the features extracted by the KAN network passing through . represents the features extracted by the KAN network passing through the basis function. represents the features extracted by the KAN network passing through the basis function. represents the features extracted by the KAN network passing through the basis function. represents the features extracted by the KAN network passing through the basis function. represents the features extracted by the KAN network passing through the basis function. represents the feature dimension after KAN. represents concatenation in the time dimension. The concatenated features are then reduced in dimension through one-dimensional convolution to obtain the mixed features. represents the dimension of the mixed features after dimensionality reduction.
7. The EEG signal spike detection method based on KAN feature fusion according to claim 2, wherein The specific steps in S3 include: S31. Calculate the dynamic fusion weights of the seven KAN network features for the obtained hybrid features through the multi-head self-attention mechanism to obtain the self-attention weights of the KAN network at each time step; Mix the features Perform dynamic weight calculation based on the self-attention mechanism. The formula is as follows: Among them, represents seven dynamic weights of the KAN network obtained by self-attention calculation; is an activation function, is the fused feature three different embedding vectors generated by mapping, are the corresponding three different mapping matrices, is the feature dimension in the attention mechanism; S32. Weight and fuse the mixed features at each time step using the self-attention weights to obtain the fused features , and the formula is: Among them, represents the KAN network with the th basis function as the underlying fitting function of the learnable activation function, takes values of , , , , , , ; represents the time step, represents the dynamic weight of the th KAN network for the data at the time step ; represents the -dimensional feature of the data after passing through the th KAN network at the time step ; represents the weighted fusion feature of the 7 KAN networks for the data at the time step t, represents the concatenation operation in the time dimension.
8. The method for detecting EEG signal sharp waves based on KAN feature fusion according to claim 7, wherein The specific steps in S4 include: S41. For the obtained fusion features Use the multi-head self-attention mechanism to capture long-term dependencies. The formula is as follows: Among them, the subscript represents the th attention head of the multi-head attention mechanism, represents the total number of multi-head attentions; is an activation function, is the fused feature three different embedding vectors generated by mapping, are the corresponding three different mapping matrices; (∙) represents the concatenation operation; is a learnable linear transformation coefficient matrix; is the residual connection and normalization; is the preliminary weight-fused feature to be normalized and residually connected; is the preliminary weight-fused feature; S42. For the obtained preliminary weight fusion features perform fixed compression in the time dimension through a learnable attention mechanism, dynamically focus on key time periods, and finally obtain the final weight fusion features , and the formula is: Among them, is an activation function, is the preliminary weight fusion feature two different embedding vectors generated by mapping, are the corresponding two different mapping matrices, is a learnable query vector. By setting the fixed dimension to the purpose of compressing the time dimension is achieved, and it can be optimized by backpropagation learning.
9. The EEG signal spike detection method based on KAN feature fusion according to claim 1, wherein The specific steps in S5 include: The weight fusion features of the final output are fed into the classifier to obtain the predicted probability of the final output of the model; Then construct the binary cross-entropy loss function of the model based on the prediction probability for backpropagation to update the model parameters and train the model. The formula is: Among them, the subscript represents the th electroencephalogram data of the input model; represents the prediction result output by the model, represents an activation function, represents a linear layer; represents the true label of the electroencephalogram data, represents the total number of electroencephalogram data samples, represents the mean of the loss function of all samples on this model.
10. A detection system using a method for detecting EEG signal spikes based on KAN feature fusion as described in any one of claims 1 to 9, characterized in that, It includes: A data preprocessing module for preprocessing and partitioning the EEG data sampled during the interictal period of epileptic patients to obtain the training set and test set of segmented EEG; A multi-KAN parallel feature extraction module for performing parallel feature extraction based on the KAN network with multiple basis functions according to the obtained training set, splicing and reducing the dimensions of the multi-KAN parallel features to obtain hybrid features; A gated dynamic selection module for performing gated dynamic selection on the obtained hybrid features to obtain the fusion features of the comprehensive multi-scale analysis of EEG signals; A dual attention temporal compression module for capturing long-term dependencies using multi-head self-attention and compressing the temporal dimension with learnable attention to focus on key period features based on the dual attention mechanism to obtain weighted fusion features; A classification prediction module for inputting the obtained weighted fusion features into a classifier and training the prediction model based on the cross-entropy loss function; A test evaluation module for evaluating the model performance using the test set and outputting the classification result.
Citation Information
Patent Citations
Epilepsy prediction method and device
CN117752308A
Topological graph-based space-time multi-mode ratchet wave detection method
CN118411366A
Epilepsy detection method based on multi-scale space-time diagram attention fusion network
CN119745399A
Method and device for identifying abnormal trajectory of smuggling ship based on multi-source information fusion
CN119782987A
Double-branch electroencephalogram signal decoding method and device based on multi-scale feature fusion
CN119848781A
Cited By
Continuous monitoring method and system for multi-modal physiological parameter fusion
CN120753668A
Multi-dimensional signal feature mapping method and device based on double-branch structure
CN121188724A
Electrocardio gating scanning control method and system based on multi-model fusion algorithm
CN121667735A