1 Introduction

It is known that a noninvasive approach based on electroencephalogram (EEG) signals has proven to be very useful in Brain-computer interface (BCI). BCIs strictly do not use normal neuromuscular output pathways. The original idea of BCI is to replace or restore brain function in patients with neuromuscular disorders such as amyotrophic lateral sclerosis, stroke, and spinal cord injury (McFarland et al. 2017). The study on the features of electrophysiological indicators associated with brain potentials is a key aspect in improving the accuracy and reliability of the BCI. Usually these indicators (brain patterns) in EEG signals are random a priori undefined structures with unknown temporal dynamics and fluctuations of frequency oscillators with various intensities. Nowadays, the search in multidimensional EEG signals for these brain patterns is being thoroughly studied (Abiri et al. 2019). The widely used methods for analyzing and decoding brain EEG signals can promote widespread application of neural control. These methods have an impact on the accuracy of the pattern classification of electrical brain activity (Colamarino et al. 2018).

Nevertheless, the character of movement-related brain potential (MRP) patterns being displayed in EEG signals sets a limit on the use of a classical approaches to solving the problem of their automatic detection (Takashima et al. 2020). First and foremost, the quasistationary nature of the EEG itself makes it problematic to analyze and interpret the bioelectric activity of the brain (Craik et al. 2019). There have been numerous attempts to use spectral density decomposition method for automatic detection of specific brain patterns associated with the epileptic foci (Türk and Özerdem 2019), or to assess the effects of EEG synchronization/desynchronization (Li et al. 2019), and others. Second, the main disadvantage of known approaches, however, is the assumption that several parameters, including nonlinear indicators in different frequency regions of the signal, are known a priori. The EEG assumes the presence of a set of narrow-band MRPs that specifically reflect the voluntary motor activity of a person associated with movement preparation (Readiness potentials, RP), or movement execution (Motor potentials, MP), or motor imagery (MI) and inner speech activity (IS). Parameters of recorded MRPs depend on the nature of the activity being executed—visual or kinesthetic imagination (Lee et al. 2019). Moreover, the frequency spectrum of target MRP patterns is determined by the current psychophysiological and functional state of a person, and, for example, the type of movement being prepared—voluntary motor execution or ballistic (spontaneous) (Lazurenko et al. 2018; Chen et al. 2019). Thus, as a rule, the frequency composition and power spectrum of these specific EEG patterns are not known in advance as they are determined by a sufficiently large set of uncontrolled random factors unknown to the researcher. Another substantial problem in the study of voluntary motor activity, especially, motor imagery is the blurring of time boundaries in determining the processes of planning, preparation, and execution of motor acts (Freer and Yang 2020). This problem does not allow for a sufficiently reliable coherent summation of induced brain electrograms, as compared to evoked potentials (Jin et al. 2012; Eidel and Kübler 2020; Kübler et al. 2021). In addition, the modal frequencies of various brain rhythm oscillators usually associated with an individual’s different activity can demonstrate a very high variability even during one experimental series. This phenomenon may be caused by fatigue and monotony (Sengupta 2020). Thus, several problems related to the detection, interpretation, and classification of MRPs accompanying voluntary motor activity (including motor imagery) of a person have not yet been fully resolved. Such nonstationary character of the required EEG patterns, as well as the a priori uncertainty of their parameters and time boundaries require the development of new adaptive approaches for MRPs automatic detection (Samuel et al. 2021).

This study is aimed at the development of the new adaptive method for automated detection of MRPs as EEG markers of the well-known individual brain activity associated with voluntary movement preparation. The hypothesis of the study is that the search function reflects the presence of the initial and final time boundaries of the MRPs. First, an adaptive spectro-temporal decomposition of the EEG signals employing a number of band-pass filters (BPF) is performed. Only one of the adaptive BPFs is selected so that the filtered EEG signal has a frequency range corresponding to the maximum frequency spectrum of the target MRPs. The subsequent search of time boundaries of for low-amplitude target MRP pattern in time domain we carried out not in the original EEG signal, but in so preliminary filtered original EEG time series. Therefore, we ensured high sensitivity of the search algorithm. Based on the found time boundaries of the MRPs, time epochs corresponding to the voluntary motor preparation brain activity of a person are extracted from the original unfiltered multidimensional EEG. This allows to create an efficient machine learning dataset to classify the type of movement being prepared and designed to build the most reliable BCIs.

2 Method for automatic detection time boundaries of the MRPs

Registration of the multidimensional EEG

$$ {\mathbf{S}}\left( t \right) = \left( {S_{1} \left( t \right)\;\;S_{2} \left( t \right)\;\; \ldots\;\; S_{J} \left( t \right)} \right)^{{\text{T}}} $$
(1)

was carried out at the same time intervals \(t \in \left[ {t_{0} ,t_{k} } \right]\) on J standard leads (where t0 and tk are the initial and final time intervals; T signifies transposition). The EEG S(T) (1) assumes the presence of a number of movement-related brain potentials that specifically reflect the voluntary motor preparation brain activity, where \(T = t_{k} - t_{0}\) is the observed time for automated detection of MRPs. The time interval T was known a priori and corresponded to the duration of the target MRP pattern \(T_{p} = t_{k,p} - t_{0,p}\), where t0,p and tk,p are the initial and final time boundaries of the MRP pattern. Thus, T and Tp were close in value, but Tp < T is guaranteed.

Time boundaries of MRP patterns were detected in time domain. Criterion-based search reflected the presence of the time boundaries of the MRPs. Usually, the search sensitivity isn’t sufficient for searching low-amplitude MRP patterns with a priori unknown parameters in noisy EEG signals. It is known that some parameters of MRP patterns and their spatial localizations are determined by the type of human mental activity (Amin et al. 2019). For instance, frequencies from 30 to 70 Hz (γ1 and γ2- frequencies) demonstrate high directional sensitivity to the type of motor activity being executed and correlate with the processes of selective attention. But it is the alpha frequencies (α-range) from 12 to 16 Hz of the frontal and central regions of the cerebral hemispheres that are closely related to the preparation for the execution of voluntary movements (Babiloni et al. 1999; Deiber et al. 2012; Kobler et al. 2020). It was shown that the maximum frequency power spectrum of narrow-band pattern of the named regions in the α range specifically reflect BCIs compatible early conscious access to preparation of voluntary motor activity, related to the pre-motor potential (also known as Bereitschaftspotential or Readiness potential) (Shibasaki and Hallett 2006; Parés-Pujolràs et al. 2019; Braquet et al. 2020). So, it is advisable to run a preliminary search of the narrow-band MRP pattern in the individual frequencies related to the different type of movement-related brain activity of an individual at the observed moment. Preliminary filtering the original EEG in the frequency range maximum correspond to the frequency range of the target MRP pattern can provide a very high sensitivity for subsequent searching of time boundaries of this pattern.

Obviously, the modal frequencies of MRPs are a priori uncertain and can demonstrate a very high variability even during one experimental series. Therefore, the use of band-pass filter with a priori specified parameters would not provide maximum corresponding of the frequency range of the filtered EEG signal to the frequency range of the sought narrow-band MRP patterns at the observable time moment. For example, experimental studies confirmed the well-established fact (Zapała et al. 2020) that multiple executions of the same type of movement can significantly modify the frequency range of these patterns.

To transfer EEG signals from the temporal representation to the time–frequency representation, historically, a mathematical tool has been used based on the windowed Fourier transform and spatial filtering of oscillating components (Jusas and Samuvel 2019), or discrete or continuous wavelet transforms (Taran and Bajaj 2019), or multi-taper spectral decomposition (Walden 2000; Babadi and Brown 2014), or empirical mode decomposition (EMD) (Huang et al. 1998; Bajaj and Pachori 2012). These methods allow to search for a specific brain pattern within the framework of various criteria functions (Shcherban et al. 2018, 2019; Bablani et al. 2019). Nowadays, wavelet decomposition and EMD are the most widely discussed frequency domain techniques in this case. But each method has some features that can be used to synthesize required adaptive BPF. It was considered that, depending on the type of cognitive load, physiological EEG rhythms can demonstrate multidirectional changes in narrow frequency bands. Thus, for example, preparation for the implementation of real movement is accompanied by changes both in low-frequency delta- (1–4 Hz) and alpha-ranges (8–12 Hz) of the EEG, and in higher-frequency beta- (13–35 Hz) and gamma (γ1, 35–45 Hz) frequencies (Onay and Köse 2019). For this reason, it is necessary that parameters of BPFs correspond to the spectrum characteristics of the most high-frequency rhythm of all frequency ranges related to the studied process of preparation for the execution of motor acts recorded at the interval T in target channels. It is still difficult to control parameters of the synthesized adaptive filter so that its bandwidth matches the narrow-band frequency range of the sought MRP pattern at the observable time moment.

It is known that such time series as EEG signal can be deconstructed in the time domain with the use of the Singular Spectrum Analysis (SSA) methodology into a sum of oscillatory components—reconstructed components (RC) (Golyandina and Zhigljavsky 2020). The frequency spectra of each RC depend on the number of SSA filters used in the decomposition and are ordered in ascending order. Thanks to this feature, SSA filters are adaptive to probabilistic changes in the original signal. This feature enabled us to solve, for example, the problems of extraction of multisource brain activity using only single-channel recordings of electromagnetic brain signals (James and Lowe 2003), rejection of low-frequency artifacts in spontaneous EEG (Hu et al. 2017), high-quality suppression of high-frequency noise (Ghaderi et al. 2011) and high-precision filtering (Maddirala and Shaik 2016). To automatically remove low-frequency artifacts in the human EEG, an adaptive filter was synthesized as part of the development of portable telemedicine devices (Hu et al. 2017). In Ref. (Shcherban et al. 2020) the use of an adaptive band-pass SSA filter was considered mainly for increasing the sensitivity of the criterion function to search olfactory evoked patterns in the bioelectric activity of the rat's olfactory bulb. Another important aspect of the SSA, unlike many other methods, is that it works well even for small sample sizes (Hassani 2007; Hassani and Zhigljavsky 2009). For example, a short motor potential (40–80 ms) is formed in the primary motor cortex (M1) immediately before executing a voluntary movement, which is associated with the impulse of pyramidal cells to the motor end plates of the effector muscle, that is why this feature is important for automated detection of time boundaries of short MRPs.

The new method for detecting specific MRP patterns was as follows. At first it was considered that different type of human mental activity determines different spatial localization of EEG patterns (Amin et al. 2019). That is why only J′ < J EEG leads from the regions of interest were required for subsequent analyses. Applying SSA on the measurement interval T with a set of M filters the first of which is a low-pass filter (LPF), and the rest (M-1) are band-pass filters (BPF), each j-th (\(j = \overline{1,J^{\prime}}\))component Sj(T) of multidimensional EEG S(T) required for subsequent analysis can be divided into M time series \(S_{j} \left( T \right) = \left( {\tilde{S}_{j,1} \;\;\tilde{S}_{j,2} \;\; \ldots \;\;\tilde{S}_{j,M} } \right)^{{\text{T}}}\) of the same dimension as the original data Sj (Golyandina and Zhigljavsky 2020). To reconstruct a system of simultaneous time series similar as the multidimensional EEG S(T) (1), the multidimensional SSA (MSSA) (Golyandina and Zhigljavsky 2020) can be used. But in each j lead the narrow-band MRP pattern has different maximum frequency spectrum at the observed time moment (Xu et al. 2021). Therefore, the SSA decomposition of each j-th component Sj(T) from (1) separately is more correct in comparison with the simultaneous MSSA decomposition of the original multidimensional EEG.

The frequency spectra \(\Delta F_{j,1} ,...,\Delta F_{j,M}\) of j,m-th (\(j = \overline{1,J^{\prime}}\); \(m = \overline{1,M}\)) reconstructed components (RC) \(\tilde{S}_{j,1} {,}...,\tilde{S}_{j,M}\) depend on the number M of SSA filters used in the decomposition and are ordered in ascending order. The upper frequency limits of the spectra of the RCs satisfy \(\,f_{1}^{\,h} \le f_{2}^{h} \le \cdots \le f_{M}^{h} {,}\) where \(f_{M}^{h} = 0.5f_{s}\) and fs is the EEG sampling rate. In this case, the sum of all narrow-band RCs reconstructs the original series EEG \(S_{j} \left( T \right) = \sum\nolimits_{m = 1}^{M} {\tilde{S}_{j,m} \left( T \right)}\), while the choice of only some of them allows us to perform frequency filtering of the original EEG signal. In Ref. (Shcherban et al. 2020), to simplify the synthesis procedure for the required adaptive band-pass filter, the narrow-band signal was restored by just one RC and the required BPF was synthesized. Considering that MRP pattern has the narrow-band frequency spectral characteristics we used the same approach further on. Varying of number M in the range \(M \in \left[ {M_{\min } ;M_{\max } } \right]\) leads to change in the bandwidth of each m-th filter. With an increase in M, the effective passbands of BPFs decrease. Also in Ref. (Golyandina and Zhigljavsky 2020), it is shown, that the amplitude-frequency characteristic (AFC) \(A_{m} = \left| {H_{m} \left( {e^{j2\pi f^{\prime}} } \right)} \right| = A_{m} \left( {f^{\prime},M} \right)\) of a given M filter is a function of the M, where \(H_{m} \left( {e^{{j2\pi f^{\prime}}} } \right) = \sum\nolimits_{n = 0}^{MJ - 1} {h_{m,n} e^{{ - j2\pi \,f^{\prime}n}} }\)—the frequency response; hm—the known impulse response of non-recursive SSA filter; \(f^{\prime} \in \left[ {0;\;0.5} \right]\)—the given frequency. The choice of the given frequency step from the equality f' = 1/fs makes it possible to calculate the frequency response AFC \(A_{m} \left( {f,M} \right)\) in the real frequency range f ∈ [0; 0.5 fs] with a discreteness of 1 Hz. So, thanks to known hm in SSA decomposition it’s easy to control the frequency spectra of each m-th RC \(\tilde{S}_{j,m}\)(T). Varying the number M simultaneously changes each m-th (\(m = \overline{1,M}\)) SSA filter parameters in M-th decomposition (\(M = \overline{{M_{{{\text{min}}}} ,M_{{{\text{max}}}} }}\)) and so changes the frequency spectrum of the filtering j-th component Sj(T) of the original EEG (1).

The AFC of SSA filters has a shape of a Gaussian function (GF) \(g\left( f \right) = {\text{exp}}\left( { - {{\left( {\hat{f} - f} \right)^{2} } \mathord{\left/ {\vphantom {{\left( {\hat{f} - f} \right)^{2} } {2c^{2} }}} \right. \kern-0pt} {2c^{2} }}} \right)\). So, varying M leads to simultaneous changes in the modal frequency \(\hat{f}\): gmax = g(\(\hat{f}\)) = 1 of the Gaussian-like AFC and its bandwidth, determined by the c value (Golyandina and Zhigljavsky 2020). We also approximated the sought narrow-band MRP pattern in the frequency domain by the Gaussian shape. Therefore, it was required to select only one SSA band-pass filter (BPF) so that its Gaussian-like AFC maximally repeated the approximate MRP Gaussian function.

Parameters \(\hat{f}\) and c alternatively can be interpreted by saying that the two inflection points \(f_{L}^{GF}\) and \(f_{H}^{GF}\) of the of the GF occur at \(f_{L}^{GF} = \hat{f} - c\), \(f_{H}^{GF} = \hat{f} - c\). Moreover, for the presented GF of unit height, it is true that \({\text{g}}\left( {f_{L}^{GF} } \right) = g\left( {f_{H}^{GF} } \right) = {\text{exp}}\left( { - {1 \mathord{\left/ {\vphantom {1 2}} \right. \kern-0pt} 2}} \right)\) for any pairs of numbers (\(\hat{f}\), c). Consequently, a proximity measure of the pairs of inflection points of the GF of m-th BPF \(\left( {f_{L}^{BPF} ,f_{H}^{BPF} } \right)\) and of the approximate MRP GF \(\left( {f_{L}^{RP} ,f_{H}^{RP} } \right)\) fully reflect the proximity measure of the spectrum parameters of the m-th RC and the MRP pattern. Determination of the number mopt from the criterion

$$ m_{{{\text{opt}}}} \left( M \right) = \mathop {{\text{min}}}\limits_{\begin{subarray}{l} \;\;\;\;\;\;m = \overline{1,M} \\ M = \overline{{M_{{{\text{min}}}} ,M_{{{\text{max}}}} }} \end{subarray} } \left\{ {\left( {f_{L}^{BPF} - f_{L}^{RP} } \right)^{2} + \left( {f_{H}^{BPF} - f_{H}^{RP} } \right)^{2} } \right\}, $$
(2)

provides maximum correspondence of the spectrum parameters of the RC \(\tilde{S}_{{j,m_{{{\text{opt}}}} }} \left( T \right)\) and of the sought narrow-band MRP pattern on the j-th lead (\(j = \overline{1,J^{\prime}}\)) on the observed time interval T. In general, there are different numbers mopt on the EEG leads. The preliminary filtering of the original EEG signals in the frequency range corresponding most to the frequency range of the MRP pattern provides the required sensitivity for subsequent searching of time boundaries of this pattern in time domain.

Subsequent search of time boundaries of the MRP pattern was carried out on the analysis of the multidimensional time series of RCs

$$ {\tilde{\mathbf{S}}}\left( T \right) = \left( {\tilde{S}_{{1,m_{opt} }} \;\;\tilde{S}_{{2,m_{opt} }} \;\; \ldots \;\;\tilde{S}_{{J^{\prime},m_{{{\text{opt}}}} }} } \right)^{\text{T}} , $$
(3)

where dim(\({\tilde{\mathbf{S}}}\)) = J′ × K; K = Tfs—the time series length. By comparing two neighboring sliding time windows equal in volume and containing J′ × n point sets (\(n < < K\)) the criterion-based search reflecting the degree of dynamic differences in \({\tilde{\mathbf{S}}}\left( T \right)\) (3) for each adjacent sliding pair of windows.

The criterion function was based on the calculation of the Hausdorff distance (HD) H. The HD is a measure of dissimilarity between two-point sets. It is commonly used in many domains like pattern matching, for example, in medical applications related to the evaluation of medical segmentations (Vizilter and Zheltov 2014; Taha and Hanbury 2015). The HD is the maximum of the non-symmetrically directed Hausdorff distances in both directions. In the considered approach, the directed Hausdorff distance Hd between two J′ × n point sets \({\tilde{\mathbf{S}}}\left( {T_{i} } \right)\) and \({\tilde{\mathbf{S}}}\left( {T_{i + 1} } \right)\) from two i and i + 1 neighboring time windows (where Ti, Ti+1 << T and Ti = Ti+1 = n/fs) is the maximum of the Euclidean distances \(\left\| \cdot \right\|\) from each point \(\tilde{s}^{\,\left\langle i \right\rangle } \in {\tilde{\mathbf{S}}}\left( {T_{i} } \right)\) to its nearest neighbor \(\tilde{s}^{{\,\left\langle {i + 1} \right\rangle }} \in {\tilde{\mathbf{S}}}\left( {T_{i + 1} } \right)\):

$$ H_{d} \left[ {{\tilde{\mathbf{S}}}\left( {T_{i} } \right),{\tilde{\mathbf{S}}}\left( {T_{i + 1} } \right)} \right] = \mathop {\max }\limits_{{\tilde{s}^{\,\left\langle i \right\rangle } \in {\tilde{\mathbf{S}}}\left( {T_{i} } \right)^{\begin{subarray}{l} \\ \end{subarray} } }} \left\{ {\mathop {\min }\limits_{{\tilde{s}^{{\,\left\langle {i + 1} \right\rangle }} \in {\tilde{\mathbf{S}}}\left( {T_{i + 1} } \right)^{\begin{subarray}{l} \\ \end{subarray} } }} \left\{ {\left\| {\tilde{s}^{\,\left\langle i \right\rangle } ,\tilde{s}^{{\,\left\langle {i + 1} \right\rangle }} } \right\|} \right\}} \right\}. $$

So, HD H is given by

$$ H\left[ {{\tilde{\mathbf{S}}}\left( {T_{i} } \right),{\tilde{\mathbf{S}}}\left( {T_{i + 1} } \right)} \right] = \max \left\{ {H_{d} \left[ {{\tilde{\mathbf{S}}}\left( {T_{i} } \right),{\tilde{\mathbf{S}}}\left( {T_{i + 1} } \right)} \right],H_{d} \left[ {{\tilde{\mathbf{S}}}\left( {T_{i + 1} } \right),{\tilde{\mathbf{S}}}\left( {T_{i} } \right)} \right]} \right\}. $$
(4)

The HD (4) is calculated for all adjacent windows. Then, if there is an initial or final boundary of the desired MRP pattern in any pair of the neighboring sliding windows, the measure of the dissimilarity of these two-point sets increase, the criterion function H (4) acquires its local maximum value. The size n of the sliding time window is selected so that the a priori known duration of the MRP pattern is guaranteed to exceed the value of n/fs. We synthesized the following algorithm for automatic detection of time boundaries of the target RP patterns (Fig. 1).

Fig. 1
figure 1

Developed algorithm for automatic detection time of boundaries of the MRP

Taking into consideration the spatial localization of the studied human brain activity type, J′ < J EEG signals are selected from the original multidimensional EEG. Based on the Fast Fourier transform of each j-th (\(j = \overline{1,J^{\prime}}\)) original signal Sj(T) on the observed time T power spectral density (PSD) functions are calculated. Then, in the frequencies of interest f ∈ [fL, fH] the modal frequencies \(f_{j}^{RP}\): \(P_{j} (f_{j}^{RP} ) = 1\) of the MRPs are detected, where Pj(f) denotes normalized PSD. It is easy to calculate inflection point pairs \(\left( {f_{L}^{RP} ,f_{H}^{RP} } \right)_{j}\) of the approximate GFs of the Pj(f) of MRPs. Also, by varying the number M in the range \(M \in \left[ {M_{\min } ;M_{\max } } \right]\) the one optimal BPF with number (mopt(M))j from the criterion (2) is selected. In this case the spectrum of the filtering j, m-th RC \(\tilde{S}_{{j,m_{{{\text{opt}}}} }} \left( T \right)\) most closely matches the spectrum of the target MRP pattern, observed at the j-th EEG lead. The multidimensional so preliminary filtering signal \({\tilde{\mathbf{S}}}\left( T \right)\) (3) is divide into K/n of time windows of the same dimensions \(J^{\prime} \times n\). The HD (4) is calculated for all adjacent windows. Then, if there is an initial or final boundary of the desired pattern in any of the neighboring windows, the criterion function H (4) acquires its local maximum value.

Based on the found time boundaries of the MRPs epochs corresponding to the voluntary movement-related brain potentials, in particular, the Readiness potentials are extracted from the original unfiltered multidimensional EEG (1). We apply the above proposed method to movement and motor imagery dataset that we have previously obtained and analyzed using other methods to create new asynchronous and stimulus-independent Brain-computer interfaces (Shepelev et al. 2018; Lazurenko et al. 2019).

3 Research methodology

To test the developed tools, the following experimental studies were performed. The surveys involved 16 healthy volunteers (11 men and 5 women) with the average age of 21. In accordance with ethical standards of the 1964 Helsinki Declaration and its later amendments and the ethics committee of Southern Federal University, they all signed a voluntary consent protocol for participation in the research.

Further experimental studies were carried out only on voluntary motor activity related to the pre-movement Readiness potential (RP) (or Bereitschaftspotential). The fact of preparation for movement execution by a person is obvious and it is easy to test with the developed tools on the RP patterns compared with the motor imagery patterns. For selected type of motor activity, the alpha-range (mu-rhythm) frequencies from fL = 12 to fH = 16 Hz of the central regions of the cerebral hemispheres are closely related to the preparation for the execution of voluntary movements. It is obvious that the initial moment ta of the actual hand movement initialization practically coincides with the terminal moment of the target pre-motor RP pattern associated with the preparation for the motor act and ta = tk,p = tk. For this reason, in each study sample, we were searching for only the initial boundaries of the pre-motor RP patterns of a person t0,p. It is generally accepted that RP patterns associated with the direct preparation of a specific plan for executing voluntary movements, as a rule, do not exceed 500 ms (Kobler et al. 2020). In this regard, the detection of the desired RP patterns was carried out at T = 1000 ms preceding the moment of actual initialization of the hand movement ta and Tp < T is guaranteed.

During the electrophysiological tests, the participants were in a comfortable position (in a chair) in a specially equipped light and sound-proof Faraday chamber. The subjects executed real movements with their legs, right and left arms at a voluntary pace with the eye fixed on the placemark in the center of the screen. The movements of the upper limbs alternated with a state of rest when the subject was motionless for some random time with their eyes open. In this case, the EEG was recorded continuously—both at rest and in preparation for the execution of the actual movement. Movement execution with each arm was covered around 25 cycles for each subject. Figure 2 shows a fragment of the timing diagram of an experimental session for one type of movement.

Fig. 2
figure 2

Timing representation of a scenario with the participation of volunteers in the task of movement execution. [1] Rest with eyes open; [2] Instructions; [3] Movement execution with left or right arm; [4] Rest after movement execution. A time diagram of an experimental session for voluntary movement execution

The EEG S(t) (1) was recorded relative to the ear reference electrodes (combined reference) with an Encephalan-131–03 amplifier (Medikom MTD, Taganrog) from J = 17 standard channels (F7, F8, F3, Fz, F4, C3, Cz, C4, P3, Pz, P4, O1, O2, T3, T4, T5, T6) in accordance with the international system “10–20”. The EEG sampling rate was fs = 250 Hz for each of the recording channels. The first and second harmonics of the 50 and 100 Hz power supply were removed using a notch filter.

In parallel, an electromyogram (EMG) was recorded on the superficial muscles flexing the forearm in the elbow joint (m. Brachioradialis) and the superficial flexors of the fingers (m. Flexor digitorum superficialis). The bipolar electromyogram was used to form event markers synchronized with the EEG channels. Each EMG channel was filtered in the frequency band of 1–4 Hz. As a result, a smoothed myographic spindle was formed. The events of the actual initiation of movement execution were set automatically when the threshold amplitude of 10 μV was reached on the ascending front of the smoothed EMG spindle. Thus, the initial moment ta of the actual movement of arms was recorded quite accurately by means of bipolar EMG channels. To detect and subsequently reject artifacts associated with eye movement and blinking automatically, an electro-oculogram (horizontal and vertical EOG) was recorded. The dataset is available at (http://neuro.sfedu.ru/eeg_premotor_pattern_sfedu_2020/).

4 Computational results

4.1 Time boundaries detecting results

The correctness of the decisions made were verified with standard statistical tests and machine learning algorithms. The developed method was used to detect the initial time boundaries of the pre-motor RP patterns of 16 persons in each trial of movement execution both with the right and left arm.

For the right arm, the target leads of the left hemisphere F3, C3, P3 and T3 responsible for the development of the pre-motor pattern were selected, and for the left arm—the EEG leads F4, C4, P4 and T4 (J′ = 4 in both cases). The maximum permissible number of filters is determined by Mmax ≤ 0.5 K, where the length of the time series was K = 250. Considering the frequency range of RPs [12;16] Hz in the SSA decomposition of selected single-channel EEG components Sj(T) we used Mmax = 70, Mmin = 4. Spectrum parameters of synthesized adaptive SSA BPFs and of sought narrow-band RP patterns matched well. Three typical examples of the preliminary filtering of j-th component Sj(T) from one target EEG channel shown on Fig. 3.

Fig. 3
figure 3

The top graphs show PSD function Pj(f) (bold solid lines), normalized AFC Am, m = mopt of the selected BPFs, normalized AFC AB of the Butterworth BPF and approximate GFs of the PSD Pj(f) of RP patterns. The bottom graphs show normalized PSD PjRC(f) of the RCs \(\tilde{S}_{{j,m_{{{\text{opt}}}} }} \left( T \right)\) (solid lines) and normalized PSD PjB(f) of the filtering with Butterworth BPF EEG component Sj (dotted lines)

To verify the adaptation properties of the selected SSA BPFs, we also used six-order Butterworth BPF with the constant passband [12;16] Hz for comparison. The spectral composition of the RPs recorded for the actual movement execution preparation in the shown examples is significantly different. In the graphs (Fig. 3b) the modal frequency fjRP: \(P_{j} (f_{j}^{RP} ) = 1\) of the RP pattern shifted to the lowest frequency of alpha-rhythm (normalized in range [fL; fH] PSD Pj(f) shown with bold solid lines). In the other two examples, the modal frequency of RP patterns is in the middle of the frequency range of interest (Fig. 3a) or close to the upper frequency limits (Fig. 3c). The top graphs in Fig. 3 also show normalized amplitude-frequency characteristic (AFC) Am of the selected m = mopt BPFs, normalized AFC AB of the Butterworth BPF and approximate GFs (AGF) of the PSD Pj(f) of RP patterns. The dotted lines in the graphs at the bottom of Fig. 3 demonstrate normalized PSD \(P_{j}^{RC} \left( f \right)\) of the RCs \(\tilde{S}_{{j,m_{{{\text{opt}}}} }} \left( T \right)\) (solid lines) and normalized PSD PjB(f) of the filtering with Butterworth BPF j-th single-channel EEG time series (dotted lines). It is clear that the spectrum of RCs \(\tilde{S}_{{j,m_{{{\text{opt}}}} }} \left( T \right)\) closely matches the spectrum of the target RP patterns and, therefore, the developed algorithm made it possible to obtain individual optimal SSA BPF for the given examples of RPs. Butterworth BPF with a priori specified parameters did not provide maximum correspondence to of the frequency range of the filtered EEG signal to the frequency range of the RP patterns at the observed time moment.

When searching for the initial boundary of the RP patterns t0,p the width of the sliding window was 100 ms, and the overlap coefficient of the adjacent windows was 0.9. (Fig. 4a–c) shows 3 typical examples of the HD (4) graphs carried out at observed time interval T = t0 = 1000 ms preceding the moment ta = tk,p = tk = 0 of actual initialization of the right arm movement from one experimental session of a person.

Fig. 4
figure 4

Three examples of the HD function (4) from one experimental session of a person

We detected that the first maximum value of the HD corresponds to the initial boundary of the target RP pattern t0,p while preparing for the actual movement execution. In Ref. (Kobler et al. 2020) generally accepted that RP patterns, as a rule, do not exceed 500 ms. A detailed analysis demonstrated that there are significant fluctuations in t0,p coupled with the temporal characteristics of the RPs. In some cases, the t0,p exceeded 500 ms and were, on average, 374 ± 130 ms for the right arm and 348 ± 100 ms for the left arm. (Fig. 5) shows box plot of RPs initial time boundaries t0,p in sec for both arms.

Fig. 5
figure 5

Box plot of Mean parameters of the initial time boundaries of two target movement-related EEG patterns

The well-known fact was also confirmed (Hu et al. 2017; Pereira et al. 2019), according to which the frequency ranges associated with the preparation for movement can demonstrate a certain variability in the assessment of single trials even within the same subject. It is for this reason that the use of frequency filters with a priori given parameters seems to be ineffective.

4.2 Results of discrete classification problems

Based on the found time boundaries of the MRPs, time epochs corresponding to the voluntary motor preparation brain activity of a person were extracted from the original unfiltered multidimensional EEG signals. The hypothesis of the study was that this fact allows to create an efficient machine learning dataset to classify the type of movement being prepared by a person. We validated this hypothesis with standard machine learning algorithms. We checked the quality of the separation of time epochs related to the state of rest of each person and epochs pertaining to the preparation for the execution, therefore, containing RP patterns. Based on the detected time boundaries of the RP patterns for each trial of movement execution by each person correct time epochs [t0,p; tk] were extracted from the original EEG. Thus, we prepared data sets of classes namely the “Modified method (MM), right arm (RA)” and the “MM, left arm (LA).” Also, we had the analogous data sets of classes namely the “Standard method (SM), RA” and “SM, LA,” where detection of initial time boundaries was carried out as constant t0,pStandard = 500 ms (Kobler et al. 2020). Final time boundaries of time epochs tk were the same as in the samples of “Modified method.” For each person, we also prepared data sets of class "Rest," each containing 25 samples of 500-ms epochs selected randomly in each cycle of the experimental series in intervals corresponding to the state of operative rest before and after a single limb movement (see Fig. 2). Therefore, it was possible to solve the problem of discrete classification with standard machine learning algorithms.

At the first stage of calculations, best machine learning (ML) models and their best parameters were selected. Standard ML models Random Forest, Support Vector Machine, k-nearest neighbors, Gradient boosting decision trees (GBDT), Multilayer Perceptron and Classifier, based on linear discriminant analysis from the Python. Scikit-learn library were used. In total, about 300 reference features of different types from selected EEG epochs were calculated and synthesized—temporal, frequency, and frequency-temporal, as well as spatial. Additionally, the standardization of each selected feature in the data set was performed by removing the mean and scaling it to a unit variance. Detection of the best parameters for each ML model was provided using scikit-learn's GridSeacrh method. The selected classification models had sufficient generalizing ability which excluded the possibility of their undertraining or retraining. It turned out that the classification model of GBDT with parameters {deviance loss function, the minimum number of samples required to split an internal node and required to be in a leaf node equals 3, number of estimators equals 50} was the most efficient among the trained methods. The most important features were slopes of the regression lines, intersections of regression lines, correlation coefficients, standard errors of the estimated slopes, standard errors of the calculated intersection points assuming residual normality between the non-filtering single-channel EEG time series.

At the second stage, the binary discrete classification problem on standard datasets of two target states {“SM, RH/LH”—“Rest”} was solved. As expected, the maximum accuracy of binary classification in Stratified ShuffleSplit cross-validation at this stage was low and averaged at only 62% for the right arm and 67% for left arm. (Fig. 6a) shows box plot of accuracy of the solved classification problem. There were also significant variations in the classification accuracy—from 48 to 82% among different subjects. Interindividual differences are known to make a significant contribution to the assessment of subsets of EEG channels that usually differ significantly. In fact, the low average classification accuracy in the general set of data observed at the first calculation stage is most likely explained by the fact that, in addition to the target RP patterns, the composition of the epochs T = 500 ms of the “SM, RH/LH” classes includes other electrographic patterns not related to the current motor task.

Fig. 6
figure 6

Box plot of accuracy of the binary discrete classification of two target movement-related EEG patterns: a classes "SM, RA/LA" and "Rest (R)"; b classes "MM, RA/LA" and "Rest (R)"; c classes "SM/MM, Movement execution" and "Rest"

Then was solved the binary discrete classification problem of the same two target states but on modified data sets {“MM, RH/LH”—“Rest”}. The GBDT model with the best parameters was retrained, and its accuracy was verified during cross-validation. The accuracy of the binary classification for Modified method increased in comparison with Standard method on average by 32% for the right and 26% for left arm (see Fig. 6b). At the same time, the maximum observed classification accuracy on modified datasets calculated separately for each person, in some cases, increased to 99% for the right arm and to 100% for the left arm.

Then data sets of classes “MM, RH” and “MM, LH” had been merged in one class “MM, Movement execution.” Classes “SM, RH” and “SM, LH” were also combined in one class “SM, Movement execution.” Two binary discrete classification problems of classes {“MM, Movement execution”—“Rest”} and classes {“SM, Movement execution”—“Rest”} were solved. The accuracy of the binary classification categorized by "Method" was significantly higher for Modified method and amounted to average 94% ± 6% (see Fig. 6, c).

(Fig. 7a) shows quantile–quantile plot of the accuracy categorized by Method with Gamma distribution reflecting two probability movement-related EEG pattern distributions by comparing their quantiles against each other. MM had accuracy 89 + 3.9 × x and SM had accuracy only 55 + 8.9 × x (Shape par. x = 1, 2). (Fig. 7b) shows quantile–quantile plot of accuracy, categorized by Method and State (Rest and Movement preparation) with Gamma distribution. MM had accuracy 89/88 for RH/LH and SM had accuracy only 53/57 for RH/LH.

Fig. 7
figure 7

Box plot of quantile–quantile plot of accuracy: a Categorized by "Method" with Gamma distribution (Gamma shape = 1,2); b Categorized by "Method" and State (Rest and Movement preparation) with Gamma distribution

5 Discussion

Results highlighted the main features of the work and proved the hypothesis of the study that detailed determination of time boundaries of MRP patterns reflected in EEG signals allows increasing the classification accuracy of the state of rest of a person and of the state associated with movement preparation. Therefore, developed method is capable of automatic detection of MRPs as a marker of voluntary motor EEG activity of an individual. Application of a synthesized method obtain to correctly extract from EEG signals of those time epochs that containing the desired pre-motor MRPs. Thanks to this fact, it is possible to prepare an efficient machine learning dataset and, therefore, to increase the accuracy of the subsequent classification of the type of movement executed by a person at the observable time moment.

The required search sensitivity of time boundaries of MRPs is achieved through preliminary filtering of the original EEG signals. SSA methodology allows to take into account significant fluctuations in spatial-frequency characteristics of the EEG in terms of voluntary movements execution (Mammone et al. 2020; Wang et al. 2020; Santos et al. 2020) and, therefore to control parameters of the synthesized adaptive filter so that to obtain individual optimal SSA band-pass filter with bandwidth closely matching the spectrum of the desired MRP at the observed moment. We showed that Butterworth BPF with a priori specified parameters did not provide maximum correspondence of the frequency range of the filtered EEG signal to the frequency range of the sought narrow-band RP pattern at the observed time moment.

We made a statistical analysis of the results and showed that duration of RP patterns was, on average, 374 ± 130 ms for the right hand and 348 ± 100 ms for the left hand. We have emphasized the well-known fact (Hu et al. 2017; Pereira et al. 2019) that frequency ranges associated with the preparation for movement can demonstrate a certain variability in the assessment of single trials even within the same subject. It is for this reason that the use of frequency filters with a priori given parameters seems to be ineffective. Our results also indicate that the information processes of the brain related to pre-movement EEG patterns in particular can be seen as a promising direction for improving Brain-Computer Interfaces (Bocquelet et al. 2016; Cooney et al. 2018). The results obtained in this study are consistent with the findings related to the fact that subjective desire to perform a movement (W-judgment) occurs 300–500 ms before it is execution (Libet et al. 1983, Alexander et al. 2014; Drozdzewska et al. 2017; Kobler et al. 2020).

We also used standard machine learning algorithms. We checked the quality of the separation of time epochs from original EEG signals related to the state of rest of each person and epochs pertaining to the preparation for the execution, i.e., containing RP patterns. A detailed determination of initial time boundaries of the pre-movement RP patterns allowed to extract from original EEG epochs, containing only the desired pre-motor brain patterns. The main goal of analysis was to prove, that classification accuracy on the data sets with determined time boundaries of epochs, higher than classification accuracy on the data sets with standard time intervals (500 ms) of epochs containing RP patterns. On average, the developed method has increased the accuracy of the binary classification by 32% for the right and 26% for the left arm. The maximum observed classification accuracy calculated separately for each subject, in some cases, increased to 99% for the right arm and to 100% for the left arm. Results obtained allow us to prove that the method of adaptive search we developed is able to effectively and reliably determine the time intervals when the functional state of brain structures transit from idle activity or default mode to the actual motor task. These transitions between states are important for identifying the presence of a target movement preparation and motor imagery EEG patterns potentially suitable for control in the circuit of “Brain-computer” or “Brain-to-Brain” systems.

6 Conclusion

This study presents a new method for automatic detection in the spontaneous bioelectric activity of the human brain of specific, invariant patterns of activity associated with the execution of voluntary motor acts by individuals. An adaptive band-pass filter with bandwidth closely matching the spectrum of the desired pre-motor EEG patterns preceding the execution of actual movements was synthesized based on Singular Spectrum Analysis methodology. The preliminary filtering of the original EEG signals provides the required sensitivity for subsequent searching of time boundaries of this pattern in time domain. The search function calculates the Hausdorff distance between two neighboring sliding time windows and reflects the presence of time boundaries of the pattern. If there is an initial or final boundary of the desired pattern in any pair of the neighboring sliding windows, the criterion function acquires its local maximum value.

The correctness of the developed method was confirmed with standard machine learning tools through the validation of the adaptive search method carried out on the general set of initial data. Computational experiments have convincingly demonstrated that the use of the developed method is possible to provide reliable detection of induced pre-motor EEG patterns and the correct determination of their time intervals. Extracting from original EEG signals of those epochs, that containing only the desired pre-motor brain patterns made it possible to increase the accuracy of binary classification for all subjects without exception by 29% on average and reach maximum values of 99% for the right arm and to 100% for the left arm with some subjects.

The developed method can be a reliable tool for solving applied problems of neural control in the BCIs circuit, as well as increasing the overall reliability of Neural interfaces for various purposes. We consider potential brain signals such as movement-related EEG patterns as well as the goals of BCI-based therapeutic applications. These useful BCI applications rely mostly on original and adaptive signal-processing technologies.