A spatial covariance-based adaptive filter bank cut-space sleep staging method
Patent Information
- Application Number
- CN202611125988.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-28
- Publication Date
- 2026-10-23
AI Technical Summary
N1 期持续时间短(通常 < 10% 总睡眠时间),频谱特征与清醒期和 N2 期高度相似,现有算法的 F1 得分普遍低于 0.35,严重影响睡眠结构分析的准确性和临床应用价值
[0040]1)多频段黎曼特征融合:本发明首次将滤波组谱分解与黎曼切空间映射结合,实现多频段空间特征的有效提取,同时捕获睡眠脑电的空间协方差结构和频段特异性神经生理特征。
Smart Images

Figure CN122954445A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of EEG signal processing and sleep medicine technology, and particularly relates to an adaptive filtering group-based spatial sleep staging method based on spatial covariance, which is suitable for resource-constrained portable EEG devices to achieve high-precision and robust five-category automatic sleep staging. Background Technology
[0002] Portable EEG sleep monitoring systems have gained widespread attention in recent years due to their ability to provide long-term home monitoring and their relatively low medical costs. However, deploying automated sleep staging algorithms on resource-constrained embedded devices faces three core challenges: balancing high accuracy, noise robustness, and computational efficiency.
[0003] Existing automatic sleep staging methods are mainly divided into three categories:
[0004] The manual feature + traditional classifier method extracts features in the time domain, frequency domain, and time-frequency domain and then uses classifiers such as random forests. This method is computationally efficient, but it relies on manually designed features, has limited generalization ability, and performs poorly in detecting transitional sleep stages such as N1 stage.
[0005] Deep learning methods, such as DeepSleepNet and TinySleepNet, learn hierarchical representations directly from the raw signal, achieving high accuracy. However, these methods require substantial computational resources and training data, the models are sensitive to noise, and they have poor interpretability, making them difficult to deploy on portable devices.
[0006] Riemannian geometric methods utilize the manifold structure of the EEG covariance matrix for classification, exhibiting inherent noise robustness. However, existing Riemannian sleep staging methods (such as MDM) only use single-band covariance matrices, failing to fully leverage the multi-band neurophysiological characteristics of sleep EEG and lacking temporal context modeling, resulting in low overall accuracy.
[0007] In particular, the detection of stage N1 (the transitional stage of light sleep) has long been a technical challenge. Stage N1 is short in duration (usually < 10% of total sleep time), and its spectral characteristics are highly similar to those of the wakefulness stage and stage N2. Existing algorithms generally achieve F1 scores below 0.35, which seriously affects the accuracy of sleep structure analysis and its clinical application value. Summary of the Invention
[0008] The purpose of this invention is to overcome the shortcomings of the prior art and provide a spatial sleep staging method based on an adaptive filtering group based on spatial covariance. While maintaining computational efficiency and model compactness, it significantly improves the detection performance and noise robustness of the N1 phase, achieving high-precision five-class sleep staging suitable for portable devices.
[0009] To solve the above-mentioned technical problems, the specific technical solution of the present invention is as follows:
[0010] An adaptive filtering group spatial sleep staging method based on spatial covariance, the method comprising the following steps:
[0011] Step S1: Acquire multi-channel EEG signals from multiple subjects, preprocess and decompose the EEG signals using a filter group to obtain multiple frequency band EEG signals, and construct an EEG dataset;
[0012] Step S2: Calculate the spatial covariance matrix for each frequency band of the EEG signal for each sample in the EEG dataset, and regularize the spatial covariance matrix to obtain the regularized spatial covariance matrix.
[0013] Step S3: Riemann tangent space projection: Using the Riemann mean of the training set as a reference point, project the regularized spatial covariance matrix of each sample and each frequency band onto the tangent space to obtain the tangent space features.
[0014] Step S4: Feature fusion and classification: After concatenating the tangent space features of all frequency bands of each sample, an SVM classifier with RBF kernel is used for classification to obtain the probability prediction of each sleep stage of the sample; and the probability prediction is normalized to obtain the normalized probability prediction.
[0015] Step S5: Adaptive temporal smoothing: A moving average filter with a window size of 3 is used to smooth the normalized probability prediction of the sample. At the same time, an N1-period protection mechanism is introduced: when the normalized probability prediction of the sample in N1 period exceeds the confidence threshold, the original normalized probability prediction of N1 period is retained; thus obtaining the final sleep stage prediction result.
[0016] Step S6: Construct a loss function, and train the SVM classifier using the loss function to obtain the trained SVM classifier;
[0017] Step S7: Calculate the regularized spatial covariance matrix using samples from the validation set, obtain the tangent vector through Riemann mapping, and finally obtain the fused feature vector. Use the trained SVM classifier to classify the samples and obtain the probability prediction of each sleep stage. Through the N1-stage protection mechanism, obtain the final sleep stage prediction result.
[0018] Further, step S1 includes the following steps:
[0019] Step S11: Acquiring and filtering EEG signals: Acquire multi-channel EEG signals from multiple subjects, and perform 4th-order Butterworth bandpass filtering on the EEG signals from 0.5 to 40 Hz to obtain filtered EEG signals;
[0020] Step S12: Signal framing: The filtered EEG signal is divided into non-overlapping epochs according to a fixed time length, and each epoch corresponds to a sleep stage label annotated by an expert.
[0021] Step S13: Data cleaning: Perform a validity check on the segmented epochs, and remove invalid epochs with missing signals, abnormal signal amplitudes, or missing sleep stage labels to obtain the preprocessed EEG signal.
[0022] Step S14: The preprocessed EEG signal of each epoch and the corresponding label constitute a sample. All the samples of the subjects constitute the EEG dataset. The EEG dataset is divided into training set and test set.
[0023] Step S15: Filter group spectrum decomposition: The preprocessed EEG signal is decomposed into multiple sub-bands that are highly correlated with the neurophysiological characteristics of sleep according to frequency, resulting in multiple frequency band EEG signals.
[0024] Further, step S2 includes the following steps:
[0025] Step S21: Calculate the spatial covariance matrix for the EEG signal of each frequency band;
[0026] Step S22: Use the OAS estimator to regularize the spatial covariance matrix to obtain the regularized spatial covariance matrix.
[0027] Further, step S3 includes the following steps:
[0028] Step S31: Calculate the Riemann mean of the regularized spatial covariance matrix of all samples in the training set for each frequency band, and use it as a reference point for the tangent space;
[0029] Step S32: Logarithmic mapping: Using the Riemann mean of the regularized spatial covariance matrix of each frequency band as a reference point, the regularized spatial covariance matrix of each frequency band of the sample is projected from the symmetric positive definite manifold to the tangent space through logarithmic mapping to obtain the tangent vector corresponding to the sample.
[0030] Step S33: Feature extraction: Expand the tangent vectors of each frequency band of all samples into one-dimensional feature vectors, thus obtaining the tangent space features in Euclidean space.
[0031] Further, step S4 includes the following steps:
[0032] Step S41: Feature concatenation: Concatenate the tangent space features of each frequency band of all samples into a complete fusion feature vector in sequence;
[0033] Step S42: Use an SVM classifier to classify the concatenated fused feature vector to obtain the original decision values for each sleep stage;
[0034] Step S43: Probability calibration: Convert the raw decision values of the SVM into probability values using Platt scaling;
[0035] Step S44: Probability Normalization: Normalize the probability values of each sleep stage so that the sum of the probabilities of all stages is 1, and obtain the normalized probability prediction of each sleep stage.
[0036] Further, step S5 includes the following steps:
[0037] Step S51: Temporal smoothing: The normalized probability prediction of the samples is smoothed by using a moving average filter with a window size of 3.
[0038] Step S52: Adaptive N1-stage protection mechanism: Identify the N1-stage index, determine whether the normalized probability prediction of the N1-stage at the current time exceeds the confidence threshold. If it exceeds, retain the normalized probability prediction of the N1-stage without smoothing. If it does not exceed, use the smoothed probability prediction. Based on the processed probability sequence, select the stage with the highest probability as the final sleep stage prediction result.
[0039] Compared with the prior art, the present invention has the following beneficial technical effects:
[0040] 1) Multi-band Riemann feature fusion: This invention is the first to combine filter group spectral decomposition with Riemann tangent space mapping to achieve effective extraction of multi-band spatial features, while capturing the spatial covariance structure and frequency band-specific neurophysiological features of sleep EEG.
[0041] 2) Adaptive Temporal Smoothing and N1 Protection Mechanism: While maintaining the temporal continuity of the sleep phase, it specifically protects the brief N1 transition phase, solving the problem of N1 phase being overwhelmed by traditional smoothing methods. Significantly Improved N1 Phase Detection Performance: On the Sleep-EDF dataset, the N1 phase F1 score reaches 0.481, far exceeding the current best TinySleepNet (0.325), solving the industry-wide challenge of detecting transitional sleep phases.
[0042] 3) Lightweight Design and Efficient Inference: While maintaining accuracy, the model features a lightweight design suitable for deployment on portable devices. Classifier Selection: Using SVM instead of a deep learning model reduces the number of parameters from millions to thousands; Feature Selection: ANOVA F-value feature selection compresses feature dimensions, reducing computational overhead; Model Compression: The number of support vectors is much smaller than the number of training samples, resulting in a model size of only 6.04 MB.
[0043] 4) Noise Robustness Design: Utilizing the inherent characteristics of covariance matrix estimation, natural noise suppression is achieved; noise cancellation through covariance estimation: covariance matrix estimation has a canceling effect on uncorrelated zero-mean noise; when the noise has zero mean and is uncorrelated with the signal, the noise covariance is a diagonal matrix, which can be effectively suppressed through regularization. Filter bank decomposition enhances signal-to-noise ratio: bandpass filters retain only the target frequency band signal, effectively filtering out noise from other frequency bands. OAS regularization improves stability: the shrinking estimator has a smoothing effect on noise-induced covariance matrix perturbations.
[0044] 5) Cross-dataset generalization ability: The inherent cross-domain invariance of the Riemann framework enables the model to generalize well across different datasets. Stability of the mean: The Riemann mean is robust to changes in data distribution; Consistency of the tangent space mapping: The tangent space mapping preserves the intrinsic geometric structure of the data and is unaffected by external factors (such as lead configuration and population differences); Generality of spatial covariance: Spatial covariance features describe the relative relationships between channels and have generality across populations and lead configurations.
[0045] 6) Performance-efficiency-robustness balance: Through compact feature representation (only 24-dimensional features in 2 channels) and efficient SVM classification, it achieves accuracy comparable to deep learning, while improving training speed by 1.5 times, with a model size of only 6.14MB. Moreover, in a high-noise environment with a 5dB SNR, the overall accuracy only decreases by 1.2%, which is far superior to traditional handmade feature methods (2.8%), making it suitable for portable monitoring in home environments.
[0046] 7) High computational performance: Training time is 1.5 times faster than TinySleepNet (781.6s vs 1194.6s), inference time is only 7.61ms / epoch, model size is 6.14MB, and it can be directly deployed on resource-constrained embedded devices.
[0047] 8) Good cross-dataset generalization: It achieves 75.8% accuracy on the ISRUC dataset and 60.2% accuracy on the DREAMS patient dataset, making it suitable for different populations and clinical scenarios.
[0048] 9) High interpretability: The filter bank decomposition and Riemann geometric features have clear neurophysiological significance, which makes it easy for clinicians to understand and verify the model's decision-making.
[0049] 10) Traditional methods typically use 5 frequency bands (Delta, Theta, Alpha, Beta, Gamma), while this invention uses 8 fine frequency bands: This fine frequency band division allows SCA-FBTS to capture more subtle differences in sleep stages, especially in the identification of transition stages. Attached Figure Description
[0050] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0051] Figure 1 This is the overall flowchart of the SCA-FBTS algorithm of this invention.
[0052] Figure 2 This is a diagram showing the performance-efficiency comparison of different algorithms in this invention (the size of the bubble represents the model size).
[0053] Figure 3 This is a schematic diagram comparing the F1 scores of different sleep stages in this invention.
[0054] Figure 4 This is a schematic diagram comparing sleep and hypnosis in representative subjects of this invention (Ground truth value, SCA-FBTS, TinySleepNet, DeepSleepNet, SSC-SleepNet).
[0055] Figure 5 This is a t-SNE visualization diagram of the SCA-FBTS feature of the present invention. Detailed Implementation
[0056] 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.
[0057] This invention proposes an adaptive filtering group slicing spatial sleep staging method based on spatial covariance, such as... Figure 1 As shown, the method includes the following steps:
[0058] Step S1: Acquire multi-channel EEG (Electroencephalogram) signals from multiple subjects, preprocess and decompose the EEG signals using a filter group to obtain multiple frequency band EEG signals, and construct an EEG dataset.
[0059] Step S11: Acquire EEG signal and filter: Acquire multi-channel EEG signals from multiple subjects, and perform 4th-order Butterworth bandpass filtering on the EEG signals from 0.5 to 40 Hz to obtain filtered EEG signals.
[0060] Specifically, the EEG signal originates from electroencephalogram (EEG) data acquired via scalp electrodes. The filtering process is used to remove DC offset components and high-frequency noise interference above 40Hz.
[0061] Step S12: Signal framing: The filtered EEG signal is divided into non-overlapping epochs (continuous signal segments) according to a fixed time length. Each epoch corresponds to a sleep stage label marked by an expert.
[0062] Preferred, each epoch has a fixed duration of 30 seconds. The sleep stage labels include five labels: W, REM, N1, N2, and N3. W represents wakefulness, REM represents rapid eye movement (REM) sleep, N1 represents light sleep stage 1, N2 represents light sleep stage 2, and N3 represents deep sleep.
[0063] Step S13: Data cleaning: Perform a validity check on the segmented epochs, and remove invalid epochs with missing signals, abnormal signal amplitudes, or missing sleep stage labels to obtain the preprocessed EEG signal.
[0064] Specifically, the preprocessed EEG signal for each epoch is used This indicates that the sleep stage label corresponding to each epoch is represented as... .
[0065] Step S14: The preprocessed EEG signal of each epoch and the corresponding label constitute a sample. All the samples of the subjects constitute the EEG dataset. The EEG dataset is divided into training set and test set.
[0066] Specifically, the EEG dataset is represented as: , The total number of samples is represented as ; the training set is represented as , The training set represents the total number of samples; the test set represents... , This represents the total number of samples in the test set.
[0067] Step S15: Filter group spectrum decomposition: The preprocessed EEG signal is decomposed into multiple sub-bands that are highly correlated with the neurophysiological characteristics of sleep according to frequency, resulting in multiple frequency band EEG signals.
[0068] Preferably, it is decomposed into 8 frequency bands as shown in Table 1:
[0069] Table 1. Frequency bands of neurophysiological characteristics of sleep
[0070]
[0071] Specifically, the preprocessed EEG signal is decomposed into multiple frequency bands using a Butterworth bandpass filter, as shown below:
[0072]
[0073] in, Indicates the first EEG signal after 1 epoch of preprocessing Indicates the number of channels (portable devices typically have 1-4 channels). Indicates the number of time points (30-second epochs, sampling rate 100Hz). ); Indicates the first epoch number EEG signals after preprocessing in each frequency band Indicates the frequency band number. Indicates the total number of frequency bands. Indicates the first A bandpass filter.
[0074] No. The transfer function of the bandpass filter is:
[0075]
[0076] in, Indicates the first The complex frequency domain amplitude-frequency response of a bandpass filter; Represents the Laplace complex frequency; Indicates the filter order, and The filter is a fourth-order Butterworth bandpass filter; Indicates the first The low-frequency cutoff frequency of a bandpass filter; Indicates the first A bandpass filter with a high-frequency cutoff frequency.
[0077] The first bandpass filter has a low-frequency cutoff frequency of 0.5Hz and a high-frequency cutoff frequency of 4Hz; the second bandpass filter has a low-frequency cutoff frequency of 4Hz and a high-frequency cutoff frequency of 6Hz; the third bandpass filter has a low-frequency cutoff frequency of 6Hz and a high-frequency cutoff frequency of 8Hz; the fourth bandpass filter has a low-frequency cutoff frequency of 8Hz and a high-frequency cutoff frequency of 10Hz; the fifth bandpass filter has a low-frequency cutoff frequency of 10Hz and a high-frequency cutoff frequency of 12Hz; the sixth bandpass filter has a low-frequency cutoff frequency of 12Hz and a high-frequency cutoff frequency of 14Hz; the seventh bandpass filter has a low-frequency cutoff frequency of 14Hz and a high-frequency cutoff frequency of 20Hz; and the eighth bandpass filter has a low-frequency cutoff frequency of 20Hz and a high-frequency cutoff frequency of 30Hz.
[0078] Step S2: Calculate the spatial covariance matrix for each frequency band of the EEG signal for each sample in the EEG dataset, and perform regularization on the spatial covariance matrix to obtain the regularized spatial covariance matrix.
[0079] Step S21: Calculate the spatial covariance matrix for the EEG signal of each frequency band.
[0080] Specifically, the spatial covariance matrix is calculated as follows:
[0081]
[0082] in, Indicates the first The first sample The spatial covariance matrix of each frequency band; Indicates the first One sample in At that moment, all channels were at the... The amplitude vector of the EEG signal in each frequency band; Indicates the first The sample at the th The mean vector of EEG signals in each frequency band; Indicates the number of time points; This indicates transpose.
[0083] Step S22: Use the OAS (Oracle Approximating Shrinkage) estimator to regularize the spatial covariance matrix to obtain the regularized spatial covariance matrix.
[0084] When the number of channels When the sample size is large or limited, the spatial covariance matrix may exhibit estimation bias. Regularization is performed using the Oracle Approximating Shrinkage (OAS) estimator, with the following regularization method:
[0085]
[0086] in, Indicates the first The first sample Each frequency band regularized spatial covariance matrix; Indicates the first The first sample The contraction factor of each frequency band; Indicates the number of channels; Represents the matrix trace operation; express Identity matrix.
[0087] Furthermore, the first The first sample Contraction factor of each frequency band Determined by minimizing the mean squared error (MSE):
[0088]
[0089] in, Indicates the first The first sample Variance estimation of elements of the spatial covariance matrix for each frequency band; Indicates the first The first sample The expected square of the elements of the spatial covariance matrix of each frequency band.
[0090] The OAS estimator balances bias and variance, improving estimation stability and exhibiting better robustness to small sample data. Through adaptive shrinkage factor adjustment, the OAS estimator can enhance the estimation accuracy and stability of the covariance matrix under small sample conditions, avoiding estimation bias caused by insufficient sample size.
[0091] Step S3: Riemann tangent space projection: Using the Riemann mean of the training set as a reference point, project the regularized spatial covariance matrix of each sample and each frequency band onto the tangent space to obtain the tangent space features.
[0092] Step S31: Calculate the Riemann mean of the regularized spatial covariance matrix of all samples in the training set for each frequency band, and use it as a reference point for the tangent space.
[0093] The Riemannian Mean is the "center" of all covariance matrices in the training set on the SPD manifold, serving as a reference point for the tangent space. The SPD manifold can be imagined as a "curved space" where each point represents a covariance matrix. In this space, "straight lines" are geodesics, and "distances" are Riemannian distances.
[0094] The first of all samples in the training set The regularized spatial covariance matrix of each frequency band is represented as { };in, This represents the total number of samples in the training set. The Riemann mean of the regularized spatial covariance matrix of each frequency band is obtained by a fixed-point iterative algorithm, including the following steps:
[0095] Step S311: With the first The Euclidean mean of the regularized spatial covariance matrix of each frequency band is used as the Riemann mean for the initial iteration.
[0096]
[0097] in, Indicates the first Riemann mean of the initial iteration of each frequency band; Indicates the first The first sample Each frequency band regularized spatial covariance matrix.
[0098] Step S312: For each sample, the first... The covariance matrix after center transformation is obtained by performing a symmetric square root transformation on the regularized spatial covariance matrix of each frequency band.
[0099]
[0100] in, Indicates the first The first frequency band The Riemann mean of the next iteration; Indicates the first The first sample The first frequency band The covariance matrix after the center transformation in the next iteration.
[0101] Step S313: Calculate the first value of all samples. Geometric mean of the covariance matrix of each frequency band.
[0102] Step S3131: For each sample, the first... Eigenvalue decomposition is performed on the covariance matrix after center transformation of each frequency band.
[0103]
[0104] in, Indicates the first The first sample A matrix of orthogonal eigenvectors for each frequency band; Indicates the first The first sample Diagonal eigenvalue matrix of each frequency band.
[0105] Step S3132: Align feature vectors: Select the first sample... The orthogonal eigenvector matrix of each frequency band is used as the common eigenvector basis, that is and other samples The eigenvalues of the orthogonal eigenvector matrix of each frequency band are transformed to the common eigenvector basis.
[0106]
[0107] in, Indicates the first The first sample The diagonal eigenvalue matrix after projecting each frequency band onto the common eigenvector basis.
[0108] Step S3133: Calculate the first value of all samples. The arithmetic mean of the logarithmic diagonal eigenvalues of each frequency band.
[0109]
[0110] in, Indicates the first of all samples The arithmetic mean of the logarithmic diagonal eigenvalues of each frequency band.
[0111] Step S3134: Reconstruct all samples Geometric mean of the covariance matrix of each frequency band.
[0112]
[0113] in, Indicates the first of all samples The first frequency band The geometric mean of the covariance matrix in the next iteration.
[0114] Step S314: Update the first Riemann mean of each frequency band.
[0115]
[0116] in, No. The first frequency band The Riemann mean of the next iteration.
[0117] Step S315: Determine if the Riemann mean satisfies the convergence condition. If the convergence condition is not met, continue with steps S312-S314; if the convergence condition is met, stop the iteration and obtain the result. The Riemann mean of the regularized spatial covariance matrix for each frequency band.
[0118] Specifically, the convergence condition is expressed as follows:
[0119]
[0120] in, Indicates the preset convergence threshold (preferred). ); It is the Frobenius norm.
[0121] The first convergence condition is satisfied The first frequency band Riemann mean of the next iteration As the first Riemann mean of the regularized spatial covariance matrix for each frequency band .
[0122] Riemann mean has the following functions: 1) Tangent space anchor: defines the position and orientation of the tangent space, around which all samples are projected; 2) Data alignment: normalizes data from different distributions to the same coordinate system, eliminating absolute positional differences; 3) Enhanced generalization: captures the common structure of data and improves cross-domain adaptability.
[0123] Step S32: Logarithmic mapping: Using the Riemann mean of the regularized spatial covariance matrix of each frequency band as a reference point, the regularized spatial covariance matrix of each frequency band of the sample is projected from the symmetric positive definite (SPD) manifold to the tangent space through logarithmic mapping to obtain the tangent vector corresponding to the sample.
[0124] Specifically, the first The first sample Each frequency band regularized spatial covariance matrix Projected to the first Riemann mean of the regularized spatial covariance matrix for each frequency band The tangent space centered at the logarithmic point has the following logarithmic mapping formula:
[0125]
[0126] in, Indicates the first The first sample The tangent vector of each frequency band.
[0127] Geometric meaning of tangent space mapping:
[0128] This indicates centralization, and the first The first sample Each frequency band regularized spatial covariance matrix Projected to the first Riemann mean of the regularized spatial covariance matrix for each frequency band A coordinate system centered at the center;
[0129] This represents a logarithmic mapping that maps points on a manifold to the tangent space (linear space).
[0130] It indicates rotation, preserving the original spatial geometry.
[0131] Traditional machine learning algorithms (such as SVM and LDA) are designed for Euclidean space and cannot directly process data on SPD manifolds. The purpose of tangent space mapping is to: linearize nonlinear problems: the tangent space is a linear approximation of a point on the manifold; preserve geometric structure: the relative geometric relationships on the manifold are preserved through logarithmic mapping; and provide a unified representation: projecting all samples onto the same linear space for easier subsequent processing.
[0132] Step S33: Feature Extraction: Project the tangent vector of each frequency band of all samples Expanding into one-dimensional feature vectors yields the tangent space features in Euclidean space. .
[0133] The first after spatial mapping The first sample The tangent vector of each frequency band The matrix is symmetric, and its number of independent elements is:
[0134]
[0135] in, Indicates the first The first sample The tangent vector of each frequency band Dimensions.
[0136] The expand operation is represented as follows:
[0137]
[0138] in, Indicates the first The first sample The tangent space characteristics of each frequency band; This indicates that the upper triangular elements of the tangent vector are extracted to form the feature vector.
[0139] for Portable devices for each channel, generating [data / frequency] in each frequency band. Dimensional features; generated across 8 frequency bands Dimensional features.
[0140] for Channels, each frequency band generates Dimensional features; generated across 8 frequency bands Dimensional features.
[0141] Step S4: Feature fusion and classification: After concatenating the tangent space features of all frequency bands of each sample, use an SVM (Support Vector Machine) classifier with RBF kernel to classify the sample and obtain the probability prediction of each sleep stage; and normalize the probability prediction to obtain the normalized probability prediction.
[0142] Step S41: Feature concatenation: Concatenate the tangent space features of each frequency band of all samples into a complete fusion feature vector in sequence.
[0143]
[0144] in, Indicates the first The fusion feature vector of each sample.
[0145] Step S42: Use an SVM classifier to classify the concatenated fused feature vector to obtain the original decision values for each sleep stage.
[0146] Specifically, the SVM classifier uses a radial basis function (RBF) as its kernel function and outputs the original decision values for each sleep stage through a decision function.
[0147] The SVM decision function is expressed as follows:
[0148]
[0149] in, Indicates the first The sample at the th The original decision values corresponding to the sleep-like stage; Indicates the first The fusion feature vector of each sample; Indicates the first Support vectors (i.e., satisfying) (samples) Indicates the first The support vectors at the th ... Lagrange multipliers of the class; Indicates the first The support vectors at the th ... Tags for sleep-like stages; Indicates the first Classification bias item; This represents the RBF radial basis function.
[0150] The RBF radial basis function is represented as follows:
[0151]
[0152] in, Indicates the first The fusion feature vector of the nth sample and the nth sample The kernel function value obtained by mapping the support vectors through the RBF kernel; Indicates the first The fusion feature vector of each sample; Indicates the first Support vectors; For kernel parameters; This represents the square of the bandwidth parameter of the RBF kernel function.
[0153] Step S43: Probability calibration: Convert the raw decision values of the SVM into probability values using Platt scaling.
[0154] Specifically, the Platt scaling maps the original decision values to a probability distribution in the [0,1] interval by fitting a logistic regression model; the conversion of decision values into probabilities using Platt scaling is calculated as follows:
[0155]
[0156] in Indicates the first The fusion feature vector of the nth sample belongs to the nth sample. Posterior probability of sleep-like stages; Indicates the first Slope scaling parameters; Indicates the first Class intercept bias parameter; and It was obtained by fitting with logistic regression.
[0157] Step S44: Probability Normalization: Normalize the probability values of each sleep stage so that the sum of the probabilities of all stages is 1, and obtain the normalized probability prediction of each sleep stage.
[0158] Specifically, the probabilities of all categories are normalized to ensure that the sum is 1:
[0159]
[0160] in, Indicates the first The total predicted probability distribution after normalizing all categories of the nth sample, i.e., the nth Normalized probability prediction for each sample; Indicates the first one sample Normalized probability prediction for the period; Indicates the first one sample Normalized probability prediction for the period; Indicates the first one sample Normalized probability prediction for the period; Indicates the first one sample Normalized probability prediction for the period; Indicates the first one sample Normalized probability prediction for the period; .
[0161] Step S5: Adaptive time smoothing: A moving average filter with a window size of 3 is used to smooth the normalized probability prediction of the sample. At the same time, an N1 period protection mechanism is introduced: when the normalized probability prediction of the sample in the N1 period exceeds the confidence threshold, the original normalized probability prediction in the N1 period is retained to prevent the transition phase from being over-smoothed.
[0162] Step S51: Temporal smoothing: A moving average filter with a window size of 3 is used to smooth the normalized probability prediction of the samples.
[0163] Specifically, the moving average is calculated by averaging the normalized probability predictions of the current time period and the time periods before and after it. That is, it is calculated by averaging the normalized probability predictions of the current sample and the samples before and after it. One sample corresponds to one epoch, and the fixed time length is 30 seconds. The moving average reduces the impact of instantaneous noise on the prediction results. The moving average is expressed as follows:
[0164]
[0165] in, Indicates the first The predicted probability distribution of each sample after smoothing; Indicates the smooth window size (default is 3).
[0166] The N1 stage is usually very short (1-2 epochs), and temporal smoothing can over-eliminate N1 predictions, leading to a decrease in the recognition rate of the N1 stage.
[0167] Step S52: Adaptive N1-stage protection mechanism: Identify the N1-stage index, determine whether the normalized probability prediction of the N1-stage at the current time exceeds the confidence threshold. If it exceeds, retain the normalized probability prediction of the N1-stage without smoothing. If it does not exceed, use the smoothed probability prediction. Based on the processed probability sequence, select the stage with the highest probability as the final sleep stage prediction result.
[0168] Specifically, the adaptive N1-period protection is implemented in the following way:
[0169]
[0170] in, Indicates the first The sleep stage probability distribution of each sample after N1-period adaptive protection correction; Indicates the first The predicted probability distribution of each sample after smoothing; Indicates the first one sample Normalized probability prediction (confidence level) for the period; Indicates the confidence threshold (default 0.5); This represents the original predicted sleep stage (i.e., the category with the highest probability).
[0171] The final sleep stage prediction result is based on the sleep stage probability distribution after N1-phase adaptive protection correction, selecting the stage with the highest probability as the final sleep stage prediction result, as shown in the following formula:
[0172]
[0173] in, Indicates the first Predict sleep stages for each sample. Return the stage index with the highest probability.
[0174] The core of the N1 protection mechanism is "selective temporal smoothing": smoothing is applied to stable sleep stages (N2, N3, REM) to reduce misjudgments; smoothing is skipped for unstable N1 stages, retaining the original prediction, thus effectively preventing prediction bias caused by over-smoothing of transitional stages and improving the accuracy of sleep staging; confidence thresholds are used to identify N1 samples that need protection. The confidence-based adaptive temporal smoothing strategy intelligently protects the identification accuracy of short transitional stages (N1) while ensuring the continuity of the sleep architecture.
[0175] Confidence threshold The value of needs to strike a balance between "protecting the true N1" and "eliminating noise-induced misjudgments": Too small: Protecting too many low-confidence N1 predictions may retain noisy misjudgments; Too large: Protecting too few high-confidence N1 predictions may miss the true N1; experiments have shown that... It is the optimal value, achieving the best overall performance on the Sleep-EDF dataset.
[0176] Step S6: Construct a loss function and train the SVM classifier using the loss function.
[0177] Specifically, the loss function of the Support Vector Machine (SVM) is constructed, which consists of a margin maximization term and a classification error penalty term, as follows:
[0178]
[0179] in, Represents the loss function; For the first The normal vector of the class-classifying hyperplane; For the first Classification bias item; This is the penalty parameter, used to balance maximizing the margin and penalizing classification errors; For the first The sample at the th Slack variables for classes are used to allow a small number of samples to fall within the classification margin; Let be the total number of samples in the training set. The constraints are: and ,in For the first The fused feature vector of each sample, For the first The sample at the th The class label.
[0180] By minimizing the aforementioned loss function, the Lagrange multipliers are obtained using a decomposition algorithm. Determine the support vectors (that satisfy) (sample) and calculate the bias term Simultaneously train the Platt scaling parameters and Used for probability calibration; finally, the trained SVM classifier parameters, including Lagrange multipliers, are saved. Bias terms Support vectors nuclear parameters Penalty parameters Platt scaling parameters .
[0181] Step S7: Calculate the regularized spatial covariance matrix using samples from the validation set, obtain the tangent vector through Riemann mapping, and finally obtain the fused feature vector. Use the trained SVM classifier to classify the samples and obtain the probability prediction of each sleep stage. Through the N1-stage protection mechanism, obtain the final sleep stage prediction result.
[0182] Five-fold subject-wise stratified cross-validation was employed, with the core principle being strict separation of data from the same subject. The training set was used to calculate the Riemann mean reference point and train the SVM classifier, while the test set was used to evaluate the model's cross-subject generalization ability. This five-fold subject-wise stratified cross-validation ensures the reliability and authenticity of the evaluation results.
[0183] Experimental verification and result analysis:
[0184] This embodiment validates the performance of the invention on three publicly available datasets: Sleep-EDF (40 healthy subjects), ISRUC-Sleep (40 patients with sleep disorders), and DREAMS (25 patients with sleep disorders). A stratified cross-validation with 5-fold subject testing was employed, and evaluation metrics included accuracy, Cohen's Kappa score, Macro-F1 score, and F1 scores at each stage.
[0185] 1. Main Experiment Results (Sleep-EDF Dataset)
[0186] Table 2 Comparison of Sleep Partitioning Algorithms for the SLEEP-EDF Dataset
[0187]
[0188] As can be seen from Table 2, the Macro-F1 score of this invention (0.776) surpasses all the comparison algorithms, including TinySleepNet (0.765), while the training time is 1.5 times faster than TinySleepNet, and the model size is only 1.3% of that of handcrafted features + RF. Figure 2 The performance-effect comparison chart of different algorithms is shown. The present invention (SCA-FBTS) achieves a good balance between performance and efficiency, and achieves accuracy comparable to deep learning algorithms with a very small model size and a very short training time.
[0189] 2. Performance Analysis of F1 Scores at Each Stage
[0190] Table 3 Performance Analysis of F1 Scores at Each Stage
[0191]
[0192] As shown in Table 3, the present invention achieves an F1 score of 0.481 in N1, which is 48% higher than TinySleepNet, while maintaining performance comparable to deep learning in N2, N3 and REM periods. Figure 3The chart showing the F1 score comparison for each sleep stage demonstrates that the accuracy of this invention remains at a relatively high level, not much different from that of deep learning algorithms. However, its accuracy in the N1 stage is higher than that of other algorithms, which is attributed to the N1 protection mechanism.
[0193] 3. Smoothing Processing Comparison Analysis
[0194] Table 4. Comparison and Analysis of Smoothing Processing
[0195]
[0196] As shown in Table 4, by adopting adaptive smoothing processing, the F1 score in the N1 stage of this invention is improved by 15% compared to no smoothing processing, from 0.281 to 0.323, and the overall accuracy is improved by 1.5%; compared to traditional smoothing processing, the F1 score in the N1 stage of adaptive smoothing processing is improved by 45% compared to traditional smoothing processing, from 0.223 to 0.323, and the overall accuracy is improved by 0.8%.
[0197] Figure 4 A comparison of sleep-hypnosis charts of representative subjects shows that the invention is basically consistent with the ground truth value, and has a high degree of recognition. Figure 5 The t-SNE visualization is a feature of this invention. It is clear from the figure that the five sleep stages are well distinguished, while the N1 stage is the most difficult to distinguish, but it is also relatively concentrated in the figure.
[0198] This invention achieves a dynamic balance of "smoothing when it should be smoothed and being precise when it should be precise" by using an adaptive N1-stage protection mechanism to protect the true N1 stage while reasonably smoothing other stages.
[0199] Portable device deployment:
[0200] The spatial covariance-based adaptive filtering group slicing spatial sleep staging method of the present invention can be easily deployed on resource-constrained embedded devices. The hardware requirements are as follows:
[0201] • Memory: ≥10MB
[0202] • Computing power: ≥50 MFLOPs / epoch
[0203] Inference time: ≤10ms / epoch
[0204] Further optimizations are possible during deployment:
[0205] 1. Use the quantized SVM model to compress the model size to less than 2MB.
[0206] 2. Pre-calculate the Riemann mean to reduce runtime computation.
[0207] 3. Fixed-point arithmetic is used instead of floating-point arithmetic to further improve inference speed.
[0208] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A spatial sleep staging method based on spatial covariance of adaptive filtering groups, characterized in that, The method includes the following steps: Step S1: Acquire multi-channel EEG signals from multiple subjects, preprocess and decompose the EEG signals using a filter group to obtain multiple frequency band EEG signals, and construct an EEG dataset; Step S2: Calculate the spatial covariance matrix for each frequency band of the EEG signal for each sample in the EEG dataset, and regularize the spatial covariance matrix to obtain the regularized spatial covariance matrix. Step S3: Riemann tangent space projection: Using the Riemann mean of the training set as a reference point, project the regularized spatial covariance matrix of each sample and each frequency band onto the tangent space to obtain the tangent space features. Step S4: Construct a loss function, and train the SVM classifier using the loss function to obtain the trained SVM classifier; Step S5: Feature Fusion and Classification: After concatenating the tangent space features of all frequency bands of each sample, an SVM classifier with RBF kernel is used for classification to obtain the probability prediction of each sleep stage of the sample; and the probability prediction is normalized to obtain the normalized probability prediction. Step S6: Adaptive time smoothing: A moving average filter with a window size of 3 is used to smooth the normalized probability prediction of the sample. At the same time, an N1 period protection mechanism is introduced: when the normalized probability prediction of the sample in the N1 period exceeds the confidence threshold, the original normalized probability prediction of the N1 period is retained. The final sleep stage prediction results are obtained.
2. The adaptive filtering group-based spatial sleep staging method based on spatial covariance according to claim 1, characterized in that, Step S1 includes the following steps: Step S11: Acquiring and filtering EEG signals: Acquire multi-channel EEG signals from multiple subjects, and perform 4th-order Butterworth bandpass filtering on the EEG signals from 0.5 to 40 Hz to obtain filtered EEG signals; Step S12: Signal framing: The filtered EEG signal is divided into non-overlapping epochs according to a fixed time length, and each epoch corresponds to a sleep stage label annotated by an expert. Step S13: Data cleaning: Perform a validity check on the segmented epochs, and remove invalid epochs with missing signals, abnormal signal amplitudes, or missing sleep stage labels to obtain the preprocessed EEG signal. Step S14: The preprocessed EEG signal of each epoch and the corresponding label constitute a sample. All the samples of the subjects constitute the EEG dataset. The EEG dataset is divided into training set and test set. Step S15: Filter group spectrum decomposition: The preprocessed EEG signal is decomposed into multiple sub-bands that are highly correlated with the neurophysiological characteristics of sleep according to frequency, resulting in multiple frequency band EEG signals.
3. The adaptive filtering group-based spatial sleep staging method based on spatial covariance according to claim 1, characterized in that, Step S2 includes the following steps: Step S21: Calculate the spatial covariance matrix for the EEG signal of each frequency band; Step S22: Use the OAS estimator to regularize the spatial covariance matrix to obtain the regularized spatial covariance matrix.
4. The adaptive filtering group spatial sleep staging method based on spatial covariance according to claim 1, characterized in that, Step S3 includes the following steps: Step S31: Calculate the Riemann mean of the regularized spatial covariance matrix of all samples in the training set for each frequency band, and use it as a reference point for the tangent space; Step S32: Logarithmic mapping: Using the Riemann mean of the regularized spatial covariance matrix of each frequency band as a reference point, the regularized spatial covariance matrix of each frequency band of the sample is projected from the symmetric positive definite manifold to the tangent space through logarithmic mapping to obtain the tangent vector corresponding to the sample. Step S33: Feature extraction: Expand the tangent vectors after projection of each frequency band of all samples into one-dimensional feature vectors, thus obtaining the tangent space features in Euclidean space.
5. The adaptive filtering group spatial sleep staging method based on spatial covariance according to claim 1, characterized in that, Step S5 includes the following steps: Step S51: Feature concatenation: Concatenate the tangent space features of each frequency band of all samples into a complete fusion feature vector in sequence; Step S52: Use an SVM classifier to classify the concatenated fused feature vector to obtain the original decision values for each sleep stage; Step S53: Probability calibration: Convert the raw decision values of the SVM into probability values using Platt scaling; Step S54: Probability Normalization: Normalize the probability values of each sleep stage so that the sum of the probabilities of all stages is 1, and obtain the normalized probability prediction of each sleep stage.
6. The adaptive filtering group-based spatial sleep staging method based on spatial covariance according to claim 1, characterized in that, Step S6 includes the following steps: Step S61: Temporal smoothing: The normalized probability prediction of the samples is smoothed by using a moving average filter with a window size of 3. Step S62: Adaptive N1-stage protection mechanism: Identify the N1-stage index, determine whether the normalized probability prediction of the N1-stage at the current time exceeds the confidence threshold. If it exceeds, retain the normalized probability prediction of the N1-stage without smoothing. If it does not exceed, use the smoothed probability prediction. Based on the processed probability sequence, select the stage with the highest probability as the final sleep stage prediction result.