Impact of walking speed and motion adaptation on optokinetic nystagmus-like head movements in the blowfly Calliphora

The optokinetic nystagmus is a gaze-stabilizing mechanism reducing motion blur by rapid eye rotations against the direction of visual motion, followed by slower syndirectional eye movements minimizing retinal slip speed. Flies control their gaze through head turns controlled by neck motor neurons receiving input directly, or via descending neurons, from well-characterized directional-selective interneurons sensitive to visual wide-field motion. Locomotion increases the gain and speed sensitivity of these interneurons, while visual motion adaptation in walking animals has the opposite effects. To find out whether flies perform an optokinetic nystagmus, and how it may be affected by locomotion and visual motion adaptation, we recorded head movements of blowflies on a trackball stimulated by progressive and rotational visual motion. Flies flexibly responded to rotational stimuli with optokinetic nystagmus-like head movements, independent of their locomotor state. The temporal frequency tuning of these movements, though matching that of the upstream directional-selective interneurons, was only mildly modulated by walking speed or visual motion adaptation. Our results suggest flies flexibly control their gaze to compensate for rotational wide-field motion by a mechanism similar to an optokinetic nystagmus. Surprisingly, the mechanism is less state-dependent than the response properties of directional-selective interneurons providing input to the neck motor system.

The optokinetic nystagmus (OKN) describes a characteristic pattern of fast and slow eye movements that occur as the entire visual surrounding moves over the retina (Fig. 1A). The eyes saccade against the direction of visual motion and then move slowly with the direction of motion. The OKN complements a range of gaze-stabilization strategies which together have numerous benefits for visual processing, including the reduction of motion blur, lowering retinal slip speed, and facilitating the tracking of stationary objects within a moving scene [1][2][3] . It is displayed by many species, including both vertebrates (rabbit 4 , pigeon 5 , cat 6 , salamander 7 , flying snake 8 ) and invertebrates (mantis shrimp 9 , crab 10 , locusts 11 ) and has proved a fruitful tool for analyzing the neural circuits of visual motion processing (mice 12,13 , crab 10 , zebrafish 14 , macaque, rabbit, cat, dog, pigeon 15 ).
The neural circuits enabling the OKN can be well studied in flies because much is known about the mechanisms of motion detection at every neural connection between the photoreceptors and the neck muscles in several species. Flies have to move their heads to control their gaze, as their compound eyes are not actuated to perform independent compensatory movements. Large, well-studied interneurons that respond to wide-field visual motion, known as lobula plate tangential cells (LPTCs), innervate directly and indirectly via descending neurons the neck motor neurons that move the fly's head [16][17][18][19][20][21][22][23][24][25][26][27][28][29] . In particular, LPTCs have motion receptive fields that match combinations of rotational and translational optic flow [30][31][32] , and are thought to support behavioral responses to wide-field motion, such as head turns and locomotor steering responses [33][34][35][36] . These cells integrate . The black arrows indicate the point of fixation moving rightwards as the eyes move syndirectionally with the grating, compensating for its motion. As the yaw angle of the eye's principal axis (θ) increases towards the limit of its angular range, the eyes saccade leftward, against the motion of the grating. Right: Schematic traces of the yaw eye angle (θ), indicating saccadic increases of the yaw angle against the direction of grating motion, and slow decreases in the yaw angle of the compensatory eye movements that follow the direction of grating motion. The net result is the characteristic sawtooth pattern of yaw eye angle. (B) Experimental design. Left: In every trial, a fly first viewed a pre-stimulus screen for 3 s (t = − 3 s to 0 s) of gratings that moved progressively in a front-to-back direction ('progressive') with either one of the following temporal frequencies, 0 Hz, 0.25 Hz, 1 Hz, 4 Hz, 10 Hz, or a grey screen. Center: We measured the yaw angle (θ) of the fly's head. During the stimulus period (t = 0 to 0.5 s) the fly viewed gratings moving in the same direction simulating the image motion that would occur during a yaw rotation ('rotation') with one of the following temporal frequencies, 0.25 Hz, 1 Hz, 4 Hz, 7 Hz, 10 Hz, 13 Hz, 18 Hz, 25 Hz. Right: After the stimulus period (t = 0.5 to 1.0 s), the fly viewed a grey screen. The visual field of the display screens spanned 180° azimuth and 90° elevation. www.nature.com/scientificreports/ motion due to yaw rotation, flies can saccade against the direction of motion 61,62,65 , but it is unclear whether these saccades are part of an OKN to stabilize the visual input, or a casting search for an object to fixate 66 . Here, we have recorded the head movements of tethered flies standing or walking on a trackball. The flies viewed a period of progressive translational image motion over both eyes that set the level of motion adaptation within a trial, before they were presented with image motion simulating a yaw rotation to induce movements of the head. We find that flies make fast and slow head yaw turns in both directions during the progressive motion stimulus. When they view rotational motion, on the other hand, the fast, saccadic head turns are biased against the direction of motion, while the slow head turns are syndirectional with the direction of the visual stimulus, creating head movements similar to an OKN. It is important to note that this response is not a fixed reflex. We observed flies to move their heads only in approximately half the trials, and it does not require the fly to be walking to be engaged, indicating that flies may choose from different gaze-stabilization strategies. In the trials with head movements, the temporal frequency tuning curve follows that found in LPTCs 43,44 , with a peak between 4 and 13 Hz. Surprisingly, we find that the temporal frequency tuning of this OKN-like behavior is robust to changes in walking speed and visual motion adaptation, despite the profound effects these factors have on the temporal frequency tuning of LPTCs.

Results
To observe the head movement responses to wide-field horizontal motion, we placed tethered blowflies on a trackball in front of gratings that covered a large fraction of the visual field (Fig. 1B) and filmed the head movements with a high-speed camera viewing the fly from above. The visual stimuli were organized to achieve two aims: (i) to characterize the temporal frequency tuning of head movements in response to simulated yaw rotations, and (ii) to assess the tuning's dependence on the level of motion adaptation. For the first aim, we presented yaw rotation gratings of a fixed spatial wavelengths moving with different velocities during a stimulus period lasting 0.5 s (Fig. 1B, center). For the second aim, the stimulus period was preceded by 3 s of progressive motion, simulating the horizontal image motion components induced by forward translation during walking (Fig. 1B, left). Since the level of motion adaptation increases with the temporal frequency 51 , we presented the flies with different temporal frequencies of progressive image motion in the pre-stimulus period, randomly ordered selections of 0 Hz, 0.25 Hz, 1 Hz, 4 Hz and 10 Hz, as well as a grey screen with equal mean luminance. Finally, the stimulus period was followed by a grey screen for 0.5 s between trials (Fig. 1B right).
Head movements in response to rotational image motion. In individual trials, flies moved their head with fast, saccadic turns or with slow turns (Fig. 2). In example trials ( Fig. 2A), the saccadic head turns were against the direction of visual motion, shown as a positive change in yaw angle, while slow head turns followed the grating, resulting in a negative change in yaw angle. Combined, these fast and slow head turns have the structure similar to the kinetics of an OKN (cf. Figure 1A).
The kinetics of the head movements were revealed by phase plots of the head yaw velocity and yaw angle (Fig. 2B). In this representation, a saccade against the direction of the grating described an upwards and rightwards arc (Fig. 2B, black lines). At the start of the movement, the head turned with the grating for a brief period (Fig. 2B, black arrows)-this was observed as a dip in the head position trace ( Fig. 2A, black arrows). The head then accelerated smoothly and peaked in velocity halfway through the turn, before slowing down. In the final phase, the head angle overshot and moved with the grating for a brief period ( Fig. 2A-B, white arrows), before the fly engaged in slow turns (Fig. 2B, grey lines). This phase structure of saccadic head turns-the trajectory of the head yaw angle and velocity-was preserved across fast (> 100°/s) head movements, with peak velocity and duration of the turns covarying approximately linearly (compare, e.g., 'saccade 1' and 'saccade 2' in Fig. 2B; positive fast turns in Fig. 2D-E).
The slow head movements also showed stereotypical structure in the phase plots (Fig. 2B). Sequences of slow compensatory motion were composed of small turns with initial counter-rotations and final overshoot sections of their trajectories, but unlike saccades they frequently lasted longer than 50 ms. The peak velocity and duration of the slow turns (> 50 ms) also covaried, but with peak velocities rarely exceeding 200°/s (slow head turns in Fig. 2C-E).
To classify head turns, we used thresholds that combined the peak angular velocity and duration (Fig. 2E). These thresholds identified fast, saccadic head turns as having an angular velocity > 100°/s, and slow head turns as having a duration > 50 ms, separated by linear boundaries. During the pre-stimulus period of progressive visual motion, there were saccadic and slow head movements in both yaw directions ( Fig. 2D; S1A). During the yaw rotation stimuli, head saccades against the direction of motion predominated, while slow turns were most frequently syndirectional with the motion stimulus ( Fig. 2E; S1A).

Rotational image motion selectively recruits OKN-like head movements.. The yaw movements
of the fly's head were constrained to a range of ± 25º (Fig. 3). The largest head saccades occurred when the head was to the side, with positive saccades occurring at negative yaw angles and vice versa (Fig. 3A Top). Head saccades occurred in both directions for the progressive motion, but the rate of positive saccades-moving against the direction of motion-increased during the rotational motion (Fig. 3A, Bottom -red traces). The rate of positive saccades significantly increased from 0.56 ± 0.07 turns/s across all pre-stimulus conditions to 0.79 ± 0.10 turns/s for the 4, 7 and 10 Hz rotational motion that generated robust OKN-like responses (mean ± S.E.M.; p = 0.004, paired t-test, N = 18; Fig. 3A, Bottom-red traces). Meanwhile, the rate of negative saccades decreased (from 0.52 ± 0.07 to 0.41 ± 0.07 turns/s; mean ± S.E.M.; p < 0.001, paired t-test, N = 18; Fig. 3A, Bottom-black traces). Slow head turns also occurred in both directions during the pre-stimulus progressive motion (Fig. 3B Fig. 3B, Bottom). Thus, while fast and slow head movements occur during progressive optic flow, rotational image motion selectively recruits fast head saccades against and slow head turns with the direction of motion. Saccades occurred most frequently when the head aligned with the body axis (yaw = 0º; Fig. 3A, Bottom). In contrast, slow head turns were most often initiated when the head was to the side. For the progressive motion, positive and negative slow head turns most frequently began at yaw angles of − 3.5 ± 0.9º and 4.6 ± 0.7º (mean ± S.E.M.) respectively, values significantly different from zero (positive turns: p = 0.001; negative turns: p < 0.001, t-test, N = 18; Fig. 3B, Bottom-left). During rotational motion, the peak initial angles of the slow To analyze the sequence of head movements, we considered large head turns (≥ 2.5º), since saccade head movements are characteristically preceded and followed by small movements in the opposite directions (Fig. 1A). In the trials analyzed in Fig. 3, the first head movement ≥ 2.5º was a head saccade against the direction of motion in 54 ± 4% of trials (mean ± S.E.M.), and a slow head movement with the direction of motion in 28 ± 5% of trials (mean ± S.E.M.). For the trials where the first head movement ≥ 2.5º was a head saccade against the direction of motion followed by another turn ≥ 2.5º, the second turn was a slow head movement with the direction of motion in 83 ± 4% of trials (mean ± S.E.M.). As a result of the typical sequence of fast then slow head turns, the average change in the head yaw angle from the start of rotational image motion is a small net positive movement against the direction of motion, illustrated for one fly in Fig. S1B, and for all flies in Fig. S2. This average change contrasts with the head movements of Drosophila, where average head movements are with the direction of motion 35,62,64 , and follow a typical sequence of slow then fast head turns over longer periods of rotational image motion 57,67 .
Together, these results show that saccadic and slow head turns can be generated at all head yaw angles within the range of movement, and that combinations of fast and slow head movements most often begin with a saccade to the side, followed by a slow turn of the head back to the forward direction.
Flexible performance of OKN-like head movements, independent of the locomotor state. While the OKN-like responses, consisting of fast turns against followed by slow turns with the direction of motion, occurred for all stimulus conditions, flies did not always engage in this behavior. In some trials, we observed the two kinds of head movements independent of the locomotor state of the animal (Fig. 4A). The distribution of head movements was bimodal (Fig. 4A, Right) and we separated head movements from periods of the head being kept nearly still when the rotation angle was below a threshold value of 2.5°. Likewise, the distribution of walking speeds was bimodal (Fig. 4A, Top). In this case we considered flies to be walking when they exceeded a walking speed of > 3 mm/s, otherwise they were classified as standing (Fig. 4B). In standing flies the head was most frequently still, while walking flies were most likely moving their head (stationary flies, p = 0.001; walking flies, p = 0.013; Wilcoxon signed rank test with Holm-Bonferroni correction for multiple comparisons, www.nature.com/scientificreports/ N = 18; Fig. 4B). However, we also observed head movements in standing flies, and stationary heads in walking flies (Fig. 4B).
To quantify the effect of visual motion on yaw head rotations in trials where the fly moved her head, we calculated an optokinetic index (OKI). The OKI is defined as the yaw angle accumulated during fast saccadic head turns minus the accumulated angle due to slow turns during the period of visual stimulation, scaled to a unit time of 1 s (see "Methods"). Thus, if in one second a fly saccades 10° against the yaw grating, and then compensates for the motion of the grating with slow turns for 10°, the optokinetic index is 20°/s. The range of observed head movements was limited to a maximum of ~ 40° (Fig. 4A, Right). The largest head yaw ranges (max Δ head yaw, Fig. 4A) occurred for the slowest walking speeds, and fast walking flies (> 30 mm/s) either displayed large head movements or kept their heads still.

Impact of visual motion adaptation on temporal frequency tuning of the optokinetic index, OKI.
During the yaw rotation stimulus period, the optokinetic index of walking flies varied with the temporal frequency of the moving grating, reaching a peak between 4 and 10 Hz and decreased at higher temporal frequencies (Fig. 5A). When a grey screen was shown in the pre-stimulus period (Fig. 5A, Left), the response to a yaw rotation stimulus presented at 0.25 Hz contrast frequency was low, and the peak response was an OKI of 13.5 ± 2.1°/s to a 7 Hz grating, decreasing to 3.6 ± 1.9°/s for 25 Hz motion. The OKI temporal frequency tuning curves are broadly consistent with the temporal frequency tuning of visual interneurons responding to widefield horizontal motion. For example, in response to comparable stimuli the H2 LPTC has a peak response at a temporal frequency of 5 Hz, and a sustained non-zero response to 25 Hz gratings in walking flies 44 . During the pre-stimulus progressive motion period, there was a near-zero optokinetic index, with a small bias between 0.7 and 1.7°/s (mean values for 0 Hz and 10 Hz pre-stimulus conditions, respectively) that was not significantly different from zero except for the 10 Hz pre-stimulus condition (p = 0.01, t-test with Holm-Bonferroni correction for multiple comparisons, N = 18; Fig. 5B).
The mean walking speed of the trials varied with the temporal frequency of the pre-stimulus progressive visual motion (Fig. 5C). Flies viewing a grey screen or stationary grating in the pre-stimulus period respectively walked with a forward velocity of 11.2 ± 1. www.nature.com/scientificreports/ Fig. 5C). As the velocity of the pre-stimulus grating increased, the forward walking speed increased significantly to 20.5 ± 2.7 mm/s after a 4 Hz pre-stimulus grating (p = 0.007, paired t-test with Holm-Bonferroni correction for multiple comparisons, N = 18; Fig. 5C), and reduced to 18.2 ± 1.7 mm/s when the pre-stimulus motion was 10 Hz (mean ± S.E.M.; Fig. 5C). An increase in walking speed is associated with higher sensitivity to visual motion stimuli presented at speeds beyond the LPTC temporal frequency optimum (e.g., > 5 Hz for H2 44 ). For high stimulus temporal frequencies, the OKI varied across the pre-stimulus conditions in a way that qualitatively reflected the differences in forward walking speed. For example, for the 25 Hz stimulus, the OKI increased from 3.6 ± 1.9°/s when preceded by the grey screen, to 12.8 ± 2.5°/s when preceded by 4 Hz progressive motion (mean ± S.E.M., p = 0.009, Wilcoxon signed rank test, N = 18; Fig. 5D). This trend of linear scaling of OKI with walking speed was maintained for the responses to 10, 13, 18 and 25 Hz stimuli across all pre-stimulus conditions, with the linear fit explaining 15% of the variance in the OKI (R 2 = 0.15, Fig. 5E).

Impact of walking speed on temporal frequency tuning of the OKI.
To investigate further the effect of walking speed on the OKI, we compared the head movements of flies across all pre-stimulus conditions combined (Fig. 6). During the pre-stimulus progressive motion period, the OKI was near-zero, with mean values between 1.4 and 1.6°/s (compared to zero: 0-3 mm/s, p = 0.1; 3-25 mm/s, p = 0.002; 25-100 mm/s, p = 0.1; t-test with Holm-Bonferroni correction for multiple comparisons, N = 18; Fig. 6A). In stationary flies (< 3 mm/s), the OKI peaked at 7 Hz, and in slow (3-25 mm/s) and fast walking (25-100 mm/s) flies the OKI peak occurred at 10 Hz (Fig. 6B). The walking speed also significantly increased the magnitude of the peak OKI, from 15.3 ± 2.6°/s in stationary flies to 23.7 ± 2.7°/s in fast walking flies (p = 0.04, two-sample t-test, N = 18; Fig. 6B). At high temporal frequencies such as 18 and 25 Hz, the gain of the OKI was not significantly affected (25 Hz: p = 0.84; 18 Hz, p = 0.84, with Holm-Bonferroni correction for multiple comparisons; Wilcoxon rank sum test, N = 18; Fig. 6B).
Neither the contribution of slow nor saccadic head movements significantly altered the responses to stimuli in this fraction of the input dynamic range (p > 0.05, with Holm-Bonferroni correction for multiple comparisons; Wilcoxon rank sum test, N = 18). Within the pre-stimulus conditions these trends were maintained, although www.nature.com/scientificreports/ with less statistical power. Together, these data indicate that the net amplitude of OKN-like head movements is correlated with walking speed, but that walking did not significantly increase the sensitivity to high temporal frequencies.

Discussion
We have shown that fast and slow head movements of flies combine to produce OKN-like responses to horizontal image motion, with fast head saccades against and slow head movements in the same direction as the retinal image shift (Fig. 2). In particular, we have shown how the kinematics of saccades and slow head turns can be discriminated in angular velocity and position phase space, allowing small amplitude saccades and slow turns to be detected (Fig. 2B,E). The head saccades were typically generated from central head positions, with slow turns bringing the head back into alignment with the longitudinal body axis (Fig. 3), a sequence of events that was hard to appreciate in previous work that quantified fly head movements with the average head position in the direction of the rotational image motion 35,[62][63][64] . Head movements were not unconditional reflexes, as flies were able to keep their head still when presented with rotational image motion. The ability to suppress head movements did not require locomotion, in contrast to a previous report on head movement responses to yaw and pitch image motion 63 (Figs. 4B, 6B). The temporal frequency tuning of the combined fast and slow optokinetic head movements matched that of upstream LPTCs reported in other studies 43,44 (Fig. 5A). While there were modest correlations between walking speed and the magnitude of the OKN-like response (Figs. 5C-E, 6), there was little evidence for the profound effect motion adaptation has on the temporal frequency tuning or gain of LPTCs. Our study has focused on yaw rotations, which have specific constraints and functional consequences compared to pitch and roll rotations 16,68 . Previous work has characterized how flying Drosophila stabilize their gaze for yaw image motion relative to the wide-field background, even when they produce saccadic body turns to track an object against a moving background 65,66 . Thus, rather than tracking the object by means of gaze shifts, the motion of the object is tracked against a stabilized background. This coordinated head and eye movement strategy has been argued to reduce motion blur and to increase the acceptable input dynamic range of wide-field image motion, allowing the visual system to better track motion in the visual field 57 . Our results are consistent with such a functional interpretation, and we propose that the slow head movements following rotational image motion are part of the blowfly's gaze stabilization against wide-field background motion.
Another recent study in Drosophila has found that saccadic head turns during optokinetic head movements are characteristically preceded by large (± 9º) yaw angles that trigger reset, ballistic head movements against the direction of motion 67 . The kinematics of head movements we observed were stereotypical and consistent with ballistic turns, but in contrast to that study 67 , we rarely observed head saccades from large yaw angles (Fig. 3A). This difference may reflect the species studied 56,58 , or the effects on gaze stabilization of flying versus walking 59,60 , but may also be a consequence of the stimuli used or of the task performed. In the vertebrate optokinetic nystagmus, the frequency and amplitude of saccades are affected by the visual stimulus parameters, such as the spatial  www.nature.com/scientificreports/ wavelength of the grating 69 , and by the instructions given to the subject, for example whether to 'look' at features in the grating or to 'stare' at the grating without trying to follow it 15 . Depending on these factors, saccades can stabilize the gaze with respect to the forward direction 15,70 or may be triggered by the need to reset the angular position of the eyes to enable the next slow eye movement 15,71 . In our data, flies were able to perform types of head movements other than those typical of the primate OKN, for example keeping their heads stationary (Fig. 4B) or saccading with the image motion (Figs. 2E, 3A). A limitation of our study is that we lack a detailed description of these other types of head movements required to quantify their properties and underlying control mechanisms. For example, Cellini et al. (2021) have suggested that flying Drosophila perform oscillatory microsaccades of ~ 1-2º when viewing stationary visual scenes 67 . These microsaccades may have contributed to many of the small head turns we recorded (Fig. 2D-E), and may be part of a gaze shift strategy used by the flies when not executing OKN-like head movements (Fig. 4B).
Two surprising results of our study were that prior motion adaptation does not dramatically reshape the gain or temporal frequency tuning of head movements (Fig. 5A), and that walking speed has only a modest effect on the response dynamics (Fig. 5E, 6A). These findings contrast with the strong effects of locomotion and motion adaptation on LPTCs 43,44,46,48,51 . Our visual stimuli were chosen to facilitate the comparison with recordings of an LPTC in a previous study on the effect locomotion has on the activity of the H2-cell, which is sensitive to regressive visual motion 44 . However, the left and right visual fields experience different directions of directional motion and visual motion adaptation in the switch from progressive to rotational pattern motion. In particular, the effect of the direction of pattern motion on visual motion adaptation has been explored in detail by Harris et al. (2000) 48 . They found that both preferred and anti-preferred motion shifted the contrast tuning to higher input dynamics and lowered the maximum response. However, the termination of motion in the preferred and anti-preferred direction resulted in a hyperpolarization and small depolarization, respectively. Thus, differentially adapted visual motion pathways in the left and right optic lobes may partially explain the observed differences between optokinetic-like head movements 36,62,72,73 and our previously reported LPTC responses 44 . On the other hand, the difference between the behavioral results and the electrophysiological LPTC responses was consistent with recordings from downstream descending neurons sensitive to wide-field visual motion, which are not affected by visual motion adaptation and the animal's locomotor state 54,55 . The mechanisms underlying such state-independent signaling are still not understood.
Our study further emphasizes the OKN-like eye movements as a general functional principle across phyla that facilitates visual processing by reducing wide-field retinal image shifts. It offers a conceptual framework to address the question of how state-dependent response properties found at central sensory interneurons are converted into state-invariant signals that are well suited to control adaptive motor behavior in a variety of visual surroundings. Recent work has highlighted how neck motor neurons and LPTCs receive sophisticated signals corresponding to the motor output and anticipated sensory effects of voluntary movements 42,63,64,[74][75][76] . Wellcharacterized OKN-like head movements offer an opportunity for detailed future studies of the sensorimotor transformations along the comparatively short neural pathways that connect LPTCs and other sensory modalities with the fly neck motor system.

Methods
Animal preparation. We used 5-16 day old female blowflies, Calliphora vicina, from our colony which were kept at 23 °C and at 50% humidity on a 12 h ON 12 h OFF light cycle. Flies were briefly cooled and a cardboard tether waxed to the thorax. The wing joints were also waxed to prevent wing movements. A dot of white acrylic paint was applied to the dorsal edge of each compound eye as markers for measuring changes in the head yaw angle. The flies recovered for > 1 h in a large holding cage with ad libitum access to sucrose and water.
We recorded the head movements of 18 flies. Experiments were run at room temperature of 21 °C. Individual flies were used for sets of 64 trials lasting 5 min, and then returned to the holding cage while we downloaded movies taken with a high-speed video camera (see below). Flies were tested over a mean of three days, and nine days was the longest period over which a fly was tested.
Experimental setup. We positioned flies on a trackball system described previously 44 . The polystyrene trackball had a diameter of 48 mm and a mass of the 1.6 g. The mass of the flies was typically ≈100 mg, and lighter trackballs were lifted by the flies. The trackball movements were detected by the sensors of two Razer Imperator computer mice (Razer GmbH, Germany), calibrated by rotating a mounted trackball with a step motor along the pitch, yaw and roll axes. The trackball sensors were connected by USB to the controlling computer and driven with NI VISA drivers (National Instruments Corp., USA). The trackball position was sampled at 170 Hz.
The visual stimuli were displayed on two CRT monitors (Vision Master Pro 454, Iiyama, Japan; 'screen 1' and 'screen 2' in Fig. 1B). The monitors were separated by 80° azimuth, and spanned a visual field of 180° azimuth and 90° elevation (Fig. 1B). Visual patterns were displayed at 170 Hz using PowerStrip (3.90 Entech, Taiwan) and an Quadro NVS290 graphics card (Nvidia Corp., USA), and generated using VisionEgg 1.2.1 77 , with a frame update rate of 170 Hz. To ensure that gratings were rendered and displayed correctly, we filmed the gratings at 500 frames per second with a high-speed camera when setting up the display, and then monitored frame update times using VisionEgg. Using the same display and method for identifying trials with dropped frames, we recorded high neuronal activities of H2-cells in walking flies in response to visual gratings moving at temporal frequencies of 25 Hz, e.g. Figure 3A of Longden et al. 44 . Thus, we were confident that the rendering of rapid gratings was sufficiently accurate to drive high neural responses.
The head position of the flies was filmed with a FASTCAM SA3 high-speed camera (Photron, UK) mounted vertically above the fly. The fly head movements were filmed at 500 Hz with a field of view of 128 × 128 pixels www.nature.com/scientificreports/ with 8 bits per pixel, controlled by the FASTCAM Viewer software (Photron, UK). Movies were stored on the camera's internal hard drive and downloaded by an Ethernet connection after each trial. Experiments were coordinated using Python 2.5 scripts running under Windows XP. The timing of each frame drawn from VisionEgg was used to query the trackball sensors using PyVISA. The filming was triggered at the start of a trial using Python NI-DAQmx package (National Instruments Corp., USA).
Visual stimuli. Trials lasted for 4 s. For the first 3 s, the flies viewed pre-stimulus visual gratings moving perpendicular to their vertical orientation, in the progressive front-to-back direction simulating forward translation, designed to result in different levels of visual motion adaptation (Fig. 1B). They then viewed for 0.5 s stimulus displays of wide-field horizontal image motion simulating yaw rotations, which were designed to test whether the flies performed head movements similar to an OKN. Finally, they viewed a blank grey screen for 0.5 s, which was included to mitigate the effects of visual motion adaptation between trials. We refer to the first 3 s of each trial as the pre-stimulus progressive image motion period (labelled 'progressive' in figures) and the subsequent 0.5 s as the stimulus rotational image motion period (labelled 'rotation' in figures). The visual stimuli were organized in this way to facilitate comparison with recordings of one LPTC in our prior study, in which we described the effect of locomotion on the activity of the H2 cell using a similar design 44 .
For all grating stimuli, the contrast ( I max −I min /I max + I min ) was 50%, and the spatial wavelength was 20° at the closest position to the fly. The grey screen conditions were luminance matched to the mean luminance of the gratings. There were 6 pre-stimulus conditions: a grey screen or gratings moving horizontally and progressively (in the front-to-back direction for the fly) on each screen to simulate the horizontal components of forward translation (Fig. 1B). For the five pre-stimulus conditions with moving gratings, the temporal frequencies were 0 Hz, 0.25 Hz, 1 Hz, 4 Hz and 10 Hz. There were 8 stimulus conditions: gratings moving with temporal frequencies of 0.25 Hz, 1 Hz, 4 Hz, 7 Hz, 10 Hz, 13 Hz, 18 Hz, and 25 Hz.
Trials were organized into sets of 64 trials, in which one fly was shown eight repetitions of all stimulus conditions, for one pre-stimulus condition, in a randomized order. In between the sets of 64 trials, flies were returned to the holding cage.
Image processing and data analysis. Images were processed using MATLAB 2014a (Mathworks, USA).
The angle of the thorax was manually determined for each fly. An intensity threshold was then applied to frames to generate a binary image of the white dots painted on the head, from which the yaw angle of the head relative to the thorax was tracked. The head yaw angle traces, which were sampled at 500 Hz, were filtered with a Savitzky-Golay filter with an order 7 polynomial and a window of 51 data points, corresponding to a 102 ms time window. The head and trackball movement responses to the left-to-right rotation stimuli were inverted and combined with the right-to-left rotation stimuli.
To analyze head turns, we classified every head yaw angle as part of a leftward or rightward turn. By necessity, leftward and rightward head turns must alternate, so we identified all the points where the head yaw direction changed, and classified the head yaw angles between these points as leftward or rightward turns. For each head turn we calculated the duration and maximum velocity of the turn (Fig. 2D-E), the maximum change in yaw angle (Fig. 4A), as well as the dynamics of the turns ( Fig. 2A-B). Positive and negative head yaw velocities indicate movements against and with the direction of rotational image motion, respectively. This convention was maintained during the pre-stimulus progressive image motion phase, where, for example, a rightward (clockwise) head turn defines a positive head yaw velocity.
To identify saccades, we used piecewise linear thresholds in a space of head turn duration (x-coordinate) and peak head yaw velocity (y-coordinate) shown in Fig. 2E: for head turn durations ≤ 50 ms, this was a peak head yaw velocity > 100°/s, or < − 100°/s; and for head turn durations > 50 ms, a point in this space above the line connecting [50 ms, 100°/s] and [100 ms, 1000°/s], or below the line connecting [50 ms, − 100°/s] and [100 ms, − 1000°/s]. We classified saccades as turns in one direction, and although saccades are preceded and followed by small turns in the opposite direction, as illustrated in Fig. 2A-B, we did not include these in the duration of the saccade. To identify slow turns, we also used piecewise linear thresholds in the space of head turn durations and peak head yaw velocities shown in Fig. 2E To identify stimulus periods of trials in which flies moved their heads, we calculated the maximum range of head yaw angles covered, max Δ head yaw, and applied a threshold of 2.5° (Fig. 4A). In trials in which the fly moved her head during the stimulus period, we calculated the optokinetic index by combining the sum of the yaw angle turned, θ, of all the positive saccades, θ + sac , and the sum of all the negative slow turns, − θ − slow . This combination ( θ + sac − θ − slow ) is the yaw angle covered by OKN-like head movements, that is, saccades against the direction of motion and slow movements with the direction of movement. We then subtracted the optokinetic nystagmus head movements in the opposing direction, the negative saccades, �θ − sac , and positive slow turns, − θ + slow , and scaled this index by the time period assessed, τ: The OKI, therefore, is the angle covered by OKN-like head movements per unit time.
For the data shown in Figs. 5 and 6, we used the responses of flies with ≥ 3 trials per stimulus temporal frequency condition.
To identify stimulus periods when the fly was stationary, we calculated the mean walking speed in the stimulus period and also the 0.5 s preceding the stimulus period, to rule out the effect of walking immediately prior to www.nature.com/scientificreports/ the stimulus period. We used a threshold of 3 mm/s to classify stationary trials (Fig. 4A). During the rotation stimulus, there was no significant optomotor response measured in the rotational velocity of the trackball 78 . This was likely a consequence of the rotation stimulus lasting for only 0.5 s, as comparable yaw rotation stimuli that were longer (4 s) generated robust optomotor responses using the same setup 44 .

Statistics.
To check the normality of data, we used the Anderson-Darling test. For pairwise comparisons of normally distributed data, we used the paired Students t-test, and two-sample t-test when not every fly contributed data. For testing whether the mean of normally distributed data was significantly different from zero, we used a one sample Student's t-test. For comparisons between data that was not normally distributed, we used the non-parametric Wilcoxon rank sum test for data where not every fly contributed, and the Wilcoxon signed rank test for pairwise data. To control for multiple comparisons, we used the Holm-Bonferroni correction.