Method for generating driving fatigue electroencephalogram data by improving potential diffusion model
By generating EEG data on driver fatigue using an improved latent diffusion model, the problem of poor sample quality in existing technologies is solved. This achieves high signal-to-noise ratio and diverse data generation, thereby improving the training effect and generalization ability of the driver fatigue recognition model.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 淮北职业技术学院
- Filing Date
- 2026-03-11
- Publication Date
- 2026-06-09
AI Technical Summary
Existing technologies struggle to generate high-quality, diverse, and physiologically plausible EEG data on driver fatigue, resulting in poor training performance and insufficient generalization ability of deep learning models in driver fatigue identification.
An improved latent diffusion model is used to generate EEG data on driving fatigue through multi-scale wavelet denoising, covariance alignment, short-time Fourier transform, and conditional variational autoencoder. The process includes signal preprocessing, time-frequency feature extraction, training of conditional variational autoencoder, and conditional data synthesis to ensure that the generated data conforms to physiological characteristics and diversity.
The generated EEG data on driver fatigue has a high signal-to-noise ratio, which can accurately capture complex spatiotemporal dynamic features, alleviate the problem of data class imbalance, improve the generalization ability and recognition accuracy of the model, and significantly improve the performance of the driver fatigue recognition model.
Smart Images

Figure CN122174015A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electroencephalogram (EEG) signal processing technology, and in particular to an improved method for generating EEG data on driving fatigue using a latent diffusion model. Background Technology
[0002] Early identification of driver fatigue is a key issue in the fields of intelligent driving and traffic safety. Compared to indirect detection methods based on behavior or vehicle parameters, electroencephalography (EEG) signals can directly reflect changes in the functional state of the brain, offering significant advantages in capturing early and subtle signs of driver fatigue. However, EEG data collection faces challenges such as high cost, complex procedures, and high requirements for subject cooperation, leading to problems in practical studies, including limited sample size, class imbalance, strong noise interference, and significant individual differences. High-quality, large-scale EEG data, especially covering early fatigue states, is particularly scarce, severely limiting the training effectiveness, robustness, and generalization ability of deep learning-based fatigue recognition models across different subjects. Therefore, developing EEG data augmentation methods capable of generating physiologically plausible and diverse data is of great significance for advancing reliable driver fatigue identification.
[0003] To address the problem of data scarcity, existing research has primarily explored data augmentation in EEG decoding areas such as motor imagery and emotion recognition. Mainstream methods can be broadly categorized into two types: one is based on Generative Adversarial Networks (GANs), which synthesize data through adversarial learning between a generator and a discriminator; the other is based on time-frequency decomposition (such as wavelet transform and short-time Fourier transform), which transforms or reassembles data in the time-frequency domain to generate new samples. These methods provide preliminary insights for EEG data augmentation.
[0004] However, existing technologies have significant limitations. Generative adversarial networks (GANs) are prone to instability issues such as gradient vanishing and pattern collapse during training, leading to insufficient diversity or poor quality of generated samples. While time-frequency decomposition-based methods can construct new samples in the time-frequency domain, they often struggle to effectively capture and reconstruct the complex nonlinear dynamic features of EEG signals, limiting the physiological consistency and realism of the generated samples. Furthermore, traditional data augmentation techniques (such as geometric transformations and adding simple Gaussian noise) also fail to preserve the unique spatiotemporal structure and physiological significance of EEG signals. Therefore, existing methods cannot fully meet the requirements of signal realism, diversity, and physiological rationality for EEG data augmentation in driving fatigue, necessitating the development of more stable generation methods that better capture the intrinsic characteristics of EEG signals. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide an improved method for generating EEG data of driving fatigue using a latent diffusion model. The method expands the EEG signals collected under both fatigue and normal conditions using an improved latent diffusion model to train a more stable deep learning model for driving fatigue recognition.
[0006] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows: An improved method for generating driver fatigue EEG data using a latent diffusion model includes the following steps: S1. Signal preprocessing: Multi-scale wavelet denoising is performed on the original multi-channel driving fatigue EEG signal. Adaptive threshold and improved soft threshold function are used for processing. Then, channel covariance alignment and whitening are performed to eliminate channel redundancy and obtain the preprocessed EEG signal. S2. Time-frequency feature extraction: Perform short-time Fourier transform on the preprocessed EEG signal to obtain the time-frequency representation and perform logarithmic energy normalization to obtain the normalized time-frequency features; S3. Training the Conditional Variational Autoencoder: Input the time-frequency features into the encoder to obtain the mean and variance of the latent variables, and obtain the latent variables through reparameterized sampling; the decoder reconstructs the time-frequency features by combining fatigue state labels; the conditional variational autoencoder is trained by minimizing the reconstruction loss and KL divergence loss. S4. Training the Conditional Latent Diffusion Model: Forward diffusion is performed in the latent space of the conditional variational autoencoder and Gaussian noise is gradually added; during the reverse denoising process, the denoising network is trained to predict and remove noise from the noisy latent variables based on the fatigue state labels, and the original latent variables are restored. S5. Conditional Data Synthesis: The denoised latent variables are input into the trained conditional variational autoencoder decoder, and new EEG time-frequency features are generated by combining the specified fatigue state. The multi-channel EEG signal of driving fatigue is then reconstructed.
[0007] A further improvement of the technical solution of the present invention is that: in step S1, the original multi-channel driving fatigue EEG signal is a subject's EEG signal with a duration of 3 seconds, which is collected by 30 EEG electrode channels, and the state label corresponding to each EEG signal sample includes alertness state and fatigue state.
[0008] A further improvement of the technical solution of the present invention is that: in step S1, the original multi-channel driving fatigue EEG signal includes at least electrooculography artifact noise, electromyography artifact noise, and power frequency interference noise.
[0009] A further improvement to the technical solution of this invention lies in the following: In step S1, the multi-scale wavelet denoising of the original multi-channel driving fatigue EEG signal, using adaptive thresholding and an improved soft thresholding function, specifically includes: The J-level discrete wavelet transform of the original multi-channel driving fatigue EEG signal is shown in the following formula: Where x(n) represents the nth sampling point of the original multi-channel driving fatigue EEG signal; W is the wavelet basis function at position k in the j-th layer; j (k) represents the corresponding wavelet coefficients; J represents the number of decomposition levels; An adaptive threshold for signal local variance is introduced, as shown in the following formula: in, The standard deviation of the noise at layer j is estimated; N j The number of wavelet coefficients in the j-th layer; This represents the absolute deviation of the median. As an adaptive adjustment factor, ; An improved soft thresholding function is used to shrink the wavelet coefficients, as shown in the following formula: in, These are the denoised wavelet coefficients; It is an exponential decay factor that controls the smooth transition characteristics of the threshold.
[0010] A further improvement to the technical solution of this invention lies in: in step S1, channel covariance alignment and whitening are performed to eliminate channel redundancy and obtain preprocessed EEG signals, specifically including: Let the original multi-channel driver fatigue EEG signal matrix be: Where C is the number of electrode channels and T is the number of time points; The channel covariance matrix is calculated using the following formula: in, This is the mean vector of the EEG signals from each channel; The covariance matrix is eigenvalued by eigenvalue decomposition to obtain the eigenvalue diagonal matrix and eigenvector matrix. The covariance matrix is then standardized to the identity matrix using a whitening transformation, as shown in the following formula: in, ; The eigenvector matrix; It is an eigenvalue diagonal matrix; Introducing a reference covariance matrix The signal is further normalized through the alignment process to perform domain alignment, as shown in the following formula: .
[0011] A further improvement of the technical solution of the present invention is that, in step S2, the following steps are specifically included: the EEG signal is segmented by selecting a sliding window function, and the time-frequency representation of each segment of the EEG signal is obtained by short-time Fourier transform, as shown in the following formula: in, For time-frequency representation; w(n) is the window function; N is the window length; t represents the time index; f represents the frequency index; x(n) represents the nth sampling point of the original EEG signal; Logarithmic energy normalization of the extracted time-frequency representation can suppress energy differences under different experimental settings and enhance the stability of the features, as shown in the following formula: .
[0012] A further improvement to the technical solution of the present invention is that: in step S3, specifically, the variational autoencoder consists of two parts: an encoder and a decoder. The encoder maps the preprocessed EEG signal. From the latent space, we obtain the mean and log-variance of the latent variables, as shown in the following formula: in, This is the time-frequency feature tensor obtained through short-time Fourier transform; For encoder networks; For encoder parameters; The mean of the latent variables; d represents the log-variance of the latent variables; d represents the dimension of the latent space. Using the reparameterization technique, the latent variables are generated from the mean and standard deviation, as shown in the following formula: in, These are the latent variables obtained through sampling; This represents element-wise multiplication; This is a noise vector sampled from a standard normal distribution; The decoder forward propagation formula is shown below: in, For reconstructing the signal; For decoder networks; These are decoder parameters; The loss function of a variational autoencoder consists of reconstruction loss and KL divergence loss, as shown in the following formula: in, These are the KL divergence weighting coefficients; The reconstruction loss uses the mean squared error to calculate the difference between the original signal and the reconstructed signal, as shown in the following formula: in, This represents the original signal value of channel C at time t. Let be the reconstructed signal value of channel C at time t; The KL divergence loss forces the latent distribution to approximate a standard normal distribution, as shown in the following formula: in, Let be the mean of the i-th dimension of the latent variables; Let be the variance of the i-th dimension of the latent variable; d is the dimension of the latent space.
[0013] A further improvement to the technical solution of this invention lies in: in step S4, forward diffusion is performed in the latent space of the conditional variational autoencoder, and Gaussian noise is gradually added; specifically: In the latent space, given latent variables Gaussian noise is gradually added to simulate the signal diffusion process, with the noise scheduling coefficient at each step. The formula for controlling the rate of noise addition is shown below: in, Let be the latent noise variable at step t. Denotes the latent variables at step t-1 in the latent space; Let be the noise scheduling coefficient at step t; ; This represents the total number of diffusion steps; Through forward diffusion, latent variables are gradually transformed into noise, providing randomness to signal generation and making the generated signals diverse. The encoder uses a multi-layer convolutional neural network and compresses high-dimensional data through a global pooling layer, making the latent space more compact and having higher representational power.
[0014] A further improvement to the technical solution of this invention lies in: in step S4, during the reverse denoising process, the trained denoising network predicts and removes noise from the noisy latent variables based on the fatigue state label, thereby restoring the original latent variables; specifically: Training a noise reduction network To gradually recover the noisy signal, the network input consists of latent noise variables and fatigue state level labels. The signal recovery is predicted through the denoising process, as shown in the following formula: Where 'c' represents the fatigue state level label; The goal of training the denoising network is to minimize the difference between the generated signal and the real signal, thereby generating high-quality synthetic EEG signals. Fatigue state level labels are added to the encoder and decoder to ensure that the generated EEG signals can be associated with the application scenario of fatigue driving.
[0015] A further improvement to the technical solution of this invention lies in: in step S5, the denoised latent variables are input into the trained conditional variational autoencoder decoder, combined with the specified fatigue state to generate new EEG time-frequency features, and the multi-channel EEG signal of driving fatigue is reconstructed, specifically as follows: After the reverse denoising process is completed, new multi-channel EEG signal samples of driving fatigue are generated. Finally, the latent variables are mapped back to the original signal space by the decoder to generate a new multi-channel EEG signal of driving fatigue that is similar to the original driving fatigue signal. The formula is as follows: Where, x gen For new multichannel EEG signals of driver fatigue; For decoder networks; As latent variables; These are the decoder parameters.
[0016] The technological advancements achieved by this invention due to the adoption of the above technical solutions are as follows: 1. This invention effectively filters out noise and individual difference interference in the original multi-channel driving fatigue EEG signal through multi-scale wavelet denoising and covariance alignment preprocessing; and trains the latent diffusion model in the regular latent space obtained by variational autoencoder compression, so that the generated multi-channel driving fatigue EEG signal has a higher signal-to-noise ratio, can accurately capture and reconstruct the complex spatiotemporal dynamic features of the signal, and ensure that the synthesized signal has high physiological rationality and authenticity.
[0017] 2. This invention uses fatigue state and normal state as conditional labels, and embeds variational autoencoder and latent diffusion model training process to accurately and controllably generate EEG signals of specified driving fatigue state; the improved latent diffusion model can synthesize multi-channel driving fatigue EEG signals on demand, alleviate the problem of data class imbalance in actual collection process, and provide effective support for building a balanced training dataset.
[0018] 3. Compared with traditional generative adversarial networks, the latent diffusion model used in this invention is optimized based on a stable variational lower bound, avoiding the pattern collapse and training instability problems that are prone to occur in adversarial training. By progressively adding and removing noise in the latent space, richer and more diverse latent variables can be generated, thereby decoding EEG signals with obvious morphological differences, significantly improving the diversity of generated samples, and overcoming the shortcomings of traditional methods such as single samples and insufficient variation.
[0019] 4. This invention explicitly models and normalizes the spatial covariance structure of multi-channel driving fatigue EEG signals through covariance alignment processing, so that the potential diffusion model can retain the physiologically meaningful spatial topological relationships and statistical dependencies between channels during generation, generating multi-channel signals with correct spatial distribution characteristics, rather than a simple superposition of multiple independent time-series signals.
[0020] 5. The synthetic multi-channel EEG signals of driving fatigue generated by this invention possess both high diversity and physiological plausibility. They can be used as high-quality augmented data for training and fine-tuning driving fatigue recognition models, effectively expanding the size and coverage of the original dataset, improving the model's generalization ability, robustness, and recognition accuracy, and significantly alleviating the overfitting problem in small sample scenarios. Attached Figure Description
[0021] 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. Figure 1 This is a flowchart of an improved method for generating driver fatigue EEG data using a latent diffusion model, provided in an embodiment of the present invention. Figure 2 This is a schematic diagram of the structure of the improved potential diffusion model in an embodiment of the present invention; Figure 3 This is a diagram showing the results of testing EEG samples using discrete wavelet transform decomposition in an embodiment of the present invention. Figure 4 This is a diagram showing the time-frequency domain feature extraction results of the test EEG samples in this embodiment of the invention; Figure 5 This is a comparison diagram of the real EEG signal and the reconstructed EEG signal of the test EEG sample in an embodiment of the present invention; Figure 6 (a) is a schematic diagram of the noise addition process for testing EEG samples in an embodiment of the present invention; Figure 6 (b) is a schematic diagram of the noise reduction process for testing EEG samples in an embodiment of the present invention. Detailed Implementation
[0022] It should be noted that the terms "comprising" and "having" and any variations thereof in the specification, claims and accompanying drawings of this invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such processes, methods, products or devices.
[0023] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments: like Figure 1 , Figure 2 As shown, an improved method for generating driving fatigue EEG data using a latent diffusion model is presented. This embodiment uses a publicly available dataset: the original multi-channel driving fatigue EEG signal (continuous attention driving) dataset, which contains 2022 samples, each corresponding to 3 seconds of EEG signal, and includes 11 subjects. The EEG signal of each subject was collected by 30 EEG electrode channels. The state labels of each sample include normal (alert) state and fatigue state. The specific steps include: S1. Signal preprocessing: Multi-scale wavelet denoising is performed on the original multi-channel driving fatigue EEG signal. Adaptive threshold and improved soft threshold function are used for processing. Then, channel covariance alignment and whitening are performed to eliminate channel redundancy and obtain the preprocessed EEG signal. Specifically, it includes: (1) To address the various noises (e.g., electrooculogram artifacts, electromyogram artifacts, power line interference, etc.) mixed in the original multi-channel driving fatigue EEG signals, an adaptive multi-scale wavelet thresholding denoising method is used. Traditional DWT usually only focuses on signal features at a certain scale, while by introducing multi-scale wavelet transform, the EEG signal can be decomposed at different scales, enabling a more comprehensive extraction of detailed features from the EEG signal. Assuming the signal has J layers of wavelet decomposition, after each layer of wavelet transform, the signal is decomposed into low frequency (approximation term) and high frequency (detail term).
[0024] The J-level discrete wavelet transform of the original multi-channel driving fatigue EEG signal is shown in the following formula: (1) Among them, W j (k) represents the corresponding wavelet coefficient; x(n) represents the nth sampling point of the original multi-channel driving fatigue EEG signal; Let J be the wavelet basis function at position k in the j-th layer; J is the decomposition layer number.
[0025] This decomposition allows for the extraction of different frequency components of the signal and the identification of the frequency band where noise is located.
[0026] Based on wavelet transform, an adaptive threshold denoising method is employed. An adaptive threshold is introduced to dynamically adjust the threshold according to the noise characteristics of different signals. Specifically, the threshold is calculated based on the noise estimate of each wavelet coefficient layer, and the noise estimate depends on the local variance of the signal. This allows the threshold for each signal component to be optimized according to its characteristics, thereby improving the denoising effect. The noise standard deviation of each wavelet coefficient layer (…) The noise standard deviation is obtained through local variance estimation. Using these noise standard deviations, the denoising threshold for each layer of wavelet coefficients is calculated, as shown in the following formula: (2) in, The standard deviation of the noise at layer j is estimated; N j The number of wavelet coefficients in the j-th layer; This represents the absolute deviation of the median. For adaptive adjustment factors, we take [the appropriate value here]. .
[0027] Next, an improved soft thresholding function is used to shrink the wavelet coefficients, as shown in the following formula: (3) in, These are the denoised wavelet coefficients; This is an exponential decay factor that controls the smooth transition characteristics of the threshold. By adjusting... This approach allows for more flexible control over the degree of signal contraction, reducing the loss of high-frequency details. Improvements in the soft thresholding function, such as introducing an exponential decay factor and an adaptive threshold, enhance its flexibility and accuracy. This method effectively removes noise components while preserving useful information in the signal, resulting in smoother denoising.
[0028] By decomposing each signal into multiple frequency bands using discrete wavelet transform, useful features can be effectively extracted. Based on the local variance of the wavelet coefficients at each scale, an adaptive threshold is calculated to suppress noise while preserving the effective signal. In this embodiment, the wavelet basis is selected as db4, and the decomposition level is 5, decomposing the original EEG signal into detail signals in 5 frequency bands. The decomposition results are as follows: Figure 3 As shown.
[0029] (2) Calculate the covariance matrix of the multi-channel driving fatigue EEG signal and standardize it by eigenvalue decomposition and whitening transformation to eliminate signal distribution differences; To eliminate the distribution differences of EEG signals among different subjects and at different time periods, a multi-channel covariance alignment standardization method is proposed to enable data from different signal sources to be compared and aligned under the same standard.
[0030] Let the original multichannel EEG signal matrix be... Where C is the number of electrode channels and T is the number of time points. The channel covariance matrix is calculated using the following formula: (4) in, This represents the mean vector for each channel. The calculated covariance matrix is used to capture the correlation between different channels.
[0031] Eigenvalue decomposition of the covariance matrix yields the eigenvalue diagonal matrix. and eigenvector matrix The covariance matrix is standardized to the identity matrix using a whitening transformation, as shown in the following formula: (5) in, ; The eigenvector matrix; This is the eigenvalue diagonal matrix. In the covariance standardization process, eigenvalue decomposition and whitening transformation are employed. This step removes redundant information from the signal, eliminates data redundancy and collinearity through refined eigenvalue decomposition methods, and enhances the independence of the signal.
[0032] Subsequently, a reference covariance matrix is introduced. Domain alignment is performed, and the signal is further normalized through the alignment process, as shown in the following formula: (6) This process helps eliminate signal variability caused by differences in experimental design and equipment, making data from different experimental conditions more comparable. In the covariance matrix calculation and whitening process, to enhance the adaptive standardization capability of different channel signals, the statistical characteristics of each EEG channel within the current time window are first calculated, including the mean and variance, to assess the signal fluctuation and noise intensity of that channel. The variance of each channel is compared with the average variance of all channels to construct a channel noise intensity index. Based on this index, a corresponding standardization weight is assigned to each channel. When the variance of a channel is significantly higher than the overall average, it is determined that its noise influence is significant, and its standardization weight is increased in subsequent whitening processing to enhance the denoising strength of that channel. When the variance of a channel is lower than or close to the average, its standardization weight is reduced to avoid over-processing and loss of effective information. Subsequently, the weighted covariance matrix is used for eigenvalue decomposition and whitening transformation to align different channels in a unified statistical space. Through this method, the strong noise channels are effectively suppressed while the stable channels are finely preserved, thereby improving the overall standardization effect and spatial consistency of multi-channel EEG signals.
[0033] Converting EEG signals into time-frequency domain features reveals that the frequency characteristics of EEG signals differ between fatigue and alert states. Through covariance alignment and standardization, the model can better understand data from different subjects, avoiding the influence of individual differences. In this embodiment, one alert sample and one fatigue sample are selected, and the time-frequency representations of their Fp1, F7, C3, and P3 electrode channels before and after standardization and alignment are compared. Figure 4 As shown in the figure, TF represents the time frequency.
[0034] S2. Time-frequency feature extraction: Perform short-time Fourier transform on the preprocessed EEG signal to obtain the time-frequency representation and perform logarithmic energy normalization to obtain the normalized time-frequency features; Specifically, the signal is segmented using a sliding window function, and a Fourier transform is performed on each segment to obtain a time-frequency representation. The time-frequency representation is obtained using the short-time Fourier transform, and then processed by logarithmic energy normalization, as shown in the following formula: (7) Where w(n) is the window function; N is the window length; t represents the time index; and f represents the frequency index.
[0035] By logarithmically normalizing the energy of the Short-Time Fourier Transform (STFT) results, the energy range of the signal can be compressed to a suitable scale, making the time-frequency characteristics of the signal more stable and reducing the impact of energy differences under experimental conditions on signal representation. Introducing an adaptive window function, which dynamically adjusts the length and shape of the window function according to the spectral characteristics of different signals, allows for the automatic selection of the most suitable window function based on frequency changes, thereby improving the resolution of time-frequency analysis. This is particularly effective for capturing subtle changes in time-varying signals such as electroencephalogram (EEG) signals.
[0036] In this embodiment, one sample each from fatigue and alertness EEG tests were selected. Short-time Fourier transforms were performed, followed by logarithmic energy normalization. The time-frequency results of Fp1, F3, T7, C3, P3, and O1 were visualized, as follows: Figure 4 As shown.
[0037] S3. Training Conditional Variational Autoencoder (VAE): The time-frequency features are input into the encoder to obtain the mean and variance of the latent variables, and the latent variables are obtained through reparameterized sampling; the decoder reconstructs the time-frequency features by combining fatigue state labels; the conditional variational autoencoder is trained by minimizing the reconstruction loss and KL divergence loss. Specifically, this includes: such as Figure 2 As shown, the variational autoencoder consists of two parts: an encoder and a decoder. The encoder receives the input EEG signal. The probability distribution parameters mapped to the latent space.
[0038] (1) Forward propagation of the encoder, the formula is as follows: (8) in, This is the time-frequency feature tensor obtained through short-time Fourier transform; For encoder networks; For encoder parameters; The mean of the latent variables; d represents the log-variance of the latent variables; d represents the dimension of the latent space.
[0039] The reparameterization technique is illustrated in the formula below: (9) in, These are the latent variables obtained through sampling; This represents element-wise multiplication; This is a noise vector sampled from a standard normal distribution. A noise term is added during the reparameterization of the latent variables. Stepwise noise optimization is performed to ensure that the generation process fully considers the noise characteristics of the signal and generates a high-quality reconstructed signal.
[0040] (2) Forward propagation of the decoder, the formula is as follows: (10) in, For reconstructing the signal; For decoder networks; These are the decoder parameters.
[0041] The loss function of a variational autoencoder consists of reconstruction loss and KL divergence loss, as shown in the following formula: (11) in, is the KL divergence weighting coefficient.
[0042] The reconstruction loss uses mean squared error (MSE) to calculate the difference between the original signal and the reconstructed signal: The reconstruction loss uses mean squared error, and the formula is as follows: (12) Where, x c,t and These are the original and reconstructed signal values of channel c at time t, respectively.
[0043] The KL divergence loss forces the latent distribution to approximate a standard normal distribution, as shown in the following formula: (13) in, and Let be the mean and variance of the i-th dimension of the latent variable, respectively.
[0044] By weighting and adjusting the KL divergence loss, and optimizing these two loss terms, the regularization of the latent space can be dynamically adjusted during training based on different signal distributions, enabling the model to learn effective latent representations. A higher-dimensional latent space is employed, along with an encoder network using non-linear activation functions, allowing the encoder to learn the non-linear characteristics of EEG signals. The latent space is optimized to provide a low-dimensional representation of EEG signals while preserving their important time-varying properties.
[0045] Variational autoencoders employ reparameterization techniques to ensure the fluency and generativeness of the latent space, allowing the model to sample and generate new latent variables from the latent space. This enables the model to freely sample and generate EEG signals within the latent space. In this embodiment, a single EEG test sample is selected, and its real EEG signal is compared with the reconstructed EEG signal for visualization. Figure 5 As shown.
[0046] S4. Training the Conditional Latent Diffusion Model: Performing forward pass in the latent space of the conditional variational autoencoder. Gaussian noise is diffused and gradually added; in the reverse denoising process, the denoising network is trained to predict and remove noise from the noisy latent variables based on the fatigue state labels, and restore the original latent variables; Specifically, this includes: conditional potential diffusion models, such as Figure 2 As shown, Gaussian noise is gradually added to the latent variables, making the latent representation increasingly blurred. The amount of noise at each step is controlled by a scheduling coefficient. A denoising network is trained to gradually recover a clear latent representation based on the historical state of the noise. This process is conditionally generated based on the fatigue label (0 or 1) of each sample, so that the generated latent variables are associated with the fatigue state.
[0047] (1) Forward diffusion process, i.e., noise addition process, such as Figure 6 As shown in (a): Given latent variables Gaussian noise is added gradually, as shown in the formula below: (14) in, Let be the latent noise variable at step t; Let be the noise scheduling coefficient at step t; ; This represents the total number of diffusion steps.
[0048] Noise scheduling coefficient at each step The rate at which noise is added is controlled; through forward diffusion, latent variables are gradually transformed into noise. This process introduces randomness into signal generation, resulting in diverse generated signals. The encoder employs a multi-layer convolutional neural network and uses global pooling layers to compress high-dimensional data, making the latent space more compact and possessing higher representational power.
[0049] The cumulative noise figure is defined by the following formula: (15) You can directly from Sampling any step The formula is shown below: (16) Equivalent to: (17) (2) Reverse denoising process, such as Figure 6 As shown in (b): Training a noise reduction network The formula for predicting added noise is shown below: (18) in, For conditional information (fatigue level label); A parameterized noise prediction network; These are network parameters.
[0050] The formula for calculating the predicted mean is shown below: (19) The loss function for the diffusion model is shown in the following formula: (20) Where t is uniformly distributed sampling; Sampled from a standard normal distribution.
[0051] Condition generation is performed using a classifier-guided approach, as shown in the following formula: (twenty one) Where w is the guiding intensity coefficient; This represents the unconditional case (randomized during training with probability). Discarding conditions).
[0052] The sampling iteration of DDPM (Denoising Diffusion Probability Model) is shown in the following formula: (twenty two) in, When t>1, add random noise.
[0053] The goal of training the denoising network is to minimize the difference between the generated signal and the real signal, thereby generating high-quality synthetic EEG signals. Conditional information is incorporated into the encoder and decoder to ensure that the generated EEG signals can be associated with specific application scenarios.
[0054] S5. Conditional Data Synthesis: The denoised latent variables are input into the trained conditional variational autoencoder decoder, and new EEG time-frequency features are generated by combining the specified fatigue state. The multi-channel EEG signal of driving fatigue is then reconstructed.
[0055] After the reverse denoising process is completed, new multi-channel EEG signal samples of driving fatigue are generated. Finally, the latent variables are mapped back to the original signal space by the decoder of the variational autoencoder (VAE), generating new multi-channel EEG signals (EEG samples) of driving fatigue that are similar to the original multi-channel driving fatigue signals. The formula is shown below: (twenty three) The generated multi-channel EEG signals of driving fatigue not only retain the characteristics of the original signals, but also enhance the diversity of the data, thus providing rich training data for further fatigue detection models.
[0056] Finally, the generated multi-channel EEG signals of driver fatigue and the original real multi-channel EEG signals of driver fatigue are combined to form an enhanced training dataset. This enhanced training dataset is used to train a deep learning classification model to obtain a driver fatigue state recognition model. The EEG signals to be identified are input into the driver fatigue state recognition model, and the corresponding fatigue or normal state classification results are output.
[0057] To illustrate the advantages of the improved latent diffusion model for generating data provided by this invention, a baseline convolutional neural network model is constructed, and the model parameters are shown in Table 1.
[0058] Table 1 Baseline CNN Network Structure Parameters Table 2 shows the performance metrics of the baseline CNN model for driver fatigue recognition under different data augmentation methods, comparing the original data, GAN, WGAN, DCGAN, VAE, and CVAE training models with the improved latent diffusion model.
[0059] Table 2 Comparison of the improved potential diffusion model with the original data and other data augmentation methods As shown in Table 2, the improved latent diffusion model provided by this invention achieved the best results on all evaluation metrics (accuracy 81.24%, F1 score 81.22%, AUC 88.34%), significantly outperforming all compared data augmentation methods and also clearly superior to the baseline model trained directly using the original data. This demonstrates that the data generated by this method has higher quality and greater augmentation effectiveness.
[0060] It is noteworthy that the model performance of all other data augmentation methods listed in Table 2 (including GAN, WGAN, DCGAN, VAE, and CVAE) is lower than that of directly using the original data. This reveals a key issue: for physiological signals with high noise, low signal-to-noise ratio, and complex spatiotemporal structures, such as driver fatigue EEG data, traditional generative models, without targeted design, may fail to effectively retain key discriminative features and may even introduce interference, leading to a decline in the performance of downstream recognition models.
[0061] In stark contrast to the traditional methods described above, the improved latent diffusion model provided by this invention achieves a stable performance improvement. This is attributed to its unique progressive denoising generation paradigm and its operation within a regular latent space. This method can more stably learn and reconstruct the intrinsic, fatigue-related distribution of EEG signals, thereby generating synthetic samples with greater diversity, stronger physiological plausibility, and greater benefit for classification tasks.
[0062] The comparative results strongly confirm that the improved latent diffusion model proposed in this invention has a fundamental advantage over traditional generation methods in the task of augmenting EEG data related to driver fatigue. It successfully overcomes the latter's tendency to generate low-quality synthetic data, leading to performance degradation, and is an effective data augmentation scheme that can genuinely improve the performance of early fatigue recognition models.
[0063] 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 method for generating driver fatigue EEG data using an improved latent diffusion model, characterized in that, Includes the following steps: S1. Signal preprocessing: Multi-scale wavelet denoising is performed on the original multi-channel driving fatigue EEG signal. Adaptive threshold and improved soft threshold function are used for processing. Then, channel covariance alignment and whitening are performed to eliminate channel redundancy and obtain the preprocessed EEG signal. S2. Time-frequency feature extraction: Perform short-time Fourier transform on the preprocessed EEG signal to obtain the time-frequency representation and perform logarithmic energy normalization to obtain the normalized time-frequency features; S3, Training Conditional Variational Autoencoder: Input the time-frequency features into the encoder to obtain the mean and variance of the latent variables, and obtain the latent variables through reparameterized sampling; The decoder reconstructs time-frequency features by combining fatigue state labels; the conditional variational autoencoder is trained by minimizing the reconstruction loss and KL divergence loss. S4. Training the Conditional Latent Diffusion Model: Forward diffusion is performed in the latent space of the conditional variational autoencoder and Gaussian noise is gradually added; during the reverse denoising process, the denoising network is trained to predict and remove noise from the noisy latent variables based on the fatigue state labels, and the original latent variables are restored. S5. Conditional Data Synthesis: The denoised latent variables are input into the trained conditional variational autoencoder decoder, and new EEG time-frequency features are generated by combining the specified fatigue state. The multi-channel EEG signal of driving fatigue is then reconstructed.
2. The method according to claim 1, characterized in that, In step S1, the original multi-channel driving fatigue EEG signal is a subject's EEG signal with a duration of 3 seconds, collected from 30 EEG electrode channels. The state label corresponding to each EEG signal sample includes alertness state and fatigue state.
3. The method according to claim 1, characterized in that, In step S1, the original multi-channel The EEG signals of driver fatigue include at least electrooculography artifacts, electromyography artifacts, and power frequency interference noise.
4. The method according to claim 1, characterized in that, In step S1, the multi-scale wavelet denoising of the original multi-channel driving fatigue EEG signal, using adaptive thresholding and an improved soft thresholding function, specifically includes: The J-level discrete wavelet transform of the original multi-channel driving fatigue EEG signal is shown in the following formula: Where x(n) represents the nth sampling point of the original multi-channel driving fatigue EEG signal; W is the wavelet basis function at position k in the j-th layer; j (k) represents the corresponding wavelet coefficients; J represents the number of decomposition levels; An adaptive threshold for signal local variance is introduced, as shown in the following formula: in, The standard deviation of the noise at layer j is estimated; N j The number of wavelet coefficients in the j-th layer; This represents the absolute deviation of the median. As an adaptive adjustment factor, ; An improved soft thresholding function is used to shrink the wavelet coefficients, as shown in the following formula: in, These are the denoised wavelet coefficients; It is an exponential decay factor that controls the smooth transition characteristics of the threshold.
5. The method according to claim 1, characterized in that, In step S1, channel covariance alignment and whitening are performed to eliminate channel redundancy, resulting in preprocessed EEG signals, specifically including: Let the original multi-channel driver fatigue EEG signal matrix be: Where C is the number of electrode channels and T is the number of time points; The channel covariance matrix is calculated using the following formula: in, This is the mean vector of the EEG signals from each channel; The covariance matrix is eigenvalued by eigenvalue decomposition to obtain the eigenvalue diagonal matrix and eigenvector matrix. The covariance matrix is then standardized to the identity matrix using a whitening transformation, as shown in the following formula: in, ; The eigenvector matrix; It is an eigenvalue diagonal matrix; Introducing a reference covariance matrix The signal is further normalized through the alignment process to perform domain alignment, as shown in the following formula: 。 6. The method according to claim 1, characterized in that, Step S2 specifically includes: The EEG signal is segmented by selecting a sliding window function, and the time-frequency representation of each segment is obtained by short-time Fourier transform, as shown in the following formula: in, For time-frequency representation; w(n) is the window function; N is the window length; t represents the time index; f represents the frequency index; x(n) represents the nth sampling point of the original EEG signal; Logarithmic energy normalization of the extracted time-frequency representation can suppress energy differences under different experimental settings and enhance the stability of the features, as shown in the following formula: 。 7. The method according to claim 1, characterized in that, Step S3 specifically includes: the variational autoencoder consists of two parts, an encoder and a decoder. The encoder maps the preprocessed EEG signal. From the latent space, we obtain the mean and log-variance of the latent variables, as shown in the following formula: in, This is the time-frequency feature tensor obtained through short-time Fourier transform; For encoder networks; For encoder parameters; The mean of the latent variables; d represents the log-variance of the latent variables; d represents the dimension of the latent space. Using the reparameterization technique, the latent variables are generated from the mean and standard deviation, as shown in the following formula: in, These are the latent variables obtained through sampling; This represents element-wise multiplication; This is a noise vector sampled from a standard normal distribution; The decoder forward propagation formula is shown below: in, For reconstructing the signal; For decoder networks; These are decoder parameters; The loss function of a variational autoencoder consists of reconstruction loss and KL divergence loss, as shown in the following formula: in, These are the KL divergence weighting coefficients; The reconstruction loss uses the mean squared error to calculate the difference between the original signal and the reconstructed signal, as shown in the following formula: in, This represents the original signal value of channel C at time t. Let be the reconstructed signal value of channel C at time t; The KL divergence loss forces the latent distribution to approximate a standard normal distribution, as shown in the following formula: in, Let be the mean of the i-th dimension of the latent variables; Let be the variance of the i-th dimension of the latent variable; d is the dimension of the latent space.
8. The method according to claim 1, characterized in that, In step S4, forward diffusion is performed in the latent space of the conditional variational autoencoder, and Gaussian noise is gradually added; specifically: In the latent space, given latent variables Gaussian noise is gradually added to simulate the signal diffusion process, with the noise scheduling coefficient at each step. The formula for controlling the rate of noise addition is shown below: in, Let be the latent noise variable at step t. Denotes the latent variables at step t-1 in the latent space; Let be the noise scheduling coefficient at step t; ; This represents the total number of diffusion steps; Through forward diffusion, latent variables are gradually transformed into noise, providing randomness to signal generation and making the generated signals diverse. The encoder uses a multi-layer convolutional neural network and compresses high-dimensional data through a global pooling layer, making the latent space more compact and having higher representational power.
9. The method according to claim 1, characterized in that, In step S4, during the reverse denoising process, the training denoising network predicts and removes noise from the noisy latent variables based on the fatigue state labels, restoring the original latent variables; specifically: Training a noise reduction network To gradually recover the noisy signal, the network input consists of latent noise variables and fatigue state level labels. The signal recovery is predicted through the denoising process, as shown in the following formula: Where 'c' represents the fatigue state level label; The goal of training the denoising network is to minimize the difference between the generated signal and the real signal, thereby generating high-quality synthetic EEG signals. Fatigue state level labels are added to the encoder and decoder to ensure that the generated EEG signals can be associated with the application scenario of fatigue driving.
10. The method according to claim 1, characterized in that, In step S5, the denoised latent variables are input into the trained conditional variational autoencoder decoder, and new EEG time-frequency features are generated by combining them with the specified fatigue state. The multi-channel EEG signal of driving fatigue is then reconstructed. Specifically: After the reverse denoising process is completed, new multi-channel EEG signal samples of driving fatigue are generated. Finally, the latent variables are mapped back to the original signal space by the decoder to generate a new multi-channel EEG signal of driving fatigue that is similar to the original driving fatigue signal. The formula is as follows: Where, x gen For new multichannel EEG signals of driver fatigue; For decoder networks; As latent variables; These are the decoder parameters.