*3.2. Proposed Approach*

Description of proposed approach is depicted in Figure 2. Clusters *lef t* and *right* are separated in *trials*, from *trial*<sup>1</sup> to *trialN*. Each trial is preprocessed using a BSS algorithm, which generates equal number of estimated sources **s** (*t*) from the input channels **x**(*t*). These sources were sorted using as criterion the correlation between their spectral components and the MRIC. This procedure helps to separate the sources and the unwanted artifacts that have low correlations with MRIC. Sorted trials of **s** (*t*) are passed through a CWT block The CWT is obtained using generalized Morse wavelets. Analytic wavelets are complex-valued wavelets whose Fourier transforms are supported only on the positive real axis. They are useful for analyzing modulated signals, which are signals with time-varying amplitude and frequency [44]. The window size of each CWT is 1.0 s, each window is computed using steps of 0.25 s. CNN architecture has as input the CWT figures and finally a fully connected Multilayer Perceptron (MLP) separates into two classes, *right hand MI* and *right foot MI*. In Figure 3a is shown the CWT of a single estimated source **s <sup>1</sup>**, in Figure 3b is shown an example of input containing all estimated sources stacked along *y* axis. Each figure is re-scaled to a size of 128 × 256.

**Figure 2.** Proposed methodology. The left and right channels are prepossessed using a BSS algorithm, the MRIC sorts the estimated sources, in the CWT stage the images for each time window are obtained, finally the CNN separates the classes.

**Figure 3.** CWT maps for (**a**) one estimated source; (**b**) CWT stacked maps for left and right estimated sources.

An example of CNN architecture is depicted in Figure 4. Each CWT input images are passed through the CNN architecture. Two convolutional layers with respective max-pooling are responsible for obtaining descriptors from CWT maps. In the third layer, the matrices are flattened and passed through a dense layer. Finally, an output layer composed of two neurons is the classifier for two MI classes.

**Figure 4.** Scheme of CNN architecture used. The CWT input images are pass through two convolutional layers with respective max-pooling. The matrices are flattened and passed by a dense layer.

#### *3.3. Experiment Setup*

The experiments were conducted on an Intel Core(TM) i7-7700HQ 2.80 GHz with 16 GB of RAM. Matlab 2017 was used to compute fastICA [38] and CWT maps, while python Tensorflow and Keras libraries were used to compute the CNN architecture.
