The institutional review board 06-03 of the ethics comittee (Comité de Protection des Personnes Ile de France 06) gave its approval for the study, which was considered as non invasive.
For patients with REM sleep behavior disorder and sleepwalkers, the cognitive test was proposed to the subjects before and after a normal videopolysomnograpy procedure, scheduled for diagnosing their disease. Hence it was considered as a minor, non invasive deviation of routine clinical care in these diseases by the ethics committee, requiring an oral consent of the patient (the collection of the oral consent was consigned in the medical file by the physician in charge). As for healthy subjects, a written informed consent was obtained.
The patient and the healthy control who appear in the Video S1
and in the Figures have seen this manuscript and have provided written consent for publication in a scientific journal.
A total of 20 patients with REM sleep behavior disorder (mean age 66.5±6.5 years; 16 males, 4 females), 19 sleepwalking patients (mean age 34.4±15.4 years; 6 males, 13 females), and 18 healthy controls (mean age 57.9±5.3 years; 14 males, 4 females) took part in this study. As expected from these pathologies, the population of sleepwalkers was younger than the population of REM sleep behavior disorder patients (p<0.001). We also tested a group of healthy controls whose mean age would lie between those of the patient groups. It is important to note that the inclusion of the control group mainly serves to confirm that the sequence of ample movements could be learned equally by all these distinct populations. The critical measures of learning involve within-subject comparisons, while differences in mean reaction-times due to age are expected but not relevant here.
REM sleep behavior disorder was defined according to standard criteria 
, including i) a positive clinical history (bed partners reporting most often violent, purposeful limb or body movements, as if the patients were acting out their dreams), and ii) the presence of abnormally enhanced chin or phasic muscle tone and/or complex and non-stereotyped movements (such as gesturing, reaching, grabbing, punching, kicking, talking, laughing, running, chewing, feeding, drinking) during REM sleep on video sleep recording. In the sleep behavior disorder group, 13 patients had idiopathic REM sleep behavior disorder and 7 patients had Parkinson disease, with a mild to moderate motor disability (Hoehn and Yahr score between I and III) 
, which did not impact their daily activities, and no dementia (Mini-Mental State Examination score higher than 23) 
Sleepwalking was defined according to clinical international criteria 
, plus at least one arousal during slow-wave sleep associated with a motor episode suggestive of surprise, confusion, or fear (startle response, sitting up in the bed, looking around surprised), or numerous sudden arousals during slow-wave sleep and no epilepsy or sleep-disordered breathing. We included in the study primary sleepwalking patients, without any pre-existent psychiatric and/or neurological illness.
Subjects were informed that we tested their performance in the task execution, but they were not aware of the regularity of the trained sequence, nor that we expected a potential replay during sleep.
All participants gave informed consent to participate in this study, which was approved by the local ethics committee. Healthy volunteers (but not the patients) were paid for their participation.
Behavioral task and experimental procedure
The subjects were trained on a modified version of the serial reaction time task 
, which was previously shown to elicit sleep-related performance improvement 
. Instead of requiring finger movements, the present task involved large hand, forearm and arm movements that would be clearly visible on the video recorded during sleep. Note that twitches of finger muscles are extremely frequent during normal REM sleep, and even more during REM sleep behavior disorder 
, so that a replay of learned fingers movements could not be easily distinguished from multiple and non-specific twitches during the REM sleep.
The subjects sat comfortably facing the computer screen; they were asked to react as quickly and accurately as possible when a large, colored rectangle appeared on the screen by pressing the corresponding colored response button (e.g., when the rectangle on the screen was green, the subject had to press the green button). The four response buttons were attributed four different colors (red, yellow, blue, or green) and were placed at different spatial localizations, as shown in . The subjects were asked to use their left hand for the blue and green buttons and their right hand for the red and yellow buttons so that all participants carried out the same sequence of movements, including movements crossing the midline (see Video S1
Each correct response was immediately followed by the presentation of the next stimulus on the screen, thus eliciting a new response, and so on. If the subject failed to press the appropriate button, visual (a white rectangle) and auditory (a simple beep) feedback were simultaneously delivered followed by the presentation of the next visual stimulus. We used E-Prime (Psychology Software Tools, Inc.) for stimulus presentation and response recordings.
The subjects were intensively trained on a fixed 8-item sequence (Blue-Yellow-Green-Red-Yellow-Blue-Red-Green) and were not informed about the regularity of the sequence. To distinguish between structured sequence learning and improvement in visuomotor responses independent of the sequence, a random sequence was also presented. Like the structured sequence, the random sequence was composed of two series of four colors, in which each of the four buttons was pressed once, but in a completely random order. Because each color appeared twice in each eight-item sequence of the random condition, only the order of the colors was altered between the random and the structured conditions. Subject performance was quantified by measuring reaction time and response accuracy (correct hand and correct button use).
We developed this version of the serial reaction time task optimize the detection of spontaneous replay during a subsequent REM sleep behavior or a sleepwalking episode. In particular, the task involved ample movements, with the response buttons placed about 50 cm apart in the peripersonal space, and the movements executed during the task were unusual as compared to the behaviors generally observed during parasomnia episodes (our task included pronating forearm and flexing hand movements, as well as arms crossing the midline). Video S1
shows the sequence performed by a healthy control subject during a training session and, after acquisition, while lying in a bed and performing the sequence from memory to facilitate later visual comparison with any potential replay during sleep.
The experimental procedure consisted of a training session at 6 pm and an initial test session at 8 pm, followed by a night of sleep. The training session consisted of four consecutive blocks of structured sequences (10 sequences in each block, 80 trials per block). The initial test session consisted of four such blocks and one additional block of random sequences placed in the middle of the session (third block of the five-block session). The following morning, the subjects were retested at 9 am with the same series of blocks as during the initial test session. In this protocol, each subject performed a total of 1,120 trials.
On the morning immediately after awakening from sleep and before the test session, the participants were asked about their night dreams the previous night. A summary of the experimental procedure is provided in .
Sleep and nocturnal behavior monitoring
All subjects underwent video and sleep monitoring during the night immediately following the training; 7 sleepwalkers and 7 patients with REM sleep behavior disorder were recorded over two consecutive nights, with no additional training or retesting in between the two nights. Scalp electroencephalography included three bipolar channels for the patients with REM sleep behavior disorder and the controls (Fp1/Cz, O2/Cz, C3/A2) and eight bipolar channels for sleepwalkers (FP1/C3, C3/O1, C3/T3, T3/O1, FP2/C4, C4/O2, C4/T4, T4/O2) to exclude nocturnal frontal lobe epilepsy. Monitoring also included EEG-synchronized infrared video-monitoring and sound recording in the room (Brainet®, Medatec Ltd, France), a right and left electro-oculogram, submentalis and tibialis anterior muscle electromyogram, nasal pressure through a cannula, tracheal sound recording through a microphone placed at the surface of the trachea, thoracic and abdominal strain jauges to assess respiratory efforts, electrocardiography, and pulse oximetry. Sleep stages, EEG arousals, muscle activity, periodic leg movements and respiratory events were scored by visual inspection of the multimodal recordings, using standard criteria 
, by two independent and experienced scorers.
Statistical analyses of motor performance
Statistical analyses of behavioral measurements were performed using Statistical Package for Social Sciences (SPSS Inc, Chicago, IL, USA). For each of the three groups of subjects (sleepwalking group, REM sleep behavior disorder patients group and control group) we performed a repeated-measures ANOVA with sessions (training, testing) and type of sequence (structured, random) as factors. For the type of sequence factor, we selected the random block and the structured block performed just afterwards, because they were close in time (respectively block 3 and block 4), which was important given the fatigability of some of the patients. The selected blocks were also contextually very similar (both blocks implied a switch of sequence type, from structured to random and from random to structured sequence). In these analyses, we considered each group separately because the subjects in the different groups were not matched for age (e.g., REM sleep behavior disorder patients were significantly older and had significantly slower reaction times than the sleepwalkers, as expected in these disorders) and because the goal of these analyses was to test for sequence-specific learning by comparing change in performance for the structured sequence and for the random sequence between the pre-sleep and post-sleep testing sessions.
Assessment of sequence replay during sleep
To confirm the putative replay of a fragment of the sequence observed in one sleepwalker (see Results
), we asked 11 independent judges blind to the aim of the experiment to assess resemblance of 113 video clips of sleepwalking episodes with a video showing an awake subject performing the task from memory while lying in a bed, in the same recording conditions as the patients (Video S1
). For each video clip, the judges were asked six questions concerning the sleepwalking episode (see Text S1
), including a final assessment of the resemblance of sleepwalking movements with the movements performed by the awake subject on a scale from 0 (no resemblance at all) to 10 (identical movement sequence).
Note that because we did not observe any sign of replay in the REM sleep behavior disorder, a similar procedure was not used with REM sleep behavior disorder episodes.