A Hybrid End-to-End Spatio-Temporal Attention Neural Network with
  Graph-Smooth Signals for EEG Emotion Recognition
Recently, physiological data such as electroencephalography (EEG) signals
have attracted significant attention in affective computing. In this context,
the main goal is to design an automated model that can assess emotional states.
Lately, deep neural networks have shown promising performance in emotion
recognition tasks. However, designing a deep architecture that can extract
practical information from raw data is still a challenge. Here, we introduce a
deep neural network that acquires interpretable physiological representations
by a hybrid structure of spatio-temporal encoding and recurrent attention
network blocks. Furthermore, a preprocessing step is applied to the raw data
using graph signal processing tools to perform graph smoothing in the spatial
domain. We demonstrate that our proposed architecture exceeds state-of-the-art
results for emotion classification on the publicly available DEAP dataset. To
explore the generality of the learned model, we also evaluate the performance
of our architecture towards transfer learning (TL) by transferring the model
parameters from a specific source to other target domains. Using DEAP as the
source dataset, we demonstrate the effectiveness of our model in performing
cross-modality TL and improving emotion classification accuracy on DREAMER and
the Emotional English Word (EEWD) datasets, which involve EEG-based emotion
classification tasks with different stimuli.
Shadi Sartipi, Mastaneh Torkamani-Azar, Mujdat Cetin
A Hybrid End-to-End Spatio-Temporal Attention Neural Network with Graph-Smooth Signals for EEG Emotion Recognition

###### Abstract

Recently, physiological data such as electroencephalography (EEG) signals have attracted significant attention in affective computing. In this context, the main goal is to design an automated model that can assess emotional states. Lately, deep neural networks have shown promising performance in emotion recognition tasks. However, designing a deep architecture that can extract practical information from raw data is still a challenge. Here, we introduce a deep neural network that acquires interpretable physiological representations by a hybrid structure of spatio-temporal encoding and recurrent attention network blocks. Furthermore, a preprocessing step is applied to the raw data using graph signal processing tools to perform graph smoothing in the spatial domain. We demonstrate that our proposed architecture exceeds state-of-the-art results for emotion classification on the publicly available DEAP dataset. To explore the generality of the learned model, we also evaluate the performance of our architecture towards transfer learning (TL) by transferring the model parameters from a specific source to other target domains. Using DEAP as the source dataset, we demonstrate the effectiveness of our model in performing cross-modality TL and improving emotion classification accuracy on DREAMER and the Emotional English Word (EEWD) datasets, which involve EEG-based emotion classification tasks with different stimuli.

 Emotion, Electroencephalography, Graph Filtering, Recurrent Attention Network, Spatio-Temporal Encoding, Transfer Learning.

## I Introduction

Affective computing is a popular field of study wherein researchers try to develop automatic recognition systems or devices that can interpret or respond to human emotional states. Brain-Computer Interfaces (BCI) link brain activity with external devices [1]. Recently, emotion recognition using physiological signals attracted a notable amount of attention [2]. Physiological signals acquired with wearable devices include electroencephalogram (EEG), electrocardiogram (ECG), electromyogram (EMG), blood pressure, galvanic skin response (GSR), eye-tracking metrics such as pupil dilation and gaze entropy, body temperature, and movement kinematics, to name a few. The neural activity of cortical regions can be recorded by multichannel EEG in a way that can preserve the spectral and rhythmic characteristics of brain signals [3]. Comparing EEG with other non-invasive recording methods shows that EEG has better temporal resolution and can acquire brain signals per millisecond. High temporal resolution and ease of use made EEG one of the most practical ways of handling tasks related to cognitive and affective reactions [3]. However, EEG suffers from low signal-to-noise ratio (SNR) and poor spatial resolution. Accordingly, it is challenging to use EEG signals for downstream tasks when compared to MRI and fNIRS [4, 5].

EEG signals are primarily analyzed in particular frequency bands, including theta (\(\theta:4\)-\(8\) Hz), alpha (\(\alpha:8\)-\(12\) Hz), beta (\(\beta:12\)-\(29\) Hz), and gamma (\(\gamma:\ >30\) Hz). Most of the early pieces of work on EEG-based emotion classification have generally relied on two main steps: extracting the informative features and defining a supervised machine learning approach. Wang _et al._ evaluated the performance of three different features, namely power spectral density (PSD), wavelet entropy, and nonlinear dynamical features with kernel support vector machine (SVM) [6]. Zheng _et al._[7] investigated the critical frequency bands and channels with differential entropy (DE), DE asymmetry, and PSD features. They explored the performance of different features by \(K\)-nearest neighbors (\(K\)-NN), SVM, and deep belief networks (DBN). In [8], the authors offered an approach to calculate spectral and temporal entropies by decomposing EEG data via Fourier-Bessel series expansion-based empirical wavelet transform. Then, \(K\)-NN and Shannon entropies were computed after multi-scaling operation in the spectral and temporal domains. [9] proposed a new rhythm sequencing approach to find the best rhythmic features from the sequence of multi-channel EEG data. Finally, [10] applied transfer learning to address the issue of distribution shift between the training and test data.

Nevertheless, covering all the manually extracted features both in time and frequency domains is complicated. Besides, the susceptibility of EEG signals to artifacts severely degrades the performance of classical machine learning approaches [11]. To address this issue, one can exploit end-to-end models that start with raw signals rather than extracted features. End-to-end deep learning (DL) approaches have been indicated to surpass classic approaches in various fields, including speech recognition [12], computer vision [13], and biomedical signal processing [14]. In contrast to shallow classifiers that re
quire feature engineering, deep neural networks automatically extract practical features from the given signals and learn the low- and high-level representations of the input data [15]. Several deep learning architectures and methodologies have been proposed for EEG-based BCIs; see e.g., [16, 17, 18, 19]. Schirrmeister _et al._[20] designed a deep convolutional neural network (CNN) based architecture with temporal and spatial convolutional (conv) filters followed by conv-pooling blocks to reduce the dimension. Zhao _et al._ investigated the fusion of three different modalities, namely EEG, raw eye-movement-images (EIG), and eye movement features (EYE) [21]. Feeding the fusion of different modalities to a dense co-attention symmetric network resulted in higher classification performance than the single modality. In [17], authors applied an attention technique to set different weight importance to EEG channels. Then, they extracted spatio-temporal features by applying CNN and a recurrent neural network (RNN). Multi-column convolutional neural network (MCNN) was introduced by authors of [22] for emotional states classification. They tested their work in a subject-independent manner by assuming five participants as the test data without performing cross-validation. A novel architecture coined as frame-level distilling neural network (FLDNet), that learns the distilled properties from the correlation of various frames, was introduced in [23]. They presented a triple-net structure to distill the learned features of each net consecutively. The deep forest was proposed in [24], where EEG data were converted to two-dimensional (2D) frame sequences by considering the spatial position of the EEG channels and then fed to the model. The proposed model was insensitive to hyper-parameter settings. EEG-based emotion recognition via DL is still in its early years. Therefore, there is yet to find a better deep structure. Furthermore, although DL models have been successful in EEG analysis, there are few studies that not only explore the performance of the learned representation but also consider their generalization ability on another dataset with a similar task [25].

The main goal of this study is to design a new deep architecture to enhance the performance of the current algorithms for EEG-based emotion recognition. It has been established in different areas that CNNs are effective in capturing the spatial representations, while RNNs capture the temporal dependencies well [26]. Recording EEG data from multiple electrodes over the scalp during a period of time forms both spatial and temporal structures. In order to analyze these structured time series successfully, the extracted information from spatial structures and temporal dynamics should be accounted for [27]. We propose the hybrid end-to-end spatio-temporal attention neural network (STANN) with smooth signals over graphs to consider these two aspects of the data within a unified architecture. As the central contribution of this work, STANN consists of two parallel blocks: the spatio-temporal encoding block and the recurrent attention network block. Considering the complex structure of brain signals and their time-varying character, we propose the idea of applying the graph Fourier transform (GFT) and low pass graph filtering [28] in a pre-processing step. GFT is considered as a solution for overcoming the low SNR of EEG signals [29]. Accordingly, our proposed smooth signal spatio-temporal attention neural network (SS-STANN) simultaneously learns both spatial information and discriminative time dependencies. To evaluate the performance, we apply the introduced method on the publicly available EEG dataset named DEAP that contains discrete ratings for valence, arousal, and dominance in response to audio-visual stimuli [30]. In our comprehensive experimental analysis, we demonstrate the superiority of STANN when using either raw EEG signals or smoothed graph signals as an input.

Deep learning models commonly require a large number of parameters to be trained compared to traditional machine learning methods. Thus, DL models need a significant amount of data [31]. One of the challenges related to EEG tasks and DL is insufficient labeled data for similar tasks. A number of transfer-based approaches have been proposed to address this issue that leverage a pre-existing large enough dataset known as the source dataset. Yet, there would be inconsistency across target and source domains which necessitates fine-tuning [32] the network for the target data. We demonstrate the applicability of the information learned through our proposed hybrid architecture in similar emotion classification tasks by applying transfer learning and fine-tuning in order to investigate the generality of our proposed model. We consider \(5\) layouts for tuning the pre-existing network with confined EEG data. As the target data, we investigate the EEG signals of publicly available DREAMER dataset [33] and an Emotional English Word dataset (EEWD) recorded at Sabanci University with different stimuli types that can enlighten the capability of proposed model in cross-modal emotion learning [34]. The major contributions of our work are summarized as follows:

* A novel deep architecture that considers spatial and temporal information of time-series data is proposed for EEG emotion classification. The proposed hybrid network encodes the spatio-temporal and attentive temporal information in parallel.
* This paper considers the relation among neighbor EEG electrodes to use their spatial-spectral characteristics. Low pass graph filtering is applied to enforce graph smoothness in the spatial domain.
* This paper shows the possibility of transferring the learned model parameters for cross-subject and cross-dataset (similar EEG tasks with different stimuli) scenarios. The results are promising in both scenarios. Improved results indicate the cross-modality capability of the proposed model since the learned representations from EEG signals, elicited in response to video clips, can be used to improve classification accuracy even for datasets of emotional written words.

A preliminary version of this work was presented in [27]. While [27] contained the initial idea of the STANN framework, this paper extends that preliminary work in several major ways: (1) the approach we present here involves the use of graph signal processing (GSP) tools to perform graph smoothness in the spatial domain, (2) we propose and demonstrate the use of transfer learning within our proposed framework, (3) by visualizing activations of certain layers in our network,
we examine how our proposed approach encodes spatial information in the brain, (4) we perform a more extensive comparison of our proposed method to the state-of-the-art, and (5) we extend our experimental analysis to three datasets to demonstrate the effectiveness of the proposed method.

The rest of this paper is structured as follows. Section II introduces the proposed SS-STANN method. Section III describes the datasets and reports the experimental results. Section V concludes the paper.

## II Method

### _Overview_

Figure 1 presents an overview of the proposed pipeline. The EEG data are first graph-smoothed via graph filters, and then sliced by non-overlapping sliding windows to obtain data samples. Next, the data are fed to the proposed deep STANN architecture to learn a discriminative representation for the classification of emotional states.

### _Preprocessing using Graph Filtering_

EEG data are recorded during a total time period \(T\) from \(n\) different electrodes mounted over the scalp, which results in a two-dimensional (2D) signal, \(\mathbf{X}\in\mathbb{R}^{n\times T}\). Recent works commonly apply hand-crafted features or raw EEG data as the input of deep neural networks. Exploring structural and functional connectivity of the brain [35] and tracking the relative spatial positions of EEG nodes could be in use of decoding responses elicited from sensory stimuli [36]. In order to exploit GSP tools, we need to define an underlying graph. Thus, we calculate the pairwise Euclidean distances of EEG electrodes and build the graph accordingly. In this way, we solely require the Cartesian coordinates of electrodes while the classical common spatial pattern (CSP) filtering depends on individual subjects or tasks. Let us consider an undirected, weighted graph \(\mathcal{G}(\mathcal{V},\mathcal{E},\mathbf{A})\), where \(\mathcal{V}=\{1,2,...,n\}\) is the set of nodes or EEG channels, \(\mathcal{E}\subseteq\mathcal{V}\times\mathcal{V}\) is the set of edges or spatial connections, and \(\mathbf{A}\in\mathbb{R}^{n\times n}\) is the adjacency matrix. The edge weights \(\mathbf{A}_{ij}\) are inversely proportional to the pairwise Euclidean distances between node \(i\) and \(j\). Subsequently, one can compute the distance \(d_{ij}\) as follows:

\[\mathbf{A}_{ij}=d_{ij}^{-1},\ \mathbf{A}_{ii}=0,\ \ \text{for}\ i,j=1,2,...,n. \tag{1}\]

For each electrode, _K_-NN is considered to construct the adjacency matrix while keeping it symmetric to represent the brain topology [37]. To avoid a densely-connected graph, we set \(K\) to \(2\) and \(4\). In the literature, a \(2\)-NN topology was motivated by separating the graph into fronto-temporal and parieto-occipital networks [38]. The \(4\)-NN graph brings engagement with central areas as well. Figure 2 shows the final adjacency matrices for these \(K\) values and their corresponding scalp topologies for \(32\) nodes with the \(10\)-\(20\) electrode placement setup.

Furthermore, one can extract informative features using the spectral representation of spatial signals. Using GFT one can analyze the spatial frequency of the signals defined over the graph. The combinatorial graph Laplacian \(\mathbf{L}=\mathbf{D}-\mathbf{A}\) is needed for the calculation of GFT in which

\[\mathbf{D}_{ii}=\sum_{k}\mathbf{A}_{ik}\]

Fig. 1: Overview of the proposed SS-STANN architecture. The CNN blocks (blue) contain adopt the ReLU activation function and batch normalization. Pooling blocks (orange) are followed by a dropout layer. IN1 and IN2 correspond to inputs for STE and RAN blocks respectively. (STE: spatio-temporal encoding, RAN: recurrent attention network).

Fig. 2: The adjacency matrix (**left**) illustration, and its corresponding graph representation (**right**) from a sample \(10\)-\(20\) electrode placement setup.
is a diagonal matrix of nodal degrees [28]. Given graph signal \(\mathbf{X}\) one can compute GFT with respect to \(\mathbf{L}\) as follows:

\[\tilde{\mathbf{X}}=\mathbf{V^{T}X} \tag{2}\]

where \(\mathbf{V}\) is the orthonormal \(n\times n\) matrix of eigenvectors of the matrix \(\mathbf{L}\).

Since the electrodes installed in adjacent locations detect electrical activities of common sources [29], we apply smoothing via lowpass graph filtering with respect to the defined graph. This will ensure the similarity of the behavior among neighbor electrodes. Low frequencies in the graph correspond to small eigenvalues. Considering \(\mathbf{\tilde{h}}=[\tilde{h}_{1},\tilde{h}_{2},...,\tilde{h}_{n}]\) the ideal lowpass filter with bandwidth \(w\in\{1,2,...,n\}\) where \(\tilde{h}_{i}=0\) if \(i>w\), the GFT coefficients corresponding to the low frequencies with respect to \(\mathcal{G}\) are given by:

\[\tilde{\mathbf{X}}_{low}=\mathbf{\tilde{h}}\mathbf{\tilde{X}} \tag{3}\]

where \(\tilde{h}_{i}\) is equal to one for \(w=[1,\frac{n}{2}]\) and zero otherwise. While we choose the filter bandwidth as \(\frac{n}{2}\), users can choose a different number depending on the level of smoothing they want to apply. A smaller bandwidth would lead to more smoothing.

Next, the inverse GFT (iGFT), \(\mathbf{X}_{smooth}=\mathbf{V\tilde{X}}_{low}\), is applied to obtain the smoothed data in the spatial domain [28].

### _The Proposed Hybrid SS-STANN Network_

After the preprocessing and smoothing steps, a sliding window with length \(k\) is applied to obtain the EEG slices \(i\), i.e., \(\mathbf{Z}_{i}\in\mathbb{R}^{n\times k}\). Based on the overview presented in Figure 1, the proposed network is organized into two main blocks: the spatio-temporal encoding (STE) and the recurrent attention network (RAN) blocks.

The STE is designed to extract the spatio-temporal information from temporal slices, \(\mathbf{Z}_{i}\). This block consists multiple columns of \(2\)D CNNs. The STE follows the structure proposed in [39, 40]. This architecture contains several independently acting columns that function as a deep network. All columns receive the same input data and their weights are initialized randomly. The output of this model is equal to the average of all the columns' outputs. In this work, each column contains a series of \(2\)D CNN, batch normalization, and average-pooling followed by dropout layers with different kernel sizes and a number of filters. Presuming STE has M columns, the feature map of the \(m\_th\) column would be \(\mathbf{f}^{m}\). \(M\) feature maps,\(\{\mathbf{f}^{m}\}_{m=1}^{m=M}\), are merged to get the final feature map \(\mathbf{f}\). The final feature map passes through the \(1\times 1\) conv layer. This structure enables using different kernel sizes per column to detect the informative features at very different temporal and spatial scales across nearby EEG channels. Details of the implementation will be described in Section III.

The RAN block is composed of two bidirectional LSTM layers and an attention mechanism. LSTM networks are recurrent neural networks that capture the dependencies within time steps from sequential data. In LSTMs, the temporal dynamic behavior is captured by feedback connections [41]. Since RNNs are trained by back-propagation through time, a RNN cell is replaced by a LSTM cell to avoid the vanishing gradient problem [41].

Let \(x_{t}\) and \(h_{t}\) denote the input data and the hidden state at time \(t\), respectively. LSTM performance is controlled by three gates: (1) the forget gate \(f_{t}\) selects the information to keep or forget, (2) the input gate \(i_{t}\) controls the flow of the input, and (3) the output gate \(o_{t}\) that calculates the output of the given updated cell (Figure 3). Formulas governing the operations in the LSTM cell are as follows [41]:

\[f_{t}=\sigma(W_{f}.[h_{t-1},x_{t}]+b_{f}) \tag{4}\]

\[i_{t}=\sigma(W_{i}.[h_{t-1},x_{t}]+b_{i}) \tag{5}\]

\[C_{t}=f_{t}\circ C_{t-1}+i_{t}\circ\text{tanh}(W_{C}.[h_{t-1},x_{t}]+b_{C}) \tag{6}\]

\[o_{t}=\sigma(W_{o}.[h_{t-1},x_{t}]+b_{o}) \tag{7}\]

\[h_{t}=o_{t}\circ\text{tanh}(C_{t}) \tag{8}\]

where \(W_{(.)}\), and \(b_{(.)}\) are weights and biases, respectively. \(C_{t}\) is the cell state at time \(t\). The operator \(\circ\) denotes the element-wise vector multiplication. A bidirectional LSTM (BiLSTM) consists of two LSTM blocks that allow the layer to receive information from the sequential input data simultaneously in forward and backward directions. The output of each layer is the concatenation of outputs of two LSTM blocks, i.e, \(h_{i}=[\overrightarrow{h_{f}},\overrightarrow{h_{b}}]\) where \(\overrightarrow{h_{f}}\) and \(\overrightarrow{h_{b}}\) correspond to the forward and backward hidden states, respectively [41].

In several sequence-based applications such as semantics analysis, natural language processing, and medical imaging, certain time steps of the input data might contain the most discriminative information, and attention mechanism addresses this issue by focusing on specific time steps [42]. In this mechanism, the most discriminative task-related features are calculated by multiplication of outputs of hidden states by trainable weights. The output of the attention layer, \(v\), is computed as bellow:

\[v=\sum_{i}\alpha_{i}h_{i} \tag{9}\]

\[\alpha_{i}=\frac{\exp(Wh_{i}+b)}{\sum_{j}\exp(Wh_{j}+b)} \tag{10}\]

where \(h_{i}\) denotes the output of the \(i\_{t}\)_th LSTM layer, and \(W\) and \(b\) are trainable parameters.

Fig. 3: LSTM cell block.
### _Training, Optimization, and Transfer Learning_

In order to examine the performance of the proposed network, the features of STE and RAN block are fused and fed to the dense layer. Next, the encoded representation is fed to the final softmax classifier. The cross-entropy loss, \(\mathcal{L}\), is calculated as follows:

\[\mathcal{L}=\sum_{i}Y_{i}log\hat{Y}_{i}, \tag{11}\]

where \(Y_{i}\) is the ground truth emotion label for each data sample and \(\hat{Y}_{i}\) is the predicted label. Finally, the weights and the biases are trained with batch gradient descent.

The trained model is used to perform the supervised emotion classification task. Additionally, in the case of medical imaging in general and EEG-based diagnosis in particular, there exist legitimate interests and needs for using such a training model to solve a similar problem with insufficient training data [34, 43, 44]. To this end, the model has to be trained on the whole data to get the transferable model parameters. The target data would never be seen in the training phase.

To investigate the possibility of using this trained network in similar EEG-based emotion recognition tasks, we propose and implement a transfer learning (TL) approach. The goal of TL is to test our model ability in real-life conditions where the available amount of labeled data is not sufficient. TL helps to improve the learning capability of the target data by leveraging the knowledge of the source domain. In this study, we investigate transferring the learned model parameters assuming that individual models across different datasets with similar tasks should share some parameters. Firstly, the model is fully trained using sufficient labeled data (source dataset). Second, we peruse different schemes to tune the pre-trained network via the target dataset. The source and target datasets involve EEG-based emotion recognition experiments with different stimuli.

Figure 4 demonstrates five different schemes that we consider in the calibration (fine-tuning) session. The TL schemes in our STE blocks are inspired by observations in CNN-based TL frameworks in computer vision where usually the later network layers are retrained, as the earlier layers are responsible for generic features [45]. In our work, we consider different retrainable cells in both STE and RAN blocks. In particular, going from scheme (a) to scheme (e), we change the status of exactly one layer either to retrainable or non-retrainable (frozen) at each step. In each scheme, blocks marked with a cross are left unchanged during fine-tuning of the network. The number of retrainable parameters in scheme (a) to scheme (e) is equal to \(239100\), \(311420\), \(280295\), \(207975\), and \(53735\), respectively.

Due to the variations in inter-dataset samples, we use a small part of the new data (target data), \(\mathbf{N}\), to calibrate and fine-tune our pre-trained model. Since the amount of calibration data is limited, we scale down the initial learning rate to avoid clobbering in initialization [46]. Scaling down the initial learning rate \(\eta\) with the scale \(\alpha\) can be defined as:

\[\Phi^{i+1}=(1-\alpha)\Phi^{i}+\alpha(\Phi^{i}-\eta\frac{\partial\mathcal{L}}{ \partial\Phi}) \tag{12}\]

where \(\Phi^{i}\) is the trainable parameters at the \(i\_th\) iteration and \(\mathcal{L}\) is the cross-entropy loss function. Here, \(\alpha\) is set to \(0.1\).

## III Dataset and Implementation

### _Datasets_

#### Iii-A1 DEAP Dataset

The DEAP dataset was recorded from \(32\) individuals each having rated \(40\) music videos for \(60\) s [30]. After each video, the participants performed a self-assessment to show their emotional states by rating the level of valence, arousal, dominance, and liking from \(1\) to \(9\). The physiological recordings consist of \(32\) channels of EEG signals and \(8\) channels of peripheral physiological data. Here, we just consider the EEG recordings of each trial. The preprocessing scheme is as follows: 1) down-sampling the data to \(128\) Hz, 2) averaging to the common reference, 3) removing electrooculography (EOG) artifacts, and 4) applying a bandpass filter with the frequency range of \([4,45]\) Hz. Accordingly, each recording contains \(3\) s pre-trial relaxing phase followed by \(60\) s trial data.

#### Iii-A2 Dreamer Dataset

The DREAMER dataset was recorded with a \(14\)-channel, Emotiv EPOC wireless EEG headset [33]. The data were recorded with a \(128\) Hz sampling frequency from \(23\) participants while watching \(18\) film clips. Each film clip lasted \(65\) to \(393\) s to elicit the emotional states. Before data collection, participants watched a neutral film clip to neutralize the emotional state. Data collected while watching this neutral film served as the baseline. Participants were asked to assess their emotional states by rating valence, arousal, and dominance levels in each video from \(1\) to \(5\). To have consistency with the DEAP dataset, each recording contains \(3\) s pre-trial relaxing phase followed by \(60\) s trial data and is band-pass filtered from \(4.0\) to \(45.0\) Hz.

#### Iii-A3 Emotional English Word Dataset (EEWD)

Data collection was performed via \(64\) Ag/AgCl active electrodes located over the scalp based on the \(10\)-\(10\) International Electrode Placement System while participants were rating emotional words. Participants provided signed informed consents in accordance with the Sabanci University Research Ethics Council guidelines. EEG data were recorded using BioSemi ActiveTwo systems (Biosemi Inc., Amsterdam, the Netherlands) in a dimly lit EEG room within a Faraday cage. A dataset of highly-arousing English words was formed such that \(65\) negative words (arousal\(>6\) and valence\(<3\)) and \(63\) positive words (arousal\(>6\) and valence\(>7\)) were selected from the Affective Norms for English Words (ANEW) dataset [47]. Details of compiling this small dataset of Original English List (OEL) is presented in more details in [48]. Thirty native Turkish speakers participated in the experiment where English served as their secondary language. The experiment consisted of four blocks and each block contained \(32\) randomly selected words. Each word was presented for \(1\) s and then the participants were asked to rate the valence and arousal in the range of \(1\) to \(9\) using a set of pictorial self-assessment manikins (SAM) [48]. The data of two participants were discarded due to technical problems. The recorded signals were down-sampled from \(2048\) Hz to \(128\) Hz, EOG artifacts were removed via independent component analysis (ICA), and a bandpass filter from \(4.0\) to
\(45.0\) Hz was applied. All preprocessing steps were conducted using the EEGLAB toolbox [49].

### _Implementation of the Proposed Network_

The proposed network consists of two parts that operate in parallel [27]. The input of STE, IN1, has the dimensions of n\(\times\)k\(\times 1\) where \(k\) is set to \(128\) corresponding to the \(1\) s slicing window length. In order to select the STE parameters, we perform the grid search on the subset of the kernel sizes, \([9,7,5,3]\), and the parameters corresponding to the best performance on the training data samples selected. Table I provides the details of the STE structure. Each average-pooling layer is followed by a dropout layer. The dropout probability rates for each dropout layer are set to \(0.5\) and \(0.4\), respectively. In order to prevent edge information loss, the same zero-padding technique is used in each convolution (conv) operation. Here, we adopt rectified linear unit (ReLU) which has been used in many related CNN-based applications. After concatenating the outputs of all columns, a \(1\times 1\) conv filter is applied to compute the spatial feature maps.

The input of the RAN block, IN2, has the size of \(k\times n\). RAN consists of two BiLSTM layers with the same hidden layer size. The hidden layer and time steps are set to \(80\) and \(128\), respectively. We choose hyperbolic tangent (tanh) as the activation function for all BiLSTM cells. Each pair of forward and backward LSTM cells is followed by a dropout layer with probability rates of \(0.3\) and \(0.2\), respectively. BiLSTM outputs are then used as the input of the attention mechanism.

The spatial and temporal representations extracted from STE and RAN blocks are flattened and concatenated. Next, we apply a fully connected layer where the number of hidden units is \(128\). In the end, we exploit the SoftMax operation to obtain classification labels.

## IV Experiments

### _Results and Analysis on the DEAP Dataset_

In this section, we investigate the performance of the proposed DL architecture on the DEAP dataset. The DEAP dataset involves subjects watching long, continuous videos, hence trials can be defined arbitrarily as smaller segments from this dataset. While the DEAP dataset defines \(60\) s EEG intervals as trials, various methods have used different intervals as samples for training and testing. In this work, the trial data are baseline corrected and a non-overlapping sliding window with a length of \(1\) s is applied to slice the \(60\) s trials. The final size of each data sample equals \(32\times 128\) where \(32\) is the number of the EEG nodes and \(128\) is the number of time samples. Thus, the data for each participant consists of \(40\times 60=2400\) data samples. While our experiments and those of other methods we compare against have allowed non-overlapping \(1\) s data samples from any \(60\) s trial to be assigned to training or test sets randomly, a different approach could be to assign all \(1\) s samples from a particular trial to the training or test set. In order to explore different frequency bandwidths, each data sample is filtered into five subbands: theta, alpha, beta, gamma, and wide-band. In order to validate the performance of the proposed method, we consider three binary classification problems, i.e., high-versus-low valence, high-versus-low arousal, and high-versus-low dominance. Considering a threshold of \(5\), we quantize the \(9\)-level ratings of valence, arousal, and dominance into two levels to obtain a binary problem. The model is trained using subject-dependent \(10\)-fold cross-validation (CV). The validation process is repeated

Fig. 4: The proposed transfer learning schemes. The blocks marked with a black cross are the ones that remain frozen during fine tuning.
times and the average classification performance is reported. Adam optimizer [50] is used to minimize the cross-entropy between the predicted labels and true labels. The epochs and batch-size are picked as \(50\) and \(300\), respectively. Grid search is applied to select the hyper-parameters that maximize the average classification accuracy based on training data.

#### Iv-A1 Ablation Study

To analyze the impacts of using the station-temporal encoding, recurrent network, and attention mechanism, we have performed an ablation study by considering each block of the proposed STANN, namely STE and RAN as baseline models and evaluating their performance separately using the aforementioned parameters. In order to assess the effect of graph smoothing, we calculate the graph-smoothed signals and assess the network performance in frequency subbands and present the performance results of the proposed method with two different input modalities, i.e., raw EEG data and smooth EEG data. Since the GFT computing and smoothness are not dependent on a specific task or subject, this would not interfere with the automated operation of our model. Details of the ablation experiments are provided in Table II.

Tables III, IV, and V show the obtained average accuracies and standard deviations (SD) for binary valence, binary arousal, and binary dominance classification for the baseline models and the proposed method based on data from different frequency subbands with different inputs. To address cases involving unbalanced data, we also report F1-scores for the proposed model in all three classification problems. SS2-(.) and SS4-(.) correspond to graph-smoothed signals with \(2\)-NN and \(4\)-NN adjacency matrices, respectively.

Results of DEAP dataset classification in Tables III to V demonstrate that graph smoothing leads to better performance than the use of raw EEG input data. Moreover, in the majority of classification scenarios, the best performance is driven by wide-band data and SS4-STANN. The average classification accuracies for binary valence, arousal, and dominance classification problems based on SS4-STANN are \(95.6\%\), \(97.0\%\), and \(96.8\%\), respectively. These results indicate that our proposed method exceeds the baseline models and that graph smoothing enhances the overall classification performance. Moreover, our findings show that beta and wide-band frequency subbands outperform other spectral features in binary classifications problems of high-versus-low valence, arousal, and dominance dimensions which is in line with the role of different frequency subbands in characterizing affective states [7, 51].

#### Iv-A2 Comparison with the-state-of-the-art

We compare the performance of our proposed SS4-SSTANN method for the classification of valence and arousal from wide-band EEG of the DEAP dataset with a number of state-of-the-art solutions namely DCCA [52], ECLGCNN [53], DGCNN [54], CVCNN [55], CRAM [56], ACRNN [17], S-EEGNet [19], and CascCNN-LSTM [26]. In DCCA, firstly, DE features are computed in four different frequency bands and then the network computes the representations of two modalities by passing them through multiple stacked layers of nonlinear transformations.ECLGGCNN uses the infusion of graph convolutional neural networks with LSTMs while DE of the windowed EEG data are considered as the input. DGCNN1 computes DE features and applies a \(2400\) feature vector as the input of the graph CNN. CVCNN utilizes raw EEG and normalized EEG data in combination with PSD features. CRAM extracts spatio
temporal information along with attentive temporal dynamics in a cascaded format. The model uses a CNN layer with a fixed kernel and filter size and the temporal information is extracted from the extracted spatial features which makes the temporal information dependent on the spatial features. ACRNN uses an attention technique to get different weights for each EEG channel followed by a CNN to extract spatial features. S-EEGNet applies the Hilbert-Huang transform to preprocess the EEG data before feeding the data to a separable CNN. Casc-CNN-LSTM applies hybrid convolutional recurrent neural networks by using transformed 1D EEG vector sequences into 2D mesh-like matrices. Table VI presents a comparison of the proposed SS4-STANN on wide-band data with the above-mentioned methods from recent literature and demonstrates the superiority of our proposed approach. The reported results are all subject-dependent with a \(10\)-fold CV except [19] where the authors performed a \(4\)-fold CV.

#### Iv-A3 How does the STE block encode spatial information?

To investigate the learning process of the STE block, activations of the last conv layer are visualized to demonstrate wide-band EEG feature maps learned during the valence and arousal recognition tasks. The outputs of the conv layers are averaged along the time dimension to obtain the key spatial features for each kernel separately. This operation results in a \(32\)-dimensional vector for each kernel. The feature vector is then normalized in the range of \(0\) to \(1\).

Figures 5 and 6 present the topographic scalp plots for the first kernels of each column for valence and arousal, respectively. The representations are averaged over the data samples and subjects. For high-vs-low valence and arousal problems, most of the activities are over frontal, temporal, and central lobes which is consistent with the literature regarding the processing of human emotions [57]. The valence difference plots for all columns in Figure 5 show the role of temporal and parietal lobes in positive and negative emotions [58, 59]. The difference plot for arousal classification in column \(2\) of Figure 6 shows higher activity in the left cortex and frontal lobe similar to previous observations in the literature [60]. Moreover, the plots show that arousal processing has a more wide scattered pattern over the brain than valence [25].

### _Evaluating Transfer Learning Performance_

To show that the learned representations based on SS-STANN have the generality to be applied in similar tasks that have limited labeled data, we perform TL in two different schemes, namely cross-subject TL and cross-dataset TL. In order to make a fair comparison among the different amounts of calibration data, we set 10% of the target data samples as a test set, and the calibration data is selected among the rest 90% of the data.

#### Iv-B1 Cross-Subject TL

To perform cross-subject TL, one subject of the DEAP dataset is considered the target subject and the rest of the subjects are source subjects. Given its superior performance in the supervised classification task, we use SS4-STANN for the TL experiments. First, the network is trained for \(100\) epochs on the source subjects' data samples to get the pre-trained network. Second, we use \(\mathbf{N}\) data samples of the target subject's data to fine-tune the pre-trained model. During the fine-tuning process, the epoch values are set to

Fig. 5: Topographic feature maps for the weight distribution of the first kernel of the last convolutional block of each column in STE during valence classification.The feature values are averaged across the subjects and normalized to the range of \(0\) to \(1\). (Col: Column)

Fig. 6: Topographic feature maps for the weight distribution of the first kernel of the last convolutional block of each column in STE during arousal classification. The feature values are averaged across the subjects and normalized to the range of \(0\) to \(1\). (Col: Column)
\(10\) when \(\mathbf{N}\) equals \(1\) trial per class and \(20\) when \(\mathbf{N}\) equals \(10\%\) and \(20\%\) of data samples. Table VII presents the average TL results on different TL schemes for binary valence and arousal classification. As presented, increasing the number of the calibration data sample improves the classification performance. To validate the TL effect on the classification performance, we present the performance of the proposed model without TL with \(\mathbf{N}=10\%\) and \(20\%\) in Table VIII. Comparing the results of Tables VII and VIII, it is clear that TL helps to increase performance across different subjects.

#### Iv-B2 Cross-Dataset TL

To apply the cross-dataset TL, we trained our proposed model on the whole DEAP dataset and tuned the network on new EEG emotion recognition datasets collected with different stimuli. To this end, we choose the publicly available DREAMER dataset and EEWD. To have consistency between datasets' characteristics, namely EEG electrodes, frequency bands of interest, and the sliding window for segmentation, we choose the following settings. Fourteen common electrodes among all datasets are selected, namely AF3, F7, F3, FC5, T7, P7, O1, O2, P8, T8, FC6, F4, F8, and AF4. The same data slicing process is also applied to the DREAMER dataset. Since the trial length in DREAMER varies from trial to trial, we select the last \(60\) s of each trial and segment it into \(1\) s data samples. The final number of data samples corresponding to DREAMER is equal to \(18\times 60=1080\) per participant. The length of each trial sample in EEWD is \(1\) s which leaves us with \(128\) time steps. For each value of \(\mathbf{N}\), the best performing TL scheme is indicated in bold.

TL process contains two main steps. First, the proposed network is trained on the whole DEAP dataset. Given its superior performance in the supervised classification task, we use SS4-STANN for the transfer learning experiments. \(10\%\) of the wide-band EEG samples of each subject in the DEAP dataset is considered for validation and the rest of samples are set aside for training. The network is trained for \(100\) epochs and the model parameters corresponding to the least validation loss are considered as the final pre-trained network. Second, we use \(\mathbf{N}\) samples of the target data for calibration to fine-tune the pre-trained model.

In order to have a binary classification problem for the DREAMER dataset, the valence and arousal ratings are divided into two levels using a threshold of \(3\). Table X presents the TL results related to the DREAMER dataset for different schemes and various amounts of calibration data. We also report F\(1\)-score values to avoid the possibility of bias to one class. To avoid overfitting in the fine tuning process for \(\mathbf{N}\) equals \(1\) trial per class, the number of epochs is set to \(1\), and the epoch values is set \(20\) when \(\mathbf{N}\) equals \(10\%,\ 20\%\), and \(90\%\) of data samples. In the latter case, early stopping with a patience parameter of \(10\) is set for the tuning process.

As expected, an increase in the amount of calibration data improves the classification performance. To show the effectiveness of transferring pre-trained model parameters, the performance related to \(\mathbf{N}=10\%,20\%,\text{and}\ 90\%\) of data samples without applying TL is considered as the baseline which is shown in Table IX. Observing the results in Tables IX and X, it is clear that tuning the pre-trained network increases the classification performance for binary valence and arousal problems. Without using TL, the valence classification accuracy for \(\mathbf{N}=10\%,20\%,\text{and}\ 90\%\) of data samples are \(65.8\%\), \(67.6\%\), and \(70.8\%\), respectively. However, TL increases the performance for the same \(\mathbf{N}\) values to \(72.0\%\), \(74.4\%\), and \(83.0\%\). Similar performance improvement is observed for the arousal classification problem. Considering Tables IX and X, for different N values, the results corresponding for without TL and with TL increase from \(73.5\%\), \(75.6\%\), and \(77.6\%\) to \(78.2\%\), \(81.0\%\), and \(87.2\%\).

To evaluate transfer learning of models trained with EEG in response to video clips to EEG signals obtained in response to written words, we consider the EEWD and perform a binary valence classification scenario since all the words in that experiment are selected from the high arousal group. We consider trials corresponding to rating values lower or equal to \(3\) as negative valence and trials correspond to rating values higher or equal to \(7\) as positive valence. During the tuning process, the number of epochs and early stopping is set as
described in the DREAMER dataset fine-tuning phase. The output prediction of the network is performed on each trial separately. Table XI displays the results on the EEWD dataset for different values of \(\mathbf{N}\). By considering \(\mathbf{N}=1\) trial per class and \(\mathbf{N}=10\%,\text{and}\ 20\%\) of data samples, the performance reaches up to \(68.2\%\), \(68.9\%\), and \(73.5\%\) which is related to schemes a, c, and b, respectively. Due to the limited amount of data samples we do not present the results similar to Table IX for this dataset since the model overfits in early epochs.

#### Iv-D3 Verification of TL

To establish that the proposed structure works properly and TL helps to separate the components related to each class, we randomly pick the EEG samples of one of the subjects in DREAMER dataset to visualize them with t-SNE [61] (Figure 7). Figure 7(a) shows the scatter plot of samples in the last dense layer before the classification softmax layer without TL and fine-tuning. Figure 7(b) presents the results after TL and fine-tuning. As can be seen, before fine-tuning the process, the representations corresponding to different classes are more mixed up and TL helps make them more separable.

## V Conclusion

In this study, we proposed a novel deep learning architecture for subject-dependent EEG-based emotion classification tasks. The proposed SS-STANN involves a hybrid structure with parallel STE and RAN blocks and an attention mechanism. SS-STANN captures the spatial and temporal information inherent in multi-channel EEG data while enforcing graph smoothness in the spatial domain. We demonstrated that this work performs better than other state-of-the-art solutions, with classification accuracies of over 95.0\(\%\) for valence, arousal, and dominance for the DEAP dataset. Moreover, the critical frequency bands and regions are explored to validate the performance results. We also showed that the representations extracted from one EEG experiment could be used in other EEG emotion recognition tasks with similar and different stimulus modalities, highlighting the cross-modal transferability potential of the trained model and learned representations. In the future, we will investigate the effect of using different modalities along with EEG in a similar problem. Also, we will concentrate on conducting real-time experiments based on the proposed framework. Moreover, future work may involve adopting the spatio-temporal feature learning ideas presented here to problems involving other modalities of physiological data such as functional MRI (fMRI) or magnetoencephalography (MEG).
