## 5 Explanation of the Functioning of the Artificial Neural Network: Classification Part
### Neural Network for Recognizing Nervous Tics  
It was decided to choose a network consisting of 4 hidden layers. The first layer consisted of a hyperbolic tangent function \((tansig(. ))\) with 20 neurons. The second layer had a log-sigmoid activation function \((logsig(. ))\) consisting of 15 neurons. The third layer, in turn, was the radial base function \((radbas(.))\). For this function, only 10 neurons were used. In the last hidden layer, the hyperbolic tangent function was again used, but this time with 5 neurons. The last part of the neural network configured in this way must consist of a single layer containing 3 neurons with a linear activation function. It is adequate to the number of outputs of the neural network. In such a configuration, it is supposed to sum up the nonlinear activation functions of the neurons. The output signal of the designed neural network classifying the signal was consistent with the formulas in Equation (8). It describes the neural network layers (**W**), activation functions (\(f\)) and biases (\(b\)). The network output is \(y\). [4, 48]:  
\[ \begin{split} y=\textbf{W}^{(5)}f^{(4)}\bigg{[}(\textbf{W}^{(4) }\textbf{f}^{(3)}+b^{(4)})(\textbf{W}^{(3)}\textbf{f}^{(2)}+b^{(3)})\\ (\textbf{W}^{(2)}\textbf{f}^{(1)}+b^{(2)})(\textbf{W}^{(1)} \textbf{u}+b^{(1)})\bigg{]}+b^{(5)}.\end{split}  \tag{8}\]  
The neural network was trained with **IT** (input tics) (Equation (9)) and with output **OT** (output tics) (Equation (10)). The training set was composed of 32 network inputs denoting the matrix **H**, i.e., the matrix of the refiltered EEG signal. They were marked as the set of patterns \(iT\) with the number of lines \(aT=32\). The training output data set was hidden under the variable \(oT\) with the number of lines \(bT=3\). \[\textbf{IT}= \begin{bmatrix}i\textbf{T}^{(1)}\\ \vdots\\ i\textbf{T}^{(aT)}\end{bmatrix} = \begin{bmatrix}iT_{1}^{(1)}&iT_{2}^{(1)}& \ldots&iT_{r}^{(1)}\\ iT_{1}^{(2)}&iT_{2}^{(2)}&\ldots&iT_{r}^{(2)}\\ \vdots&\vdots&\vdots&\vdots\\ iT_{1}^{(31)}&iT_{2}^{(31)}&\ldots&iT_{r}^{(31)}\\ iT_{1}^{(32)}&iT_{2}^{(32)}&\ldots&iT_{r}^{(32)}\end{bmatrix} . \tag{9}\]  
Figure 16: Neural network training confusion matrix. The matrix of output patterns is illustrated according to the formula:  
\[\mathbf{OT}= \begin{bmatrix}\mathbf{oT^{(1)}}\\ \vdots\\ \mathbf{oT^{(bT)}}\end{bmatrix} = \begin{bmatrix}oT_{1}^{(1)}&oT_{2}^{(1)}&\dots&oT_{ r}^{(1)}\\ oT_{1}^{(2)}&oT_{2}^{(2)}&\dots&oT_{r}^{(2)}\\ oT_{1}^{(3)}&oT_{2}^{(3)}&\dots&oT_{r}^{(3)}\end{bmatrix} . \tag{10}\]  
The input and output training patterns covered the same number of elements. Satisfactory results of the classification were given by the set consisting of \(r\) = 118,000. The next section contains the results of the classification of the discussed algorithm. The Results of the Classification of Facial Expressions for the Purposes of Movement Commands and the Detection of Nervous Tics  
The present section describes the effects of the designed classification system. The classification of EEG signals from neural tics was tested by an expert system composed of artificial intelligence solutions. Figures 17-22 show exemplary classification results with the resulting control signals and detections of nervous tics. Only two exemplary results of the sequence of movement commands for each nervous tic are presented. This is naturally dictated by the need for transparency in the article. Each of the figures (part \"a\") contains the movement commands (forward, right and left) and a filtered EEG signal from the four electrodes considered. The spectral estimation waveforms resulting from their one-second samples were included in Section 4.1. Moreover, in part \"b\" of each figure, there are classified artifacts resulting from the simulation of a nervous tic by the examined person (shoulder, neck and blinking eyes). Additionally, the authors present a graph with the refiltered EEG signal containing the waveforms of all channels.