## 2 Materials and Methods
### Linear Transformations  
To transform feature vectors, linear discriminant analysis (LDA) with singular value decomposition as a solver method and the tolerance for stopping criteria of \(10^{-4}\) was used. The rest of the parameters were set to their default values provided in Scikit-Learn v. 1.0 for Python programming language [34]. By default, all input values were converted to z-scores. Figure 1: Timing representation of a scenario with the participation of volunteers in the task of movement execution (ME) and motor imagery (MI). (1)—rest with eyes open (EO, 60 s); (2)—instructions, 60 s; (3)—series 1 (ME) (180 s), (4)—rest after series 1, 60 s; (5)—series 2 (ME + MI) (180 s), (6)—series 3 (MI + ME) (180 s). To highlight the most discriminative frequency ranges the initial feature vector of length 153 (17 channels \(\times\) 9 frequency bands), the transformation method based on LDA was applied:  
1. For each class of movement, a separate model of a 1-component LDA model (transformer) was trained: the training sample included all the examples of the given class and as many resting state signal examples. 2. On the completion of the transformation, 153 values of features collapsed into one, a linear combination, while for each class, there was a specific set of coefficients. 3. After tuning all class-specific transformers, the final feature vector was three-dimensional (one feature for each class). A schematic of this transformation procedure is shown in Figure 4.  
During the complementing search for the most informative segments of the time domain for each two-second segment of each MI, a sample of examples of two classes was artificially created: the considered movement and the resting state signal. The feature vector consisted of the differences between feature vectors of all window combinations with each window having a length of 750 ms and a shift being 100 ms within a given MI signal epoch and a 2 s long background signal epoch. If frequency spectrum features were used, they were converted to three components in the manner described above. Otherwise, from the weights of each frequency LDA transformer, one frequency corresponding to the  
Figure 2: Artifact removal example. (**A**) Raw signal containing artifacts. (**B**) Signal with artifacts removed. Channels 1–3 are EMG channels for the right hand, left hand, and feet, respectively, and channel 4 is EOG. highest absolute weight value was extracted. Finally, multiband filtering was applied to the signals processed using the frequencies found in the previous step. The window length of 750 ms was used, since it provided the best classification accuracies (compared to 500 and 1000 ms). In 2 s, 13 different 750 ms windows are accommodated with a 100 ms shift. These windows resulted in 13 examples labeled as the class of a given mental movement. Each of these examples included differences between a particular background window and the 13 windows of a given MI epoch. A total of 13 more examples were labeled background class and included differences between pairs of the background signal epoch windows in the same manner. Figure 3: Real movement detection (left hand) detection using the EMG signal. (**A**) Raw EEG and EMG data. (**B**) 1–4 Hz filtered EEG and EMG data for movement onset detection. The blue label “5” at almost 00:17:56 is the detected onset of the movement in channel 2, where the absolute value of the filtered signal first exceeded 10 μV. Ellipsis indicates the channels skipped for more compact representation. Other designations are adopted from Figure 2.  
Thus, each MI signal epoch was first transformed into a 26 \(\times\) 153 sample, and then this sample was used to train a two-component LDA-based transformer. To be added to the final sample, each example was transformed as follows: a pseudo-example was created from the differences of the averaged feature vector over all background signal windows and all shifts of the given mental movement example, which was then transformed by a trained two-component LDA.