## 3 Materials and Methods
### EEG Image Processing
#### 3.3.2 Feature Extraction  
To extract features, we used an autoencoder with the architecture presented in Table 1. This is a neural network architecture that consists of two segments--an encoder and a decoder. The encoder compresses the data into a compact representation, and the decoder reconstructs it. The network is trained as a single whole, while the same data, that are feature vectors, are supplied to the input and output. Autoencoders are often used to extract features [27]. In total, 12 autoencoder architectures were tested, differing in the number of layers, convolution kernels and the size of the kernel of the first convolutional layer, the number of fully connected layers and neurons in each of them.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Layer Type** & **Layer Parameters** \\ \hline \multicolumn{2}{c}{Encoder} \\ \hline Input & dimension is \(32\times 256\) \\ \hline ConvL (2D) & number of filters—2, convolution window—3.3, convolution step—2.2, activation function—ReLU \\ \hline ConvL (2D) & number of filters—4, convolution window—3.3, convolution step—2.2, activation function—ReLU \\ \hline \multicolumn{2}{c}{Batch normalization} \\ \hline ConvL (2D) & number of filters—8, convolution window—3.3, convolution step—2.2, activation function—ReLU \\ \hline ConvL (2D) & number of filters—16, convolution window—3.3, convolution step—2.2, activation function—ReLU \\ \hline \multicolumn{2}{c}{Batch normalization} \\ \hline ConvL (2D) & number of filters—32, convolution window—3.3, convolution step—2.2, activation function—ReLU \\ \hline ConvL (1D) & number of filters—64, convolution window—3.3, convolution step—2.2, activation function—ReLU \\ \hline \multicolumn{2}{c}{Batch normalization} \\ \hline ConvL (1D) & number of filters—128, convolution window—1.3, convolution step—1.2, activation function—ReLU \\ \hline ConvL (1D) & number of filters—256, convolution window—1.3, convolution step—1.2, activation function—ReLU \\ \hline \multicolumn{2}{c}{Batch normalization} \\ \hline Fully connected layer & number of neurons—256, activation function –linear \\ \hline \multicolumn{2}{c}{Decoder} \\ \hline Input & dimension is 256 \\ \hline TConvL (2D) & number of filters—128, window—3.3, step—2.2, activation function—ReLU \\ \hline TConvL (2D) & number of filters—64, window—3.3, step—2.2, activation function—ReLU \\ \hline \multicolumn{2}{c}{Batch normalization} \\ \hline TConvL (2D) & number of filters—32, window—3.3, step—2.2, activation function—ReLU \\ \hline TConvL (2D) & number of filters—2, activation function—ReLU \\ \hline TConvL (2D) & number of filters—16, window—3.3, step—2.2, activation function—ReLU \\ \hline TConvL (1D) & number of filters—4, window — 1.3, step—1.2, activation function—ReLU \\ \hline \multicolumn{2}{c}{Batch normalization} \\ \hline TConvL (1D) & number of filters—2, window—1.3, step—1.2, activation function—ReLU \\ \hline TConvL (1D) & number of filters—1, window—1.3, step—1.2, activation function—ReLU \\ \hline \hline \end{tabular}
\end{table}
Table 1: Architecture of the autoencoder for feature extraction.  
Each autoencoder received one spectrogram as input and 256 features as output. The autoencoders were trained using data from 30 subjects. A total of 2 autoencoders with identical architecture were created: the first was trained using spectrograms of the original signal and the second was trained using spectrograms of the autocorrelation function. The training sample size was over 36,000 (30 subjects, at least 50 examples, 6 channels, and 4 types of window functions) images for each autoencoder. The number of epochs was 200; the Adam optimizer was used.  
After training, the decoder was removed and only the encoder was used. To extract features, 6 spectrograms were extracted from the original signal and the autocorrelation function (based only on the Hamming window, since it is noise-reducing). Spectrograms were sent to the corresponding encoders (Figure 6), which extracted features. Thus, each EEG image was transformed into a vector of 3072 features (Figure 7).