Patients
We recruited medically intractable epilepsy patients who needed intracranial electrodes for localizing the seizure onset zone and for functional mapping. The experiment involved a total of 22 patients (11 females; age range, 21-49 years). However, four datasets were excluded from the analysis due to technical issues when recording the neural signals. Also, one of the remaining subjects failed to perform ME properly due to arm weakness, causing the data from this additional patient to be excluded (Figure 1). Subdural ECoG electrodes were used as strips and/or grids (Ad-tech Medical Instrument, Racine, WI, USA) and high-density grids (PMT Corporation, Chanhassen, MN, USA). The locations of the electrodes were purely determined for clinical purposes and are illustrated in Figure 2. ECoG electrodes were implanted for 8.2 ± .4 days and the experiment were performed once, except for S1, S4, S8, and S10, who participated twice. The average task time for the experiment was 42.3±7.5 minutes. For each patient, preoperative MR images and postoperative computed tomgraphy (CT) images were acquired. Co-registrations between preoperative MRI and postoperative CT images for localization of ECoG electrodes were performed semi-automatically using CURRY software (version 7.0; Compumedics Neuroscan).
This study was performed under the Declaration of Helsinki and was approved by the Institutional Review Board (IRB) of Seoul National University Hospital (1403-093-566). All patients provided written informed consent before participating. Table 1 contains demographic and clinical information for all 17 patients. All of them were right-handed, and all electrode arrays were located in the unilateral hemisphere.
Instructions and Tasks
The patients performed three-dimensional center-out reach-and-grasp tasks. Patients moved their arm contralateral to the implantation sites. The task comprises ME and MI. Each trial consisted of a cue, reaching, grasping, and return periods. Before the task, the patients had to position in the initial status, referring to the positioning of the patient's hand in front of their abdomen (see Figures 3A and 3B). In the cue period, the experimenter presented a target ball in one of the four directions to the patients. The position of the target was the corner of a square, and the center of the square was the position of the hand in the initial status. Patients were instructed to move their arm as far as possible toward the target. This was done to elicit the greatest difference in movement that the subject could make with his/her arms. The target position was slightly different despite the fact that it was in the same quadrant because the experimenter presented the target at every trial. After the cue period, the patient reached the target ball and when they completely reached the target, they grasped around the target. This occurred because the experimenter presented the target outside of the range of where the patient could reach and grasp while sitting. They then returned to their initial status in the grasped state. They released their grasp when they completely reached the initial status (Figure 3C). After the movement task, the patients performed an imagery task. From the initial status, after the experimenter presented the target ball, the patients were asked to perform kinesthetic imagery by feeling the somatosensations of the prior movement. In the imagery task, the target direction was identical to that in the previous execution task because motor imagery is difficult to perform without any prior sensory stimuli 21,22. The four directions of the target were presented in a random order. A block consists of an execution trial and an imagery trial. One session was composed of several blocks. The number of trials for each subject is illustrated in Table 1. For subject 1 and subject 3, the ME task was performed more frequently. All experiments were recorded on video to monitor the task performance of the patients.
Electrophysiological Recordings and Preprocessing
ECoG data were recorded with a 128-channel amplifier system (Neuroscan synamps2, Compumedics, Abbotsford, Victoria, Australia). The movements of the arm and hand were tracked by a motion-capture system with an active optical marker. Six markers were fixed to the patients’ arms and hands, contralateral to the implanted hemisphere (3D investigator, Northern Digital Inc., Waterloo, Ontario, Canada) during the neural signal recording process. The sampling frequency was 2,000Hz for the ECoG. Kinematic data were sampled at 100Hz and were synchronized with ECoG signals. We delivered a 5 V input simultaneously to all devices before starting the sessions to synchronize the ECoG amplifier and the motion tracker (i.e., through the transistor-transistor logic (TTL) port of the ECoG amplifier and the external trigger port of the 3D investigator amplifier). In the imagery trials, because it was impossible to find the exact onset time, the experimenter noted only the target presentation time. The common average reference (CAR) was used to re-reference the recorded data. To remove power noise at 60 Hz and the related harmonics, the signals were notch-filtered with a finite impulse response (FIR) filter using the eegfilt function in the EEGLAB toolbox 23. We used splitters and Y-shaped connectors, allowing us to send signal copies of voltage traces to the clinical amplifier so as not to interrupt the clinical monitoring process.
Decoding Algorithms
We used a simple regression algorithm from the published literature 24. Briefly, low-frequency ECoG signals (0.5-8 Hz) were used to predict the movement velocity. Velocity predictions were selected because it is known that velocity provides higher performance than position and acceleration 25. We chose a low frequency because the low frequency band shows the highest performance 26. We analyzed low frequency bands as in our previous papers 24,27. The signals resampled at an interval of 12ms were used to estimate the current movement velocity 28. We also estimated the current movement velocity using the current time point plus the corresponding 20 previous time points (for a total of 21 points) corresponding to 252ms intervals 28. These 21 points for all channels were used as features; also, the x, y, and z velocities of the movements were estimated using a multiple linear regression method, as follows:

Evaluation of the prediction performance
We calculated the correlation coefficients using five-fold cross-validation. This method separates the data into four-fifths for training and one-fifth for testing 29. Therefore, five combinations of training and testing data were available. Weight parameters were obtained using the training data, and the correlation coefficients of the estimations were evaluated using the testing data by calculating the Pearson’s correlation coefficients (r) between the real and predicted movement trajectories for each cross-validation fold. The correlation coefficients were averaged throughout the cross-validation folds.
Trajectories of Arm Movements
To visualize the trajectories of the real and predicted arm movements, we compute the position by integrating the actual velocity and the predicted velocity, respectively. Given that the motion tracker measures the position data, we differentiated the position data to calculate the velocity. The initial status was set to zero when visualizing the results. We illustrated the trajectories only during reaching movements. Because the patients did not move under the MI condition, the averaged trajectory of ME was used as the MI trajectory in each case when training the weights for the MI condition (Figure 4C).