Wildtype WIK larvae were used for behavioral experiments; for reticulospinal imaging, nacre fish on a WIK background were used; for two-photon imaging, nacre fish expressing GCaMP2 under control of the elavl330 (link),20 (link) promoter were used (previously known as HuC), again on a WIK background. All experiments were approved by Harvard University’s Standing Committee on the Use of Animals in Research and Training. Zebrafish larvae ages 6 to 7 dpf were anesthetized with MS222 and paralyzed by injection with a 1mg/ml bungarotoxin solution (Sigma-Aldrich), then suspended from structural pipettes (Suppl. Fig. S3), or embedded in agarose after which the agarose around the tail was removed. Motor nerve recordings were made with a Multiclamp 700B amplifier, simultaneously with two-photon imaging. Experiments were done at room temperature in filtered facility fish water. Visual scenes were projected onto a diffusive screen underneath the petri dish containing the fish via a mini projector, whose light source was replaced by a red Luxeon Rebel LED that was pulsed in synchrony with the fast scan mirror, so that illumination only occurred at the edges of the image where the scan mirror changed direction (typically at 800 Hz) to avoid any corruption of the two-photon images. Visual scenes consisted of square gratings with spatial period 12mm moving at 1cm/s from tail to head in the absence of motor nerve signals (−1 cm/s). When the processed swim signal was above an automatically set threshold (see Suppl. Meth. 1.3 and Suppl. Fig. S2), the locomotor drive was defined as the area underneath the curve of the processed swim signal during the current and previous video frame. The processed swim signal was defined to be the standard deviation of the raw swim signal in a sliding window of 15ms (see Fig. 1d). In the presence of such motor nerve signals, the instantaneous virtual fish velocity was set, 60 times per second (at the rate of the 60Hz projector), to −1cm/s + [gain] × [instantaneous locomotor drive], where the gain was set experimentally, after which the velocity decayed back to −1cm/s at a rate of 15cm/s2, approximately matched to freely swimming fish dynamics (Supplementary figure S1). The high gain was chosen to be two to five times higher than the low gain and these values bracketed the ‘natural’ gain setting that described the transformation of motor activity into optic flow in a freely swimming fish. The high- and low-gain settings were manually adjusted for each fish, as different fish showed different ranges of adaptability. Some fish exhibited a transient increase in fictive motor output followed by a decrease after a gain-down change; these fish were discarded from the gain-down dataset because transient neural activity could not be distinguished from motor-related activity (rejection criterion: p < 0.03, paired t-test on fictive signal averages over seconds 0-15 versus averages over seconds 15-30 after gain-down change).