1 Introduction

An affective BCI is an integrated hardware/software system that uses neurophysiological signals (e.g., electroencephalography (EEG) signal) to extract brain features that are related to affective states (e.g., emotions and moods). This affective BCI is now being incorporated into the treatment, offering the promise of a greatly enhanced quality of life by developing cognitive prosthetics for many psychiatric diseases such as anxiety. Anxiety state is one of emotional states, which Charles D. Spielberger (a clinical community psychologist) defined as the subjective feelings of tension and fear. These anxiety emotions are related to the stimulation of the nervous system [1]. Anxiety disorders can be mainly divided into generalized anxiety disorder (GAD), panic disorder (PD) and social anxiety disorder (SAD). The lifetime prevalence of generalized anxiety disorder worldwide is estimated around 3–5% [2]. Generalized anxiety disorder also associated with serious social and occupational injuries, comorbidity with other diseases, and an increased risk of suicide [3]. Clinical manifestations of generalized anxiety disorder are mostly accompanied by a series of physical symptoms such as tremor, muscle pain, sweating, abdominal discomfort, dizziness, and mental disorder like restlessness, insomnia, inattention, memory difficulties, irritability, extreme sensitivity to things, palpitation [4]. Due to so many clinical manifestations, most of the anxiety patients have not been diagnosed, nor have they received good treatment [5].

Whether a patient suffer from anxiety disorders can be judged by professional psychiatrists according to clinical experience and some questionnaire scales like GAD-17. The design of some questionnaire scales is complicated, and the subjects become restless during the process of filling in and wish to finish the questionnaire quickly. How can such a questionnaire accurately assess the state of the subjects? How serious of anxiety states were evaluated by GAD-17 questionnaire scores [6]. Traditional medicine and psychotherapy are used for treatment of confirmed anxiety patients, but previous researches showed that the therapeutic effect of drug was not so good [7,8,9,10,11]. It is advocated to choose the staged treatment according to the severity of anxiety symptoms [12]. Therefore, one of most important problems is the evaluation of the effect of various treatment methods. The treatment effect for the patients here refers to the change of anxiety level. For instance, some severe patients become better after a period of anti-anxiety treatment. The traditional discrimination methods are still based on some questionnaires, scales and clinical experience of doctor. Although the questions in the questionnaire scale are designed as sensitive and specific [13], the results of these scales are often subjective and lack of an objective index to judge. Which kind of biomarker is sensitive with treatment effect, and can quickly reflects to mental states of the patient? In addition, diagnosis bias also exists due to the different abilities of doctors. In a large-scale study of patients and their primary diagnosis from the health care doctors, the diagnosis errors of anxiety disorders were corrected, accounting for 34% [14]. In another study, 65% of patients with pure depression were diagnosed as anxiety disorder, while only 23% of patients with pure anxiety disorder can be diagnosed as anxiety disorder [15]. How to find an effective biomarker for accurately diagnose the state of anxiety and evaluation of treatment effect is still an opening question.

In this paper, we designed a neural feedback system based on Alpha-band oscillations (frequency power) of electroencephalography signals. The subjects with anxiety disorder were recruited, and divided into anxiety moderate and severe states according to their scores of the visual simulation scale. Healthy subjects also joined this experiment, and their mental state was defined as non- anxiety states. The electroencephalography signals were recorded and analyzed. The experiment results showed that the level of anxiety states can be classified from brain activity during the neural feedback experiment. With the help of our designed neurofeedback system, we can predict and classify anxiety states by collecting electroencephalography data of subjects. In this paper, we aim to relieve anxiety through EEG-based neurofeedback experiments and not to introduce a novel neurofeedback system.

2 Method

2.1 Subjects

In this study, thirty-four subjects, 17 anxiety disorder subjects (37  ± 7.61 years) and 17 healthy subjects (24.41  ± 1.49 years), participated this experiment. They have normal hearing ability, and have not received mindfulness recording treatment or training before. These anxiety subjects were judged by professional psychiatrists in Beijing Anding Hospital, Capital Medical University. Healthy subjects were the under graduated students. Before the experiment, the subjects were instructed to read and sign the informed consent form with the detailed personal information. The subjects were classified into healthy or anxious subjects. These anxious subjects are pure anxiety patients. All subjects participated to our experiments at psychiatric hospital with their consent. The inclusion criteria were selected by professional psychiatrists to judge and evaluate whether they are qualified to participate in our experiment. If the subjects of depression participate in this experiment, follow-up study is needed.

2.2 Experiment Paradigm and Data Recording

The participants were required to sit in a chair facing a desktop computer. As shown in Fig. 1, the paradigm includes three stages. In the first stage, the subjects were required to keep themselves in emotional stability for 5 min. The mindfulness recording was played in the second stage; the subjects followed the mindfulness recording to adjust their mental state according to the sound prompts for 8 min. Finally, the subjects continued to return to the resting state for 5 min. In our experiment, the all subjects were required to have eyes open and not to close their eyes. During the three small experimental stages, the subjects needed to complete the self-evaluation of anxiety degree. Each subject was asked to fill in the visual analog scale, which was composed of a graduated axis marked with the number 0–10. 0–4 was defined as non-anxiety, 5–7 as moderate anxiety and 8–10 as severe anxiety.

Fig. 1
figure 1

Experimental paradigm of the proposed affective brain–computer interface

The 32-channel electroencephalography signals (Brain Products, Germany) were recorded from the scalp of the participants during the experiment. The FP1, F3, F7 electrodes of the left frontal lobe and FP2, F4, F8 electrodes of the right frontal lobe were selected as the data source electrodes according to the international 10–20 system for the identification of anxiety state. The electrodes Fz and Cz were used as reference electrode. The scalp potential distribution of the electrode cap is shown in Fig. 2, in which the blue-marked electrode are the electrodes of the frontal lobe, and the reference electrodes are green-marked parts. During data recording, the impedance of each electrode was kept below 5 KΩ. The electroencephalography data was collected at the sampling rate of 500 Hz.

Fig. 2
figure 2

EEG electrode placement based on 10–20 international system. Scalp potential and reference point distribution of left and right frontal lobe

During the whole experiment, the alpha band power of electrode located in the left and right frontal lobe [16] were calculated in real time and displayed as feedback to build a neural feedback system. The energy of the signal was visualized as red and blue bar to show the energy asymmetry in the frontal lobe. The red bar chart represents the energy value of α wave on the left side of the frontal lobe. The green bar chart represents the energy value of α wave on the right side of the frontal lobe. The subjects could see the change of the visual bar, and try to adjust their mental state during mindfulness training. As shown in Fig. 3a, there were some differences between power of left and right side before mindfulness training. After training, the difference of power reduced in some subjects and was showed in Fig. 3b.

Fig. 3
figure 3

Subject neuro feedback presentation using energy change diagram of left and right frontal lobe

2.3 EEG Data Processing

Because there are many noise artifacts such as electrocardiogram (ECG), electromyogram (EMG) and power frequency interference in electroencephalography signals, it is necessary to preprocess the raw EEG signal to get relatively pure brain activity. In this paper, independent component analysis method (ICA) [17] is used to remove artifacts of eye movement. Butterworth bandpass filter is used to remove power frequency interference, and then 1–45 Hz electroencephalography data is obtained. The power spectral density [18, 19] is selected as the feature eigenvector.

$${\stackrel{\sim }{S}}_{x}\left(f\right)=\frac{1}{N}{\left|x(f)\right|}^{2}$$
(1)
$${\stackrel{\sim }{S}}_{x}\left(k\right)=\frac{1}{N}{\left|X(k)\right|}^{2}=\frac{1}{N}{\left|FFT\left[x(n)\right]\right|}^{2}, k=\mathrm{0,1}\cdots ,N-1$$
(2)

where, \(FFT\left[x\left(n\right)\right]\) is Fourier transform of the sequence x (n). Because the period of \(FFT\left[x\left(n\right)\right]\) is N, the power spectrum estimation obtained takes N as the period.

As shown in Fig. 4, the average power spectral density of the six leads in the second stage of the experiment is lower than that in the first stage of the experiment.

Fig. 4
figure 4

The D-PSD of FP1, FP2, F3, F4, F7 and F8 in the three stages of the experiment

The third stage is also lower than the first stage, it can be seen that using mindfulness can balance the left- and right-side energy asymmetry.

The power spectral density of six channels and the corresponding time–frequency diagrams are selected to calculate anxiety. Through the Fig. 5, we can see a visible peak around 10 Hz. Electroencephalography rhythm is usually divided into δ (1 –4 Hz), θ (4–8 Hz), α (8–13 Hz), β1 (13–20 Hz) and β2 (20–30 Hz). In order to avoid missing relevant information, the power spectral density data of 0–60 Hz were selected as the characteristics in this study.

Fig. 5
figure 5

The power spectral density of anxiety and corresponding time–frequency diagrams of non-anxiety (healthy) state, moderate anxiety state and severe anxiety state

In the three stages of our experiment, the visual analog scale scores of healthy subjects were very low, and they were all in non-anxiety state. However, the scores of visual analog scale of anxiety subjects in the first stage of the experiment were in severe anxiety, and the scores of visual analog scale in the second and third stages of the experiment were in moderate anxiety. Therefore, the data source of F3-Health in Fig. 5 is the third stage of healthy subjects. The data source of F3-Moderate is the experimental data of the second stage of anxious subjects and the F3-Severe is the data of the first stage of anxious subjects.

Our results can be obtained by analyzing the EEG data of lead F3. Combining the time–frequency graph and power spectral density graph of the power spectral density, it can be seen that when the frequency is lower than 20 Hz, the healthy subjects (non-anxious state) show the amplitude of the power spectral density is generally higher than that of the anxious subjects (moderate and severe states). There is no difference between the three states when the EEG frequency exceed 20 Hz.

2.4 Anxiety State Classification Method

After preprocessing and feature extraction of the original electroencephalography signals, the feature matrix is used as the input of the classifier to realize the recognition of anxiety state. Support vector machine (SVM) [20,21,22,23,24,25] is employed as classification method. The main idea of support vector machine is to map the input to high dimensional space with the help of kernel function, and find a hyperplane for classification.

$$w\bullet z-b=0$$
(3)

where \(w\) is normal vector and \(b\) is bias of the separation hyperplane. The decision hyper-plane can be found by solving the following optimizing problem.

In this paper, we address the three-classification problem of anxiety state, which is necessary to choose an appropriate multi-classification algorithm to realize the problem of multi-classification. At present, the commonly used multi-classification methods are one-vs-one [26, 27] (OVO) and one-vs-rest (OVR) [28]. The algorithm idea of one-vs-one is that for N categories to be classified, the pairwise combination of these N categories becomes a two-classification problem. After the combination, we can get \(\frac{{N\left( {N - 1} \right)}}{2}\) classifiers. During the test, these classifiers can produce \(\frac{{N\left( {N - 1} \right)}}{2}\) binary classification results. Finally, the most predicted categories in these two classification results are taken as the prediction categories of the final N classification. The implementation of one-vs-rest’s algorithm is that in the problem of N classification, one class is regarded as a positive class each time, and the other categories are regarded as a negative class. There are a total of N classifiers. In the test, the class marks corresponding to the classifiers predicted to be positive classes are taken as the final classification results.

3 Empirical Results

In this study, a total of 34 subjects were collected. Studies have shown that the frontal lobe is closely related to people's emotional and mental state [16, 29]. Therefore, the electroencephalography data of leads FP1, F3, F7, FP2, F4 and F8 located in the frontal lobe are selected as the data that each subject needs to process. In two seconds, the feature is calculated respectively after preprocessing, the total data length is 4 min, and 6120 data samples are finally formed. Therefore, there are 2040 samples in non-anxiety state, 2040 samples in moderate state of anxiety and 2040 samples in severe state of anxiety. The feature matrix calculated by these samples is input to the support vector machine classifier as input, and the classification results will be further displayed and discussed. In this study, Gaussian and polynomial kernels are selected as the kernel functions of support vector machine; moreover, one-vs-rest and one-vs-one multi-classification algorithms are selected.

Immediately after this article, we made predictions on the accuracy of each subject. For the sake of distinction, the healthy subjects (the first stage of experiment) are marked as S1–S17, and the anxious subjects are marked as S18–S34 (the first stage of experiment) and S35–S51 (the third stage of experiment). Among them, each subject has 120 samples and the samples of each subject is divided into a training set and a test set according to 4:1. There are 96 samples of each subject as the test set, and the remaining 24 samples are classified into the training set.

The result of prediction accuracy for each subject is also our concern and it is great significance for practical application. Tables 1, 2 and 3 are the prediction accuracy results for each of the subjects. It can be seen from the table that the average highest prediction accuracy for healthy subjects is 97.70 ± 3.32%, and the highest accuracy for anxious subjects is 92.29 ± 4.44%. It is inevitable that some unpredictable factors may cause great fluctuation of the prediction results. Participants' degree of cooperation and attitude towards the experiment will also cause differences in classification results.

Table 1 Prediction accuracy of healthy subjects (%) (Before mindfulness adjustment)
Table 2 Prediction accuracy of anxious subjects (%) (Before mindfulness adjustment)
Table 3 Prediction accuracy of anxious subjects (%) (After mindfulness adjustment)

The average classification accuracy rate obtained by using the model RBF + OVO is very effective, so the classification accuracy rate obtained by the model is used for significance analysis. A one-way ANOVA is also applied to analyze classification accuracy for the healthy subjects, and the significant differences of healthy subjects is observed (F16, 68 = 2.942, p = 0.001). A one-way ANOVA is then applied to analyze classification accuracy for the anxious subjects, and significant differences are observed (F16, 64 = 3.776, p < 0.0001) and (F16, 68 = 1.282, p = 0.2341). Healthy subjects are numbered “S1–S17”, anxious subjects are numbered “S18–S34” for the first experimental stage, and anxious subjects are numbered “S35–S51” for the third experimental stage. There are significant differences between healthy subjects “S16, S17” and “S1, S2” by multiple comparisons. There are significant differences between “S18” and “S30–S34” in the first experimental stage of anxiety subjects, and there are also significant differences between “S19" and “S32, S33, and S34”. No significant difference was found in the third experimental stage of anxiety subjects. And the results were shown in Fig. 8. Figures 6 and 7 have marked these differences. The accuracy of topics S1–S17, S18–S34 and S35–S51 decreased in turn. Because of the large number of subjects, the order of subjects is specially sorted according to the size of classification results. The purpose of descending order is to mark the significant difference of classification accuracy between subjects in the graph.

Fig. 6
figure 6

Healthy subjects classification result statistical analysis (Before mindfulness adjustment)

Fig. 7
figure 7

Anxious subjects classification result statistical analysis (Before mindfulness adjustment)

Fig. 8
figure 8

Anxious subjects classification result statistical analysis (After mindfulness adjustment)

In our experimental results, the accuracy of the health group and the anxiety group were statistically analyzed. The purpose and significance of our doing this is: because everyone's situation is complex, the prediction of each person can accurately judge the classification results of the model for each person, and the results can first evaluate the performance of the model. For the subjects, this practice can be used to evaluate the performance of the model. In practical application, it can accurately judge the change of anxiety state of patients with anxiety. Moreover, there is a contrast between the health group and the anxiety group. It can be seen from the results that the classification results of the health group are slightly higher than that of the anxiety group. For researchers, it is necessary to further improve the prediction results of the anxiety group.

4 Discussion

In previous studies, researchers have been working on 2-class classification to identify depression (be hopeless and feel worthless) from healthy status using EEG signal. They achieved a classification accuracy around 90–95% [30, 31]. In Kimmatkar et al. [32], the classification accuracy using EEG signal to classify human emotions had reached 98.67%. Few studies focused on multi-classification of emotions such as Putra et al. who achieved an average accuracy around 60–70% [33].

In this paper, a neural feedback experiment with three experimental stages was designed to study anxiety issue. The anxiety state (non-anxiety, moderate anxiety, and severe anxiety) was divided according to the scores of the visual simulation scale of the subjects’ self-evaluation in the three experimental stages. The EEG data of the frontal lobe was taken as the research object, and it was preprocessed to get pure data. The feature vectors composed of frequency domain features “PSD” were used as an input for SVM classifiers. Through ten times tenfold cross-validation, classification results demonstrated that the average classification accuracy of Gaussian + one-vs-one is 92.30 ± 1.31%, the average accuracy of Gaussian + one-vs-rest is 92.48 ± 1.20%, the average accuracy of Polynomial + one-vs-one is 87.97  ± 1.52%, and the average accuracy of Polynomial + one-vs-rest is 88.60  ± 1.32%. From the perspective of classification accuracy, the classification accuracy obtained by using the Gaussian kernel seems to be superior, and the Gaussian kernel is also the first to consider the volatility of the classification results. The results show that the Gaussian kernel is better than the classification accuracy of the polynomial kernel function in this study. These results prove that the proposed method is effective for three-class electroencephalography anxiety state classification problems. It is also important for the prediction accuracy of each subject. By taking a part of each subject's samples and combining them into a training set, and then taking the remaining samples of each subject as a test set in turn, we get the objective accuracy results. Tables 2 and 3 are the results of prediction accuracy for each subject.

This experiment has made some progress on the classification of anxiety state, which is only a small step forward, and there is still a lot of room for improving the accuracy of classification. Because the research time is limited, there may be many methods that can be applied to the classification of anxiety state, and there are broad prospects for future research. In the near future, we are going to analyze the EEG changes of the subjects in the three stages of the experiment from the perspective of physiological signals, and assess whether they are relieved of anxiety like the scores of the visual analog scale. These kinds of affective BCI may lead in the future to help not only stressful adolescents and elderly with psychiatric diseases [34] but also people who experience extreme fear/worry or panic attacks during pandemic periods such as COVID-19 pandemic.