(a) Example of a continuous sequence of locomotion (20 s) during brain-controlled flexion and extension stimulation in an intact monkey (Q2, pre-lesion session 2, Extended Table 2). Conventions are the same as in Figure 3. The real-time decoder correctly detected the succession of 22 foot off and foot strike motor states occurring in this sequence (vertical dotted lines), and appropriately triggered the relevant stimulation protocols throughout the locomotor sequence. (b) Histograms showing the distribution of the temporal differences between the actual occurrence of foot off and foot strike events and the decoded occurrence of these motor states for all the recording sessions of the tested intact monkeys (Q1, Q2). The dotted lines indicate the median for each distribution. For the monkey Q1, the decoders were calibrated using recordings without stimulation only. For the monkey Q2, we improved the accuracy of the decoders by performing the calibration twice. First, the decoders were recalibrated using recordings without stimulation. These decoders were used to collect recordings during brain-controlled flexion or brain-controlled extension independently. New decoders were then calibrated using all the combined recording blocks together. (c) Confusion matrices reporting the accuracy of the real-time decoders without stimulation and during brain-controlled stimulation, given a tolerance window or ±125ms. The bar plots report the normalized mutual information calculated for the real-time decoders compared to random decoders and chance level decoders. Random decoders were the same decoders calibrated using shuffled gait events. The chance level decoders randomly assigned motor states with chance level probabilities, which were estimated from the data used to calibrate the online decoders, and at the same rate as the online decoders. (d) Two examples of recordings collected while monkey Q1 and Q2 initiated or terminated sequences of continuous locomotion on a treadmill. The green shaded area indicates the period during which the treadmill was turned off. The brain-spinal interface was kept on throughout the recordings. Conventions are the same as in Figure 3. Probability of foot strike and foot off motor states remained low during the periods of rest, and recommenced to modulate with the occurrence of motor states when the monkey resumed continuous locomotion. The decoder confusion matrices were calculated during brain-controlled stimulation across all the sessions with intact monkeys during which the treadmill was turned off (n = 345 and n = 127 temporal windows for Q1 and Q2). False positive detections were rare.