Self-adaptive music regulation and control method and system based on electroencephalogram emotion recognition

Through the combination of frequency spatiotemporal convolution layer, temporal convolutional neural network and Transformer encoder of the FSTrans framework, the problem of insufficient feature extraction of EEG signals is solved, high-precision EEG emotion recognition and adaptive music regulation are achieved, and the performance is improved. Emotion recognition accuracy and user experience.

CN118732847APending Publication Date: 2024-10-01SHANDONG UNIV OF TRADITIONAL CHINESE MEDICINE
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410810246.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

When the existing technology uses EEG signals for emotion recognition, it fails to fully extract the characteristics of the EEG signals, resulting in low accuracy of emotion recognition and the inability to achieve effective adaptive music regulation.

Method used

Using the FSTrans framework, combined with the frequency spatiotemporal convolution layer, temporal convolutional neural network and Transformer encoder, the frequency domain, spatial and time domain characteristics of the EEG signal are integrated, and global modeling is performed to achieve high-precision EEG emotion recognition. And automatically adjust the music based on the recognition results.

Benefits of technology

It improves the accuracy of EEG emotion recognition, automatically plays adaptive music according to emotion types, and has both emotion monitoring and early warning functions to ensure the best experience and safety of users' emotional states.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118732847A_ABST
    Figure CN118732847A_ABST
Patent Text Reader

Abstract

The invention discloses a self-adaptive music regulation and control method and system based on electroencephalogram emotion recognition, and belongs to the technical field of electroencephalogram signal recognition. Comprising the steps of obtaining to-be-recognized electroencephalogram signals; eEG signal features of the to-be-recognized EEG signals under different time-space and frequencies are captured through a frequency time-space convolution layer and fused, and EEG fusion features are obtained; inputting the electroencephalogram fusion features into a time convolutional neural network for time feature extraction, obtaining depth time features, and fusing the depth time features with the electroencephalogram fusion features to generate electroencephalogram depth fusion features; the electroencephalogram deep fusion features are input into a Transform encoder layer for global modeling, and an emotion recognition result is obtained; and transmitting the emotion recognition result to a controller, so that the controller automatically plays corresponding adjustment music according to the emotion recognition result. Corresponding music can be adaptively played according to a real-time electroencephalogram recognition emotion state, so that pressure is relieved, self emotion is adjusted, and electroencephalogram recognition accuracy is improved; the problem that existing emotion recognition is low in accuracy is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electroencephalogram (EEG) signal recognition, and in particular to an adaptive music control method and system based on EEG emotion recognition. Background Art

[0002] The statements in this section merely mention background art related to the present invention and do not necessarily constitute prior art.

[0003] With the development of cognitive neuroscience, the interaction mechanism between music and cognitive nerves has become the core of music psychology research, and more and more researchers are paying attention to regulating human emotions with music of different melodies or styles.

[0004] When the brain processes music with different melodies, it will gradually produce different psychological changes and physiological reactions. For example, when a person is in a negative mood such as sadness and anxiety, listening to soothing and peaceful music can help release negative emotions, and when a person is in a positive mood such as joy and satisfaction, listening to cheerful and beautiful music can help maintain positive emotions. Therefore, how to accurately classify emotions is an important part of achieving emotional regulation by playing music according to emotional types.

[0005] EEG signals are objective indicators of emotions. Currently, there are many wearable devices on the market that can collect EEG signals, such as headphones, headbands, etc., but these wearable devices only record brain waves and do not make further applications for the collected EEG data. In other words, there are no relevant wearable devices to identify emotion types and regulate one's own emotions.

[0006] With the rapid development of deep learning, it has also been applied to EEG emotion recognition. However, existing emotion recognition methods often only extract features based on a single dimension when processing EEG signals, which is unable to fully characterize the information contained in the EEG signals, resulting in the need to improve the accuracy of emotion recognition. Summary of the invention

[0007] In order to address the deficiencies of the prior art, the present invention provides an adaptive music control method, system, electronic device and computer-readable storage medium based on EEG emotion recognition, which can perform emotion classification according to real-time EEG signals, comprehensively extract the features of real-time EEG signals, and improve the accuracy of emotion classification.

[0008] In a first aspect, the present invention provides an adaptive music control method based on EEG emotion recognition;

[0009] An adaptive music control method based on EEG emotion recognition, comprising:

[0010] Obtaining the EEG signal to be identified;

[0011] Input the EEG signal to be recognized into a preset emotion recognition model for processing to obtain the emotion recognition result;

[0012] Transmitting the emotion recognition result to the controller so that the controller automatically plays the corresponding adjusted music according to the emotion recognition result;

[0013] The step of inputting the EEG signal to be recognized into a preset emotion recognition model for processing includes:

[0014] The EEG signal features of the EEG signal to be identified at different time, space and frequency are captured and fused through the frequency-space convolution layer to obtain the EEG fusion features;

[0015] Input the EEG fusion features into the temporal convolutional neural network for temporal feature extraction, obtain the deep temporal features and fuse them with the EEG fusion features to generate the EEG deep fusion features;

[0016] The EEG deep fusion features are input into the Transformer encoder layer for global modeling to obtain emotion recognition results.

[0017] In some embodiments, the frequency-space-time convolution layer includes a plurality of three-dimensional frequency convolution layers of different scales, and the three-dimensional frequency convolution layer includes a 3D frequency-space-time convolution kernel and a frequency-space fusion convolution kernel;

[0018] The 3D frequency-space-time convolution kernel is used to convolve the EEG signal to be identified in the time dimension, EEG channel dimension and frequency dimension, and obtain output features in the time dimension, EEG channel dimension and frequency dimension respectively; the frequency-space fusion convolution kernel is used to fuse the output features of the EEG channel dimension and the frequency dimension.

[0019] In some embodiments, the temporal convolutional neural network includes a plurality of groups of residual modules connected sequentially;

[0020] Among them, the input of the residual module is jump-connected with the output of the residual module, and the residual module includes a plurality of dilated causal convolution kernels of different scales. The dilated causal convolution kernel is used to perform a convolution operation on the input data in the time dimension. At the same time, holes are inserted between the elements of the convolution kernel to expand the receptive field.

[0021] In some embodiments, the Transformer encoder layer includes a data embedding layer, a position embedding layer and an encoder, wherein the data embedding layer is used to capture local features and local patterns of the fused features, the position embedding layer is used to introduce position information for the EEG signal, and the encoder is used to integrate frequency information, spatial information and temporal information in the fused features.

[0022] In some embodiments, the encoder includes an encoder and a convolutional layer, and the encoder layer processes input features in parallel through a multi-head self-attention mechanism.

[0023] In some embodiments, inputting the EEG deep fusion features into the Transformer encoder layer for global modeling includes:

[0024] The EEG deep fusion feature is input into the data embedding module and the position embedding module for one-dimensional convolution mapping and position encoding to obtain the EEG deep fusion feature embedding vector;

[0025] The multi-head self-attention mechanism is used to parallelly calculate the attention weights of the EEG deep fusion feature embedding vector and introduce residual connections to output the EEG deep fusion feature embedding vector and the corresponding attention score;

[0026] The convolutional layer is used to filter the EEG deep fusion feature embedding vector according to the attention score to extract features and obtain the emotion features after global modeling.

[0027] In some embodiments, it further comprises:

[0028] Filter the emotion threshold according to the type of emotion recognition results;

[0029] According to the duration and emotion threshold of the emotion recognition result, a prompt message is sent to the controller.

[0030] In a second aspect, the present invention provides an adaptive music control system based on EEG emotion recognition;

[0031] An adaptive music control system based on EEG emotion recognition, comprising:

[0032] An electroencephalogram sensor, which is used to collect and transmit electroencephalogram signals;

[0033] The server side is used to obtain the EEG signal to be identified; input the EEG signal to be identified into a preset emotion recognition model for processing, obtain the emotion recognition result and transmit it;

[0034] A controller, the controller being used to automatically play corresponding adjusted music according to the emotion recognition result;

[0035] The step of inputting the EEG signal to be recognized into a preset emotion recognition model for processing includes:

[0036] The EEG signal features of the EEG signal to be identified at different time, space and frequency are captured and fused through the frequency-space convolution layer to obtain the EEG fusion features;

[0037] Input the EEG fusion features into the temporal convolutional neural network for temporal feature extraction, obtain the deep temporal features and fuse them with the EEG fusion features to generate the EEG deep fusion features;

[0038] The EEG deep fusion features are input into the Transformer encoder layer for global modeling to obtain emotion recognition results.

[0039] In a third aspect, the present invention provides an electronic device;

[0040] An electronic device includes a memory and a processor, and computer instructions stored in the memory and running on the processor. When the computer instructions are run by the processor, the steps of the above-mentioned adaptive music control method based on EEG emotion recognition are completed.

[0041] In a fourth aspect, the present invention provides a computer-readable storage medium;

[0042] A computer-readable storage medium is used to store computer instructions. When the computer instructions are executed by a processor, the steps of the above-mentioned adaptive music control method based on EEG emotion recognition are completed.

[0043] Compared with the prior art, the present invention has the following beneficial effects:

[0044] 1. The technical solution provided by the present invention adopts the FSTrans framework to realize EEG emotion recognition, integrates TCN, CNN and Transformer to learn the frequency domain features, spatial features and time domain feature information in the EEG signal, and realizes high-precision EEG emotion recognition; the frequency-space-time convolution layer is used to extract the frequency, space and time information in the EEG signal, and TCN is used to realize the extraction of time features. Finally, the Transformer encoder is used to integrate the emotion information in different feature spaces, and the time domain, frequency domain and space features are globally modeled respectively, finally realizing high-precision EEG emotion recognition.

[0045] 2. The technical solution provided by the present invention can control the player to play corresponding adjusted music according to the emotion recognition results: for example, for negative emotions, play quiet and soothing music; for positive emotions, play cheerful and bright music; in between the two, in a neutral emotion, the user can customize the music playback to ensure the best user experience and realize adaptive regulation based on the mutual feedback model of emotion and music.

[0046] 3. The technical solution provided by the present invention has the function of monitoring and storing the user's emotional state. It can record the user's recent EEG signals and corresponding emotional state, and when the emotional state exceeds the set emotional threshold (such as the negative emotional state lasts too long or the degree of negativity is more serious than that of ordinary people), it will remind the user to calm down or seek medical treatment in time, thereby preventing the occurrence of dangerous situations. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0048] Figure 1 A schematic diagram of the network architecture of an emotion recognition model provided by an embodiment of the present invention;

[0049] Figure 2 A schematic diagram of a two-dimensional emotion classification model provided by an embodiment of the present invention;

[0050] Figure 3 A schematic diagram of the structure of an adaptive music control system provided by an embodiment of the present invention;

[0051] Figure 4 A schematic diagram of the use process of the adaptive music control system provided by an embodiment of the present invention;

[0052] Figure 5 A schematic diagram of the network architecture of the frequency-space-time convolution layer provided in an embodiment of the present invention;

[0053] Figure 6 A schematic diagram of the network architecture of a spatiotemporal convolutional neural network provided by an embodiment of the present invention;

[0054] Figure 7 A schematic diagram of the network architecture of the Transformer encoder layer provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0055] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used in the present invention have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.

[0056] It should be noted that the terms used herein are only for describing specific embodiments, and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that the terms "include" and "have" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0057] In the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.

[0058] Embodiment 1

[0059] There is currently a lack of methods for adaptive music regulation based on people's real-time emotions, and when using EEG signals for emotion recognition, the emotional characteristics contained in the EEG signals are not fully and comprehensively explored, resulting in low accuracy in emotion recognition, which in turn affects the accuracy of adaptive music regulation; therefore, the present invention provides an adaptive music regulation method based on EEG emotion recognition.

[0060] Next, combine Figure 1-Figure 7 , a method for adaptive music regulation based on EEG emotion recognition disclosed in this embodiment is described in detail. The method for adaptive music regulation based on EEG emotion recognition is applied to the server side and includes the following steps:

[0061] S1. Obtain the EEG signal to be identified.

[0062] In this embodiment, the EEG signals to be identified are collected by the EEG sensor and transmitted to the server through the Bluetooth module. Here, the EEG collection channels select five EEG channels with greater emotion correlation. The electrode positions follow the international 10-20 system, and the EEG channels are F3, T7, FPz, F4 and T8 respectively.

[0063] S2. Input the EEG signal to be recognized into a preset emotion recognition model for processing to obtain an emotion recognition result.

[0064] Among them, the emotion recognition module includes a frequency-space-time convolution layer, a time convolutional neural network and a Transformer encoder layer connected in sequence. First, the frequency-space-time convolution layer is used to extract the frequency information and spatial information in the EEG signal to be identified, and the three-dimensional frequency-space convolution kernel is used to capture the time information, frequency domain information and spatial information; then, the time convolutional neural network TCN is used to extract the time features; finally, the Transformer encoder layer is used to integrate the emotion information in different feature spaces, and the time domain, frequency domain and spatial features are globally modeled respectively, finally achieving high-precision EEG emotion recognition.

[0065] As an implementation mode, step S2 specifically includes:

[0066] S201. Capture the EEG signal features of the EEG signal to be identified at different time, space and frequency through the frequency-space convolution layer and fuse them to obtain EEG fusion features.

[0067] In this embodiment, in order to capture the features of different time, space and frequency levels in the signal to be identified, a frequency-time-space convolution layer is composed of three-dimensional frequency convolution layers of three different scales. The three-dimensional frequency convolution layer includes 3D frequency-time-space convolution kernels and frequency-space fusion convolution kernels connected in sequence, and a 3D batch normalization layer and a relu activation function are connected after each convolution kernel, thereby accelerating the training of the network and improving the generalization performance of the model and introducing nonlinear mapping so that the network can learn more complex features.

[0068] Since the 2D convolution kernel cannot move simultaneously in the frequency, space, and time dimensions to extract features, a 3D convolution kernel is selected as the feature extractor and designed as a frequency-space convolution kernel of three different scales. This multi-scale convolution kernel design helps the network to effectively capture the EEG signal features at different frequency, time, and EEG channel number scales, and can enhance the model's ability to learn different types of features.

[0069] The function of the frequency-space fusion convolution kernel is to fuse the features of the space and frequency dimensions. The convolution kernel moves in both the frequency and space dimensions, but does not change in the time dimension. The size of the convolution kernel corresponds to the frequency and space dimensions of the output data after the 3D frequency-space convolution, thereby learning the feature fusion information of all channels and frequency bands.

[0070] Exemplarily, the specific implementation process of step S201 is as follows:

[0071] S2011. The EEG signals to be identified are convolved in the time dimension, EEG channel dimension and frequency dimension through 3D frequency spatiotemporal convolution kernels of different scales. After the 3D batch normalization layer and relu activation function, the corresponding output features in the time dimension, EEG channel dimension and frequency dimension are obtained respectively.

[0072] Here, 3D frequency spatiotemporal convolution kernels of different scales are used to convolve the EEG signals in the dimensions of time, EEG channels, and frequency. Compared with the traditional two-dimensional convolution kernel at a single scale, it can better capture the multidimensional features of the signal at different scales, making the extracted features richer and more representative, reflecting the emotional characteristics.

[0073] S2012. The output features of the EEG channel dimension and the frequency dimension are fused through the frequency-space fusion convolution kernel to obtain preliminary fusion features of different scales.

[0074] The frequency-space fusion convolution kernel moves in both the frequency dimension and the EEG channel dimension, but does not change in the time dimension. The size of the frequency-space fusion convolution kernel corresponds to the frequency dimension and space dimension of the output data after 3D frequency-space convolution, so as to achieve the learning of feature fusion information of all channels and frequency bands. Finally, the useless dimensions are reduced by dimensional transformation, and the signal is reduced to the data dimension of only channel and time signals to adapt to the input of the subsequent network structure.

[0075] Through this convolution kernel, the features of the EEG signal in the EEG channel and frequency dimensions are fused. This fusion is not just a simple feature superposition, but the movement and operation of the convolution kernel in multiple dimensions ensures that the information of each frequency and channel is fully integrated, thereby improving the expressiveness of the features and the accuracy of the data. Traditional feature extraction methods often ignore the role of frequency information and do not take into account the rich emotional feature information brought by the fusion of frequency information and spatial information.

[0076] S2013, the preliminary fusion features of different scales are fused to obtain the EEG fusion features. Specifically, different weights are assigned to the preliminary fusion features of different scales, and then they are added together. It is expressed as follows:

[0077]

[0078] In the formula, F weighted represents the EEG fusion feature, F i represents the initial fusion feature of the i-th scale, n represents the number of initial fusion features, and w i It represents the weight corresponding to the i-th preliminary fusion feature. This weight is equal at the beginning. During the model training process, through back propagation, the model will continuously adjust this weight to achieve the best effect.

[0079] S202, input the EEG fusion feature into the temporal convolutional neural network to extract the temporal feature, obtain the deep temporal feature and fuse it with the EEG fusion feature to generate the EEG deep fusion feature.

[0080] Among them, the temporal convolutional neural network includes multiple groups of residual modules connected in sequence, and the input of the residual module is fused with the final output of the residual module after one-dimensional convolution and output.

[0081] The residual module includes a dilated causal convolution kernel, a WeightNorm layer, a ReLu activation function, a Dropout layer, a dilated causal convolution kernel, a WeightNorm layer, a ReLu activation function, and a Dropout layer connected in sequence. The original input is fused with the output of the second Dropout layer after one-dimensional convolution. The WeightNorm layer is used to stabilize the model, alleviate the gradient vanishing problem, and enhance the learning ability of the model.

[0082] Temporal convolutional network (TCN) is a convolutional neural network designed to handle sequence modeling tasks. It adopts three designs: causal convolution, dilated convolution, and residual connection. The dilation factor determines the jump step of the convolution kernel on the time series data and affects the size of the receptive field. As the dilation factor increases, the receptive field is expanded and can capture information in a more distant time range, but this will also lead to an increase in the amount of calculation. Therefore, when selecting parameters, the contradiction between the size of the receptive field and the amount of calculation should be considered, and the value of the dilation factor should be set reasonably. In the construction of this model, it is used to further extract the temporal features in the data. The residual module ensures the stability of the model's deep training. For example, the EEG fusion features at each time point are represented as {x0, x1,…, x t}, the specific process of step S202 is as follows:

[0083] The EEG fusion features {x0, x1, ..., x t} Input multiple groups of residual modules connected in sequence for processing to obtain the deep temporal features {y0, y1, ..., y t}.

[0084] Specifically, the dilated causal convolution kernel performs a convolution operation on the input data in the time dimension, which is expressed as follows:

[0085]

[0086] Where y(t) is the convolution output at time step t, and w i is the weight of the convolution kernel, x t-d*i is the corresponding EEG signal element, taking into account the influence of the expansion factor d, and i is the index of the convolution kernel, ranging from 0 to k-1.

[0087] The dilated causal convolution expands the receptive field by inserting holes between the elements of the convolution kernel, while ensuring that the output of the current time step only depends on the current and previous inputs while maintaining the causal relationship of the EEG signal input. Then, by introducing multiple dilated causal convolution kernels, the model can extract features at different time scales.

[0088] The input data processed by the dilated convolution kernel is directly added to the original input (i.e., EEG fusion features) to obtain the EEG deep fusion features. If the original input dimension does not match the feature map, the dimension can be adjusted through a 1*1 convolution kernel. The design is called "Residual Connection" to alleviate the gradient vanishing problem. In this way, even if the network depth is increased too much, the performance of the model training will not be reduced.

[0089] The output of this model is the EEG deep fusion feature obtained by directly adding the deep temporal feature map extracted by the dilated causal convolution kernel to the original input (EEG fusion feature), which contains the captured time, space, and frequency information.

[0090] As shown in the figure, d is the dilation factor, which determines the jump step of the convolution kernel on the time series data and affects the size of the receptive field. As the dilation factor increases, the receptive field is expanded and can capture information in a more distant time range, but this will also lead to an increase in the amount of calculation. In the experiment, the size of d is set according to the power of 2, and the receptive field size of the network increases with the superposition of the number of TCN layers. k is the size of the convolution kernel. Each predicted value is predicted based on the k input values ​​of the previous layer. In TCN, the convolution kernel size also affects the size of the receptive field and the level of detail of the model's feature extraction. It is set to 4 in the experiment. This is the experimental parameter that has achieved the best results through multiple experiments. Causal convolution ensures the causal relationship in time series prediction and ensures that the current result depends only on the current and previous input data. Dilated convolution expands the receptive field to capture a wider range of contextual information while maintaining the resolution of the feature map.

[0091] S203, input the acquired EEG deep fusion features into the Transformer encoder layer for global modeling, and classify them after calculation by the Softmax function to obtain the emotion recognition results.

[0092] Specifically, the deep fusion features of EEG are obtained and input into the Transformer encoder to globally model it and integrate different types of emotional features using the self-attention mechanism. Finally, the feature output of the Transformer encoder layer is mapped to the vector of the emotion category through the linear layer. This vector is then normalized through the Softmax function to obtain the probability distribution of each emotion category, that is, the validity value and dimension value corresponding to the emotional feature, thereby realizing the classification of emotions.

[0093] The Transformer encoder layer includes a data embedding layer, a position embedding layer, and an encoder. The signal first enters the DATAEmbedding module in this layer. In this module, a one-dimensional convolutional mapping is performed through a one-dimensional convolutional layer with token embedding to map the data into a higher-dimensional space, which helps capture local features and patterns in the signal and improves the model's ability to understand the signal. PositionalEmbedding introduces position information to EEG signals. Positional embedding is particularly helpful in capturing relative position information between sequence data. This may be a key point in EEG emotion tasks. Finally, the two are added together so that the model can better understand and learn the key features in the signal.

[0094] The Encoder layer has two built-in layers, namely the Multihead Attention Layer and the Conv Layer. In the Multihead Attention Layer, a multi-head self-attention mechanism is used to process different attention weights in parallel. Each head can focus on different time, space and frequency information hidden in the data. Among them, the core self-attention mechanism uses dot product scaling attention. The self-attention mechanism calculates the degree of association between each element and all other elements in the sequence and captures the dependency between elements. This attention mechanism has good performance in this experiment. The calculation of the self-attention mechanism can be expressed as follows: Then the data enters the Conv Layer. This layer uses a 1D convolution layer to extract the dominant emotional features, and then performs batch normalization. The ELU activation function is used to introduce nonlinearity, and finally the maximum pooling layer is used to reduce the data dimension to improve the computational efficiency of the network. It is superimposed twice in total, and the Multihead Attention Layer layer is used again at the end to realize the production of a layer-by-layer progressive focus self-attention feature map, thereby integrating three different types of emotional features: frequency, space, and time.

[0095] For example, the specific process is as follows:

[0096] S2031. Perform one-dimensional convolution mapping and position encoding on the EEG deep fusion feature input data embedding module and position embedding module to obtain the EEG deep fusion feature embedding vector.

[0097] Among them, the EEG deep fusion features are input into the data embedding (DATAEmbedding) module for processing, and a one-dimensional convolution mapping is performed through the one-dimensional convolution layer of node embedding to map the data into a higher-dimensional space, which helps to capture local features and patterns in the signal and improve the model's ability to understand the signal.

[0098] The deep temporal features are input into the Positional Embedding module for processing to introduce position information into the EEG signal. Positional embedding is particularly helpful in capturing the relative position information between sequence data. Each dimension of the positional embedding encoding corresponds to a sine curve, so that the model learns the relative position between data. The specific representation is as follows:

[0099]

[0100] Where pos represents the position, i represents the dimension of the embedding vector, and dmodel represents the dimension of the output vector of the position embedding module.

[0101] Finally, the outputs of the data embedding module and the position embedding module are added together so that the model can better understand and learn the key features in the signal, and obtain the EEG deep fusion feature embedding vector, which is expressed as:

[0102] DataEmbedding(x)=TokenEmbedding(x)+PositionalEmbedding(x).

[0103] S2032. Use the multi-head self-attention mechanism to parallely calculate the attention weights of the EEG deep fusion feature embedding vector and introduce residual connections to output the EEG deep fusion feature embedding vector and the corresponding attention score.

[0104] Specifically, the EEG deep fusion feature embedding vector is input into the Encoder layer. This layer has two built-in layers, namely the Multiheadattentionlayer layer and the Convlayer layer. In the Multiheadattentionlayer layer, a multi-head self-attention mechanism is used to process different attention weights in parallel. Each head can focus on different time, space, and frequency information hidden in the data. Among them, the core self-attention mechanism uses dot product scaling attention. The self-attention mechanism calculates the degree of association between each element and all other elements in the sequence, capturing the dependency between elements. This attention mechanism has good performance in this experiment. The calculation of the self-attention mechanism can be expressed as:

[0105]

[0106] Among them, Q is the query matrix, K is the key matrix, V is the value matrix, and d_k is the dimension of the query key. Residual connections are introduced to ensure the training effect when the network depth is large. The representation of self-attention and residual connection is:

[0107] out=DotProductAttention(x, x, x);

[0108] out=x+Dropout(out).

[0109] S2033. The deep temporal feature embedding vector is filtered according to the attention score through the convolution layer to perform feature extraction, and the emotion features after global modeling are obtained.

[0110] Specifically, the deep temporal feature embedding vector and the corresponding attention score are input into the Convlayer, which uses the 1D convolution layer to extract the dominant emotional features, and then performs batch normalization. The RELU activation function is used to introduce nonlinearity to further extract high-level emotional features to improve the computational efficiency of the network.

[0111] A layer of Convlayer is used between two layers of Mutiheadattentionlayer. Using Convlayer after the first Mutiheadattentionlayer can reduce the data dimension and improve the calculation efficiency. Then using Mutiheadattentionlayer for processing can achieve better results, realize the production of layer-by-layer progressive focused self-attention feature maps, integrate three different types of emotional features of frequency, space, and time, and extract the emotional features after global modeling.

[0112] The emotional features after global modeling are calculated and classified by the Softmax function to obtain the corresponding value and dimension value of the emotional features. Figure 2 The two-dimensional emotion classification model shown in Figure 1 obtains the emotion recognition results.

[0113] For example, when the value of valence is large and the value of arousal is small, the corresponding emotion is happy emotion.

[0114] In this embodiment, when training the emotion recognition model, the EEG signal data set is labeled with the effect value and dimension value, and a training set is constructed to train the emotion recognition model until a trained emotion recognition model is obtained. Here, when applied, the input of the emotion recognition model is the EEG signal to be recognized, and the output is the corresponding effect value and dimension value.

[0115] S3. Transmitting the emotion recognition result to the controller so that the controller adjusts the music according to the emotion recognition result.

[0116] Furthermore, it also includes: screening the emotion threshold according to the type of emotion recognition result; and sending a prompt message to the controller according to the duration of the emotion recognition result and the emotion threshold. For example, if the user's negative emotion lasts too long, a warning is sent to the controller.

[0117] To sum up, the adaptive music control method based on EEG emotion recognition described in this embodiment has better feature extraction capability and higher data expression capability. Multi-scale convolution and frequency space fusion ensure that the features extracted from the original signal are more comprehensive and detailed. The fusion operation not only combines information of different dimensions, but also enhances the abstraction and generalization capabilities of the features through the convolution operation.

[0118] Embodiment 2

[0119] This embodiment discloses an adaptive music control system based on EEG emotion recognition, including an EEG sensor, a Bluetooth module, a server, a controller, headphones and a player. The EEG sensor, the Bluetooth module, the controller and the player are installed in the headphones, the EEG sensor and the controller are respectively communicated with the Bluetooth module, and the Bluetooth module is communicated with the server.

[0120] The EEG sensor is used to collect EEG signals and transmit them to the server through the Bluetooth module. Here, the EEG collection channels select five EEG channels with greater emotion relevance. The electrode positions follow the international 10-20 system. The EEG channels are F3, T7, FPz, F4 and T8 respectively.

[0121] The server receives the EEG signal and processes it. The processing steps are as follows:

[0122] The EEG signal to be recognized is input into a preset emotion recognition model for processing to obtain the emotion recognition result; the emotion recognition result is transmitted to the controller, and the controller automatically plays the corresponding adjusted music according to the emotion recognition result.

[0123] The step of inputting the EEG signal to be recognized into a preset emotion recognition model for processing includes:

[0124] The EEG signal features of the EEG signal to be identified at different time, space and frequency are captured and fused through the frequency-space convolution layer to obtain the EEG fusion features; the EEG fusion features are input into the time convolutional neural network for time feature extraction to obtain deep time features and fuse them with the EEG fusion features to generate EEG deep fusion features; the EEG deep fusion features are input into the Transformer encoder layer for global modeling to obtain emotion recognition results.

[0125] The specific details of the above content have been discussed in Example 1 and will not be repeated here.

[0126] Embodiment 3

[0127] Embodiment 3 of the present invention provides an electronic device, including a memory and a processor, and computer instructions stored in the memory and executed on the processor. When the computer instructions are executed by the processor, the steps of the above-mentioned adaptive music control method based on EEG emotion recognition are completed.

[0128] Embodiment 4

[0129] Embodiment 4 of the present invention provides a computer-readable storage medium for storing computer instructions. When the computer instructions are executed by a processor, the steps of the above-mentioned adaptive music control method based on EEG emotion recognition are completed.

[0130] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0131] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0132] These computer program instructions can also be loaded onto a computer or other programmable data processing device, and a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0133] The description of each embodiment in the above embodiments has different emphases. For parts not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0134] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. An adaptive music control method based on EEG emotion recognition, characterized in that: include: Obtaining the EEG signal to be identified; Input the EEG signal to be recognized into a preset emotion recognition model for processing to obtain the emotion recognition result; Transmitting the emotion recognition result to the controller so that the controller automatically plays the corresponding adjusted music according to the emotion recognition result; The step of inputting the EEG signal to be recognized into a preset emotion recognition model for processing includes: The EEG signal features of the EEG signal to be identified at different time, space and frequency are captured and fused through the frequency-space convolution layer to obtain the EEG fusion features; Input the EEG fusion features into the temporal convolutional neural network for temporal feature extraction, obtain the deep temporal features and fuse them with the EEG fusion features to generate the EEG deep fusion features; The EEG deep fusion features are input into the Transformer encoder layer for global modeling to obtain emotion recognition results.

2. The method for adaptive music control based on EEG emotion recognition according to claim 1, characterized in that: The frequency-space-time convolution layer includes a plurality of three-dimensional frequency convolution layers of different scales, and the three-dimensional frequency convolution layer includes a 3D frequency-space-time convolution kernel and a frequency-space fusion convolution kernel; The 3D frequency-space-time convolution kernel is used to convolve the EEG signal to be identified in the time dimension, the EEG channel dimension and the frequency dimension, and obtain output features in the time dimension, the EEG channel dimension and the frequency dimension respectively; The frequency-space fusion convolution kernel is used to fuse the output features of the EEG channel dimension and the frequency dimension.

3. The method for adaptive music control based on EEG emotion recognition according to claim 1, characterized in that: The temporal convolutional neural network includes a plurality of groups of residual modules connected in sequence; Among them, the input of the residual module is jump-connected with the output of the residual module, and the residual module includes a plurality of dilated causal convolution kernels of different scales. The dilated causal convolution kernel is used to perform a convolution operation on the input data in the time dimension. At the same time, holes are inserted between the elements of the convolution kernel to expand the receptive field.

4. The method for adaptive music control based on EEG emotion recognition according to claim 1, characterized in that: The Transformer encoder layer includes a data embedding layer, a position embedding layer and an encoder. The data embedding layer is used to capture the local features and local patterns of the fused features, the position embedding layer is used to introduce position information into the EEG signal, and the encoder is used to integrate the frequency information, spatial information and temporal information in the fused features.

5. The adaptive music control method based on EEG emotion recognition as claimed in claim 4, characterized in that: The encoder includes an encoder and a convolutional layer, and the encoder layer processes input features in parallel through a multi-head self-attention mechanism.

6. The method for adaptive music control based on EEG emotion recognition according to claim 1, characterized in that: The EEG deep fusion feature is input into the data embedding module and the position embedding module for one-dimensional convolution mapping and position encoding to obtain the EEG deep fusion feature embedding vector; The multi-head self-attention mechanism is used to parallelly calculate the attention weights of the EEG deep fusion feature embedding vector and introduce residual connections to output the EEG deep fusion feature embedding vector and the corresponding attention score; The convolutional layer is used to filter the EEG deep fusion feature embedding vector according to the attention score to extract features and obtain the emotion features after global modeling.

7. The method for adaptive music control based on EEG emotion recognition according to claim 1, characterized in that: Also includes: Filter the emotion threshold according to the type of emotion recognition results; According to the duration and emotion threshold of the emotion recognition result, a prompt message is sent to the controller.

8. An adaptive music control system based on EEG emotion recognition, characterized in that: include: An electroencephalogram sensor, which is used to collect and transmit electroencephalogram signals; A server side, the server side is used to obtain the EEG signal to be identified; Input the EEG signal to be recognized into the preset emotion recognition model for processing, obtain the emotion recognition result and transmit it; A controller, the controller being used to adjust the music according to the emotion recognition result; The step of inputting the EEG signal to be recognized into a preset emotion recognition model for processing includes: The EEG signal features of the EEG signal to be identified at different time, space and frequency are captured and fused through the frequency-space convolution layer to obtain the EEG fusion features; Input the EEG fusion features into the temporal convolutional neural network for temporal feature extraction, obtain the deep temporal features and fuse them with the EEG fusion features to generate the EEG deep fusion features; The EEG deep fusion features are input into the Transformer encoder layer for global modeling to obtain emotion recognition results.

9. An electronic device, characterized in that: It includes a memory and a processor, and computer instructions stored in the memory and running on the processor. When the computer instructions are run by the processor, the adaptive music control method based on EEG emotion recognition as described in any one of claims 1 to 7 is completed.

10. A computer-readable storage medium, characterized in that: Used to store computer instructions, which, when executed by a processor, complete the adaptive music control method based on EEG emotion recognition as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Emotion recognition result visualization method and system based on electroencephalogram data

    CN119818070A

  • Generative AI-driven physiology-music following response intelligent emotion regulation system

    CN119896792A

  • Intelligent music regulation and control system and method based on electroencephalogram signal multi-modal feature recognition

    CN120437460A

  • High-fidelity music reconstruction method and device, equipment and medium

    CN120472930A