## 3 Preparation of EEG and EMG Signals for Classification: Pre-Classification Part
### Presentation of EEG Signal Integration and Filtration Method  
The EEG signal activated by the headset is filtered. The raw signal from the 22 most critical electrodes is not directly classified by the designed system. This would be associated with increased difficulty arising at the stage of creating the algorithm, because as shown in Figure 4 unfiltered waveforms are characterized by a long stabilization time and a transient state in the case of an increase in the voltage measured by the sensors. Therefore, a high-pass filter with a sampling frequency was used \(f_{s}\) = 1000 Hz and bandwidth \(f_{p}\) = 200 Hz. Figure 4 also presents the final form of the filtered signal. In this form, it is subjected to the method of periodic, 1-second integration, which facilitates the classification process by the system. Figure 4: The observation of raw and filtered EEG signals. As part of this study, a classification algorithm based on an unusual approach to measuring the EEG signal was used. The Emotiv Epoc Flex kit was used, because its use in this type of experiment is quite rare. This in turn prompts the search for new possibilities and applications for this device. The next section will effectively present the method of preparing a signal for classification and the methods used, which are used by the system shown in Figure 5.  
As was the case with the article [5], it was decided to re-analyze the archived samples measured with the Emotiv headset and exported from the original software of this manufacturer. The dedicated application provides EEG signal sampling with the frequency \(f_{e}=128\) Hz. Using this knowledge, the authors again proposed an approach using the rolling integration of each electrode's signal for a period of one second. It is an original approach to the topic of electroencephalogram pre-classification of a biomedical signal. Referring to the presented methodology, it is possible to efficiently present its analytical form. The \(M\) variable shows the number of samples contained in the signal, while \(k\) contains the value of full one-second periods in the signal. Based on the \(f_{e}\) sampling rate information, it is known that an exemplary 5 s EEG signal will be composed of \(M=640\) samples. Using the calculations in Equation (1) it is known that the number of full one-second periods that will later undergo classification is \(k=\)5. Importantly, in the case of an exemplary signal lasting 10.5 s, only 10 s will be taken into account; hence, full sampling periods will constitute \(M=1280\) samples, resulting in \(k=10\) integrated samples of the signal. This approach is due to the concern for efficiency and unambiguity in the interpretation of each course. \[k=\frac{M}{128}. \tag{1}\]  
The variable \(S\) is defined separately for each of the electrodes. As a result, they are presented in the form: \(S_{1}-S_{22}\), which can be seen in the formula below (Equation (2)). Each of the 22 variables \(S_{1}-S_{22}\) is an array. It collects the values resulting from the use of the rolling integration of one-second EEG periods of each electrode. Its superscript contains \(1-k\), a sample of the integrated value. Taking this fact into account, it is possible to indicate an example form of the variable \(S\) for a 10 s signal of the third electrode. In that case, \(k=10\), so \(S_{3}^{(1..k)}\). This is confirmed by the Equation (2). Collecting data in the following tabular manner is convenient and effective for this type of application. Figure 5: Presentation of the classification expert system. \[S_{1\_22}^{(1\_k)}=\left[\int_{(((1\_k)-1)\cdot 128)+1}^{(1\_k)\cdot 128}\left|E_{1\_ 22}^{EEG}\right|\right]. \tag{2}\]  
The \(E_{1\_22}^{EEG}\) variable presents the signal from individual electrodes of the set. According to the Formula (2) it can be seen that the absolute value of each channel signal is integrated over a period of 128 samples. This method makes it possible to use the rolling method of integration and write values to S variables.