Abstract
Animals must adapt their behavior to survive in a changing environment. Behavioral adaptations can be evoked by two mechanisms: feedback control and internal-model-based control. Feedback controllers can maintain the sensory state of the animal at a desired level under different environmental conditions. In turn, internal models learn the relationship between behavior and resulting sensory consequences in order to modify the behavior when this relationship changes. Here, we present multiple perturbations in visual feedback to larval zebrafish performing the optomotor response and show that they react to these perturbations through a feedback control mechanism. In contrast, if a perturbation is long-lasting, fish adapt their behavior by updating a cerebellum-dependent internal model. We use modelling and functional imaging to show that neuronal requirements for these mechanisms are met in the larval zebrafish brain. Our results illustrate the role of the cerebellum in encoding internal models and how these can calibrate neuronal circuits involved in reactive behaviors depending on the interactions between animal and environment.
Highlights
Behavioral reactions to unexpected changes in visual feedback are implemented by a feedback control mechanism
A long-lasting change in visual feedback updates the state of the neuronal controller
The cerebellar internal model mediates this recalibration
Introduction
The interaction between animals and their surroundings changes constantly, due to changes in the environment or processes such as development, growth or injury, which modify the body plant of the animal. Nevertheless, precise behavior is so important that evolution has provided animals with mechanisms to produce successful behavior in these changing conditions. The task of adapting behavior to the changing environment can be solved in two ways. One way is to react to these changes through a feedback control mechanism, which ensures that the goal of a behavioral act is achieved under a variety of conditions. A second option is for the animal to learn the new environmental conditions and adjust its behavioral program in the long-term. This second mechanism is only possible if the change in conditions lasts and can therefore be predicted.
Many stimulus-driven behaviors result in the effective cancellation of the stimulus that evoked them. Examples include the optokinetic reflex (OKR) 1, in which retinal slip evokes eye motion that sets this slip to zero. If the stimulus is monitored constantly, a feedback control loop with well-tuned parameters may provide an appropriate mechanism for performing the task of setting the stimulus to zero 2. This happens online, so feedback controllers are limited by the time delay required for sensory processing, which in the case of visual feedback is estimated to be between 100 to 300 ms 3–7. If the processing of sensory information is long with respect to the duration of the motor action, the current state of the body will change dramatically by the time the feedback signal starts to influence the motor command. As a result, the feedback signal will implement an inappropriate correction based on out-of-date sensory information 8.
To overcome this limitation of feedback motor control, the brain can encode internal models of different parts of the body and/or of different aspects of the external world 9–11. These models monitor the sensorimotor transformation performed by a motor plant and learn a forward or an inverse transfer function of this transformation either to predict sensory consequences of a motor command (forward models) or to provide an appropriate feedforward command to reach a desired sensory state (inverse models). If the transfer function changes in a long-term manner, the model updates, leading to motor learning. It is widely believed that internal models for motor control exist in the central nervous system and that in vertebrates, the cerebellum plays a major role in encoding them 8, 12–16.
In this study, we investigate the interplay between feedback controllers and internal models and the role of the cerebellum in encoding them. We make use of the larval zebrafish optomotor response (OMR) 17, a behavior shared by many animals 18, 19, by which they turn and move in the direction of perceived whole-field visual motion. The OMR can be defined in terms of a feedback control mechanism as a locomotor behavior that tries to set the optic flow to zero, thus stabilizing the animal with respect to its visual environment; in this framework, the OMR is similar to the OKR as both of these behaviors effectively cancel the stimulus that evoked them.
As larvae, zebrafish swim in bouts that comprise several full tail oscillations and last around 350 ms, separated by quiescent periods called interbouts 20. When zebrafish, or any other animal, move forward, they experience the visual scene coming towards them. Previous work has shown that larval zebrafish swimming in a closed-loop experimental assay react to perturbations in this visual feedback 21–23. Specifically, if a larva receives less feedback than normally, it tries to compensate for this lack of feedback by increasing its bout duration. This reaction happens on the time scale of individual bouts 21, so we call this phenomenon “acute reaction”. A hypothesized mechanism of acute reaction is that fish use an internal representation of expected sensory feedback, and if the actual feedback does not meet this expectation, they adapt their behavior to minimize this discrepancy 21. This postulates that fish use forward internal models to compute predicted sensory feedback from motor commands during acute reaction. In a subsequent study, it was further proposed that these predictive computations take place in the cerebellum 22.
Here, we employ behavioral tests, modelling and loss-of-function experiments to demonstrate that acute reaction to unexpected perturbations can be implemented without internal models by a simple feedback controller. The state of this feedback controller can be adjusted if the animal experiences a long-lasting and therefore predictable perturbation in sensory feedback. Crucially, an intact cerebellum was necessary for this recalibration but not for the functioning of the feedback controller itself. We used functional imaging in animals performing adaptive optomotor locomotion to determine whether neuronal requirements of this hypothesis are met in the larval zebrafish brain. Our results illustrate the role of the cerebellum in encoding internal models, which can calibrate existing neuronal circuits according to predictable features of the environment.
Results
Unexpected perturbations in visual reafference result in acute behavioral reaction
When an animal, such as larval zebrafish, moves in a given direction, it naturally experiences optic flow in the opposite direction (Fig. 1a). We will refer to the swimming-elicited velocity of the optic flow as visual reafference (Fig. 1b). To investigate how perturbations in visual reafference affect ongoing behavior, we took advantage of the previously developed closed-loop experimental assay 21, 22 (Fig. 1c). In this assay, head-restrained zebrafish larvae swim in response to a forward moving grating, a behavior known as the OMR. A high-speed camera captures this behavior, and the fictive larvae velocity is inferred from the tail motion (see Closed-loop experimental assay in head-restrained zebrafish larvae in Methods). To provide fish with visual reafference, this estimated velocity can be subtracted from the initial stimulus velocity such that the larvae experience the sensory consequences of their own swimming (Fig. 1c-d). Importantly, the transformation that determines how estimated swimming velocity translates to reafference is under experimental control, which allows us to introduce perturbations in reafference and to study how the animals react to these perturbations.
In the first set of experiments we aimed to characterize acute reactions of zebrafish larvae to a variety of different perturbations and to determine whether these reactions can result from a feedback control mechanism. We used three distinct perturbations in reafference to probe the space of possible behavioral reactions (Fig. 2a). The first reafference condition, which has been previously used 21, 22, we call gain change and corresponds to changing the gain of the experimental closed-loop, such that larvae receive more or less visual reafference upon swimming (Fig. 2ai). Note that a gain of 0 corresponds to open-loop and a gain of 1 to the freely-swimming condition, referred hereafter as the normal reafference condition (respectively, red and blue vertical bars in Fig. 2a). The gain change tests how behavior depends on the amount of reafference that larvae receive upon swimming (e.g. covered distance or reached velocity). The second condition we call lag, and corresponds to introducing an artificial temporal delay between the behavior of the larva and the reafference it experiences (Fig. 2aii). In the shunted lag version of this condition, the reafference is set to zero when the larvae stop swimming (Fig. 2aii, bottom). The lag tests how behavior depends on the temporal relationship between the bout and its related reafference. The final reafference condition, gain drop, corresponds to dividing the first 300 ms of a bout into four 75 ms segments and setting the visual reafference to zero during one or more of these segments (Fig. 2aiii). The gain drop tests whether perturbations in reafference lead to the same behavioral reactions regardless of when they occur within the bout.
Individual wild-type larvae were exposed to 15-second trials during which a grating moved in a caudal to rostral direction at 10 mm/s (Fig. 1d). Larvae responded by performing swimming bouts and the reafference conditions were randomized on a bout-by-bout basis. Perturbation-induced changes in bout and subsequent interbout duration are presented in Fig. 2c-d (black data points).
For all types of reafference conditions, the bout duration increased when the overall reafference was less than normal (Fig. 2c). This was particularly noticeable for the very low gains 0 and 0.33 (Fig. 2ci), under the lag and shunted lag conditions (Fig. 2cii-ciii) and under the gain drop conditions where more than one bout segment had gain 0 (Fig. 2civ). Interestingly, the observed increase in bout duration was close to linear as a function of the lag and, as expected, it did not show a significant difference between the lag and shunted lag cases, as these two conditions were identical during the bout (Fig. 2aii). Finally, under the gain drop condition, the mean bout duration was differentially prolonged depending on what bout segment had a perturbed reafference. Overall, a segment with a gain of 0 had a larger effect on increasing the bout duration the earlier it occurred within the bout: compare for example the cases for gain profiles 0111 and 1110 (gray triangles in Fig. 2civ).
The effects on the interbout duration are displayed in Fig. 2d. Decreasing the gain initially resulted in shorter interbouts (gain 0.66 - 2) although further decreases reversed this tendency to the extent that interbouts at gain 0 were longer than those at gain 1 (Fig. 2di). Under the lag conditions, the mean interbout duration increased with longer lag in the non-shunted setting only (Fig. 2dii-diii). This demonstrates that the duration of a bout and a subsequent interbout can be independently influenced by different aspects of the reafference. Explicitly, insufficient reafference in the beginning of the bout, present in both lag settings (red triangles in Fig. 2aiii), increases the bout duration (Fig. 2cii-ciii), whereas excessive reafference after the bout end, only present in a non-shunted lag setting (blue triangle in Fig. 2aii), lengthens the interbouts (Fig. 2dii). Under the gain drop conditions, the interbout duration decreased if the preceding bout had a gain drop (Fig. 2div). In contrast with the results for mean bout duration, interbouts were affected more when the gain was dropped in segments closer to the end of the bout: compare for example the cases for gain profiles 0011 and 1100 (gray triangles in Fig. 2div).
In summary, these results demonstrate that larval zebrafish acutely react to unexpected perturbations in visual reafference in an intricate way. Bout duration is prolonged if the reafference is insufficient or delayed compared to the normal reafference condition, and reafference during the early segments of swimming bouts has more influence over the bout duration. On the other hand, larvae prolong the interbout duration if they receive excessive reafference during or after the preceding bout, with reafference during late bout segments having more influence.
Acute reaction is implemented after a sensory processing delay
We hypothesized that this acute reaction is implemented by a feedback controller, which must rely on a relatively slow measurement of the controlled variable (see Introduction). Therefore, this acute reaction should be implemented only after a sensory processing delay. To identify the time that larval zebrafish need to react to unexpected perturbations in reafference, we analyzed the temporal dynamics of the tail beat amplitude in the form of bout power within individual bouts in different reafference conditions (Fig. 2e; see Behavioral data analysis in Methods for details).
Comparing the mean bout power profiles across different reafference conditions revealed that, when the reafference was perturbed from the very beginning of a bout (as in gain change, lag and shunted lag conditions), larvae reacted by increasing the tail-beat amplitude only 220 ms after the bout onset (Fig. 2ei-eiii). However, if the change in the reafference was introduced once the bout had already started (as in the gain drop condition with gain profiles 1000, 1100), the deviation in the respective mean bout power was observed only around 220 ms after the start of the perturbation (blue triangles in Fig. 2eiv).
We conclude that larval zebrafish react to perturbations in visual reafference with a delay of 220 ms. This result prompted us to define two periods within bouts: an initial stereotyped ballistic period lasting 220 ms and a subsequent reactive period. An unexpected change in reafference condition (regardless of whether the change occurs during the ballistic or the reactive period), can only affect the tail-beat amplitude during the reactive period (Fig. 2e). Such a prominent sensory processing delay suggests that the OMR is implemented by a feedback controller. Finally, we note that the delay duration is consistent with processing time of visual feedback information in other species 3–7.
Acute reaction can be implemented by a feedback controller that integrates the optic flow
To confirm that acute reaction is implemented by a feedback controller, we took a simulation approach, which involved designing such a controller and testing its performance under the aforementioned perturbations in reafference.
The main rationale of the designed model derives from the definition of the OMR in terms a feedback control mechanism, as a locomotor behavior that tries to keep perceived optic flow at zero. If optic flow is constant, an animal moving in discrete bouts cannot achieve this goal at all possible points in time. Instead, it can stabilize its position on average by integrating the optic flow in time, estimating displacement with respect to the visual environment over a time window and performing bouts whenever the integrated signal reaches a threshold.
Following this reasoning, we designed a feedback controller consisting of three parts: a sensory part, a sensory integration part and a motor output generation part (Fig. 2b). The sensory part instantaneously combines forward and backward grating velocity with independent excitatory and inhibitory weights, respectively. This weighted sensory input is then integrated in time by a velocity integrator. The output of this integrator can be interpreted as a metric of motivation to swim, which we refer to as sensory drive. This sensory drive is then fed into a motor output generator that produces a motor command when it reaches a threshold. As zebrafish larvae swim in discrete bouts, the model contains a motor integrator that inhibits the motor output generator and eventually leads to the termination of the bout. The output of the motor integrator can be interpreted as a metric of tiredness that ensures that bouts have finite length even when the sensory drive to continue swimming is very high. Finally, to ensure that bouts last for some minimum time once started in cases when the sensory drive becomes low immediately after bout onset (for example, if the gain of the closed-loop is very high and the fish receives a lot of reafference), we introduced a self-excitation loop to the motor output command generator (see Feedback control model of acute reaction in Methods for further details; see also Extended Data Fig. 1 for formal mathematical description of the model).
Using cross-validation, we fit the model with a set of parameters such that it generated bouts and interbouts of realistic duration in response to forward moving grating in the normal reafference condition (Extended Data Fig. 1). Furthermore, the behavior of the model under different perturbations in reafference reproduced the findings presented in Fig. 2c-d, including the increased motor output in response to decreased or delayed reafference, the difference in reaction of interbout duration to shunted and non-shunted lags, and different reactions under the gain drop condition depending on which bout segment had a perturbed reafference (Fig. 2b-d, cyan data points). Therefore, acute reaction to perturbed reafference can be implemented by a feedback control mechanism that relies solely on temporal integration of the optic flow.
Larval zebrafish are able to integrate the optic flow
To test the main assumption of this model, namely, the existence of the velocity integration in the larval zebrafish brain, and to gain some further insight into the model, we performed whole-brain functional imaging in head-restrained larvae expressing GCaMP6s in all neurons 24, while they were performing the OMR in a custom-built light-sheet microscope (Fig. 3a).
After segmenting the imaged brains (Fig. 3b) into regions of interest (ROIs, N = 24677 ± 4811, mean ± s.e.m. across 6 imaged larvae) (see Functional imaging data analysis in Methods for details), we observed ROIs that increased their fluorescence at the onset of the moving grating (sensory ROIs; see gray triangle in Fig. 3c) or when the larvae were performing bouts (motor ROIs; see black triangle in Fig. 3c). Analysis of the mean grating- or bout-triggered fluorescence (Fig. 3d-e) revealed that the activity of a large fraction of detected ROIs was either sensory-, or motor-related (respectively, 36 ± 5 % and 40 ± 4 %, mean ± s.e.m. across imaged larvae, N = 6). Motor ROIs were located predominantly in the hindbrain and in the nucleus of the medial longitudinal fascicle in the midbrain, and sensory ROIs were mostly present in the hindbrain, midbrain and diencephalic regions, including the inferior olive, dorsal raphe and surrounding reticular formation, optic tectum, pretectum, and thalamus (Fig. 3f, see also Extended Data Fig. 2 for anatomical reference).
As one of the main assumptions of the model is the existence of stimulus velocity-integrating ROIs, we analyzed the rise time of sensory ROIs (Fig. 3g-i). To identify whether some of these ROIs integrate the stimulus velocity in time, we fitted a leaky integrator model to the grating-triggered average fluorescence of each ROI. The integration time constant was zero for about half of sensory ROIs (56 ± 5 %, mean ± s.e.m. across larvae), indicating that these ROIs did not integrate sensory evidence and could be therefore termed “velocity sensors”. The remaining 44 ± 5 % of sensory ROIs had positive time constants, and we defined these to be “velocity integrators” (Fig. 3g-i). Sensors and integrators were located in distinct brain regions. Sensors were located predominantly in the optic tectum and in the inferior olive, whereas the integrators occupied the dorsal raphe with surrounding reticular formation and aforementioned diencephalic regions (Fig. 3j, see also Extended Data Fig. 2 for anatomical reference). The anatomical location of the ROIs assigned to all aforementioned functional groups was significantly consistent across imaged larvae (Extended Data Fig. 2, see Functional imaging data analysis in Methods for details).
We conclude that certain regions of the larval zebrafish brain (dorsal raphe, pretectum, and thalamus) integrate the velocity of the moving grating in time, and could therefore compute the sensory drive that evokes the OMR (as shown also for other experimental paradigms by 25, 26). This provides an important substrate for the feedback controller-based mechanism of acute reaction presented in Fig. 2.
Larval zebrafish adapt their behavior in response to a long-lasting perturbation in visual reafference
We next hypothesized that the role of the cerebellum is to update the state of the neuronal controller of the OMR if the relationship between the behavior and the resulting sensory consequences changes in a consistent and predictable manner and can therefore be captured by an internal model. To test this hypothesis, we first developed a long-term adaptation experimental assay, in which zebrafish larvae performed the OMR and experienced a long-lasting and consistent perturbation in visual reafference. The paradigm consisted of 240 trials that were grouped into four phases: calibration, pre-adaptation, adaptation and post-adaptation (Fig. 4a; see Experimental protocols in Methods for details). Animals were divided into two experimental groups: normal-reafference control and lag-trained. Lag-trained animals received a constantly lagged reafference during the adaptation phase (225 ms non-shunted lag; Fig. 4a, red trace). Importantly, this assay allows to monitor both acute reaction to unexpected perturbation in reafference (immediately after the perturbation is presented to a naïve larva) and potential long-term behavioral changes (after the larvae experiences the perturbation for some time).
We analyzed the duration of first bouts in each trial, as the first bout should not depend on putative short-term sensorimotor memory accumulated during the current trial and should therefore reflect potential long-term changes in the OMR circuitry more clearly than subsequent bouts. As expected, naïve lag-trained larvae acutely reacted to unexpected lag in reafference by increasing their bout duration in the beginning of the adaptation phase (dark-blue arrows in Fig. 4b-d). However, by the end of the adaptation phase, their bout duration returned to the baseline level even though the reafference was still lagged (light-green arrows in Fig. 4b, c, e) and became statistically indistinguishable from the control group that was never exposed to perturbed reafference (Fig. 4e). We refer to this phenotype as the “back-to-baseline effect”, which demonstrates that the circuitry underlying the OMR was recalibrated during long-term exposure to a novel reafference condition. This interpretation is confirmed by a prominent decrease in bout duration of lag-trained animals observed during the post-adaptation phase, referred to as the “after-effect” (orange arrows in Fig. 4b, c, f).
When we analyzed modulation of the tail-beat amplitude within individual bouts during the experiment, we confirmed our previous observations presented in Fig. 2e. Thus, acute reaction to lagged reafference in the beginning of the adaptation phase occurred only after a considerable sensory processing delay (Fig. 4g, i; compare black and dark-blue traces in Fig. 4gii, acute reaction is indicated by magenta arrows). On the other hand, tail-beat amplitude during the initial ballistic period was not modulated during acute reaction (Fig. 4g-h). Since the tail-beat amplitude during the ballistic period does not depend on the current reafference, it can be used as a readout of the homeostatic state of the neuronal controller that determines how forward motion of the grating is transformed into optomotor behavior. If, according to the proposed hypothesis, this state updates during the long-term adaptation, one could expect that the ballistic power would change during the long-term exposure to a novel reafference condition. As expected, we observed that ballistic bout power during the post-adaptation phase was indeed significantly larger than during the pre-adaptation phase (Fig. 4g, compare black and orange traces, increase in ballistic power is indicated by black arrows). Interestingly, this metric of long-term adaptation did not depend on the reafference condition presented during the adaptation phase (Fig. 4j; see Discussion).
These results demonstrate that larval zebrafish are able not only to acutely react to unexpected perturbation in reafference but also to adapt their behavior in the long-term if this perturbation is persistent. The long-term adaptation includes a decrease of bout duration during the adaptation period down to the baseline level and a consequent after-effect. In addition, the tail-beat amplitude during the ballistic period is increased during long-term adaptation.
Long-term adaptation, but not acute reaction, is impaired after PC ablation
Our hypothesis predicts that long-term adaptation depends on cerebellar output, whilst acute reaction is implemented by a cerebellum-independent mechanism. To test this prediction, we generated a transgenic line expressing nitroreductase in all cerebellar Purkinje cells (PCs), which allows targeted pharmaco-genetic ablation of PCs by treating the larvae with metronidazole (Fig. 5a; see Targeted pharmaco-genetic ablation of PCs in Methods for details). Treatment resulted in severe damage of PCs including swelling and destruction of the PC nuclei and aggregation of the neuropil into puncta with complete loss of the characteristic filiform structure (Extended Data Fig. 3).
PC-ablated fish were still able to perform the OMR and to acutely react to perturbations in visual reafference. When we probed the responses of treated and control zebrafish larvae in the acute reaction paradigm (Fig. 2), we found that responses to all the perturbations (gain, lag, shunted lag, gain drop) were not affected by the ablation of PCs (Extended Data Fig. 4). Also when tested in the long-term adaptation paradigm, naïve PC-ablated larvae were still able to react acutely to unexpected lag in the reafference in the beginning of the adaptation phase (blue arrows in Fig. 5b-c). In fact, the magnitude of acute reaction to lag was even higher in PC-ablated larvae compared to the treatment control group (Fig. 5c).
On the other hand, long-term adaptation was significantly impaired after PC ablation. The back-to-baseline effect (light-green arrows in Fig. 5b, d) was absent in PC-ablated lag-trained animals. Thus, by the end of the adaptation phase, their bouts were still significantly longer than in PC-ablated normal-reafference control group (Fig. 5d) and their own bouts during the pre-adaptation phase (Fig. 5bii). Furthermore, the after-effect was also absent in PC-ablated larvae (Fig. 5bii). Although this effect was clearly observed in the treatment control group (orange arrow in Fig. 5b), it was not statistically significant in both groups (Fig. 5e). Finally, the increase in ballistic bout power (black arrow in Fig. 3f) was significantly less prominent in PC-ablated animals compared to the treatment controls (Fig. 5f-g).
Taken together, these results demonstrate that PC ablation impairs only the long-term adaptation to a consistently changed reafference condition, while sparing the OMR itself, as well as acute reaction to unexpected perturbations in reafference. This is consistent with the hypothesis that the neuronal controller involved in reactive optomotor swimming does not require an intact cerebellum for its functioning, but its state can be modulated by a cerebellar internal model.
Activity of a subpopulation of PCs can represent the output of an internal model
After observing that long-term behavioral adaptation to consistently perturbed reafference is a cerebellum-dependent process, we set out to determine whether the output of the cerebellum contains features of a recalibrating internal model. To this end, we performed functional imaging of PC activity in zebrafish larvae expressing GCaMP6s in all PCs 27 while they were performing long-term adaptation in a custom-built light-sheet microscope (Fig. 6a). The experimental protocol was modified from the one described in Fig. 4 by shortening the adaptation phase from 210 trials to 50 trials and prolonging the post-adaptation phase from 10 trials to 50 trials (Fig. 6b). This was done to ensure stable recordings of the PC activity during the whole experiment, and to follow the cell activity for a longer time after the adaptation.
We first divided lag-trained larvae into two groups: adapting and non-adapting (Fig. 6c). Adapting animals were defined based on the magnitude of the back-to-baseline effect as it was the most prominent feature of long-term adaptation: larvae which decreased their bout duration during the adaptation phase by at least 40 ms were considered adapting. We verified that despite the small sample size (8, 8 and 9 larvae in normal-reafference control, lag-trained non-adapting and lag-trained adapting groups, respectively), the shorter adaptation phase and the microscope excitation light, the long-term adaptation effects were still detectable (Extended Data Fig. 5). Lag-trained adapting larvae acutely reacted to presentation of lagged reafference in the beginning of the adaptation phase (blue arrows in Extended Data Fig. 5biii, ci), decreased their bout duration to a level indistinguishable from that of the control group by the end of the adaptation phase (light-green arrows in Extended Data Fig. 5biii, cii), and demonstrated a clear after-effect in the beginning of the post adaptation phase (orange arrow in Extended Data Fig. 5biii, ciii). The after-effect in lag-trained adapting animals was statistically significant only when compared with lag-trained non-adapting larvae (p = 0.03) but not with normal-reafference control group (p = 0.24) (Extended Data Fig. 5ciii) presumably due to small sample size and high variability in bout duration.
After confirming that the long-term adaptation effects were detectable in lag-trained adapting larvae and not in other experimental groups, we turned to analyzing the activity of ROIs in the cerebellum (N = 366 ± 19 ROIs, mean ± s.e.m. across all 25 imaged larvae; see Functional imaging data analysis in Methods for details). The activity of two example ROIs in several trials sampled from different phases of the experiment is presented in Fig. 6di, and their location within the cerebellum is presented in Fig. 6a. We observed that the activity of the vast majority of ROIs was to some extent modulated during swimming bouts (data not shown), so we focused our analysis on first-bout-triggered activity (Fig. 6dii). We first computed the bout-triggered response in each trial by averaging the bout-triggered fluorescence of each ROI in a 1.2-second window after the first bout onset (Fig. 6diii). Then, we measured how much the bout-triggered response changed during four crucial transitions in the experimental protocol by computing the following four criteria for each ROI (Fig. 6div):
Criterion 1: how much the bout-triggered response increased in response to unexpected presentation of lagged reafference to a naïve larva.
Criterion 2: how much the response increased during the adaptation phase, while the lag-trained animals were adapting to a novel reafference condition.
Criterion 3: how much the response increased when the reafference condition was switched back to normal.
Criterion 4: how much the response increased during the post-adaptation phase, while the animals were adapting back to the original reafference condition.
We determined the statistical significance of the computed criteria, which allowed us to assign a 4-digit barcode to each ROI (Fig. 6dv). Each digit corresponds to one of the criteria defined above and can take one of three values: “+” (significant increase of bout-triggered response), “-” (significantly decrease), or “0” (no significant change). We aimed to find activity profiles that were significantly enriched in lag-trained adapting larvae compared to both non-adapting and normal-reafference controls, because these activity profiles might reflect the output of a recalibrating internal model. To this end, we divided all ROIs into distinct clusters based on their barcodes. We found that the only cluster that contained significantly higher fractions of ROIs in lag-trained adapting fish was the 0-0+ cluster (9.4 ± 5.4 % in lag-trained adapting fish versus 0.2 ± 0.2 % in lag-trained non-adapting fish and 1.0 ± 0.3 % in normal-reafference control fish, mean ± s.e.m. across larvae; Fig. 6e).
The bout-triggered responses of these ROIs gradually decreased during the adaptation phase and increased back to the original level during the post-adaptation phase (Fig. 6f). Such an activity profile is similar to the expected output of a putative internal model, which monitors the motor-to-sensory transformation rule and gradually recalibrates if a long-lasting and therefore learnable change in this rule occurs. Furthermore, we were able to show that the activity of this cluster could not result from changes in motor activity throughout the experiment (see Functional imaging data analysis in Methods) and therefore rather reflect the output of a recalibrating internal model. ROIs belonging to this functional cluster were distributed within the cerebellum without apparent spatial organization (Extended Data Fig. 7).
Discussion
Feedback control mechanism drives acute reaction
In this study, we propose that the OMR and its acute reactions to unexpected perturbations in reafference are implemented by a feedback control mechanism. This contradicts the previously proposed internal-model-based mechanism suggesting that fish use an internal representation of expected reafference and adapt their behavior if the actual reafference does not meet this expectation 21–23. In those studies, the behavioral changes in response to perturbed reafference were termed “adaptive locomotion”, highlighting that larvae actually adapt their behavior when they experience a sudden unexpected perturbation. The term “adaptation” implies that something in the brain has changed during this process. Here, we use the term “reactive locomotion” to emphasize that we believe these behavioral changes represent reactions of a simple feedback controller without any changes in the underlying circuitry.
The proposed mechanism represents a straightforward implementation of the OMR definition in a control loop. Thus, while the essence of the OMR is to stabilize the animal’s position with respect to its visual environment, the feedback controller might be trying to keep the integrated optic flow at zero. We were surprised to find that implementing this simple definition in a circuit not only results in swimming behavior similar to that of real larvae (compare Extended Data Fig. 1 with Fig. 1d) but also closely reproduces the acute reactions to all tested perturbations in reafference (Fig. 2c-d). The model suggests that bout and interbout duration is determined by the interplay between the two variables computed by the controller: sensory drive and tiredness. Sensory drive accumulates while the grating moves forward and can be interpreted as motivation to swim. In the model, an increased sensory drive leads to longer bouts and shorter interbouts. On the other hand, larval zebrafish rarely perform bouts that are longer than 500 ms. This is implemented in the model by a motor integrator that encapsulates a family of possible reasons for bout termination, such as tiredness. In the model, high tiredness terminates the bouts and prolongs subsequent interbouts.
This interplay between sensory drive and tiredness can explain all the subtleties in observed acute reactions. Thus, high gains decrease sensory drive during bouts which results in shorter bouts and longer interbouts (Fig. 2ci-di). On the other hand, very low gains result in increased sensory drive, which significantly prolongs the bouts (Fig 2ci). If the bouts are very long, the effect of high tiredness starts to dominate over high sensory drive, and as a result, the interbouts following these long bouts would be shorter despite high sensory drive. This explains the peculiar V-shaped trend in interbout duration as a function of gain (Fig. 2di).
In the case of lagged reafference, bouts are prolonged due to increased sensory drive in the beginning of the bout when there is no reafference (i.e. no slowing down of the grating) (Fig. 2cii-ciii). In addition, the model explains why the interbouts are prolonged only in the non-shunted lag setting but not in the shunted one (Fig. 2dii-diii). In the non-shunted setting, the grating continues to move backwards after the bout offset, so the sensory drives continues to decrease, which leads to prolonged interbouts (Fig 2dii). In the shunted setting, however, the grating returns to forward motion immediately after the bout offset, so the interbouts are not prolonged (Fig 2diii).
Finally, the model explains why reafference perturbed during early bout segments has more influence over the bout duration, whereas perturbations late in the bout affect the subsequent interbout (Fig. 2civ-div). The reason is that the influence of tiredness and sensory drive over the final motor output changes throughout the course of a bout. Since the tiredness accumulates during the bout, it starts to affect the output more strongly and to dominate over the sensory drive by the end of the bout. Simply, if fish is tired, it does not matter how much drive to continue swimming it has. As a result, in the beginning of the bout, while the fish is not yet tired, a decrease in sensory drive effectively prolongs the bout. If, however, sensory drive is decreased late in the bout, it does not prolong the bout as much because by then, the bout duration is almost completely determined by the increasing tiredness. In this case, the tiredness by the end of the bout will be less than if the reafference was perturbed early in the bout, so the interbout duration will decrease more.
In order for this modelled mechanism to work in real larvae, they must be able to integrate the optic flow to compute the sensory drive. Our whole-brain functional imaging experiments revealed that the process of sensory integration of the forward visual motion indeed takes place in several brain regions including the pretectum (Fig. 3j; Extended Data Fig. 2). An increasing body of work suggests that the pretectum plays a crucial role in whole-field visual processing and visuomotor behaviors in larval zebrafish 28–31. It has been shown that pretectal neurons integrate monocular direction-selective inputs from the two eyes and drive activity in the premotor hindbrain and midbrain areas during optomotor behavior 29. Together with recent evidence from different experimental paradigms 25, 26, the present study demonstrates that the pretectum is involved not only in the binocular integration of sensory inputs, but also in temporal integration that can underlie accumulation of the sensory drive.
The proposed feedback control mechanism of reactive optomotor locomotion can therefore be mapped onto the larval zebrafish brain (Fig. 7). The sensory part of the feedback controller starts with direction-selective velocity sensors. Direction-selectivity can be observed in the brain already at the level of retinal ganglion cells in vertebrates 32, 33, including zebrafish larvae 34, 35. The velocity integrator can correspond to the pretectum, which receives projections from the contralateral direction-selective retinal ganglion cells 29, 36, 37. Finally, the pretectal neurons (velocity integrators) send anatomical projections to premotor areas in the hindbrain and to the nucleus of the medial longitudinal fascicle 31, 38, 39. As these regions both displayed motor-related activity in our experiments (Fig. 3f; Extended Data Fig. 2), we hypothesize that they correspond the premotor parts of the controller. In essence, this study suggests that the major role of the pretectum in visuomotor behaviors is computing the sensory drive, or motivation, to perform a motor action. This predicts that motor output of the fish should increase in response to increased activity of pretectal neurons, and vice versa, although more studies would be required to address this prediction.
Finally, our loss-of-function experiments have demonstrated that, in contrast with previous predictions 21–23, acute reaction is a cerebellum-independent process (Fig. 5b-c; Extended Data Fig. 4). Consequently, the neuronal controller involved in reactive optomotor behavior does not require intact cerebellum for its functioning.
A cerebellar internal model drives long-term adaptation
In the present study we demonstrate that larval zebrafish are able to gradually adapt their behavior in response to a long-lasting perturbation in reafference (Fig. 4), and that this process is cerebellum-dependent (Fig. 5). This is consistent with the view of the cerebellum as a neuronal substrate of internal models 8, 12–16.
The notion that the cerebellum is not involved in online corrections of the movements in response to wrong sensory feedback, but is involved in learning relations between movements and their feedback in order to adapt the behavior in a predictive manner, has been already proposed in the cerebellar literature 40. In two studies 15, 16, humans with impaired cerebellar function were able to update the motor program during a reaching task after the feedback of their movements was perturbed by the experimenters. However, they were not able to update their feedback estimation after the adaptation session, indicating that the cerebellum is involved in acquiring and updating a forward internal model. In our long-term adaptation experiments, a similar process has taken place. During long-lasting exposure to consistently perturbed reafference, animals with an intact cerebellum may have recalibrated their forward models to reduce their expectations, thus making them adequate to the novel environmental condition.
In this study, we took advantage of the zebrafish larvae’s accessibility for functional imaging to monitor this process of recalibration in the cerebellum during motor learning. We have identified a subpopulation of PCs that gradually decreased their responses while the animals were adapting to insufficient reafference, and increased their responses back to the original level while the animals were getting used to the original condition after the adaptation. This activity profile is similar to the expected output of a recalibrating internal model, with the bout-triggered activity in this population corresponding to a putative “expected visual feedback” signal.
Although this study provides direct evidence of internal models in the cerebellum, the exact processes that take place in the cerebellum of adapting animals remain unclear. Since functional imaging provides only a coarse view about how motor, sensory, and expectation-related signals are represented in PCs, future electrophysiological investigations are required to address these questions. Nevertheless, the fact that we observed sensory-related activity in the inferior olive (Fig. 3f,j) indirectly suggests that the cerebellum in larval zebrafish acts as a forward model during the OMR, and the highly sensory nature of PCs’ complex spikes that directly result from action potentials in the inferior olive 41 was also reported recently 27. Inferior olive activity is believed to convey a teaching signal to the PCs 42, 43 that updates the internal models in the cerebellum 9, 44 by modifying synaptic weights in the cerebellar circuitry 45, 46. Since the teaching signal must be expressed in the same coordinates as the output of the internal model, the sensory nature of the teaching signal suggests that the cerebellar internal model involved in adaptive OMR is forward in nature, although this distinction is likely to be more subtle.
A cerebellar internal model calibrates a feedback controller involved in sensorimotor control
One interesting result of this study is that bout power during the initial ballistic period of the bouts did not depend on the current reafference condition: the magnitude of the first several tail oscillations is fixed regardless of what sensory input the fish receives (Fig. 2e). This means that the behavior during this ballistic period is pre-determined by the state of the neuronal controller that converts information about moving grating into optomotor behavior. However, if larval zebrafish are exposed to a long-lasting perturbation in reafference, the magnitude of the initial tail oscillations increases (Fig. 4g), and we show that this process is cerebellum-dependent (Fig. 5f-g). This means that the cerebellum can influence the state of the neuronal controller of the OMR, and if the internal model in the cerebellum updates, the state of the controller updates as well (Fig. 7).
Unexpectedly, the increase in ballistic bout power was observed not only in the lag-trained group but also in the normal-reafference control group, which never experienced perturbed reafference (Fig. 4j). This can be explained by the fact that what we call the normal reafference condition in the closed-loop experiments may in fact differ from the real sensory feedback that larval zebrafish perceive upon free unrestrained swimming bouts. For example, the reafference presented by the projector always lags slightly behind the tail movements due to the software processing delay. In addition, the way by which we computed the swimming velocity from the tail movements may only approximate the real velocity that the fish would have reached if it were freely swimming. Finally, in our closed-loop experiments, head-restrained larvae did not receive any vestibular and lateral line sensory feedback. Therefore, even though the normal reafference condition was calibrated to closely match the visual real-life conditions, it was inevitably different from the total sensory feedback received by freely swimming larvae. Future experiments involving translation of the long-term adaptation experiment to the freely-swimming environment would be required to identify whether this disparity underlies observed recalibration of the neuronal controller of the OMR.
The exact pathway by which the cerebellum affects the circuitry involved in OMR remains unclear. One possibility is that it acts upon the premotor parts of the circuit, as cerebellar projection neurons send their output to the nucleus of the medial longitudinal fascicle and to the hindbrain 39 (this possibility is shown in Fig. 7). In this scenario, the cerebellum would recalibrate the motor parts of the controller during the long-term motor adaptation, so that fish would behave differently in response to the same sensory drive. Another possibility is that the cerebellum recalibrates the sensory parts of the OMR circuitry during the adaptation. It was proposed for the case of the eye movements that the action of the cerebellum is to modify the time constant of the oculomotor neuronal integrator in the brainstem 47, 48. Similarly, in the case of the OMR adaptation, the role of the cerebellar internal model might be to fine-tune the time constant of the optic flow integrator in the pretectum. This influence can be mediated by anatomical projections from the cerebellum to the pretectum, which have been described in zebrafish 49.
To conclude, our results demonstrate the role of cerebellar internal models in calibrating the neuronal circuits involved in reactive motor control. This process ensures that the circuit is well-tuned in the sense that the animal’s behavior has the required effect on its sensory environment.
Author Contributions
D.A.M., and R.P. conceived of the project. D.A.M. performed most of the experiments, analyzed the data, developed the model and created the figures with help from L.P. L.P. performed functional imaging experiments and pre-processed the imaging data. A.M.K. generated the Tg(PC:epNtr-tagRFP) zebrafish line and developed the gain drop paradigm. D.A.M. and R.P. wrote the manuscript with help from all authors.
Declaration of Interests
The authors declare no competing interests.
Methods
Experimental Model
Zebrafish husbandry
All experiments were conducted on larval zebrafish (Danio rerio) at 6 - 8 days post-fertilization (dpf) of yet undetermined sex. All animal procedures were performed in accordance with approved protocols set by the Max Planck Society and the Regierung von Oberbayern (TVA 55-2-1-54-2532-82-2016).
Both adult fish and larvae were maintained at 28 °C on a 14/10 hours light/dark cycle, unless otherwise specified. Adult zebrafish were housed in a zebrafish facility system with constantly recirculating water with a daily 10% fresh water exchange. The system fish water was deionized and adjusted with synthetic salt mixture (Instant Ocean) to 600 μS conductivity, with the pH value adjusted to 7.2 using NaHCO3 buffer solution. The water was filtered over bio-, fine- and carbon filters and UV-treated during recirculation. Adult zebrafish were fed twice a day with a mixture of Artemia and flake feed.
To obtain larvae for experiments, one male and one female (in some cases, three male and three female) adult zebrafish were placed in a mating box in the afternoon and kept there overnight. The embryos were collected in the following morning and placed in an incubator that was set to maintain the above light and temperature conditions (Binder, Germany). Embryos and larvae were kept in 94 mm Petri dishes at a density of 20 animals per dish in Danieau’s buffer solution (58 mM NaCl, 0.7 mM KCl, 0.4 mM MgSO4, 0.6 mM Ca(NO3)2, 5 mM HEPES buffer) until 1 dpf and in fish water from 1 dpf onwards. The water in the dish was changed daily.
Zebrafish strains
Purely behavioral experiments were conducted using wild-type Tupfel long-fin (TL) zebrafish strain or transgenic Tg(PC:epNtr-tagRFP) line that was used for PC ablation (see below).
Efficiency of PC ablation was evaluated using the progeny of Tg(PC:epNtr-tagRFP) zebrafish outcrossed to fish expressing GCaMP6s in PC nuclei and RFP in PC somata (Tg(Fyn-tagRFP:PC:NLS-GCaMP6s)) 27. This allowed evaluating effects of the ablation protocol on the morphology of both cell nuclei and somata. These larvae were homozygous for nacre mutation, which introduces a deficiency in mitfa gene that is involved in development of melanophores 50. As a result, homozygous nacre mutants lack optically impermeable pigmented spots on the skin, which enables brain imaging without invasive preparations.
Whole-brain functional imaging experiments were conducted using transgenic zebrafish strain with pan-neuronal expression of GCaMP6s (Tg(elavl3:GCaMP6s)) 24. PC functional imaging experiments were conducted using zebrafish that expressed GCaMP6s specifically in PCs (Tg(PC:-GCaMP6s)) 27. In both experiments, the animals were also homozygous for nacre mutation
A Z-stack of larval zebrafish reference brain used for anatomical registration of the whole-brain functional imaging data was previously acquired in our laboratory by co-registration of 23 confocal z-stacks of zebrafish brains with pan-neuronal expression of GCaMP6f (Tg(elavl3:GCaMP6f)) 51, homozygous for nacre mutation. For anatomical registration of PC functional imaging data, the red channel of one confocal stack of Tg(Fyn-tagRFP:PC:NLS-GCaMP6s) was used as a reference.
Targeted pharmaco-genetic ablation of PCs
To perform targeted ablation of PCs, we employed Ntr/MTZ pharmaco-genetic approach that has been successfully used in zebrafish 52–54. This method is based on treating the animals expressing nitroreductase (Ntr) in a cell population of interest with prodrug metronidazole (MTZ). Ntr converts MTZ into a cytotoxic DNA cross-linking agent leading to death of cells of interest. To this end, we generated a transgenic line that expressed enhanced Ntr (epNtr) 54 under the PC-specific carbonic anhydrase 8 (ca8) enhancer element 55. epNtr fused to tagRFP (similar to Tabor et al., 2014) was cloned downstream to the aforementioned PC-specific enhancer and a basal promoter. This construct (abbreviated as PC:epNtr-tagRFP) was injected into nuclei of single cell stage TL embryos heterozygous for nacre mutation, at a final concentration of 20 ng/ul together with 25 ng/ul tol2 mRNA. Larvae showing strong RFP expression in PCs were raised to adulthood as founders and outcrossed to TL fish to gain a stable line.
Ablation-induced changes in behavior were tested using the progeny of a single founder. The embryos obtained from a PC:epNtr-tagRFP+/- fish outcrossed to a TL fish were screened for red fluorescence in the cerebellum at 5 dpf, and 10 RFP-positive (PC:epNtr-tagRFP+/-) and 10 RFP-negative (PC:epNtr-tagRFP-/-) larvae were kept in the same Petri dish to ensure subsequent independent sampling. At 18:00, most of the water in the dish was replaced with 10 mM MTZ solution in fish water, and larvae were incubated in this solution overnight in darkness for 15 hours. The next morning at 9:00, animals were allowed to recover in fresh fish water. The next day, behavior of 7 dpf MTZ-treated larvae was tested in a respective behavioral protocol. After the experiment, the animals were screened for red fluorescence once again to reassess their genotype after mixing positive and negative larvae in one Petri dish. PC:epNtr-tagRFP-/- and PC:epNtr-tagRFP+/- siblings constituted treatment control and PC ablation experimental groups, respectively.
Efficiency of PC ablation protocol was evaluated using progeny of Tg(PC:epNtr-tagRFP) fish outcrossed to Tg(Fyn-tagRFP:PC:NLS-GCaMP6s) fish, homozygous for nacre mutation. These larvae underwent the same ablation protocol, and z-stacks of their cerebella in RFP and GFP channels were acquired under the confocal microscope (LSM 700, Carl Zeiss, Germany) before and after the ablation (at 5 and 7 dpf, respectively).
Closed-loop experimental assay in head-restrained zebrafish larvae
All experiments were conducted using head-restrained preparations of 6 – 8 dpf zebrafish larvae, similar to 21. For behavioral experiments, each larva was embedded in 1.5 % low melting point agarose (Invitrogen, Thermo Fisher Scientific, USA) in a 35 mm Petri dish. For functional imaging experiments, larvae were embedded in 2.5 % agarose in custom 3D-printed plastic chambers (Form 2, Standard Clear Resin V4, Formlabs, USA), with glass coverslips sealed on the front and left sides of the chamber, at the entry points of the frontal and lateral laser excitation beams, and the agarose around the head was removed with a scalpel to avoid scattering of the beams (see Light-sheet microscopy in Methods below). After allowing the agarose to set, the dish/chamber was filled with fish water and the agarose around the tail was removed to enable unrestrained tail movements that were subsequently used as behavioral readout.
A dish/chamber with an embedded larva was then placed onto the screen of the custom-built behavioral or functional imaging rig (Figs. 1c, 3a, 6a). In the behavioral rig, the screen with the dish was illuminated from below by an infrared (IR) light-emitting diode (LED) (not shown in Fig. 1c). A square black-and-white grating with a spatial period of 10 mm was projected onto the screen by a commercial Digital Light Processing (DLP) projector (ASUS, Taiwan). Larvae were imaged through a macro objective (Navitar, USA) and an IR-pass filter with an IR-sensitive camera (Pike, Allied Vision Technology, Germany, or XIMEA, Germany) at 200 frames per second. The functional imaging rig was built in a similar way, with the two differences:
IR LED illuminating the screen with the chamber was directed from above (not shown in Figs. 3a, 6a) and the image was reflected on a hot mirror to reach a camera (XIMEA, Germany).
DLP projector used to provide visual stimulation (Optoma, USA) was mounted with a red-pass filter to avoid bleed-through of the green component of the visual stimulus in the light collection optics.
Stimulus presentation and tail tracking were controlled by the open-source, integrated system for stimulation, tracking and closed-loop behavioral experiments (Stytra) 56. Larvae were presented with the grating moving in a caudal to rostral direction at 10 mm/s. Experiments were performed in closed-loop (similar to 21), as described below. Before starting an experiment, two anchor points enclosing the tail were manually selected. The tail between the anchor points was automatically divided into 8 equal segments, and the angle of each segment with respect to the longitudinal reference line was measured by Stytra in real time. The cumulative sum of the segment angles constituted the final tail trace (top green trace in Fig. 1d). Sliding standard deviation of the tail trace with a time window of 50 ms was computed in real time, referred hereafter as vigor. Vigor is a parameter that is close to zero when larvae do not move their tail and increases when they do, and can be therefore used to estimate the forward velocity that head-restrained larvae would have reached if they were freely swimming. To compute estimated velocity, the vigor was multiplied by a factor that was optimized during the initial calibration phase of each experiment (see Experimental protocols in Methods below) so that that the median estimated velocity during a typical bout was 20 mm/s (bottom green trace in Fig. 1d), which corresponds to a freely swimming condition. Swimming bouts were automatically detected in real time by comparing current estimated fish velocity with a set threshold of 2 mm/s. To provide behaving larvae with visual reafference, the estimated velocity was subtracted from the initial grating velocity during detected bouts (bottom magenta trace in Fig. 1d). As a result, larvae could experience the sensory consequences of their own swimming, despite being head-restrained. The initial and actually presented grating velocities, tail trace, vigor, estimated fish velocity, reafference condition (see below), and a binary variable denoting whether the fish was performing a bout or not at each acquisition frame constituted the raw data saved after each experiment (Fig. 1d).
Importantly, such closed-loop assay enables the experimenters to control and manipulate the reafference that animals receive when they swim and hence to study how perturbations in reafference affect behavior. The reafference perturbations used in this study can be grouped into three distinct categories (Fig. 2a):
The first type of perturbation, which has been previously used in the literature 21, 22, is called gain change. In the closed-loop experimental assay, the gain parameter was used as a multiplier that converts the estimated swimming velocity of the larva into presented reafference. Therefore, the actual forward velocity of a swimming larva was proportional to gain. If the gain was set to zero, the tail movements had no influence over the grating speed, so larvae did not receive any reafference. This reafference condition as therefore referred as the open-loop condition. If the gain was 1, the median velocity of the larva during a typical bout was 20 mm/s, referred as the normal reafference condition. The gain values used in the experiments included 0, 0.33, 0.66, 1, 1.33, 1.66, and 2.
The second type of perturbation was called lag, and this corresponds to delaying the reafference with respect to the bout onset. When the lag was greater than zero, normal visual reafference with gain 1 was presented with a certain delay after the bout had started. The lag values used in the experiments included 0 ms lag (corresponds to the normal reafference condition), 75 ms, 150 ms, 225 ms, 300 ms, and infinite lag (i.e. reafference never arrives after the bout onset, which is equivalent to the open-loop condition). In the shunted lag version of this condition, the reafference was set to 0 upon termination of the bout.
The third type of perturbation was called gain drop, and this corresponds to dividing the first 300 ms of a bout into four 75-ms segments and setting the gain during one or more of these segments to zero. Therefore, gain drop conditions were labelled using four-digit barcodes, where each digit represents the gain during corresponding bout segment. For example, the gain profile 1100 denotes that the gain during bout segments 3 and 4 (i.e. from 150 ms to 300 ms after the bout onset) was set to zero, and during the rest of the bout, it was set to one. Gain drop conditions used in the experiment included 1111 (normal reafference condition), 0111, 0011, 0001, 0000, 1110, 1100, and 1000.
No combinations of reafference conditions were used, e.g. if the gain was different from 1, the lag was automatically set to 0 ms, or if the lag was greater than 0 ms, the gain was set to 1, and in both cases the gain drop was set to the normal 1111.
Note that reafference conditions listed above and presented in Fig. 2a are redundant. For example, the gain drop profile 0011 is exactly the same as 150 ms shunted lag, or gain 0 is exactly the same is infinite lag. Reafference conditions are presented in a redundant way to highlight that infinite lag makes a logical sense at the end of the list of lag conditions, and gain 0 makes a logical sense in the beginning of the gains list. The exact non-redundant list of all reafference conditions (18 conditions in total) is presented below:
normal reafference (gain 1, 0 ms lag, and gain drop 1111);
open-loop (gain 0 or infinite lag);
gains: 0.33, 0.66, 1.33, 1.66, 2 (0 ms lag and gain drop 1111);
lags and shunted lags: 75 ms, 150 ms, 225 ms, 300 ms (gain 1);
gain drops: 1110, 1100, 1000 (0 ms lag).
Experimental protocols
General structure of experimental protocols
All experimental protocols used in this study had a similar general structure. Each protocol consisted of trials. Each trial consisted of a 15-second presentation of the grating moving in a caudal to rostral direction at 10 mm/s, preceded and followed by 7.5-second periods of the static grating (30 seconds in total, see top magenta trace in Fig. 1d). Trials were grouped into four phases, unless otherwise specified (Fig. 4a):
Calibration phase (trials 1:10). During this phase, the multiplier defining how vigor is converted into estimated fish velocity was automatically calibrated so that the median velocity during an average swimming bout was 20 mm/s. Reafference condition during this phase was set to normal. This calibration was implemented to equalize velocity estimation across fish. In addition, during this phase, larvae were able to get used to the experimental environment and bring their swimming behavior to a stable level. All parameters recorded during this phase were not analyzed in this study.
Pre-adaptation phase (trials 11:20). During this phase, reafference condition was set to normal. This phase was used to record the baseline level of behavior, before any perturbations in reafference were introduced.
Adaptation phase (trial numbers depend on particular experimental protocol, see below). During this phase, larvae experienced perturbations in visual reafference.
Post-adaptation phase (last 10 trials unless otherwise specified). During this phase, reafference condition was again set to normal. This phase was introduced to measure how the adaptation phase affected the baseline behavior.
Acute reaction protocol
This experiment was designed to probe the space of acute reactions to different unexpected perturbations in reafference and to test whether a feedback control mechanism can implement these reactions. The adaptation phase of the protocol consisted of 210 trials, and reafference condition for each bout performed during this phase was randomly selected from the list of 18 possible reafference conditions (see above; see also Fig 2a). Bouts performed during other experimental phases were not included in the analysis.
Whole-brain functional imaging protocol
The protocol started with 2 minutes of no visual stimulation (projector presenting a black square) to record spontaneous activity. This was followed by a calibration phase, a pre-adaptation phase and an adaptation phase (40 trials). Post-adaptation phase was omitted. In four out of six imaged larvae, the calibration phase was omitted because behavior under the light-sheet setup was less consistent than under purely behavioral rigs, and calibration of the swimming velocity often failed due to insufficient number of bouts performed during this phase. For these larvae, the multiplier defining how vigor converts into estimated swimming velocity was set manually to a value resulting from successful calibration in the other two larvae. During the adaptation phase, reafference condition for each bout was randomly set to either normal or open-loop. In addition, two 350-ms pulses of reverse grating motion (rostral to caudal direction) at 10 mm/s were presented during each static grating period (5 and 10 s after the grating stopped moving). Responses to these pulses were not analyzed in this study. Furthermore, the difference in bout-triggered responses between normal reafference and open-loop condition was also not analyzed.
Long-term adaptation protocol
This experiment was designed to test if larval zebrafish are able to adapt their behavior in response to a long-lasting and consistent perturbation in reafference. The adaptation phase of the protocol consisted of 210 trials, and reafference condition for all bouts performed during this phase was set to 225 ms lag (Fig. 4a). This reafference condition was chosen because it elicited robust acute reaction (Figs. 2cii). In normal-reafference control larvae, reafference condition during the whole experiment (including the adaptation phase) was set to normal.
PC functional imaging protocol
Experimental protocol used for PC functional imaging experiment was a modified version of the long-term adaptation experiment (Fig 6b). The adaptation phase was shortened from 210 trials to 50 trials to ensure stable recordings from PCs throughout the whole experiment. Such shortening was possible because long-term adaptation effects could already be observed after 50 trials of adaptation (Fig. 4c). On the other hand, the post-adaptation phase was prolonged from 10 trials to 50 trials to allow larvae to bring their behavior back to the original level after the adaptation.
Behavioral data analysis
Analysis of the behavioral data was performed in MATLAB (MathWorks, USA).
Tail trace was z-scored and interpolated together with the grating speed trace to a time array with a sampling period of 5 ms. For each swimming bout automatically detected by Stytra during the experiment, individual tail flicks were detected. One tail flick was defined as a section of the tail trace between two adjacent local extrema, with the magnitude greater than 0.14 rad and the duration not greater than 100 ms. Automatically detected onsets and offsets of the bouts were then corrected to coincide in time with the beginning of the first tail flick and the end of the last flick, respectively.
Only bouts that occurred while the grating was moving forward were considered for further analysis. For each bout, its duration and duration of the subsequent interbout was measured. If a bout was the last in a trial, the corresponding interbout duration was replaced with a NaN value. All bouts that were shorter than 100 ms, or had a subsequent or preceding interbout shorter than 100 ms were also excluded from the analysis as potential tail tracking artifacts.
If there was at least one block of 10 consecutive trials without any bouts, this animal was excluded from further analysis. The final numbers of included animals are listed below:
Acute reaction experiments: 100 TL larvae (wild-type experimental group), 28 Tg(PC:epNtr-tagRFP)-/- larvae (treatment control group), and 39 Tg(PC:epNtr-tagRFP)+/- larvae (PC ablation group);
Long-term adaptation experiments:
○ normal-reafference control animals: 103 TL larvae, 85 Tg(PC:epNtr-tagRFP)-/- larvae, and 83 Tg(PC:epNtr-tagRFP)+/- larvae,
○ lag-trained animals: 100 TL larvae, 85 Tg(PC:epNtr-tagRFP)-/- larvae, and 90 Tg(PC:epNtr-tagRFP)+/- larvae.
To analyze the temporal dynamics of the tail beat amplitude within individual bouts, a parameter termed bout power was computed as described below. A 1.1-second long section of the tail trace was selected for each bout, starting from 100 ms before the onset of that bout. The values of the tail trace after the bout offset were replaced with zeros to exclude subsequent bouts that could occur within this time window. In addition, the median baseline value computed for the 100 ms window before the bout onset was subtracted from the section. Resulting sections of the tail trace were then squared and referred to as bout power.
To present the results of acute reaction experiments, we averaged the metrics obtained for each bout (its duration, subsequent interbout duration and power profiles) across bouts within each reafference condition in each larva. Bout and interbout duration is presented as mean ± s.e.m. across larvae. Bout power profiles are presented as median across larvae.
To identify the time points, at which mean bout power depended on reafference condition, Kruskal-Wallis test was used (significance level 5%; Bonferroni correction for the total number of 220 tested time points). According to the test results, the bout power curves were then divided into ballistic and reactive periods (from 0 to 220 ms after the bout onset and from 220 ms onward, respectively) and the areas below the curves within these two periods were measured for each bout for each larva.
To present the results of the long-term adaptation experiments, we analyzed the aforementioned parameters only for the first bout in each trial. First bout duration in each trial is presented as mean ± s.e.m. across larvae. To quantify the effects observed in the long-term adaptation experiments (acute reaction, back-to-baseline effect and the after-effect), we divided all trials of the protocol into blocks of 10 and computed the mean value of respective parameter within each block. We then normalized computed values across fish by subtracting the corresponding baseline values obtained during the pre-adaptation phase. These quantifications are presented as median ± quartiles across larvae. To determine statistical significance of the observed differences between experimental groups, we used Mann-Whitney U test with two-tailed alternative with significance level of 5 %.
In the long-term adaptation experiments performed under the light-sheet microscope, the lag-trained animals were sub-divided into adapting and non-adapting based on magnitude of the back-to-baseline effect. If the first bout duration averaged across the last 10 trials of the adaptation phase was less than that for the first 10 trials of the adaptation phase by at least 40 ms, this larva was considered adapting. To determine statistical significance of the long-term adaptation effects in lag-trained adapting larvae, we used Mann-Whitney U test with one-tailed alternative (with significance level of 5 %) because the alternative hypothesis was already known from the main long-term adaptation experiment.
Feedback control model of acute reaction
To test whether acute reaction can be explained by a simple feedback controller that does not involve computation of expected sensory reafference (i.e. forward internal models), we developed a model that does not perform these computations (Fig. 2b) and tested its ability to adapt its output to perturbations in reafference (Fig. 2c).
The model was developed and tested in MATLAB (MathWorks, USA). The input of the model was current velocity of the moving grating, and the output was a binary variable representing swimming velocity of the model. For simplicity, we did not set out to model individual tail flicks and approximated the swimming behavior of the zebrafish larvae by a binary motor output that equaled 20 mm/s when the model was swimming and 0 otherwise. This was possible due to the discrete nature of zebrafish swimming behavior at larval stage. Since in this study we mainly focused on duration of bouts and interbouts, this simplification did not limit the ability to compare the model behavior with behavior of the real larvae.
To design the model, we used the results of the acute reaction experiment as a starting point (Fig. 2c-e). Thus, since larval zebrafish reacted to changes in visual stimulus with a fixed delay of 220 ms (Fig. 2e), the input of the model at a given time point was the grating velocity 220 ms before that point. We then assumed that forward motion of the grating should have a positive influence on the motor output, whereas reverse motion should have a negative influence. This assumption was based on the fact that if the grating was moving forward during a bout (as under open-loop or low gain conditions), this bout was significantly longer than under normal reafference condition, when the grating was moving backwards (compare cases for high and low gains in Fig. 2ci). To implement this notion in the model, the input signal was split into forward and backward components by positive and negative rectification. This was performed by two respective nodes of the model: forward and reverse velocity sensors. Rectified signals were then recombined together with independent positive and negative weights (ωf and ωr, respectively). We then proceeded from the fact that when a larval zebrafish was presented with a forward moving grating, it performed a swimming bout only after a certain latency period (for example, see Figs. 1d, 4b), suggesting that it integrates sensory evidence of the forward grating motion in time until the level of integrated signal reaches a motor command threshold. We therefore introduced a leaky velocity integrator (VI) that integrated recombined output of the velocity sensors with a time constant τs. Output of the VI can be interpreted as motivation or sensory drive to swim because it increases with longer or faster forward motion of the stimulus, decreases with backwards motion, and drives activity in the motor part of the controller (see below). Activity of the VI was not allowed to be less than 0 (no sensory drive) or greater than 1 (maximum sensory drive). The sensory drive was then fed forward to the motor output generator (MOG), and this process can be interpreted as translation of the sensory input signal into motor coordinates. Accordingly, activity of the MOG was called motor drive. Whenever the motor drive reached a threshold thr, it activated the motor command generator (MCG), and the output of the model was set to 20 mm/s instead of 0. To ensure that the swimming bouts performed by the model do not last forever, we introduced a leaky motor integrator (MI) that integrated the output of the MCG in time with an input weight ωm and a time constant τm. Output of the MI can be interpreted as a metric of “tiredness” that encapsulates possible reasons for bout termination even when high sensory drive incites to continue swimming. This is the case, for example, under open-loop reafference condition, when the grating is moving forward and the sensory drive accumulates even though fish swims and tries to reduce the sensory drive. To implement the inhibitory influence of this “tiredness” on the motor output of the model, the MI inhibited the MOG with a weight ωi, thus reproducing a self-evident fact that the longer a bout had been so far, the sooner it would stop. In simple words, if the model was “tired” it had less motor drive to continue swimming, even if the sensory drive was strong. Activity of the MI was not allowed to be greater than 1 (maximum “tiredness”), and it could not inhibit the MOG below 0 (motor drive could not be negative). Finally, to ensure that bouts can last for some time once started in cases when the sensory drive to continue swimming becomes too low immediately after bout onset (for example, under high gain conditions when larvae receive a lot of reafference), we introduced a self-excitation loop to the MCG with a weight ωs (see Extended Data Fig. 1 for formal mathematical description of the model).
Therefore, in total, the model had eight parameters. The input and output of the model, as well as activity of its nodes in an example trial with normal reafference are presented in Extended Data Fig. 1.
To evaluate the ability of the model to acutely react to different perturbations in reafference, it was tested in a shorter version of the acute reaction experimental protocol. The protocol was shortened to save the computation time required for fitting the model. One trial consisted of 300 ms of static grating followed by 9.7 seconds of the grating moving in a caudal to rostral direction at 10 mm/s. The reafference condition of the first bout was always normal, and the reafference condition of the second bout was chosen from a list of 18 reafference conditions used in the acute adaptation experiment (see Closed-loop experimental assay in head-restrained zebrafish larvae in Methods above). If the model initiated a third bout, the trial was terminated, and the duration of the second bout and subsequent interbout constituted the final output of the model in that trial. If the model did not initiate the third bout, the final output of the model in that trial was replaced with NaN values.
The parameters of the model were fitted to training datasets obtained for each larva that participated in the acute reaction experiment (N = 100) using a custom-written genetic algorithm. To obtain the training datasets, 18 arrays of bout durations and 18 arrays of interbout durations were generated for each larva, each array corresponding to one reafference condition. Average values of randomly selected 50 % from each array constituted the training datasets, the remaining 50 % were used as test datasets.
The optimization algorithm minimized the mean absolute error (absolute difference between the output array of the model and a training dataset, normalized by the training dataset) and resulted in sets of the model parameters, each optimized to fit one larva. To present the results, mean ± s.e.m. of the final output arrays of models across all sets of parameters, and of the test datasets across all larvae were computed (Fig. 2c-d).
Light-sheet microscopy
Functional imaging experiments were employed in this study for two purposes: to test the main assumption of the feedback control model (the existence of the sensory integration in the larval zebrafish brain) and to test whether activity of PCs can represent the output of an internal model. Respectively, there were two types of functional imaging experiments: whole-brain imaging experiments and PC imaging experiments. Both were performed using a custom-built light-sheet microscope (Figs. 3a, 6a).
For the whole-brain imaging (Fig 3a), a beam coming from a 473 nm laser source (modulated laser diodes, Cobolt, Sweden) was split with a dichroic mirror and conveyed to two orthogonal scanning arms. Each scanning arm consisted of a pair of galvanometric mirrors (Sigmann Electronik, Germany) that allowed vertical and horizontal scanning of the beam, a line diffuser (Edmund Optics, USA), a scan lens (Thorlabs, USA), a paper screen to protect the fish eyes from the laser, a tube lens (Thorlabs, USA), and a low numerical aperture objective (Olympus, Japan). The emitted fluorescence was collected through a water immersion objective (Olympus, Japan) mounted on a piezo (Piezosystem Jena, Germany), band-pass filtered (AHF Analysentechnik, Germany), and focused on a camera (Orca Flash v4.0, Hamamatsu Photonics K.K., Japan) with a tube lens (Thorlabs, USA).
The piezo, galvanometric mirrors, and camera triggering were controlled by a custom-written Python program. The light-sheets were created by horizontal scanning of the laser beams at 800 Hz. The light-sheets and the collection objective were constantly oscillating along the vertical axis with a saw tooth profile of frequency 1.5 Hz and amplitude of 250 μm. At each oscillation, 35 camera frames were acquired at equally timed intervals, with an exposure time of 5 ms. The resulting volumetric videos had a voxel size of 0.6 x 0.6 x 7 μm, and a sampling rate of 1.5 Hz per volume.
For the PC imaging experiments, the frontal scanning arm was removed because the whole cerebellum could be illuminated using only the lateral beam (Fig. 6a). The sampling rate was increased to 4 or 5 Hz due to smaller volume of imaging.
Functional imaging data analysis
Behavioral data acquired during the imaging experiment were analyzed as described in Behavioral data analysis in Methods above. This section describes analysis of the imaging data.
Whole-brain functional imaging data analysis
To analyze the functional imaging data, we first preprocessed them in Python, similar to Kist et al., 2017. To correct the data for motion artifacts and potential drift, they were aligned to an anatomical reference generated by averaging the first 1000 frames of each plane. For each volume in time, the translation with respect to the reference volume was computed by cross-correlation using the register_translation function from the scikit-image Python package. Before the alignment, the reference volume and volumes to be registered were filtered with a Sobel filter after a Gaussian blur (with the standard deviation of 3.3 voxels) to emphasize image edges over absolute pixel intensity. Volumes for which the computed shift was larger than 15 voxels (generally due to large motion artefacts caused by vigorous tail movements of the embedded fish) were discarded and replaced with NaN values. For subsequent registration of the imaging data to a common reference brain (see below), a new anatomical stack was computed for each animal by averaging the first 1000 frames of the aligned planes.
To segment the imaged volume into regions of interest (ROIs), a “correlation map” was computed, where each voxel value corresponded to the correlation between the fluorescence time-trace of that voxel and the average trace of eight adjacent voxels in the same plane. Then, based on the correlation map, individual ROIs were segmented in each plane with the following iterative procedure. Growing of each ROI was initiated from the voxel with the highest intensity in the correlation map among the ones still unassigned to ROIs, with a minimum correlation of 0.3 (seed). Adjacent voxels were then gradually added to the growing ROI if eligible for inclusion. To be included, adjacent voxels’ correlation with the average fluorescence time-traces of all voxels assigned to the ROI up to that point had to exceed a set threshold. The threshold for inclusion was 0.3 for the first iteration and increased linearly as a function of distance to the seed, up to a value of 0.35 at 3-μm distance. Additional criteria for minimal and maximal ROI area (9-28 μm2) ensured that the ROIs matched approximately the size of neuron somata. After segmentation, the fluorescence time-trace of each ROI was extracted by summing fluorescence of all voxels that were assigned to that ROI during segmentation.
Subsequent analysis steps were performed in MATLAB (MathWorks, USA). To de-noise the traces, a low-pass Butterworth filter with a cutoff frequency of 0.56 Hz was applied to each trace. This frequency corresponds to the half-decay time of the calcium indicator GCaMP6s expressed by the imaged larvae (1.8 s; 58), and fluorescence oscillations at frequency higher than that were unlikely to result from biological events. In addition, to correct for potential slow drift, the drifting baseline of each trace was computed by applying a low-pass Butterworth filter with a cutoff frequency of 3.3 mHz; and this baseline was then subtracted from the trace. The traces were then z-scored for subsequent analysis.
The strategy of subsequent analysis was aimed to identify velocity integrators within the larval zebrafish brain and included two steps.
The first step was aimed to identify ROIs that responded to the forward moving grating. Since this stimulus reliably triggers swimming behavior, it was important to disambiguate ROIs with responses to the forward moving grating from ROIs with motor-related activity. To this end, we computed the average grating- and bout-triggered fluorescence for each trace. To do this, we selected 5 second-long sections of the trace, starting from one second before the respective trigger. To avoid contamination of triggered responses by activity resulted from other events, we only considered triggers that did not have any other triggers in the preceding second, and if another trigger occurred within the selected time window, all fluorescence values after this another trigger were replaced with NaN values. In addition, we subtracted the baseline, defined as mean fluorescence before the trigger within the selected time window, from each triggered trace. We then computed the average traces and s.e.m. across corresponding triggers for each trace. To identify ROIs with sensory- and motor-related activity (referred hereafter as sensory and motor ROIs), we computed the mean values of average grating-triggered fluorescence within the time window from 0 to 4 s after the grating onset, and of average bout-triggered fluorescence within the time window from 0 to 2 s after the bout onsets. Obtained values were referred to as sensory and motor scores. To determine statistical significance of these scores, we used the following bootstrapping procedure. For each trace, we formulated a null-hypothesis that observed responses to grating and bout onsets were not related to these triggers and were rather observed by chance. To test this hypothesis against the one-tailed alternative that the scores are greater than expected from chance, each trace was divided into 84 sections, each 23 second-long, and the sections were randomly shuffled 1000 times. For each shuffling, sensory and motor scores were computed to build the null-distributions of the scores. The null-hypothesis was tested with a significance level of 5 % with a Bonferroni correction for multiple comparisons applied independently for each larva. Namely, if a score for a given trace was greater than the nth percentile of respective null-distribution, it was considered significant, where n = 100 − 5/m and m is a number of ROIs detected in that larva. ROIs were defined as sensory if they had a significant sensory score. If in turn, an ROI had a significant motor score, and if its sensory score was less than the 95th percentile of respective null-distribution, it was defined as a motor ROI. This additional criterion for definition of a motor ROI was introduced because almost all sensory ROIs continued to increase their grating-triggered fluorescence during swimming bouts. As a result, many sensory ROIs had a significant motor score, so this parameter alone could not be used to define motor ROIs.
The second step was aimed to identify whether some of the sensory ROIs integrate sensory evidence of the forward moving grating in time. To this end, we fitted a leaky integrator model to average grating-triggered fluorescence of sensory ROIs by iterating over a range of time constants from zero to ten seconds, with 100 ms steps, and identifying the time constant resulting in the highest correlation between the model and the triggered average trace. The leaky integrator trace was additionally convolved with a GCaMP6s kernel, modeled as an exponential function with a half-decay time of 1.8 s 58. Sensory ROIs for which the time constant was zero were referred to as velocity sensors, whereas ROIs with positive time constants were termed velocity integrators.
To compare the location of ROIs assigned to the aforementioned functional groups across larvae and to present the ROIs in the context of gross larval zebrafish neuroanatomy, the imaging data was registered to a common reference brain using the free Computational Morphometry Toolkit 59. To this end, affine volume transformations were computed to align the anatomical stacks from each larva to the reference brain. Computed transformations were then applied to each ROI to identify its coordinates in the reference space. To present the final ROI maps, binary stacks with ROIs of a given functional group were summed across larvae, and the maximum projections along dorsoventral and lateral axis were computed. In addition, to identify the anatomical regions with experiment-related activity, the regions annotated in the Z-Brain atlas 60 were registered to our reference brain using the same procedure.
If an ROI was assigned to one of the three aforementioned functional groups (sensors, integrators or motor ROIs), it was referred to as active ROI. To determine whether anatomical location of active ROIs was consistent across larvae, we first formulated a null-hypothesis for each ROI. The hypothesis stated that active ROIs that spatially overlap with this ROI in a population of larvae (i.e. ROIs that occupy the very same anatomical region in the brain) are equally likely to be either sensors, or integrators, or motor ROIs. According to this null-hypothesis, the probability of a given active ROI to be assigned to any functional group is 1/3. We then tested this null-hypothesis for each ROI against the one-tailed alternative that a given ROI was more likely to be assigned to its actual functional group than to the other two groups with a significance level of 5%. Rejection of the null-hypothesis can be interpreted as that in the brain region corresponding to this ROI, the probability of finding active ROIs of the same functional group in a population of larvae is greater than that of finding active ROIs of the other two groups. To test the null-hypothesis, we first calculated the number of larvae that had any active ROIs overlapping with the original ROI and the number of larvae that had an overlapping ROI assigned to the same functional group as the original ROI. Then, the probability of this observation given the null-hypothesis was inferred using maximum likelihood estimation. If this probability was less than 5 %, the null-hypothesis was rejected and the anatomical region corresponding to the original ROI was concluded to be consistent across larvae.
PC functional imaging data analysis
PC functional imaging data was pre-processed in Python. Before entering data in the analysis pipeline, data was previewed blindly with respect to experimental condition and behavioral performance. Data that showed any sign of drifting during the whole duration of the experiment were discarded, to avoid any confounding effect in the subsequent analysis. After this selection, N = 25 larvae were kept out of the original 50 (N = 8 normal-reafference control larvae and N = 17 lag-trained larvae). Lag-trained larvae were further sub-divided into adapting (N = 9) and non-adapting (N = 8) as described in Behavioral data analysis in Methods above.
Compared with the whole-brain data, cerebellum imaging data were smaller and PC labelling was sparser, so this dataset was better suited for signal extraction using Suite2p 61. Suite2p was used for plane-wise alignment of the data and ROIs segmentation; after these steps, the raw extracted fluorescence was used in subsequent analyses, bypassing the spike deconvolution part of the Suite2p pipeline. Parameters used for the extraction were the Suite2p default values for 2p detection, except for expected cell size and temporal resolution that were adjusted according to the imaging settings. Manual curation was performed on each fish, blindly with respect to experimental group and behavioral performance, to exclude artifactual ROIs segmented from the skin visible in the imaging.
Subsequent analysis steps were performed in MATLAB (MathWorks, USA). We first modelled a motor regressor by convolving the binary variable representing whether the fish was performing a bout or not at each acquisition frame with a GCaMP6s kernel, modeled as an exponential function with a half-decay time of 1.8 s 58 (Extended Data Fig. 6a). This regressor was processed in the same way as fluorescence traces of real ROIs, as described below.
To correct for potential slow drift, each trace was high-pass filtered using a Butterworth filter with a cutoff frequency of 3.3 mHz. The traces were then z-scored for subsequent analysis.
Subsequent analysis steps are illustrated in Fig. 6d. We first computed the first-bout-triggered fluorescence for each trace in each trial by selecting 2.2 second-long sections of the trace, starting from one second before the first bout. The baseline, defined as mean fluorescence before the first bout onset within the selected time window, was subtracted from each triggered trace. We then computed first-bout-triggered responses by averaging the triggered traces within the time window from 0 to 1.2 s after the first bout onsets. These responses were then averaged within the block of 10 trials, similarly to the first bout duration (see Behavioral data analysis in Methods above).
We used these averaged responses to define the four criteria for each trace, which represented how much the responses have changed during important transitions of the experimental protocol.
Criterion 1 was computed as the difference between the first 10 trials of the adaptation phase and 10 trials of the pre-adaptation phase.
Criterion 2 was computed as the difference between the last 10 trials and the first 10 trials of the adaptation phase.
Criterion 3 was computed as the difference between the first 10 trials of the post-adaptation phase and the last 10 trials of the adaptation phase.
Criterion 4 was computed as the difference between the last 10 trials and the first 10 trials of the post-adaptation phase.
Statistical significance of computed criteria was determined using the following bootstrapping procedure. For each trace we formulated a null-hypothesis that observed changes in bout-triggered responses were not related to transitions in the experimental protocol and were rather observed by chance. To test this hypothesis against the two-tailed alternative, the trials (excluding the calibration phase) were randomly shuffled 100’000 times. For each shuffling, criterion 1 was computed to build the null-distributions of the criteria. The null-hypothesis was tested with a significance level of 5 %. Namely, if a given criterion was greater than the 97.5th percentile of the null-distribution for that ROI, it was considered significantly high, and if it was less than the 2.5th, it was considered significantly low. This allowed to assign 4-digit barcodes to each ROI, each digit corresponding to one criterion, and all ROIs were clustered using these barcodes.
To identify activity profiles that were differentially represented in lag-trained adapting larvae compared to non-adapting and normal-reafference control groups, we computed the fractions of ROIs assigned to each cluster within each larva. Statistical significance of observed differences in fractions was determined using Mann-Whitney U test (two-tailed alternative, significance level 5 %).
To study whether the activity of the cluster 0-0+ could be explained by motor activity of the larvae, we modelled an artificial ROI, which linearly codes for motor activity of a larva (motor regressor), and processed it in exactly the same way as we processed the real ROIs (Extended Data Fig. 6a). As expected, bout-triggered responses of the motor regressors were markedly similar to the behavior of the larvae (Extended Data Fig. 6b-c), showing an acute increase in response to unexpected presentation of lagged reafference (dark-blue arrows in Extended Data Fig. 6a-c). Importantly, this acute reaction was not observed in response profiles of 0-0+ ROIs (Extended Data Fig. 6d). Finally, we were able to find ROIs whose activity actually showed an acute reaction and was in general similar to the motor regressor (Extended Data Fig. 6e, see also activity profile of the ROI 2 shown in Fig. 6d in blue). Therefore, changes in bout-triggered responses of 0-0+ ROIs cannot be fully explained by a motor component and rather reflect the output of a recalibrating internal model.
To compare the location of ROIs across larvae, the imaging data was registered to a common reference cerebellum similarly to the whole-brain imaging data (see above). To present the final maps of 0-0+ ROIs, we first applied 3D Gaussian blur with standard deviation of 1 μm to the binary stacks with these ROIs. The stacks were then summed across larvae, and the maximum projections along the dorsoventral axis were computed. 0-0+ ROIs were detected more frequently in the medial cerebellum (Extended Data Fig. 7 – top row). To estimate the statistical significance of the observed spatial clustering, we randomly sampled the same number of ROIs in each larva, computed the maps as described above, repeated this 100 times, and computed the final maps by averaging across 100 iterations. We observed a similar spatial pattern (Extended Data Fig. 7 – bottom row). Therefore, the spatial clustering of 0-0+ ROIs was not above chance level.
Extended Data Figure Titles and Legends
Extended Data Fig. 1: Behavior of the feedback control model of acute reaction
Behavior of the model in an example trial, where reafference condition was set to normal for simplicity. Magenta traces represent input of the model (grating speed, where positive values correspond to motion in a caudal to rostral direction); green trace represents output of the model (binary swimming variable representing current swimming velocity); orange traces represent output of respective nodes. Vertical shaded bars indicate swimming bouts performed by the model in this trial. Seven small Greek letters and thr denote eight parameters of the model: ωf - output weigh of forward velocity sensor, ωr - output weigh of reverse velocity sensor, τv - time constant of the velocity integrator, ωi - inhibitory output weigh of the motor integrator, ωs - feedforward self-excitation weight of the motor command generator, thr - threshold of the motor output command, ωm - input weight of the motor integrator, τm - time constant of the motor integrator. Δt denotes sensory processing delay of 220 ms, t - current time point. [x]+ = max(x, 0) - positive rectification of x; [x]− = min(x, 0) - negative rectification of x; min(x, 1) - saturation of x at 1.
Extended Data Fig. 2: Anatomical location of sensory- and motor-related ROIs is consistent across fish
a, Selected anatomical regions in the larval zebrafish reference brain. tel - telencephalon, di - diencephalon, fb - forebrain, mb - midbrain, hb - hindbrain. Presented images are maximum projections along dorsoventral or lateral axis. In all panels, ro - rostral direction, l - left, r - right, c - caudal, d - dorsal, v - ventral; scale bars: 100 μm. Colored areas depict brain regions that contained large fractions of motor- and sensory-related ROIs (Fig. 3): Thal - thalamus, preT - pretectum, OT - optic tectum, nMLF - nucleus of the medial longitudinal fascicle, DRN - dorsal raphe nucleus and surrounding reticular formation, IO - inferior olive. These anatomical regions were annotated in the Z-Brain atlas 60 and registered to our reference brain. b, Brain areas that consistently contain motor ROIs (green), sensors (blue) and integrators (red) across imaged larvae (N = 6; see Functional imaging data analysis in Methods for details). Presented images are sum projections along dorsoventral or lateral axis. Note that rostral and dorsal parts of the midbrain do not contain colored areas because these regions were blocked from the scanning laser beams by eye-protecting screens shown in Fig. 3a. c, Same is in b, but represented as maximum projections of 5 μm-thick optical slices of the reference brain along the dorsoventral axis. Numbers above the images denote distance from the dorsal surface of the reference brain in μm.
Extended Data Fig. 3: Treatment of Tg(PC:epNtr-tagRFP) larvae with metronidazole ablates the PCs
Morphology of PC nuclei (a) and somata and membranes (b) before ablation (5 dpf) and after recovery from the ablation (7 dpf, when the animals’ behavior was tested). Each image is a maximum projection of 20 confocal slices, each 1 μm-thick, along the dorsoventral axis in an example larva: ro - rostral direction, l - left, r - right, c - caudal, d - dorsal, v - ventral; scale bars: 100 μm. Small gray brains illustrate location of the PCs, shown in orange, within the larval zebrafish reference brain. After ablation, the signal in PCs was much fainter than before, so the contrast of the stack acquired after ablation was manually boosted to visually match the stack obtained before the ablation.
Extended Data Fig. 4: Acute reaction is not impaired after PC ablation
Mean bout duration (top) and interbout duration (bottom) in treatment control group (black, N = 28 larvae), and PC ablation group (orange, N = 39 larvae) tested in the acute reaction experiment (Fig. 2) as a function of reafference condition. To obtain data for one larva, all bout and interbout durations were averaged within each reafference condition. Mean ± s.e.m. across larvae is shown. Note that PC-ablated animals demonstrated acute reaction to perturbed visual reafference similarly to the control group.
Extended Data Fig. 5: Long-term adaptation effects are detectable in the light-sheet functional imaging experiment
a, Protocol of the long-term adaptation experiment used in the light-sheet experiment (repeated from Fig. 6b for convenience). b, First bout duration in each trial in normal-reafference control larvae (i; N = 8), lag-trained non-adapting larvae (ii; N = 8), and lag-trained adapting larvae (iii; N = 9). Solid lines and shaded areas represent mean ± s.e.m. across larvae. Blue arrow indicates increase of first bout duration in the beginning of the adaptation phase (acute reaction), cyan arrow indicates decrease of bout duration by the end of the adaptation phase (back-to-baseline effect), and orange arrow indicates decrease of bout duration in the post-adaptation phase (after-effect). c, Quantification of the acute reaction (i), back-to-baseline effect (ii) and the after-effect (iii). Each gray dot represents first bout duration in one fish, averaged across 10 trials and normalized by subtracting the baseline value obtained during the pre-adaptation phase. Black and red lines represent median and quartiles across larvae; n.s. - p ≥ 0.05, * - p < 0.05 (Mann-Whitney U test with one-tailed alternative).
Extended Data Fig. 6: Activity of 0-0+ ROIs cannot be explained by behavior
a, Z-scored activity of a motor regressor in four trials in an example lag-trained adapting larva (see Functional imaging data analysis in Methods for details). Vertical shaded bars indicate first swimming bout in each trial. In all panels, color-code for experimental phases is the same as in Fig. 6. In a-c and e, blue arrows indicate acute reaction of behavior (b) or of bout-triggered responses (a, c, e). b, First bout duration in each trial in an example larva shown in a (top) and averaged across all lag-trained adapting larvae (N = 9) (bottom). In b-e (bottom left), thin gray lines represent individual larvae, thick black lines represent mean across larvae. c, First-bout-triggered responses of a motor regressor shown in a (top left), first-bout-triggered responses of all motor regressors averaged across larvae (bottom left), first-bout-triggered activity of an example motor regressor, averaged across respective blocks of 10 trials (top right), and first-bout-triggered activity of all motor regressors, averaged across respective blocks of 10 trials (bottom right). In c-e (bottom right), thick colored lines and shaded areas represent mean ± s.e.m. across lag-trained adapting larvae. d,e, First-bout-triggered activity of 0-0+ ROIs (d) and of ROIs with significant criterion 1 (e). Panels are organized in the same way as in c. To compute bout-triggered responses for one larva, responses of all ROIs from respective cluster detected in that larva were averaged.
Extended Data Fig. 7: 0-0+ ROIs represent a spatially distributed subpopulation of PCs
Top, anatomical location of 0-0+ ROIs in normal-reafference control larvae (N = 8), lag-trained non-adapting larvae (N = 8) and lag-trained adapting larvae (N = 9). Color codes for percentage of larvae with ROIs in a given voxel of the reference cerebellum. Scale bar: 100 μm. Bottom, anatomical location of randomly sampled ROIs. In each larva, instead of taking 0-0+ ROIs, the same number of random ROIs was sampled. This was repeated 100 times, and presented images are averages across 100 iterations. Note that randomly sampled ROIs in lag-trained adapting larvae appear more often in the medial cerebellum, similarly to 0-0+ ROIs, indicating that this spatial clustering of 0-0+ ROIs is not above the chance level.
Acknowledgements
We thank Tugce Yildizoglu and Patricia Cooney for help with preliminary experiments that helped shape this project. We thank Hagar Lavian for help with running experiments and Vilim Štih for discussions on feedback controllers. RP would like to thank Winfried Denk for multiple in depth discussions concerning this project. All authors were funded by the Max Planck Society. DAM and AMK were funded by IMPRS for Life Sciences. AMK was funded by a Joachim-Herz Foundation fellowship. LP was funded by GSN. DAM, LP and RP were funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) through grant PO 2105/2–1. This work was funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Germany’s Excellence Strategy within the framework of the Munich Cluster for Systems Neurology (EXC 2145 SyNergy – ID 390857198).