# Serotonergic Neurons Mediate Operant Conditioning in Drosophila Larvae

Kristina T Klein, Elise C Croteau-Chonka, Lakshmi Narayan, Michael

Winding, Jean-Baptiste Masson, Marta Zlatic

► To cite this version:

Kristina T Klein, Elise C Croteau-Chonka, Lakshmi Narayan, Michael Winding, Jean-Baptiste Masson, et al. Serotonergic Neurons Mediate Operant Conditioning in Drosophila Larvae. 2021. pasteur-04008262

HAL Id: pasteur-04008262

https://pasteur.hal.science/pasteur-04008262

Preprint submitted on 28 Feb 2023

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Serotonergic Neurons Mediate Operant Conditioning in *Drosophila* Larvae

Kristina T Klein<sup>1,2,†</sup>, Elise C Croteau-Chonka<sup>1,2,†</sup>, Lakshmi Narayan<sup>1</sup>, Michael Winding<sup>1,2</sup>, Jean-Baptiste Masson<sup>1,3</sup>, Marta Zlatic<sup>1,2,4*</sup>

*For correspondence: mzlatic@mrc-lmb.cam.ac.uk (MZ)

†These authors contributed equally to this work

<sup>1</sup>Janelia Research Campus, Howard Hughes Medical Institute, Ashburn, Virginia, United States; <sup>2</sup>Department of Zoology, University of Cambridge, Cambridge, United Kingdom;

<sup>3</sup>Decision and Bayesian Computation, Neuroscience Department CNRS UMR 3751 & Computational Biology Department USR 3756 (C3BI/DBC), Institut Pasteur, CNRS, Paris,

<sup>4</sup>MRC Laboratory of Molecular Biology, Trumpington, Cambridge, United Kingdom

**Abstract** Observed across species, operant conditioning facilitates learned associations between behaviours and outcomes, biasing future action selection to maximise reward and avoid punishment. To elucidate the underlying neural mechanisms, we built a high-throughput tracker for *Drosophila melanogaster* larvae, combining real-time behaviour detection with closed-loop optogenetic and thermogenetic stimulation capabilities. We demonstrate operant conditioning in *Drosophila* larvae by inducing a bend direction preference through optogenetic activation of reward-encoding serotonergic neurons. Specifically, we establish that the ventral nerve cord is necessary for this memory formation. Our results extend the role of serotonergic neurons for learning in insects as well as the existence of learning circuits outside the mushroom body. This work supports future studies on the function of serotonin and the mechanisms underlying operant conditioning at both circuit and cellular levels.

## Introduction

Animals must rapidly alter their behaviour in response to environmental changes. An important adaptation strategy is associative learning (*Dickinson, 1981; Rescorla, 1988*), in which an animal learns to predict an *unconditioned stimulus* (US) by the occurrence of a *conditioned stimulus* (CS). The US is often a punishing or rewarding event such as pain or the discovery of a new food source (*Pavlov, 1927*). The nature of the CS distinguishes two major associative learning types: classical conditioning (*Pavlov, 1927*) and operant conditioning (*Skinner, 1938; Thorndike, 1911*).

In classical conditioning, the CS is an inherently neutral environmental stimulus such as a sound, odour, or visual cue. Pairing with an appetitive or aversive US leads to learned approach or avoidance of the CS in the future. Many vertebrates (*Andreatta and Pauli, 2015; Brown et al., 1951; Jones et al., 2005; Braubach et al., 2009*) and invertebrates (*Takeda, 1961; Vinauger et al., 2014; Alexander et al., 1984; Wen et al., 1997; Scherer et al., 2003; Davis, 2005; Cognigni et al., 2018; Vogt et al., 2014) can make these associations. Across the animal kingdom, neural circuits have been identified as convergence sites for the external CS and the rewarding or punishing US (*Heisenberg et al., 1985; Hawkins and Byrne, 2015; Owald and Waddell, 2015; Gründemann and Lüthi, 2015; Caroni, 2015; Tonegawa et al., 2015). In classical conditioning of both larval and adult *Drosophila*,
the mushroom body (MB) brain area serves this purpose (Cognigni et al., 2018; Heisenberg et al., 1985; Heisenberg, 2003; Rohwedder et al., 2016; Vogt et al., 2014; Saumweber et al., 2018; Owald and Waddell, 2015). In each larval brain hemisphere, the CS is encoded by a subset of the approximately 110 Kenyon cells (KCs) (Aso et al., 2014a; Honegger et al., 2011; Berck et al., 2016; Lin et al., 2014; Owald and Waddell, 2015; Campbell et al., 2013; Turner et al., 2008; Eichler et al., 2017), which synapse onto 24 MB output neurons (MBONs) driving approach or avoidance (Aso et al., 2014b; Owald et al., 2015; Perisse et al., 2016; Séjourné et al., 2011; Saumweber et al., 2018; Shyu et al., 2017; Plaçais et al., 2013; Eichler et al., 2017). KC to MBON connection strength is modulated by dopaminergic and octopaminergic neurons, which represent the rewarding or punishing US (Schwaerzel et al., 2003; Schroll et al., 2006; Honjo and Furukubo-Tokunaga, 2009; Vogt et al., 2014; Saumweber et al., 2018; Waddell, 2013). Activation of the MB-innervating PAM cluster dopaminergic neurons serves as both a necessary and sufficient reward signal in classical conditioning (Rohwedder et al., 2016; Liu et al., 2012; Vogt et al., 2014; Waddell, 2013; Cognigni et al., 2018).

In operant conditioning, the CS is an animal's own action (Skinner, 1938; Thorndike, 1911). After memory formation, the animal can predict the outcome of its behaviour and bias future action selection accordingly, usually to maximise reward and avoid punishment (Skinner, 1938). This behavioural adaptation can facilitate novel action sequences (Topál et al., 2006; Nottebohm, 1991; Fee and Goldberg, 2011) and, in some cases, repetitive, high-frequency motor activity (Olds and Milner, 1954; Corbett and Wise, 1980; Jin and Costa, 2010; Lovell et al., 2015). Such observations have wider implications for understanding diseases including obsessive-compulsive disorder and addiction (Everitt et al., 2018; Balleine et al., 2015; Joel, 2006). Invertebrates are also capable of operant conditioning (Brembs, 2003; Hoyle, 1979; Abramson et al., 2016; Nuwal et al., 2012; Booker and Quinn, 1981). Despite countless operant conditioning experiments across species using various CS-US combinations, the underlying neural mechanisms remain poorly understood. For an animal to associate an action with its outcome, behavioural information must converge with circuits encoding positive or negative valence. Although vertebrate basal ganglia-like structures exemplify this (Fee and Goldberg, 2011; Redgrave et al., 2011; Balleine et al., 2009), some learned action-outcome associations do not require the brain (Booker and Quinn, 1981; Horridge, 1962; Grau et al., 1998). Operant conditioning may hence occur in more than one area of the central nervous system (CNS). It is also unclear to what extent learning at these sites is mediated by synaptic plasticity (Lovinger, 2010; Surmeier et al., 2007; Reynolds and Wickens, 2002; Joynes et al., 2004; Gómez-Pinilla et al., 2007) versus changes in the intrinsic excitability of individual neurons (Dong et al., 2006; Shen et al., 2005; Nargeot et al., 1997; Brembs et al., 2002; Nargeot et al., 2009). We aim to establish the *Drosophila* larva as a tractable model system for studying the neural circuit mechanisms underlying operant conditioning.

*Drosophila melanogaster* larvae perform various different actions. Typically, when exploring an environment, a larva alternates between crawling via forward peristalsis (Heckscher et al., 2012) and bending its head once or more to the left or right (Gómez-Marin et al., 2011; Luo et al., 2010; Kane et al., 2013; Figure 1A). In the presence of nociceptive stimuli, larvae exhibit escape behaviour. While the most common response is an increase in bending away from undesirable conditions, including extreme temperature (Luo et al., 2010; Lahiri et al., 2011), light (Kane et al., 2013), or wind (Jovanic et al., 2019), larvae also retreat from aversive sources using backward peristalsis (Masson et al., 2020; Kernan et al., 1994; Heckscher et al., 2012; Vogelstein et al., 2014; Figure 1A). The fastest escape response is rolling, where the larva moves laterally by curling into a C-shape and quickly turning around its own body axis (Robertson et al., 2013; Hwang et al., 2007; Ohyama et al., 2013; Figure 1A). In nature, rolling is only observed after exposure to a strong noxious stimulus, such as heat or a predator attack (Ohyama et al., 2015; Robertson et al., 2013; Tracey et al., 2003).

Powerful genetic toolkits have advanced the observation and manipulation of larval behaviour at the cellular level, making *Drosophila* larvae particularly well-suited for studying the neural mechanisms underlying learning. In *Drosophila*, individual neurons are uniquely identifiable, with mor-
phology and function preserved across animals (Skeath and Thor, 2003; Wong et al., 2002; Marin et al., 2002; Jefferis et al., 2007). Together with tissue-localised protein expression afforded by the GAL4-UAS binary expression system (Fischer et al., 1988; Brand and Perrimon, 1993), this has yielded neuron-specific GAL4 drivers (Jenett et al., 2012; Luan et al., 2006; Pfeiffer et al., 2010) that reproducibly target the same group of cells in each individual. Adding fluorescent markers helps pinpoint a neuron's location and reveal its anatomical features (Lee and Luo, 1999), while producing light-sensitive channelrhodopsins and temperature-sensitive ion channels facilitates optogenetic (Zemelman et al., 2002; Lima and Miesenböck, 2005) or thermogenetic (Hamada et al., 2008; Kiyamoto, 2001) modulation of neural activity. Furthermore, the larva's compact CNS has made it feasible to manually reconstruct neurons and their synaptic partners from a larval electron microscope (EM) volume (Berck et al., 2016; Eichler et al., 2017; Fushiki et al., 2016; Ohyama et al., 2015; Schlegel et al., 2016; Larderet et al., 2017; Jovanic et al., 2016, 2019), giving rise to a full wiring diagram of the MB (Eichler et al., 2017; Eschbach et al., 2020a,b).

There is overwhelming evidence that larvae are capable of classical conditioning. They can be trained to approach an odour paired with a gustatory reward (Schleyer et al., 2011; Hendel et al., 2005; Kudow et al., 2017; Niewalda et al., 2008), or avoid an odour paired with light (von Essen et al., 2011), electric shock (Aceves-Piña and Quinn, 1979; Tully et al., 1994), heat (Khurana et al., 2012), vibration (Eschbach et al., 2011), or the bitter compound quinine (Gerber and Hendel, 2006; Apostolopoulou et al., 2014). Light can also be a CS: innate avoidance of light and preference for darkness (Sawin-McCormack et al., 1995) can be modulated when paired with reward or punishment (Gerber et al., 2004; von Essen et al., 2011). It has remained an open question, however, whether *Drosophila* larvae can form action-outcome associations and where in the CNS these memories are formed.

Conducting operant conditioning with larvae requires real-time behaviour detection such that reward or punishment can be administered with minimal delay (Figure 1B). Single-animal closed-loop trackers have recently been developed (Schulze et al., 2015; Tadres and Louis, 2020). However, the efficiency of training paradigms would improve with automated US delivery and simultaneous conditioning of multiple animals. Therefore, we here introduce a high-throughput tracker for *Drosophila* larvae with real-time behaviour detection and closed-loop stimulation. Efficiency of the setup stems from the simultaneous, real-time, behaviour detection for up to 16 freely moving larvae, and targeted closed-loop optogenetic and thermogenetic stimulus delivery with full intensity control and minimal delay.

## Results

### High-throughput closed-loop tracker

#### Hardware design

Designing an automated operant conditioning protocol for the *Drosophila* larva was challenging due to the larva's physical characteristics. We excluded partial immobilisation protocols similar to the ones used to condition adult *Drosophila* navigation through virtual environments (Nuwal et al., 2012; Wolf and Heisenberg, 1991; Wolf et al., 1998; Brembs, 2011). We instead built a high-throughput multi-larva tracker combining live computer vision behaviour detection with closed-loop control of US delivery in response to unrestricted larval behaviour.

All hardware resided within an optically opaque enclosure to ensure experiments were performed without environmental light. Larvae moved freely on an agarose plate, backlit from below by an infrared LED and observed from above through a high-resolution camera (Figure 1C). A Camera Link communication protocol interfaced with a high-performance field-programmable gate array (FPGA), which itself interacted with the host computer. The FPGA and the host computer performed image processing, behaviour detection, and stimulus calculation (Figure 1D).

Our operant conditioning paradigm targeted individual larvae performing specific behaviours. Optogenetic stimulation was achieved by directing red light through two digital micromirror devices.
<figure><img src="image_2.png" /></figure>

<figure><img src="image_3.png" /><figcaption>**Figure 1.** High-throughput operant conditioning in *Drosophila* larvae. **a.** Behavioural repertoire of *Drosophila* larvae. Schematics show the four most prominent actions displayed by *Drosophila* larvae ( crawl, left and right bend, back-up and roll). The larval contour is displayed as a black outline with a green dot marking the head. **b.** In fully automated operant conditioning, an action of interest was reinforced by coupling real-time behaviour detection with optogenetic activation of reward circuits. **c.** High-throughput tracker schematic showing the relative positions of the agarose plate, backlight, camera, digital micromirror devices (DMDs), and galvanometers. IR: infrared. **d.** Block diagram of hardware components. AO: analogue output, FPGA: field-programmable gate array. **e.** Data flow between software elements.</figcaption></figure>

**Figure 1-Figure supplement 1.** Contour calculation on field-programmable gate array (FPGA).

**Figure 1-Figure supplement 2.** Detecting head and tail.

**Figure 1-Figure supplement 3.** Calculating a smooth spine and landmark points.

**Figure 1-Figure supplement 4.** Calculating direction vectors.

**Figure 1-Figure supplement 5.** Features describing body shape.

**Figure 1-Figure supplement 6.** Velocity features.

**Figure 1-Figure supplement 7.** Temporal smoothing of features.

**Figure 1-Figure supplement 8.** Differentiation by convolution.
141 vices (DMDs) which were programmed to project small 1 cm² squares at the location of individual larvae. Both DMDs, which were positioned to project over the entire plate area, were operated simultaneously (Figure 1C).

142 Thermogenetic stimulation of individual larvae was achieved by directing a 1490 nm infrared (IR) laser beam through a two-axis scanning galvanometer mirror positioning system (Figure 1C), a technique previously used to stimulate single adult flies (Bath et al., 2014; Wu et al., 2014). Because the 1490 nm wavelength is well-absorbed by water (Curcio and Petty, 1951), larvae exposed to the IR beam were rapidly heated. We took advantage of the galvanometer's high scanning velocity to rapidly cycle the beam between four larvae (Figure 1D).

## Software architecture

150 Several computer vision algorithms exist for real-time tracking of freely behaving animals. Stowers et al. (2017) and Krynitsky et al. (2020) developed software for tracking mice, and Mischiati et al. (2015) developed high-speed tracking of single dragonflies in three-dimensional space. There are numerous tracking frameworks for adult *Drosophila*, some requiring the flies to move within a two-dimensional plane (Straw and Dickinson, 2009; Donelson et al., 2012) while others detect the three-dimensional position of single (Fry et al., 2008) or multiple (Grover et al., 2008; Straw et al., 2011) flies. The Multi-Worm Tracker (MWT) software developed by Swierczek et al. (2011) is suitable for simultaneously tracking a large number of *Caenorhabditis elegans* and has been adapted to analyse *Drosophila* larvae reactions in response to various stimuli (Ohyama et al., 2013; Vogelstein et al., 2014; Jovanic et al., 2019; Masson et al., 2020).

151 Operant conditioning requires live behaviour detection to trigger delivery of reward or punishment. Numerous algorithms have been developed to analyse offline behavioural recordings of animals such as *C. elegans* (Huang et al., 2006; Stephens et al., 2008; Gupta and Gomez-Marin, 2019), zebrafish larvae (*Mirat et al., 2013; Reddy et al., 2020*), adult *Drosophila* (*Katsov and Clandinin, 2008; Branson et al., 2009; Dankert et al., 2009; Robie et al., 2017; Berman et al., 2014; Klibaite et al., 2017), bees (*Veeraraghavan et al., 2008*), and mice (*Mathis et al., 2018; Luxem et al., 2020; van Dam et al., 2020). The *Drosophila* larva has also attracted attention due to analytical challenges surrounding its deformable body and limited set of distinguishing features (*Luo et al., 2010; Gomez-Marin et al., 2011; Gershow et al., 2012; Denisov et al., 2013; Vogelstein et al., 2014; Ohyama et al., 2013, 2015; Masson et al., 2020). Most of these approaches are not ideal to run in real time or require a mix of past and future information to provide reliable behaviour detection (*Gomez-Marin et al., 2011; Masson et al., 2020*). More generally, machine learning based methods have gained momentum in providing both supervised and unsupervised approaches to behaviour analysis. It is worth noting a recent trend in developing unsupervised learning methods (e. g. *Graving and Couzin, 2020; Luxem et al., 2020*).

152 While real-time behaviour detection of casts and runs has been developed for a single animal (Schulze et al., 2015), our study of operant conditioning in freely behaving *Drosophila* larvae required efficient, real-time behaviour detection of multiple animals. We built a system to simultaneously track up to 16 larvae in real time, using LabVIEW for the user interface and algorithm implementation (Figure 1E). Instrumental to this software architecture was the fast image processing speed afforded by FPGA-based parallelisation (Soares dos Santos and Ferreira, 2014; Li et al., 2011; Zhang et al., 2017). Neuroscientists have adapted FPGA's real-time analysis capabilities (Shirvaikar and Bushnaq, 2009; Uzun et al., 2005; Chiuchisan, 2013; Yasukawa et al., 2016) to track rats (Chen et al., 2005), zebrafish larvae (Cong et al., 2017), and fluorescently labelled neurons in freely behaving *Drosophila* larvae (Karagyozov et al., 2018). In our system, the FPGA and host computer worked together to read the raw camera images, detect eligible objects, and extract and process object features (i. e. contour, head and tail position, and body axis) (Figure 1E). Larval body shape, velocity, and direction of motion facilitated robust behaviour detection which, in turn, drove closed-loop optogenetic and thermogenetic stimulation. All relevant experiment parameters and time-series data were output for offline analysis through a custom MATLAB framework
191 (see Materials and methods).

Optogenetic and thermogenetic stimulation efficiency verified by behavioural readout
We conducted proof-of-principle experiments to ensure that our set-up could be successfully used
for optogenetic stimulation (Figure 2A). Ohyama et al. (2015) have identified two GAL4 lines ex-
pressed in neurons whose activation triggers strong rolling behaviour. 69F06-Gal4 drives expres-
sion in command neurons for rolling, whereas 72F11-Gal4 drives expression in the Basin neurons,
which integrate mechanosensory and nociceptive stimuli. Klapoetke et al. (2014) have developed
the red-shifted channelrhodopsin CsChrimson, which can be expressed under GAL4 control. We
tested whether 69F06-Gal4 x UAS-CsChrimson and 72F11-Gal4 x UAS-CsChrimson larvae rolled upon
exposure to red light (Figure 2B, see also Materials and methods). In each stimulation cycle, we
observed above-threshold rolls in over 40% of 69F06-Gal4 x UAS-CsChrimson larvae and over 70%
of 72F11-Gal4 x UAS-CsChrimson larvae. This behaviour significantly contrasted with that of attP2 x
UAS-CsChrimson control larvae (Figure 2C), suggesting that the DMDs could be used for optogenetic
stimulation without activating the animals' photoreceptors.

We also verified the efficacy of the galvanometer set-up for thermogenetic stimulation (Fig-
ure 2D). We tested whether 69F06-Gal4 x UAS-dTrpA1 and 72F11-Gal4 x UAS-dTrpA1 larvae rolled
upon exposure to the IR laser (Figure 2E, see also Materials and methods). In each stimulation
cycle, we observed above-threshold rolls in over 70% of 69F06-Gal4 x UAS-dTrpA1 larvae and over
35% of 72F11-Gal4 x UAS-dTrpA1 larvae; a significant contrast to the attP2 x UAS-dTrpA1 control lar-
vae whose roll rate was close to zero. We concluded that these heating conditions were effective
for targeted Trp channel activation without larvae perceiving strong pain (Figure 2F).

Operant conditioning of larval bend direction

We chose optogenetic activation of reward circuits as a US for automated operant conditioning.
The main challenge was determining which neurons could convey a sufficient reinforcement sig-
nal, especially as the capacity for *Drosophila* larvae to exhibit operant learning was not yet demon-
strated. Across the animal kingdom, it has been observed that biogenic amine neurotransmitters
can provide such a signal (Gurfa, 2006; Hawkins and Byrne, 2015; Meneses and Liy-Salmeron, 2012;
Fee and Goldberg, 2011). It is also conceivable that the *Drosophila* PAM cluster dopaminergic neu-
rons that can signal reward in classical conditioning (Rohwedder et al., 2016; Liu et al., 2012; Vogt
et al., 2014; Cognigni et al., 2018; Waddell, 2013) may perform similarly in operant conditioning.
We therefore aimed to induce operant conditioning by stimulating a broad set of dopaminergic
and serotonergic neurons. If valence signalling relevant for operant conditioning is mediated by
one of these two neurotransmitters, activation of this large set of neurons paired with behaviour
should be sufficient to induce learning.

We expressed UAS-CsChrimson under the control of the Ddc-Gal4 driver, which covers a large
set of dopaminergic and serotonergic neurons in the CNS (Li et al., 2000; Sitaraman et al., 2008;
Lundell and Hirsh, 1994), including the PAM cluster (Liu et al., 2012; Aso et al., 2012). Although the
function of most Ddc neurons is unknown, their collective activation can substitute for an olfactory
conditioning reward in adult flies (Liu et al., 2012; Shyu et al., 2017; Aso et al., 2012). The goal
of our paradigm was to establish a learned direction preference for bending, conditioning Ddc-
Gal4 x UAS-CsChrimson larvae to bend more often to one side than the other. Although stimulation
side was randomized across trials, we describe (for simplicity) the experiment procedure where
this predefined side was the left. Each experiment began with a one-minute test period where
no light was presented. What followed were four training sessions, each three-minutes long, in
which larvae received optogenetic stimulation when bending to the left. Between training sessions,
larvae experienced three minutes without stimulation. Larvae were periodically brushed back to
the centre of the agarose plate to mitigate the experimental side effects of reaching the plate's
edge (see Materials and methods for more details). Following the fourth training session was a
one-minute test period without stimulation (Figure 3A).
<figure><img src="image_4.png" /></figure>

<figure><img src="image_5.png" /></figure>

<figure><img src="image_6.png" /></figure>

**Figure 2. Optogenetic and thermogenetic stimulation with the high-throughput tracker.** a. Hardware design schematic for optogenetic stimulation. Although the high-throughput tracker included two digital micromirror devices (DMDs), only one is shown for simplicity. b. Proof-of-principal experiment protocol for optogenetic stimulation. c. The fraction of larvae for which a roll was detected in each stimulation cycle. 69F06-Gal4 x UAS-CsChrimson and 72F11-Gal4 x UAS-CsChrimson larvae (*CsChrimson* expressed in neurons triggering roll behaviour; experiment groups) were compared to *attP2* x *UAS-CsChrimson* larvae (no *CsChrimson* expression; control group). Fisher's exact test was used to calculate statistical differences between the experiment and control groups (*** *p* < 0.001). d. Hardware design schematic for thermogenetic stimulation. Although the high-throughput tracker included four two-axis galvanometers, only one is shown for simplicity. IR: infrared. e. Proof-of-principal experiment protocol for thermogenetic stimulation. f. The fraction of larvae for which a roll was detected in each stimulation cycle. 69F06-Gal4 x UAS-dTrpA1 and 72F11-Gal4 x UAS-dTrpA1 larvae (*dTrpA1* expressed in neurons triggering roll behaviour; experiment groups) were compared to *attP2* x *UAS-dTrpA1* larvae (no *dTrpA1* expression; control group). Fisher's exact test was used to calculate statistical differences between the experiment and control groups (*** *p* < 0.001).
<figure><img src="image_7.png" /></figure>

<figure><img src="image_8.png" /></figure>

<figure><img src="image_9.png" /></figure>

○ no expression

○ dopaminergic

○ dopaminergic and serotonergic

<figure><img src="image_10.png" /></figure>

<figure><img src="image_11.png" /></figure>

<figure><img src="image_12.png" /><figcaption>**Figure 3. Operant conditioning of bend direction in *Drosophila* larvae requires the ventral nerve cord.** **a.** Experiment protocol using the high-throughput closed-loop tracker. Behaviours are depicted as larval contours (black) with head (green). During training, the larva received an optogenetic stimulus (red light bulb) whenever it bent to one predefined side (here depicted as the left for simplicity), and light was switched off during all other behaviours (grey light bulb). **b,d,e.** Larval bend rate shown as the number of bends per minute, grouped by bend direction. The bend rate to the stimulated side (depicted as a left bend with a red light bulb for simplicity) is shown in red and the bend rate to the unstimulated side (depicted as a right bend with a grey light bulb for simplicity) is shown in grey. For larvae that received random, uncorrelated stimulation during 50% of bends, the bend rates to the left and right are shown in black. Statistical differences within groups were tested with a two-sided Wilcoxon signed-rank test; statistical differences between two groups were tested with a two-sided Mann-Whitney *U* test.</figcaption></figure>

**c,f.** Probability that a given bend was directed towards the stimulated side or, in the case of the uncorrelated training group, towards the left. Grey line indicates equal probability of 0.5 for bends to either side. Statistics calculated from a two-sided Wilcoxon signed-rank test. **b-f.** Gal4 expression depicted as color-coded **CNS.** All data is shown as (mean ± s. e. m.). n. s. *p* ≥ 0.05 (not significant), * *p* < 0.05, ** *p* < 0.01, *** *p* < 0.001.

**b.** Bend rate for *Ddc-Gal4* x *UAS-CsChrimson* larvae. Data is shown from the test period before the first training session and the test period after the fourth training session. **c.** Data from same experiments as in **b.** **d.** Same data as in **b**, but bend rate for uncorrelated training group was calculated without stratification by bend direction. **e.** Bend rate for *Ddc-Gal4* x *UAS-CsChrimson*; *tsh-LexA*, *LexAop-Gal80* and *58E02-Gal4* x *UAS-CsChrimson* larvae. The effector, *UAS-CsChrimson*, is omitted from the figure for visual clarity. Data is shown from the test period immediately following the fourth training session. **f.** Data from same experiments as in **e.**

**Figure 3-Figure supplement 1.** *Ddc-Gal4* expression pattern without and with *tsh-Gal80* restriction.
For each larva, two measures served as a read-out for bend direction preference: i) the bend rate, measured as the number of bends per minute performed towards a given side, and ii) the probability that a given bend was directed towards the stimulated side, obtained by normalising the bend rate with the total number of bends performed by the larva in that minute. Individual larva variation in bend rate yielded different results for these measures at the population level. In the one-minute test prior to the first training session, we observed no significant difference in larval bend rate to either side and the likelihood of these naïve animals choosing one side over the other was not significantly different from chance. In the one-minute test following the fourth training session, larvae showed a preference for bends towards the side paired with red light stimulation during training, and the probability of these larvae bending towards this previously stimulated side was significantly greater than 50% (Figure 3B).

The light-dependent activation of neurons using *CsChrimson* requires a cofactor, retinal, which we supplemented in the food during development (Klapoetke et al., 2014; see Materials and methods). A control group of larvae raised on food without retinal showed no significant difference in absolute bend rate (Figure 3B) or bend direction probability (Figure 3C) throughout the experiment. This suggested that the *US*, which triggered a learned direction preference for bends in larvae raised on retinal, was indeed the collective activation of all *Ddc* neurons and not the red light itself. Notably, when directly comparing larvae raised with retinal to this control group raised without, the two groups showed no significant difference in the bend rate towards the stimulated side. Instead, the bend rate towards the unstimulated side was significantly reduced in larvae that received paired training compared to this control (Figure 3B). This raised the question whether larvae were learning to prefer the side paired with the rewarding *US*, or rather to avoid the side without the stimulus.

To confirm that the bend preference we observed after training was attributable to pairing light with bends solely in one direction, we conducted another control experiment in which larvae received random, uncorrelated stimulation during 50% of bends regardless of direction. After training, larvae showed neither a difference in absolute left and right bend rates, nor a significant probability of choosing one side over the other (Figure 3B, Figure 3C). These bend rates averaged together were indistinguishable from those of pair-trained larvae as they bent to the previously stimulated side. However, larvae which received uncorrelated training showed a significantly higher bend rate overall compared to pair-trained larvae bending to the previously unstimulated side (Figure 3D).

## The mushroom body is not sufficient to mediate operant conditioning in larvae

Our experiments showed that activation of *Ddc* neurons is a sufficient *US* for operant conditioning. While we did not identify which individual neurons mediate the observed effect, we hypothesised that not all *Ddc* neurons are involved. Some prior work in adult flies suggests that the *MB* is involved in operant conditioning (Sun et al., 2020), while other studies in the adult suggest that operant conditioning does not require the *MB* (Booker and Quinn, 1981; Wolf et al., 1998; *Colomb and Brembs*, 2010, 2016) and may instead involve motor neuron plasticity (*Colomb and Brembs*, 2016). The extent to which the *MB* is dispensable in larval operant conditioning is unknown. We investigated whether smaller subsets of *Ddc* neurons in the brain and subesophageal zone (SEZ) could support memory formation in our bend direction paradigm.

GAL80 under control of the *tsh* promoter suppresses GAL4 expression in the ventral nerve cord (VNC), but not in the brain or SEZ (Clyne and Miesenböck, 2008; Figure 3–Figure Supplement 1). When trained under our operant conditioning protocol (Figure 3A), *Ddc-Gal4* x *UAS-CsChrimson*; *tsh-LexA*, *LexAop-Gal80* larvae were equally likely to bend towards the side where they had previously received the optogenetic stimulus as they were to bend towards the unstimulated side (Figure 3E, Figure 3F). Activating these neurons was thus an insufficient rewarding *US* in this paradigm. The loss of the operant conditioning effect we observed with *Ddc-Gal4* x *UAS-CsChrimson* larvae highlighted the necessity of dopaminergic or serotonergic neurons in the VNC for the formation of a
290 bend direction preference. Their sufficiency was inconclusive, however, since perhaps two or more
291 distinct groups of *Ddc* neurons needed collective activation in order to form a memory.

292 We then assessed whether exclusively activating the PAM cluster dopaminergic neurons inner-
293 vating the MB could induce operant conditioning, as is the case for classical conditioning. 58E02-
294 *Gal4* drives expression in the majority of these neurons (*Rohwedder et al., 2016*). 58E02-*Gal4* x UAS-
295 *CsChrimson* larvae did not develop any direction preference for bends following training (*Figure 3E*,
296 *Figure 3F*). It is unsurprising that activation of these neurons alone could not act as a rewarding
297 US in this paradigm, given our finding that *Ddc* neurons in the brain and SEZ are insufficient. It is
298 remarkable, however, because it suggests that the neural circuits signalling reward in operant con-
299 ditioning differ from those of classical conditioning. Although it remains to be seen whether these
300 PAM cluster neurons contribute to memory formation by interacting with other *Ddc* neurons, these
301 results further supported the idea that operant conditioning in *Drosophila* may not be mediated
302 by the MB.

303 **Serotonergic neurons in brain and SEZ are a sufficient reward signal in classical conditioning**
304

305 Pairing an action with activation of numerous dopaminergic and serotonergic neurons across the
306 CNS was sufficient to induce operant conditioning of bend direction preference. Furthermore, our
307 results indicated that the VNC subset of these neurons was essential for memory formation in the
308 paradigm. It was an open question, however, whether this learning was mediated by dopamine,
309 serotonin, or both. Dopamine and serotonin receptors are necessary for different classical con-
310 ditioning tasks in honeybees, suggesting that the two neurotransmitters may carry out separate
311 functions (*Wright et al., 2010*). We conducted a high-throughput classical conditioning screen of
312 sparser dopaminergic and serotonergic driver lines to identify US candidates for comparison with
313 our operant conditioning paradigm.

314 We expressed *CsChrimson* under the control of different GAL4 driver lines and tested whether
315 pairing optogenetic activation of these neurons (US) with odour presentation (CS) could induce
316 olfactory memory. Conditioning was performed using a similar procedure to those described in
317 *Gerber and Hendel (2006)*, *Saumweber et al. (2011)* and *Eschbach et al. (2020b)*. In the paired
318 group, larvae were exposed to alternating three-minute presentations of ethyl acetate with red
319 light and air with no light. To ensure that any observed effects were a result of learning rather
320 than innate odour preference or avoidance, an unpaired group was trained simultaneously with
321 reciprocal stimulus presentation (odour/dark, air/light). Following training, larvae in both groups
322 were tested on their preference for the odour in the absence of light (*Figure 4A*). All learning scores
323 were compared to a negative control containing no GAL4 driver, *w*<sup>1118</sup> x UAS-*CsChrimson*, which
324 did not exhibit a learning phenotype (*Figure 4B*). Consistent with prior study results (*Rohwedder
325 et al., 2016; Eichler et al., 2017; Almeida-Carvalho et al., 2017*), 58E02-*Gal4* x UAS-*CsChrimson* larvae
326 showed appetitive olfactory learning with a significantly higher performance index than *w*<sup>1118</sup> x UAS-
327 *CsChrimson* larvae and so were used as a positive control (*Figure 4B*). *Ddc-Gal4* x UAS-*CsChrimson*
328 larvae exhibited appetitive memory comparable to 58E02-*Gal4* (*p* = 0.1304, two-sided Mann-Whitney
329 *U* test); an unsurprising result since the *Ddc-Gal4* expression pattern includes the PAM cluster neu-
330 rons. Consistent with previous studies in the larva (*Schroll et al., 2006*) and adult (*Aso et al., 2012*;
331 *Claridge-Chang et al., 2009*; *Liu et al., 2012*), *TH-Gal4* x UAS-*CsChrimson* larvae exhibited significant
332 aversive olfactory learning. *TH-Gal4* covers most dopaminergic neurons, excluding the PAM clus-
333 ter (*Rohwedder et al., 2016*). The effect we observed may be mediated by punishment-signalling
334 dopaminergic neurons that project to the MB vertical lobes (*Eschbach et al., 2020b; Selcho et al.,
335 2009*). Isolating the locus of this effect may prove challenging, given the dearth of larval driver lines
336 targeting dopaminergic neurons without MB innervation.

337 Serotonergic signalling is required for associative learning in both larval (*Huser et al., 2017*) and
338 adult (*Johnson et al., 2011; Sitaraman et al., 2012*) *Drosophila*. We tested *Trh-Gal4* and *Tph-Gal4*,
339 two driver lines that target the majority of serotonergic neurons and no dopaminergic neurons
<figure><img src="image_13.png" /></figure>

<figure><img src="image_14.png" /></figure>

<figure><img src="image_15.png" /></figure>

<figure><img src="image_16.png" /><figcaption>**Figure 4.** Different serotonergic neurons mediate classical and operant conditioning. All fly lines contained the *UAS-CsChrimson* effector, which is omitted from the figure for visual clarity. Gal4 expression depicted as color-coded CNS. **a.** Olfactory conditioning experiment protocol. During training, larvae in the paired group received three minutes of optogenetic red light stimulation (solid red circles) paired with the odour (white cloud) followed by three minutes of darkness (solid white circles) paired with air (no cloud). The unpaired group received reciprocal stimulus presentation (dark paired with odour, light paired with air). This procedure was repeated three times. In half of the experiments, the order of training trials was reversed, starting with air presentation instead of odour presentation. Both groups were then tested for learned odour preference in the dark with odour presented on one side of the plate and no odour on the other (PI = performance index).</figcaption></figure>

**b.** Performance indices following olfactory conditioning, plotted as raw data points and mean. $w^{1118} \times UAS-CsChrimson$ was the negative control (grey, $n = 8$), $58E02-Gal4 \times UAS-CsChrimson$ was the positive control (blue, $n = 8$). Statistical comparisons to $w^{1118} \times UAS-CsChrimson$ were calculated using a two-sided Mann-Whitney *U* test with Bonferroni correction; n. s. $p \ge 0.05/7$ (not significant), **$p < 0.01/7$*. Statistical comparisons to *Tph-Gal4 \times UAS-CsChrimson* were calculated using a two-sided Mann-Whitney *U* test with Bonferroni correction; n. s. $p \ge 0.05/2$ (not significant), ***$p < 0.001/2$. **c,d.** All data is shown as (mean ± s. e. m.), n. s. $p \ge 0.05$ (not significant), *$p < 0.05$. **c.** Experiments followed the protocol depicted in *Figure 3A*. Data is shown from the test period immediately following the fourth training session. Larval bend rate shown as the number of bends per minute, grouped by bend direction. The bend rate to the stimulated side (depicted as a left bend with a red light bulb for simplicity) is shown in red and the bend rate to the unstimulated side (depicted as a right bend with a grey light bulb for simplicity) is shown in grey. Statistical differences within a group were tested with a two-sided Wilcoxon signed-rank test. **d.** Probability that a given bend is directed towards the stimulated side. Grey line indicates equal probability of 0.5 for bends to either side. Statistics were based on a two-sided Wilcoxon signed-rank test.

**Figure 4-Figure supplement 1.** *Tph-Gal4* expression pattern without and with *tsh-Gal80* restriction.

**Figure 4-Figure supplement 2.** SS01989 exclusively drives expression in the CSD neuron.

**Figure 4-Figure supplement 3.** Paired and unpaired group data for olfactory conditioning experiments.
across the CNS of third-instar larvae (Huser et al., 2012). Consistent with previous reports (Gan-guly et al., 2020), larvae expressing *CsChrimson* under either driver line formed strong appetitive olfactory memory, highlighting the sufficiency of serotonin as a US in associative learning. *Tph-Gal4* targets fewer serotonergic neurons than *Trh-Gal4*, making it valuable for narrowing down which serotonergic neurons serve as a relevant reward signal. We eliminated all *Tph-Gal4* expression in the VNC using *tsh-Gal80* (Figure 4-Figure Supplement 1). Activating the remaining *Tph* neurons in the brain and *SEZ* was sufficient to induce strong appetitive memory (Figure 4B). This result was notable and raised further questions: are serotonergic neurons in the brain and *SEZ* indirectly connected to MB-innervating dopaminergic neurons or do alternative learning circuits exist that altogether bypass the MB?

The contralaterally projecting serotonin-immunoreactive deutocerebral (CSD) neuron (Roy et al., 2007) is one previously described serotonergic brain neuron within the *Tph-Gal4* expression pattern (Huser et al., 2012) that innervates the antennal lobe and only has a few indirect connections to the MB (Berck et al., 2016). Combining anatomical features from existing EM reconstruction (Berck et al., 2016) with available lineage information facilitated identification of a split-GAL4 line (SS01989) that drives expression exclusively in the CSD neuron (Figure 4-Figure Supplement 2). Pairing activation of SS01989 with ethyl acetate was insufficient for inducing olfactory memory (Figure 4B), suggesting that the classical conditioning phenotype we observed under *Tph-Gal4* x UAS-*CsChrimson*; *tsh-LexA*, *LexAop-Gal80* was mediated by at least one other group of serotonergic neurons in the brain or *SEZ*.

## Serotonergic neurons in VNC are necessary for operant conditioning of bend direction

Given their strong associative learning phenotypes, we used the *TH-Gal4* and *Tph-Gal4* drivers to investigate whether operant conditioning of bend direction could be induced exclusively by dopaminergic or serotonergic neurons, respectively. Under our high-throughput training protocol (Figure 3A), *TH-Gal4* x *UAS-CsChrimson* larvae showed no difference in bend rate between the previously stimulated and unstimulated sides in the one-minute test period (Figure 4C). Furthermore, the probability that any given bend was directed towards the previously stimulated side was not significantly different from chance (Figure 4D). Activating these dopaminergic neurons was an insufficient substitute for reward or punishment in operant conditioning.

Paired activation of *Tph-Gal4* neurons during bends to one side resulted in a significantly higher bend rate to the stimulated side relative to the unstimulated side during the test period (Figure 4C). The probability of bending in the previously stimulated direction was also significantly elevated (Figure 4D). In this way, activation of *Tph*-positive serotonergic neurons paired with bends to one side was sufficient for the formation of a learned direction preference. Combining this result with the knowledge that operant conditioning was impaired following restriction of *Ddc-Gal4* x *UAS-CsChrimson* expression to the brain and *SEZ* suggests that the serotonergic neurons of the VNC were necessary for memory formation in this paradigm. Because *Tph-Gal4* is a broad driver line, it is possible that its expression pattern contains brain or *SEZ* neurons outside of those in *Ddc-Gal4*. The existence of these neurons could have potentially induced learning through an alternate mechanism independent from that which drove memory formation following *Ddc* neuron activation.

To assess whether the VNC serotonergic neurons were necessary for the observed operant conditioning effect, we used *tsh-Gal80* to restrict the *Tph-Gal4* expression pattern to the brain and *SEZ*. Paired optogenetic activation of *Tph-Gal4* x *UAS-CsChrimson*; *tsh-LexA*, *LexAop-Gal80* with larval bends to one side was insufficient for operant conditioning (Figure 4C, Figure 4D). The *Tph-Gal4* expression pattern contains two neurons per VNC hemisegment (with the exception of a single neuron in each A8 abdominal hemisegment), all of which are serotonergic (Huser et al., 2012). While there are few serotonergic VNC candidates, we could not conclude from our data whether the operant conditioning effect relied solely on these neurons or whether synergistic activity from both the VNC and the brain or the *SEZ* was needed. Testing these hypotheses remains challenging
390 since, to our knowledge, no sparse driver lines exist to exclusively target VNC serotonergic neurons.

391 Under a classical conditioning paradigm, we have confirmed that there exist learning pathways
392 in *Drosophila* that rely on serotonergic neurons. We have also shown that serotonergic neurons can
393 serve as a sufficient US for operant conditioning. Notably, different circuit mechanisms underlie
394 classical and operant conditioning mediated by serotonergic neurons: activation of the brain and
395 SEZ is sufficient for classical conditioning, whereas the VNC is necessary for operant conditioning.

Discussion
---

396 Due to available genetic tools and the emerging connectome, the *Drosophila* larva is a uniquely
397 advantageous model organism for neuroscience. We have uncovered a previously unknown neu-
398 ronal mechanism of operant conditioning in the *Drosophila* larva. Serotonergic signalling can be
399 employed as a reinforcing US in both classical and operant associative learning, but we are mind-
400 ful that a single neural mechanism for learning may not exist. Distinct types of learning may share
401 neurotransmitters or circuit components, but there may remain fundamental differences in con-
402 nectivity and function. The experimental system we built was instrumental in investigating the
403 neural circuits of operant conditioning, as it combined FPGA-based real-time tracking of multiple
404 larvae with robust online behaviour detection and closed-loop stimulus presentation. This system
405 could facilitate further research in taxis (Luo et al., 2010; Gomez-Marin et al., 2011; Kane et al.,
406 2013; Jovanic et al., 2019), decision-making (Krajbich, 2019; DasGupta et al., 2014), and spatial nav-
407 408 gation and memory (Neuser et al., 2008; Haberkern et al., 2019). While further work is necessary,
409 our bend direction paradigm provides a strong foundation for continued study of the circuit and
410 cellular mechanisms underlying operant conditioning.

High-throughput operant conditioning in *Drosophila* larvae
---

411 We have shown that *Drosophila* larvae are capable of operant conditioning and that optogenetic
412 activation of *Ddc* neurons serves as a rewarding US during this learning process. With training,
413 larvae formed an association between the presence or absence of this US and the direction in which
414 they were bending. During testing, in the absence of any stimulation, larvae showed a significant
415 learned preference for bending towards the previously stimulated side. This learned modification
416 of future behaviour was only observed when the CS and US were paired during training; a hallmark
417 of operant conditioning. Because *Ddc-Gal4* drives expression in dopaminergic and serotonergic
418 neurons (*Li et al., 2000; Sitaraman et al., 2008*), we concluded that one or both neurotransmitters
419 are involved in memory formation under these experiment conditions.

420 Strong parallels exist between our operant learning paradigm and those employed for condi-
421 tioning direction preference in adult *Drosophila*. Consider the work of *Nuwal et al.* (2012), in which
422 tethered flies walked on a rotating ball and were rewarded with optogenetic activation of sugar-
423 sensing neurons upon turns to one direction. As a consequence of this pairing, the flies learned
424 to increase the number of turns to this side. Notably, the nature of the US remains an important
425 difference between these paradigms. Our initial attempts to operantly condition larvae using ac-
426 tivation of sugar-sensing neurons as a rewarding US were unsuccessful. These neurons, defined
427 by two different *Gr43a-Gal4* drivers, were also insufficient for memory formation when activated
428 with a paired odour in an olfactory conditioning screen. This was surprising, considering extensive
429 evidence that natural sugar can serve as a rewarding US for classical conditioning in larvae (*Apos-
430 tolopoulou et al., 2013; Schleyer et al., 2015; Weiglein et al., 2019; Honjo and Furukubo-Tokunaga,
431 2005; Neuser et al., 2005; Rohwedder et al., 2012; Scherer et al., 2003; Schipanski et al., 2008*).
432 One possible explanation for these discrepancies is that multiple groups of sensory neurons must
433 be co-activated in order to relay a meaningful reward signal. Alternatively, it may be necessary to
434 adjust the temporal pattern or intensity of optogenetic stimulation.

435 It remains to be seen whether operant learning can occur by pairing roll or back-up behaviour
436 with reward or punishment. Conditioning these actions is challenging given their infrequency in
437 naïve, freely behaving animals. Rolls only occur in response to noxious stimuli (*Ohyama et al., 2013*,
2015; Robertson et al., 2013; Tracey et al., 2003). Back-ups also occur at very low rates (Masson et al., 2020). Consequently, the amount of US which larvae would receive during paired training would be very small, making observable memory formation more difficult. Our high-throughput tracker could potentially address this challenge with probabilistic, thermogenetic activation of roll or back-up command neurons (Ohyama et al., 2015; Carreira-Rosario et al., 2018) and optogenetic reward when performing the desired action.

## Neural circuits of operant conditioning

From the available data, it cannot be concluded that the brain and SEZ are dispensable for operant conditioning in *Drosophila* larvae. Examples from both vertebrates (Grau et al., 1998) and invertebrates (Horridge, 1962; Booker and Quinn, 1981) show the spinal cord or VNC as sufficient for learning, suggesting that conserved mechanisms exist for brain-independent operant conditioning across species. This does not, however, exclude the possibility that there exist alternative learning pathways using the brain. In mammals (Redgrave et al., 2011; Balleine et al., 2009) and birds (Fee and Goldberg, 2011), brain correlates of operant conditioning have been identified. It is unclear where such pathways would be located in the insect brain. Both our larval experiments and previous adult fly studies (Colomb and Brembs, 2016; Wolf et al., 1998; Colomb and Brembs, 2010; Booker and Quinn, 1981) support the idea that operant conditioning can occur independently of the MB, such that other learning centres might exist. To determine whether larval operant conditioning can be fully mediated by the VNC or whether the brain or SEZ are necessary, new driver lines must be created. A collection of sparse split-GAL4 lines, each specific to a distinct group of serotonergic neurons, could help identify the minimum subset of neurons necessary for conveying a US in our bend direction paradigm.

Even if the learning signal for operant conditioning can be mapped to a few serotonergic neurons, there remain several open questions regarding the neuronal mechanisms underlying this learning. Locally, neurons could drive synaptic plasticity or modulate the intrinsic excitability of their postsynaptic partners. Alternatively, the learning signal could propagate further downstream, yielding learning correlates elsewhere in the network. Furthermore, memory formation requires integrating the US with information about the occurrence of the reinforced action. Motor feedback (e. g. efference copy, Webb, 2004; Fee, 2014) or proprioceptive input could be used to transmit this movement signal to higher-level circuits for convergence with the valence-encoding US. However, if memory formation occurred at a lower level, the action-specific signal and associated valence could be locally integrated inside the motor or premotor neuron without the need for feedback loops.

Lorenzetti et al. (2008) proposed intracellular mechanisms for modulating the intrinsic excitability of the Aplysia premotor neuron B51 during operant conditioning, mediated by the highly conserved protein kinase C (PKC) gene. PKC signalling is also essential for operant conditioning in *Lymnaea* (Rosenegger and Lukowiak, 2010) and adult *Drosophila* (Brembs and Plendl, 2008; *Colomb and Brembs*, 2016). If the *Drosophila* larva showed evidence of PKC-induced motor neuron plasticity, EM reconstruction of the pathways between the serotonergic neurons of the VNC and the PKC-positive motor neurons could further elucidate the mechanisms of memory formation and retrieval. A similar investigation of the *Drosophila* gene *FoxP* may also be informative, as its mutation in the adult results in impaired operant self-learning (Mendoza et al., 2014). The vertebrate homologue *FOXP2* is associated with deficits in human speech acquisition (Lai et al., 2001), song learning in birds (Haesler et al., 2007), and motor learning in mice (Groszer et al., 2008).

## Serotonin as a learning signal

A limited set of studies have shown that serotonergic signalling is sufficient to induce learning (Liu et al., 2014; Hawkins and Byrne, 2015; Ganguly et al., 2020). Previous *Drosophila* studies highlight other roles of serotonin in associative learning (Yu et al., 2005; Keene et al., 2004, 2006; Lee et al., 2011; Huser et al., 2017). Sitaraman et al. (2012) have shown that synaptic transmission from sero-
tonergic neurons is essential for appetitive olfactory conditioning in the adult. Aversive olfactory memory formation is impaired in flies fed with a tryptophan hydroxylase inhibitor which blocks serotonin biosynthesis (Lee et al., 2011). Furthermore, serotonin receptor signalling is required for memory formation in classical conditioning tasks (Johnson et al., 2011). In larvae, aversive olfactory conditioning is impaired by either ablation of serotonergic neurons during development or mutations in a serotonin receptor gene (Huser et al., 2017).

Our work suggests a novel role of serotonin as a reward signal for learning in *Drosophila* larvae. In our olfactory classical conditioning screen, optogenetic stimulation of serotonergic neurons in the brain and *SEZ* was sufficient to induce strong appetitive learning. Conversely, operant conditioning necessitated serotonergic neuron activity in the *VNC*. Since it remains unclear to what extent serotonergic neurons in the brain and *SEZ* are also involved in the operant conditioning effect we observed, it is possible that some neurons mediate both forms of associative learning.

Further investigation is necessary to better understand the function of serotonin in memory formation. It is possible that even a single instance of learning leads to a variety of changes across the nervous system. In the case of operant conditioning, higher brain centres, motor command neurons, premotor circuits and motor neurons would all qualify as potential learning sites. In addition to thoroughly analysing the expression patterns of driver lines used in our classical conditioning screen, developing new, sparse driver lines targeting serotonergic neurons would be valuable for identifying the minimal subset of neurons which provide the serotonergic learning signal. The larval connectome could be used to subsequently trace the paths from these neurons to the *MB*. One could then test whether learning as induced by the serotonergic *US* remains intact when these connections are silenced. The expression pattern of serotonin receptors could also provide clues about how the serotonergic signal triggers learning. One should certainly consider the possibility that learning is not induced by serotonin itself, but by other neurotransmitters coexpressed by serotonergic neurons. This could be assessed by suppressing serotonin biosynthesis in the desired neuronal subset.

## Materials and methods

### High-throughput closed-loop tracker

#### Hardware set-up

A high-resolution camera (3072 x 3200 pixels) (#TEL-G3-CM10-M5105, Teledyne DALSA, Ontario, Canada) positioned above a 23 cm x 23 cm 4% agarose plate captured 8-bit greyscale images at 20 Hz. The agarose plate was illuminated from below by a 30 cm x 30 cm 850 nm LED backlight (#SOBL-300x300-850, Smart Vision Lights, Norton Shores, Michigan) equipped with intensity control (#IVP-C1, Smart Vision Lights, Norton Shores, Michigan). An 800 nm longpass filter (#LP800-40.5, Midwest Optical Systems, Palatine, Illinois) mounted on the camera blocked all visible wavelengths, including those used for optogenetics. When the agarose plate comprised most of the camera image, each pixel corresponded to a 72.92 µm diameter section of the plate.

Each camera image was processed in parallel on both the host computer (#T7920, running Windows 10, Dell Technologies Inc, Round Rock, Texas) and an FPGA device (#PCIe-1473R-LX110, National Instruments, Austin, Texas). LabVIEW 2017 (National Instruments, Austin, Texas) software extracted larval contours and interfaced with C++ software that performed real-time behaviour detection. The LabVIEW software controlled closed-loop optogenetic and thermogenetic stimulation in response to these detected behaviours.

### Multi-animal detection and tracking

Raw camera images were read by the FPGA at 20 Hz and then sent to the host computer. The LabVIEW process on the host computer then filtered out non-larval objects by combining background subtraction and binary thresholding. The remaining objects were each enclosed in a rectangular box of minimal size, with edges parallel to the camera image axes. We defined the following criteria to detect third-instar larvae within these boxes:
* Pixel intensity range (default 25-170): the minimum and maximum brightness values for pixels selected by binary thresholding (between 0 and 255 for an 8-bit image).

537

* Box side length (pixels) (default 6-100): the range of eligible values for width and height of each box.

538

* Box width + height (pixels) (default 12-200): the range of eligible values for the sum of each box's width and height.

539

540

* Box area (pixels) (default 300-900): the range of eligible values for the area of each box.

541

542

543

To track larvae over time, the host computer assigned a numerical identifier to each eligible object. We used distance-based tracking with a hard threshold of 40 pixels to maintain larval ID based on centroid position. Although identity was lost when larvae touched or reached the plate's edge, new IDs were generated when larvae matched detection criteria. For each of the largest 16 objects, the host computer sent a binary pixel pattern and location (defined as the centre of the box) to the FPGA. Since the host computer required more than 50 ms of run time for object detection, this process was not executed in every frame. On average, the FPGA received updated objects and their locations every three frames.

544

545

546

547

548

549

550

551

The FPGA extracted object contours in three steps. Within a 2 cm² region of interest around the object's centre, the FPGA first applied a user-defined binary threshold, then applied both vertical and a horizontal convolution with a 2 x 1 XOR kernel, and finally generated edge pixels by combining the results of the two convolutions using an OR operation. Contours were extracted from edge images using the Moore boundary tracing algorithm (Gonzalez and Woods, 2018) with three added error capture procedures. First, if the algorithm yielded a contour that ended prematurely or contained small loops, the construction process could be reversed by up to 16 contour points to find an alternative contour. Second, 10,000 FPGA clock cycles (≈ 100 us) was the maximum allotted execution time, with each pixel comparison occurring within one clock cycle. In the rare event that this window was exceeded, the algorithm returned the already constructed contour points. Third, a contour containing fewer than 63 points was rejected and the FPGA returned the last valid contour detected for a given larva ID. The algorithm stopped when none of the remaining neighbours were edge pixels (Figure 1–Figure Supplement 1).

552

553

554

555

556

557

558

559

560

561

562

563

564

## Contour processing and landmark detection

565

An undesired result of the FPGA contouring algorithm was the variable number of contour points across larvae and frames. We aimed to detect behaviour based on a smooth contour with a fixed number of 100 contour points. This contour regularization was achieved inside the Behaviour Programme using Fourier decomposition and reconstruction as in Masson et al. (2020).

566

567

568

569

The initial detection of head and tail was implemented on FPGA. The larva's head and tail were defined as the contour points with the sharpest and second-sharpest curvature, respectively (Figure 1–Figure Supplement 2). While correct in most cases, this calculation sometimes led to flipped detection of the two body ends. The Behaviour Programme flagged and corrected these false detection events at run time by calculating the distance head and tail traveled between frames and tracking the number of correct versus flipped detection events. The vote system correction commonly failed when the larva made large angle bends. The resulting contour was nearly-circular and exhibited similar curvature across all points. The solution required resetting the vote tallies when detecting these ball events (Figure 1–Figure Supplement 2).

570

571

572

573

574

575

576

577

578

We defined the larval spine as 11 points running along the central body axis from head to tail (Figure 1–Figure Supplement 3; Swierczek et al., 2011). In addition to head and tail, the Behaviour Programme calculated three equally distributed landmark points along the spine (neck_top, neck, and neck_down). A fourth landmark, the centroid, defined the larva's location. The six landmarks were collectively used to extract features for training behaviour classifiers (Figure 1–Figure Supplement 3).

579

580

581

582

583

584

The Behaviour Programme transformed the raw contour and spine from camera coordinates

585
(in pixels) to world coordinates (in mm). If stable larval detection criteria were met, all spine points were temporally smoothed using exponential smoothing (Figure 1-Figure Supplement 3).

Feature extraction

We developed a machine learning approach to address the high deformability of the larva shape, ensure live execution, reduce overfitting, and limit the volume of data tagging. What follows is a brief summary of larval features describing motion direction, body shape, and velocity that were calculated from the contour and spine data inside the Behaviour Programme. Features were designed as in Masson et al. (2020), with notable modifications required to run the inference live:

1. Motion Direction (Figure 1-Figure Supplement 4)

• direction_vector: normalised vector describing the main body axis

• direction_head_vector: normalised vector describing the head axis

• direction tail vector: normalised vector describing the tail axis

2. Body Shape (Figure 1-Figure Supplement 5)

• skeleton_length: summed distances between consecutive spine points

• perimeter: summed distances between neighbouring contour points

• larva_arc_ratio: ratio of contour perimeter to convex hull perimeter (larva_arc_ratio ≥ 1 and was close to 1 when larva was in either straight or ball-like shape)

• larva_area_ratio: ratio of the areas enclosed by the contour and its convex hull (0 ≤ larva_area_ratio ≤ 1 and was close to 1 when the larva was in either straight, heavily curved, or ball-like shape)

• eig_reduced: eig_reduced = [λ₁ - λ₂] / (λ₁ + λ₂) where λ₁, λ₂ were the eigenvalues of the structure tensor of the larval contour with respect to the neck (0 ≤ eig_reduced ≤ 1 and eig_reduced decreased as the bend amplitude of the larva increased)

• s: normalised angle along the body (−0.5 ≤ s ≤ 1, was close to 1 when larva was straight, and decreased with increasing bend amplitude)

• asymmetry: sine of the angle between direction_vector and direction head vector (asymmetry > 0 when larva bent left and asymmetry < 0 when larva bent right)

• angleUpper_lower: absolute angle between direction_vector and direction head-vector (despite similarity to asymmetry, this develops different dynamics following temporal smoothing, which are valuable for stable left and right bend detection)

3. Velocity (Figure 1-Figure Supplement 6)

• Velocity of all six landmark points (head_speed, neck_top_speed, neck_speed, neck_down-speed, tail_speed, and v_centroid) in mm/s over interval dt = 0.2 s (four frames)

• v_norm: arithmetic mean of neck_top_speed, neck_speed, and neck_down_speed, passed through a hyperbolic tangent activation function to suppress excessively large values

• speed_reduced: relative contribution of neck_top_speed to v_norm, passed through a hyperbolic tangent activation function to suppress excessively large values (speed_reduced increased when the anterior larval body moved quickly compared to the posterior, e. g. when a bend was initiated)

• damped_distance: distance (mm) travelled by neck, giving greater weight to recent over past events

• crab_speed: lateral velocity (mm/s), defined as the component of neck_speed orthogonal to direction_vector_filtered

• parallel_speed: forward velocity (mm/s), defined as the component of neck_speed-filtered parallel to direction_vector_filtered

• parallel_speed_tail_raw: tail's forward velocity (mm/s), defined as the component of tail_speed_filtered parallel to direction_tail_vector_filtered
<table><caption>**Table 1.** Manual quantification of behaviour detection performance.</caption><tbody><tr><td colspan="2">back (268 events from 24 larvae in 60 minutes of video data)</td></tr><tr><td>Precision</td><td>86.5%</td></tr><tr><td>Recall</td><td>88.4%</td></tr><tr><td colspan="2">bend (714 events from 24 larvae in 60 minutes of video data)</td></tr><tr><td>Precision</td><td>95.6%</td></tr><tr><td>Recall</td><td>96.4%</td></tr><tr><td>Accuracy of left and right detection (true-positive bends)</td><td>97.3%</td></tr><tr><td colspan="2">forward (425 events from 24 larvae in 60 minutes of video data)</td></tr><tr><td>Precision</td><td>97.8%</td></tr><tr><td>Recall</td><td>94.1%</td></tr><tr><td colspan="2">forward_peristaltic (2954 events from 24 larvae in 60 minutes of video data)</td></tr><tr><td>Precision</td><td>99.5%</td></tr><tr><td>Recall</td><td>93.6%</td></tr><tr><td>Events which are falsely combined with another event</td><td>10.7%</td></tr><tr><td>Events which are detected as more than one event</td><td>1.2%</td></tr><tr><td colspan="2">roll (240 events from 24 larvae in 60 minutes of video data)</td></tr><tr><td>Precision (rolls and roll-like events)</td><td>96.6%</td></tr><tr><td>Recall (rolls)</td><td>86.7%</td></tr><tr><td>Recall (roll-like events)</td><td>25.8%</td></tr></tbody></table>

within the previous 1.5 s. *forward_peristaltic* detected individual forward peristaltic waves based on the *forward* classifier and a threshold on forward tail velocity.

The *roll* classifier was based on thresholds for body shape and velocity combined with no ball detection and was exponentially smoothed over time. If a *roll* was detected within the previous 1.5 s, *forward*, *forward_peristaltic*, and *back* classifier values were reset to reduce false-positive detection for these classifiers. Unusual behaviour patterns such as rapid bending or twitching could be observed in addition to true larval rolling. These behaviours were considered "roll-like" events during manual validation of the *roll* classifier's performance.

Optogenetic stimulation

Optogenetic stimulation was achieved using two digital micromirror devices *DMDs* to project light patterns onto larvae on the agarose plate. During the hardware design process, two different *DMD* models were tested. One contained an integrated 613 nm LED (#CEL-5500-LED, Digital Light Innovations, Austin, Texas) and the other (#CEL-5500-FIBER, Digital Light Innovations, Austin, Texas) received input from an external 625 nm LED (#BLS-GCS-0625-38-A0710, Mightex Systems, Ontario, Canada) controlled by a BioLED light source control module (#BLS-13000-1, Mightex Systems, Ontario, Canada) and fed through an optic fibre (#LLG-05-59-420-2000-1, Mightex Systems, Ontario, Canada). Both *DMDs* operated like a 768 x 1024 pixel monochrome red light projector with numerous rotatable micromirrors used to modulate the intensity of individual pixels. Although both achieved similar light intensities, each *DMD* on its own was insufficient for optogenetic stimulation of larvae. We installed both devices on the system such that their projections each covered the entire agarose plate. In this way, the summed light intensities of the two *DMDs* could be achieved at all locations. Accurately aiming light at crawling larvae required spatial calibration of each *DMD*. Calibration was performed by projecting square spots at fixed *DMD* pixel locations and linearly fitting the corresponding camera coordinates.
We determined that DMD illumination using the default light output was not uniform at plate level, which could have resulted in variable optogenetic stimulation depending on larval location. The maximum achievable light intensity at the plate's edge was approximately 40% of the peak value at its centre. We therefore normalised the pixel intensity of the DMD image to the highest intensity uniformly achievable at all plate locations. A look-up table containing the normalisation factor for each DMD pixel was then calculated using bi-linear interpolation with approximately 100 light intensity values measured across the plate. To accommodate for possible differences in non-uniformity between the two DMDs, this intensity calibration was performed for both DMDs simultaneously following spatial calibration. When fully calibrated, the system could achieve a uniform light intensity of 285 µW/cm².

A user-defined Behaviour Programme protocol operated on the behaviour detection output and sent 8-bit optogenetic stimulation instructions to the LabVIEW application. Because the LabVIEW application updated DMD projections at 20 Hz, the delay between behaviour detection and closed-loop optogenetic stimulation of individual larvae did not exceed 50 ms. Furthermore, if two or more larvae were close enough such that their corresponding stimulation areas overlapped, the light intensity in the overlapping region was set to the smallest of those values to avoid undesired stimulation.

## Thermogenetic stimulation

Thermogenetic stimulation was achieved by heating up larvae with a custom IR laser set-up. A 1490 nm laser diode beam (#2CM-101, SemiNex, Peabody, Massachusetts) was fed into a two-axis galvanometer system (#GVSM002, Thorlabs, Newton, New Jersey), both controlled by an analogue output device (#PCIe-6738, National Instruments, Austin, Texas). Two mirrors inside the galvanometer were rotated around orthogonal axes to target the beam spot to any user-defined location on the agarose plate. The beam spot measured approximately 5 mm in diameter, depending on the beam's angle of incidence to the plate. Mirror positions were controlled by two integrated motors that received voltage inputs. Each voltage pair clearly defined the laser beam's position.

Spatially calibrating the galvanometer was necessary to obtain a map between larval locations in world coordinates and the mirror motor input voltages. A visible aiming beam was scanned across the agarose plate using a fixed set of voltage pair inputs to the galvanometer. With the optical filter removed from the camera, the aiming beam's location in camera coordinates was automatically extracted from the image using binary thresholding. Two voltage-to-camera look-up tables were generated through bi-linear interpolation of these measured coordinates. For accurately targeted thermogenetic stimulation, the location of the larval centroid was first converted to camera coordinates using the existing world-to-camera transform and was then mapped to a pair of galvanometer input voltages using the look-up tables.

Laser intensity calibration was also necessary to ensure that all larvae received the same stimulation regardless of their position on the agarose plate. A larva's location changed the laser beam's angle of incidence, causing the illuminated spot at plate level to take an elliptical shape with variable size. Although laser beam power was constant, the changing spot area generated inconsistencies in the amount of IR light covering each larva. Calibration was used to normalise the desired laser intensity to achieve constant power per unit area. A visible aiming beam was scanned across the plate and the camera image automatically measured the beam's spot size at various locations. Bi-linear interpolation was then used to generate a pixel-wise look-up table containing the necessary scaling factors for the laser power. At the location where the laser spot area was smallest, the maximum power was reduced to 67.3%. We also accounted for a nonlinear relationship between the laser source input voltage and the laser's total power output by generating a voltage-to-power map from manual measurements. With these transformations, the system could calculate the laser source input voltage necessary to produce uniform, 5.26 W stimulation at any location.

A user-defined Behaviour Programme protocol operated on the 20 Hz behaviour detection out-
put and sent thermogenetic stimulation instructions to the LabVIEW application which controlled the galvanometer and laser. Four centroid locations were specified on every frame, enabling a single galvanometer to cycle the laser beam between four individual larvae at 20 Hz. Within the available 50 ms time window, each larva was heated for 11 ms. Switching off the laser input for 1.5 ms between larvae accounted for small time fluctuations surrounding each new galvanometer position update and helped avoid undesired stimulation of other plate areas (Figure 2D). If fewer than four objects were detected in a given frame, the remaining galvanometer target locations were set to the plate's centre and the corresponding laser intensity was set to zero. This temporal pattern of galvanometer position updates yielded no more than 100 ms delay between behaviour detection and closed-loop thermogenetic stimulation.

Three parameters influenced larval temperature increase following thermogenetic stimulation with the IR beam: i) the laser power, ii) the total duration of the stimulus, and iii) the order in which the galvanometer cycles between locations in its 80 Hz movement. Preliminary experiments suggested that these parameters could be adjusted to simultaneously stimulate eight or twelve larvae using a single galvanometer. This could potentially eliminate the need to install three additional laser sources to target all 16 larvae.

## Software availability

All software code is available upon request.

## Fly strains and larval rearing

We used the following fly strains: 58E02-Gal4 (Bloomington stock 41347), 69F06-Gal4 (Bloomington stock 39497), 72F11-Gal4 (Bloomington stock 39786), attP2 (Pfeiffer et al., 2008), Ddc-Gal4 (Li et al., 2000), SS01989 (own stock), TH-Gal4 (Friggi-Grelin et al., 2003), Tph-Gal4 (Park et al., 2006), Trh-Gal4 (Alekseyenko et al., 2010), UAS-CsChrimson (Bloomington stock 55134), UAS-CsChrimson; tsh-LexA, LexAop-Gal80 (Dr Stefan Pulver, Dr Yoshinori Aso), UAS-dTrpA1 (Dr Paul Garrity), UAS-GFP (Nern et al., 2015), and w1118 (Hazelrigg et al., 1984).

Fly stocks were maintained in vials filled with standard cornmeal food (Wirtz and Semey, 1982; 49.2 ml of molasses, 19.9 g of yeast, 82.2 g of cornmeal, 7.4 g of agarose, 9.8 ml of 20% Tegosept solution in 95% ethanol and 5.2 ml of propionic acid in 1 litre of water). For proof-of-principle and operant and classical learning experiments, eggs were collected overnight for approximately 12–18 hours on standard cornmeal food plates with additional dry yeast to increase laying. These experiments were performed using foraging-stage third-instar larvae (72–96 hours after egg laying) reared at 25°C and 65% humidity (Ohyama et al., 2013, 2015; Jovanic et al., 2016, 2019; Eschbach et al., 2020b). Specifically for optogenetics experiments, larvae were raised in the dark and a 1:200 retinal solution (diluting 1 g of powdered all-trans-retinal (#R240000, Toronto Research Chemicals, Ontario, Canada) in 35.2 ml of 95% ethanol) was added to the food unless indicated otherwise. For immunohistochemistry, eggs were collected during daytime for approximately four hours on standard cornmeal food plates with added yeast. Dissections were performed using wandering-stage third-instar larvae (118–122 hours after egg laying).

## Immunohistochemistry and confocal imaging

All dissections, immunohistochemical stainings, and confocal imaging were done using a procedure adapted from Jenett et al. (2012) and Li et al. (2014). Larval CNSs were dissected in cold 1x phosphate buffer saline (PBS, Corning Cellgro, #21-040) and transferred to tubes filled with cold 4% paraformaldehyde (Electron Microscopy Sciences, #15713-S) in 1x PBS. Tubes were incubated for one hour at room temperature. The tissue was then washed four times in 1x PBS with 1% Triton X-100 (#X100, Sigma Aldrich St. Louis, Missouri) (PBT) and incubated in 1:20 donkey serum (#017-000-121, Jackson Immuno Research, West Grove, Pennsylvania) in PBT for two hours at room temperature.
The tissue was then incubated in the primary antibody solution, first for four hours at room temperature and then for two nights at 4°C. This solution contained mouse anti-Neuroglian (1:50, #BP104 anti-Neuroglian, Developmental Studies Hybridoma Bank, Iowa City, Iowa), rabbit anti-green fluorescent protein (GFP) (1:500, #A11122, Life Technologies, Waltham, Massachusetts) and rat anti-N-Cadherin (1:50, #DN-Ex #8, Developmental Studies Hybridoma Bank, Iowa City, Iowa) in PBT. This solution was then removed and the tissue washed four times in PBT. The tissue was then incubated in the secondary antibody solution, first for four hours at room temperature and then for two nights at 4°C. This solution contained Alexa Fluor 568 donkey anti-mouse (1:500, #A10037, Invitrogen, Waltham, Massachusetts), FITC donkey anti-rabbit (1:500, #711-095-152, Jackson Immuno Research West Grove, Pennsylvania) and Alexa Fluor 647 donkey anti-rat (1:500, #712-605-153, Jackson Immuno Research West Grove, Pennsylvania) in PBT. After removal of the secondary solution, the tissue was washed in PBT four times and mounted on a coverslip coated with poly-L-lysine (#P1524-25MG, Sigma Aldrich, St. Louis, Missouri).

The coverslip with the CNSs was dehydrated by moving it through a series of jars containing ethanol at increasing concentrations (30%, 50%, 75%, 95%, 100%, 100%, 100%) for ten minutes each. The tissue was then cleared by soaking the coverslip with xylene (#X5-500, Fisher Scientific, Waltham, Massachusetts) three times for five minutes each. Finally, the coverslips were mounted in dibutyl phthalate in xylene (DPX, #13512, Electron Microscopy Sciences, Hatfield, Pennsylvania) with the tissue facing down on a microscope slide with spacers. The DPX was allowed to dry for at least two nights prior to confocal imaging with an LSM 710 microscope (Zeiss).

Details on the confocal imaging settings are provided in the respective figure captions. Confocal images were analysed using Fiji (ImageJ). Neurons were counted by specifying regions of interest around the cell bodies using raw image stacks.

## Verification of optogenetic and thermogenetic stimulation efficiency

We assessed the multi-larva tracker's optogenetic and thermogenetic stimulation efficiency through open-loop experiments. The behavioural readout was rolling upon exposure to stimulation. All larval handling and experiments were performed in the dark to avoid unintended optogenetic stimulation. The one-minute experiment protocol began with a 15 s initialisation period in which larvae acclimated to the agarose plate and the roll behaviour classifier stabilised. In three subsequent 15 s stimulation cycles, larvae received 5 s of open-loop stimulation followed by 10 s without stimulation (Figure 2B, Figure 2E). Optogenetics were performed with the maximum available red light intensity of 285 µW/cm². Thermogenetics were performed with 40% of the maximum available laser intensity.

We analysed both optogenetic and thermogenetic experiment data using identical assessment and exclusion criteria. For each larva, the criterion for a single roll was detection of the behaviour for at least 300 ms during a given 15 s stimulation cycle. This threshold ensured true rolls were counted, as opposed to rapid larval bends characteristic of aversion to light.

## High-throughput operant conditioning

### Experiment procedures

We performed high-throughput operant conditioning using our multi-larva closed-loop tracker. All larval handling and experiments were performed in the dark to avoid unintended optogenetic stimulation. We used water to wash approximately 10-12 larvae out of their food. Using a brush, we immediately placed these larvae into the centre of the agarose plate in such a way that they were not touching each other. We placed the agarose plate inside the tracker on top of the backlight and then shut the tracker door. Larvae were given at least 30 s to accustom to their new environment before we started the experiment.

The experiment protocol began and ended with a one-minute test period without optogenetic stimulation. Between these test periods were four, three-minute training sessions during which larvae received red light stimulation of 285 µW/cm² for the entire duration of the detected bend.
840 Which side received stimulation was randomized across trials such that approximately 50% of larvae were trained to develop a right bend preference and 50% a left bend preference. No stimulus was triggered when the larva was bending right or when its body was straight. The test periods were each separated by three-minute periods without stimulation. After the first minute of this period, a brush was used to gently move all larvae back to the centre of the plate and larvae were given time to recover before the beginning of the next training session. This recentring addresses problems encountered when performing prolonged experiments with freely behaving larvae on a small agarose plate. The longer larvae are left undisturbed, the more likely they are to touch the plate's edge, causing tracking disruption and temporary loss of valid objects. This shrinks sample size and reduces training efficiency by decreasing the proportion of animals which are receiving the stimulus.

851 Control experiments were designed so that valid objects received optogenetic stimulation uncorrelated with behaviour. These control experiments were split into 60 s time bins, during which each valid object was randomly assigned a stimulus train from this same time bin, pulled from a prior experiment where stimulation correlated with behaviour.

855 Data analysis

856 Data analysis was conducted using custom MATLAB software. To ensure high quality data, it was necessary to remove invalid objects from the data set prior to behavioural analysis. These included corrupted objects (e.g. scratches on the plate or residual food) that the software mistook for larvae. They also included larvae that lost their object identity and were consequently detected for only part of the experiment (e.g. after temporarily reaching the plate's edge or touching other larvae). After equally splitting each experiment into 60 s time bins, we retained objects for analysis that fulfilled strict criteria: i) the object must have been detected in every frame of the bin; ii) the object's initial detection must have occurred at least 20 s prior to the start of the bin; iii) at no point during the bin did the smoothed velocity of the larval centroid exceed 1.5 mm/s; and iv) the mean of the smoothed centroid velocity across the object's detection period in the bin was at least 0.5 mm/s. To quantify the accuracy of this method, we manually reviewed 350 videos of objects flagged as valid for a given 60 s bin. In this group, we observed no severely corrupted objects. In one case (0.3%), a larva briefly touched another larva. In another case (0.3%), head and tail of a larva were falsely detected the majority of the time, leading to flipped detection of left and right bends.

860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
When analysing valid bin data for operant conditioning of bend direction preference, we counted, for each larva, the numbers of left and right bends initiated within the bin. This was defined as the bend rate towards the respective direction. The probability of the larva bending towards the side paired with the optogenetic stimulus was defined as the ratio of the number of bends towards this side to the total number of bends initiated in the bin. We pooled together all larval data within each bin because bends to the left and right were each paired with the optogenetic stimulus for approximately half of the larvae. Mean and standard error were calculated for bend rate to the stimulated side, bend rate to the unstimulated side, and probability of bending towards the stimulated side. For the control condition in which larvae received random stimulation during 50% of bends regardless of direction, we calculated mean and standard error for bend rates to the left and right and the probability for bending towards the left. Bend rates to either side were compared to each other using a two-sided Wilcoxon signed-rank test. The probability for bending to a given side was compared to chance level (0.5) using a two-sided Wilcoxon signed-rank test. The behaviour characteristics of experimental animals were compared to the control group using a two-sided Mann-Whitney U test.

885 Classical conditioning

886 Experiment procedures

887 CsChrimson (Klapoetke et al., 2014) was expressed under the control of driver lines targeting candidate valence-conveying neurons. These driver lines were classified based on expression pattern
889 and previous functional data and are known to drive expression in larvae. Optogenetic activation of neurons (US) was paired with odour presentation (CS) to induce olfactory memory (Figure 4A). For each driver line, data was acquired from at least two separate crosses.

890
891
892
893
894
895
896
897
898
899
900
901
902
Classical conditioning followed a procedure similar to those described in Gerber and Hendel (2006), Saumweber et al. (2011) and Eschbach et al. (2020b). Approximately 40 third-instar larvae were transferred onto a 4% agarose petri dish. Larvae were presented with an odour (1:10⁴ ethyl acetate in ddH₂O) pipetted onto two pieces of filter paper attached to the lid of the dish. This enclosed dish was exposed to red light (630 nm, 350 µW/cm²) for three minutes. Larvae were then transferred to a new agarose-filled petri dish with no odour on its lid (“air”) and placed in the dark for three minutes. This training procedure was repeated three times, with alternating presentation of odour/light and air/dark (paired group). An unpaired group receiving reciprocal stimulus presentation (odour/dark, air/light) was trained simultaneously. This ensured that any observed effects were attributable to learning rather than innate odour preference or avoidance. The training trial order was reversed in half of the experiments, starting with air instead of odour presentation.

903
904
905
906
907
908
After training, larvae of both paired and unpaired groups were immediately transferred to a 1 cm middle zone in the centre of fresh agarose-filled petri dishes. A lid was placed on each dish, with odour presented on one side (odour side) but not the other (air side). After a three-minute test period in the dark, the number of larvae on the odour side, the air side, and in the middle zone were manually counted and entered into an Excel spreadsheet (Microsoft Corporation, Remond, Washington).

909 Data analysis

All data was manually entered into MATLAB and analysed using custom software. For each experi-
ment, a performance index (PI) was calculated as follows:

$$
\text{Pref}_{\text{paired}} = \frac{\#(\text{larvae on odour side}) - \#(\text{larvae on air side})}{\#(\text{larvae on plate})} \quad \text{(paired dish)}
$$

$$
\text{Pref}_{\text{unpaired}} = \frac{\#(\text{larvae on odour side}) - \#(\text{larvae on air side})}{\#(\text{larvae on plate})} \quad \text{(unpaired dish)}
$$

$$
\mathrm{PI}=\frac{\mathrm{Pref}_{\mathrm{paired}}-\mathrm{Pref}_{\mathrm{unpaired}}}{2} \quad(\text { combined })
$$

910
911
912
913
914
PIs take values between -1 and +1, where a positive PI reflects appetitive learning and a neg-
ative PI reflects aversive learning. Mean and standard error were calculated for each condition.
Statistical differences between two groups were tested using a two-sided Mann-Whitney U test
with Bonferroni correction. Significance compared to zero was tested with a two-sided Wilcoxon
signed-rank test with Bonferroni correction.

915 Acknowledgments

916
917
918
919
920
We thank Dr. Chris McRaven for design and technical assistance with the thermogenetic laser light
source; Howard Hughes Medical Institute (HHMI) Janelia FlyCore and FlyLight teams for assistance
with fly crosses, fly food, and confocal imaging; Gates Cambridge Trust, Cambridge Trust, HHMI
Janelia Visiting Scientist Program, University of Cambridge Trinity College, HHMI Janelia, European
Research Council, Wellcome Trust, and Medical Research Council for funding.

921 Competing interests

922
The authors declare that no competing interests exist.

923 References

924 Abramson CI, Dinges CW, Wells H. Operant Conditioning in Honey Bees (Apis mellifera L.): The Cap Pushing Response. PLoS ONE. 2016; 11(9):e0162347. doi: 10.1371/journal.pone.0162347.
926 Aceves-Piña EO, Quinn WG. Learning in Normal and Mutant Drosophila Larvae. Science. 1979; 206(4414):93-96. doi: 10.1126/science.206.4414.93.

928 Alekseyenko OV, Lee C, Kravitz EA. Targeted Manipulation of Serotonergic Neurotransmission Affects the Escalation of Aggression in Adult Male Drosophila melanogaster. PLoS ONE. 2010; 5(5):e10806. doi: 10.1371/journal.pone.0010806.

931 Alexander J, Audesirk TE, Audesirk GJ. One-trial reward learning in the snail Lymnea stagnalis. Journal of Neurobiology. 1984; 15(1):67-72. doi: 10.1002/neu.480150107.

933 Almeida-Carvalho MJ, Berh D, Braun A, Chen YC, Eichler K, Eschbach C, Fritsch PMJ, Gerber B, Hoyer N, Jiang X, Kleber J, Klämbt C, König C, Louis M, Michels B, Miroschnikow A, Mirth C, Miura D, Niewalda T, Otto N, et al. The OlImpiad: concordance of behavioural faculties of stage 1 and stage 3 Drosophila larvae. The Journal of Experimental Biology. 2017; 220:2452-2475. doi: 10.1242/jeb.156646.

937 Andreatta M, Pauli P. Appetitive vs. Aversive conditioning in humans. Frontiers in Behavioral Neuroscience. 2015; 9:128. doi: 10.3389/fnbeh.2015.00128.

939 Apostolopoulou AA, Mazija L, Wüst A, Thum AS. The neuronal and molecular basis of quinine-dependent bitter taste signaling in Drosophila larvae. Frontiers in Behavioral Neuroscience. 2014; 8:6. doi: 10.3389/fnbeh.2014.00006.

942 Apostolopoulou AA, Widmann A, Rohwedder A, Pfitzenmaier JE, Thum AS. Appetitive Associative Olfactory Learning in Drosophila Larvae. Journal of Visualized Experiments. 2013; 72:e4334. doi: 10.3791/4334.

944 Aso Y, Hattori D, Yu Y, Johnston RM, Iyer NA, Ngo TTB, Dionne H, Abbott LF, Axel R, Tanimoto H, Rubin GM. The neuronal architecture of the mushroom body provides a logic for associative learning. eLife. 2014; 3:e04577. doi: 10.7554/eLife.04577.

947 Aso Y, Herb A, Ogueta M, Siwanowicz I, Templier T, Friedrich AB, Ito K, Scholz H, Tanimoto H. Three Dopamine pathways induce aversive odor memories with different stability. PLoS Genetics. 2012; 8(7):e1002768. doi: 10.1371/journal.pgen.1002768.

950 Aso Y, Sitaraman D, Ichinose T, Kaun KR, Vogt K, Belliart-Guérin G, Plaçais PY, Robie AA, Yamagata N, Schnaitmann C, Rowell WJ, Johnston RM, Ngo TTB, Chen N, Korff W, Nitabach MN, Heberlein U, Preat T, Branson KM, Tanimoto H, et al. Mushroom body output neurons encode valence and guide memory-based action selection in Drosophila. eLife. 2014; 3:e04580. doi: 10.7554/eLife.04580.

954 Balleine BW, Liljeholm M, Ostlund SB. The integrative function of the basal ganglia in instrumental conditioning. Behavioural Brain Research. 2009; 199:43-52. doi: 10.1016/j.bbr.2008.10.034.

956 Balleine BW, Morris RW, Leung BK. Thalamocortical integration of instrumental learning and performance and their disintegration in addiction. Brain Research. 2015; 1628(Pt A):104-116. doi: 10.1016/j.brainres.2014.12.023.

959 Bath DE, Stowers JR, Hörmann D, Poehlmann A, Dickson BJ, Straw AD. FlyMAD: rapid thermogenetic control of neuronal activity in freely walking Drosophila. Nature Methods. 2014; 11(7):756-762. doi: 10.1038/nmeth.2973.

962 Berck ME, Khandelwal A, Claus L, Hernandez-Nunez L, Si G, Tabone CJ, Li F, Truman JW, Fetter RD, Louis M, Samuel AD, Cardona A. The wiring diagram of a glomerular olfactory system. eLife. 2016; 5:e14859. doi: 10.7554/eLife.14859.

965 Berman GJ, Choi DM, Bialek W, Shaevitz JW. Mapping the stereotyped behaviour of freely moving fruit flies. Journal of The Royal Society Interface. 2014; 11(99):20140672. doi: 10.1098/rsif.2014.0672.

967 Booker R, Quinn WG. Conditioning of leg position in normal and mutant Drosophila. Proceedings of the National Academy of Sciences. 1981; 78(6):3940-3944. doi: 10.1073/pnas.78.6.3940.

969 Brand AH, Perrimon N. Targeted gene expression as a means of altering cell fates and generating dominant phenotypes. Development (Cambridge, England). 1993; 118(2):401-15.

971 Branson K, Robie AA, Bender J, Perona P, Dickinson MH. High-throughput ethomics in large groups of Drosophila. Nature Methods. 2009; 6(6):451-457. doi: 10.1038/nmeth.1328.

973 Braubach OR, Wood HD, Gadbois S, Fine A, Croll RP. Olfactory conditioning in the zebrafish (Danio rerio). Behavioural Brain Research. 2009; 198(1):190-198. doi: 10.1016/j.bbr.2008.10.044.
975 Brembs B. Operant conditioning in invertebrates. Current Opinion in Neurobiology. 2003; 13(6):710-717. doi: 10.1016/j.conb.2003.10.002.

977 Brembs B. Spontaneous decisions and operant conditioning in fruit flies. Behavioural Processes. 2011; 87(1):157-164. doi: 10.1016/j.beproc.2011.02.005.

979 Brembs B, Lorenzetti FD, Reyes FD, Baxter DA, Byrne JH. Operant Reward Learning in Aplysia: Neuronal Correlates and Mechanisms. Science. 2002; 296(5573):1706-1709. doi: 10.1126/science.1069434.

981 Brembs B, Plendl W. Double Dissociation of PKC and AC Manipulations on Operant and Classical Learning in Drosophila. Current Biology. 2008; 18(15):1168-1171. doi: 10.1016/j.cub.2008.07.041.

983 Brown JS, Kalish HI, Farber IE. Conditioned fear as revealed by magnitude of startle response to an auditory stimulus. Journal of Experimental Psychology. 1951; 41(5):317-328. doi: 10.1037/h0060166.

985 Campbell RAA, Honegger KS, Qin H, Li W, Demir E, Turner GC. Imaging a Population Code for Odor Identity in the Drosophila Mushroom Body. Journal of Neuroscience. 2013; 33(25):10568-10581. doi: 10.1523/JNEUROSCI.0682-12.2013.

988 Caroni P. Inhibitory microcircuit modules in hippocampal learning. Current Opinion in Neurobiology. 2015; 35:66-73. doi: 10.1016/j.conb.2015.06.010.

990 Carreira-Rosario A, Zarin AA, Clark MQ, Manning L, Fetter RD, Cardona A, Doe CQ. MDN brain descending neurons coordinately activate backward and inhibit forward locomotion. eLife. 2018; 7:e38554. doi: 10.7554/eLife.38554.

993 Chen YJ, Li YC, Huang KN, Young MS. The Implementation of a Stand-alone Video Tracking and Analysis System for Animal Behavior Measurement in Morris Water Maze. In: *IEEE Engineering in Medicine and Biology 27th Annual Conference* IEEE; 2005. p. 1766-1768. doi: 10.1109/iembs.2005.1616788.

996 Chiuchisan I. A new FPGA-based real-time configurable system for medical image processing. In: *E-Health and Bioengineering Conference (EHB)* IEEE; 2013. p. 1-4. doi: 10.1109/EHB.2013.6707301.

998 Claridge-Chang A, Roorda RD, Vrontou E, Sjulson L, Li H, Hirsh J, Miesenböck G. Writing Memories with Light-Addressable Reinforcement Circuitry. Cell. 2009; 139(2):405-415. doi: 10.1016/j.cell.2009.08.034.

1000 Clyne JD, Miesenböck G. Sex-Specific Control and Tuning of the Pattern Generator for Courtship Song in Drosophila. Cell. 2008; 133(2):354-363. doi: 10.1016/j.cell.2008.01.050.

1002 Cognigni P, Felsenberg J, Waddell S. Do the right thing: neural network mechanisms of memory formation, expression and update in Drosophila. Current Opinion in Neurobiology. 2018; 49:51-58. doi: 10.1016/j.conb.2017.12.002.

1005 Colomb J, Brembs B. The biology of psychology. Communicative & Integrative Biology. 2010; 3(2):142-145. doi: 10.4161/cib.3.2.10334.

1007 Colomb J, Brembs B. PKC in motorneurons underlies selflearning, a form of motor learning in Drosophila. PeerJ. 2016; 4:e1971. doi: 10.7717/peerj.1971.

1009 Cong L, Wang Z, Chai Y, Hang W, Shang C, Yang W, Bai L, Du J, Wang K, Wen Q. Rapid whole brain imaging of neural activity in freely behaving larval zebrafish (Danio rerio). eLife. 2017; 6:e28158. doi: 10.7554/eLife.28158.

1011 Corbett D, Wise RA. Intracranial self-stimulation in relation to the ascending dopaminergic systems of the midbrain: A moveable electrode mapping study. Brain Research. 1980; 185(1):1-15. doi: 10.1016/0006-8993(80)90666-6.

1014 Curcio JA, Petty CC. The near infrared absorption spectrum of liquid water. Journal of the Optical Society of America. 1951; 41(5):302-304. doi: 10.1364/JOSA.41.000302.

1016 van Dam EA, Noldus LPJJ, van Gerven MAJ. Deep learning improves automated rodent behavior recognition within a specific experimental setup. Journal of Neuroscience Methods. 2020; 332:108536. doi: 10.1016/j.jneumeth.2019.108536.

1019 Dankert H, Wang L, Hoopfer ED, Anderson DJ, Perona P. Automated monitoring and analysis of social behavior in Drosophila. Nature Methods. 2009; 6(4):297-303. doi: 10.1038/nmeth.1310.

1021 DasGupta S, Ferreira CH, Miesenböck G. FoxP influences the speed and accuracy of a perceptual decision in Drosophila. Science. 2014; 344(6186):901-904. doi: 10.1126/science.1252114.
1023 Davis RL. Olfactory Memory Formation in Drosophila: From Molecular to Systems Neuroscience. Annual Review of Neuroscience. 2005; 28:275-302. doi: 10.1146/annurev.neuro.28.061604.135651.

1025 Denisov G, Ohyama T, Jovanic T, Zlatic M. Model-based Detection and Analysis of Animal Behaviors using Signals Extracted by Automated Tracking. In: *BIOSIGNALS*; 2013. p. 175-181. doi: 10.13140/2.1.5191.6168.

1027 Dickinson A. Conditioning and Associative Learning. British Medical Bulletin. 1981; 37(2):165-168. doi: 10.1093/oxfordjournals.bmb.a071695.

1029 Donelson N, Kim EZ, Slawson JB, Vecsey CG, Huber R, Griffith LC. High-Resolution Positional Tracking for Long-Term Analysis of Drosophila Sleep and Locomotion Using the "Tracker" Program. PLoS ONE. 2012; 7(5):e37250. doi: 10.1371/journal.pone.0037250.

1032 Dong Y, Green T, Saal D, Marie H, Neve R, Nestler EJ, Malenka RC. CREB modulates excitability of nucleus accumbens neurons. Nature Neuroscience. 2006; 9(4):475-477. doi: 10.1038/nn1661.

1034 Eichler K, Li F, Litwin-Kumar A, Park Y, Andrade I, Schneider-Mizell CM, Saumweber T, Huser A, Eschbach C, Gerber B, Fetter RD, Truman JW, Priebe CE, Abbott LF, Thum AS, Zlatic M, Cardona A. The complete connectome of a learning and memory centre in an insect brain. Nature. 2017; 548(7666):175-182. doi: 10.1038/nature23455.

1038 Eschbach C, Cano C, Haberkern H, Schraut K, Guan C, Triphan T, Gerber B. Associative learning between odorants and mechanosensory punishment in larval Drosophila. Journal of Experimental Biology. 2011; 214(Pt 23):3897-3905. doi: 10.1242/jeb.060533.

1041 Eschbach C, Fushiki A, Winding M, Afonso B, Andrade IV, Cocanougher BT, Eichler K, Gepner R, Si G, Valdes-Aleman J, Gershow M, Sxe Jefferis G, Truman JW, Fetter RD, Samuel A, Cardona A, Zlatic M. Circuits for integrating learnt and innate valences in the fly brain. bioRxiv. 2020; doi: 10.1101/2020.04.23.058339.

1044 Eschbach C, Fushiki A, Winding M, Schneider-Mizell CM, Shao M, Arruda R, Eichler K, Valdes-Aleman J, Ohyama T, Thum AS, Gerber B, Fetter RD, Truman JW, Litwin-Kumar A, Cardona A, Zlatic M. Recurrent architecture for adaptive regulation of learning in the insect brain. Nature Neuroscience. 2020; 23(4):544-555. doi: 10.1038/s41593-020-0607-9.

1048 von Essen AMHJ, Pauls D, Thum AS, Sprecher SG. Capacity of Visual Classical Conditioning in Drosophila Larvae. Behavioral Neuroscience. 2011; 125(6):921-929. doi: 10.1037/a0025758.

1050 Everitt BJ, Giuliano C, Belin D. Addictive behaviour in experimental animals: prospects for translation. Philosophical Transactions of the Royal Society B. 2018; 373(1742):20170027. doi: 10.1098/rstb.2017.0027.

1052 Fee MS, Goldberg JH. A hypothesis for basal ganglia-dependent reinforcement learning in the songbird. Neuroscience. 2011; 198:152-170. doi: 10.1016/j.neuroscience.2011.09.069.

1054 Fee MS. The role of efference copy in striatal learning. Current Opinion in Neurobiology. 2014; 25:194-200. doi: 10.1016/j.conb.2014.01.012.

1056 Fischer JA, Giniger E, Maniatis T, Ptashne M. GAL4 activates transcription in Drosophila. Nature. 1988; 332(6167):853-856. doi: 10.1038/332853a0.

1058 Friggi-Grelin F, Coulom H, Meller M, Gomez D, Hirsh J, Birman S. Targeted gene expression in Drosophila dopaminergic cells using regulatory sequences from tyrosine hydroxylase. Journal of Neurobiology. 2003; 54(4):618-627. doi: 10.1002/neu.10185.

1061 Fry SN, Rohrseitz N, Straw AD, Dickinson MH. TrackFly: Virtual reality for a behavioral system analysis in free-flying fruit flies. Journal of Neuroscience Methods. 2008; 171(1):110-117. doi: 10.1016/j.jneumeth.2008.02.016.

1064 Fushiki A, Zwart MF, Kohsaka H, Fetter RD, Cardona A, Nose A. A circuit mechanism for the propagation of waves of muscle contraction in Drosophila. eLife. 2016; 5:e13253. doi: 10.7554/eLife.13253.

1066 Ganguly A, Qi C, Bajaj J, Lee D. Serotonin receptor 5-HT7 in Drosophila mushroom body neurons mediates larval appetitive olfactory learning. Scientific Reports. 2020; 10(1):21267. doi: 10.1038/s41598-020-77910-5.

1068 Gerber B, Scherer S, Neuser K, Michels B, Hendel T, Stocker RF, Heisenberg M. Visual learning in individually assayed Drosophila larvae. The Journal of Experimental Biology. 2004; 207(Pt 1):179-188. doi: 10.1242/jeb.00718.
1071 Gerber B, Hendel T. Outcome expectations drive learned behaviour in larval Drosophila. Proceedings of the Royal Society B. 2006; 273(1604):2965-2968. doi: 10.1098/rspb.2006.3673.

1073 Gershow M, Berck M, Mathew D, Luo L, Kane EA, Carlson JR, Samuel ADT. Controlling airborne cues to study small animal navigation. Nature Methods. 2012; 9(3):290-296. doi: 10.1038/nmeth.1853.

1075 Giurfa M. Associative Learning: The Instructive Function of Biogenic Amines. Current Biology. 2006; 16(20):R892-R895. doi: 10.1016/j.cub.2006.09.021.

1077 Gomez-Marin A, Stephens GJ, Louis M. Active sampling and decision making in Drosophila chemotaxis. Nature Communications. 2011; 2:441. doi: 10.1038/ncomms1455.

1079 Gómez-Pinilla F, Huie JR, Ying Z, Ferguson AR, Crown ED, Baumbauer KM, Edgerton VR, Grau JW. BDNF and learning: Evidence that instrumental training promotes learning within the spinal cord by up-regulating BDNF expression. Neuroscience. 2007; 148(4):893-906. doi: 10.1016/j.neuroscience.2007.05.051.

1082 Gonzalez RC, Woods RE. Digital image processing, Ebook. Fourth, gl ed. Pearson Education, Limited; 2018.

1083 Grau JW, Barstow DG, Joynes RL. Instrumental learning within the spinal cord: I. Behavioral properties. Behavioral Neuroscience. 1998; 112(6):1366-1386. doi: 10.1037/0735-7044.112.6.1366.

1085 Graving JM, Couzin ID. VAE-SNE: a deep generative model for simultaneous dimensionality reduction and clustering. bioRxiv. 2020; doi: 10.1101/2020.07.17.207993.

1087 Groszer M, Keays DA, Deacon RMJ, de Bono JP, Prasad-Mulcare S, Gaub S, Baum MG, French CA, Nicod J, Coventry JA, Enard W, Fray M, Brown SDM, Nolan PM, Pääbo S, Channon KM, Costa RM, Eilers J, Ehret G, Rawlins JNP, et al. Impaired Synaptic Plasticity and Motor Learning in Mice with a Point Mutation Implicated in Human Speech Deficits. Current Biology. 2008; 18(5):354-362. doi: 10.1016/j.cub.2008.01.060.

1091 Grover D, Tower J, Tavaré S. O fly, where art thou? Journal of the Royal Society Interface. 2008; 5(27):1181-1191. doi: 10.1098/rsif.2007.1333.

1093 Gründemann J, Lüthi A. Ensemble coding in amygdala circuits for associative learning. Current Opinion in Neurobiology. 2015; 35:200-206. doi: 10.1016/j.conb.2015.10.005.

1095 Gupta S, Gomez-Marin A. A context-free grammar for Caenorhabditis elegans behavior. bioRxiv. 2019; https://www.biorxiv.org/content/10.1101/708891v1.

1097 Haberkern H, Basnak MA, Ahanonu B, Schauder D, Cohen JD, Bolstad M, Bruns C, Jayaraman V. Visually Guided Behavior and Optogenetically Induced Learning in Head-Fixed Flies Exploring a Virtual Landscape. Current Biology. 2019; 29(10):1647-1659.e8. doi: 10.1016/j.cub.2019.04.033.

1100 Haesler S, Rochefort C, Georgi B, Licznerski P, Osten P, Scharff C. Incomplete and inaccurate vocal imitation after knockdown of FoxP2 in songbird basal ganglia nucleus Area X. PLoS Biology. 2007; 5(12):e321. doi: 10.1371/journal.pbio.0050321.

1103 Hamada FN, Rosenzweig M, Kang K, Pulver SR, Ghezzi A, Jegla TJ, Garrity PA. An internal thermal sensor controlling temperature preference in Drosophila. Nature. 2008; 454(7201):217-220. doi: 10.1038/nature07001.

1105 Hawkins RD, Byrne JH. Associative Learning in Invertebrates. Cold Spring Harbor Perspectives in Biology. 2015; 7(5):a021709. doi: 10.1101/cshperspect.a021709.

1107 Hazelrigg T, Levis R, Rubin GM. Transformation of white locus DNA in Drosophila: Dosage compensation, zeste interaction, and position effects. Cell. 1984; 36(2):469-481. doi: 10.1016/0092-8674(84)90240-X.

1109 Heckscher ES, Lockery SR, Doe CQ. Characterization of Drosophila Larval Crawling at the Level of Organism, Segment, and Somatic Body Wall Musculature. Journal of Neuroscience. 2012; 32(36):12460-12471. doi: 10.1523/JNEUROSCI.0222-12.2012.

1112 Heisenberg M. Mushroom body memoir: from maps to models. Nature Reviews Neuroscience. 2003; 4(4):266-75. doi: 10.1038/nrn1074.

1114 Heisenberg M, Borst A, Wagner S, Byers D. Drosophila Mushroom Body Mutants are Deficient in Olfactory Learning. Journal of Neurogenetics. 1985; 2(1):1-30. doi: 10.3109/01677068509100140.
1116 Hendel T, Michels B, Neuser K, Schipanski A, Kaun K, Sokolowski MB, Marohn F, Michel R, Heisenberg M, Gerber B. The carrot, not the stick: Appetitive rather than aversive gustatory stimuli support associative olfactory learning in individually assayed Drosophila larvae. Journal of Comparative Physiology A. 2005; 191(3):265-279. doi: 10.1007/s00359-004-0574-8.

1120 Honegger KS, Campbell RAA, Turner GC. Cellular-Resolution Population Imaging Reveals Robust Sparse Coding in the Drosophila Mushroom Body. Journal of Neuroscience. 2011; 31(33):11772-11785. doi: 10.1523/JNEUROSCI.1099-11.2011.

1123 Honjo K, Furukubo-Tokunaga K. Induction of cAMP Response Element-Binding Protein-Dependent Medium-Term Memory by Appetitive Gustatory Reinforcement in Drosophila Larvae. Journal of Neuroscience. 2005; 25(35):7905-7913. doi: 10.1523/jneurosci.2135-05.2005.

1126 Honjo K, Furukubo-Tokunaga K. Distinctive Neuronal Networks and Biochemical Pathways for Appetitive and Aversive Memory in Drosophila Larvae. Journal of Neuroscience. 2009; 29(3):852-862. doi: 10.1523/JNEUROSCI.1315-08.2009.

1129 Horridge GA. Learning of leg position by the ventral nerve cord in headless insects. Proceedings of the Royal Society of London Series B Biological Sciences. 1962; 157(966):33-52. doi: 10.1098/rspb.1962.0061.

1131 Hoyle G. Mechanisms of simple motor learning. Trends in Neurosciences. 1979; 2:153-155. doi: 10.1016/0166-2236(79)90060-2.

1133 Huang KM, Cosman P, Schafer WR. Machine vision based detection of omega bends and reversals in C. elegans. Journal of Neuroscience Methods. 2006; 158(2):323-336. doi: 10.1016/j.jneumeth.2006.06.007.

1135 Huser A, Eschment M, Güllü N, Collins KAN, Böpple K, Pankevych L, Rolsing E, Thum AS. Anatomy and behavioral function of serotonin receptors in Drosophila melanogaster larvae. PLoS ONE. 2017; 12(8):e0181865. doi: 10.1371/journal.pone.0181865.

1138 Huser A, Rohwedder A, Apostolopoulou AA, Widmann A, Pfitzenmaier JE, Maiolo EM, Selcho M, Pauls D, von Essen A, Gupta T, Sprecher SG, Birman S, Riemensperger T, Stocker RF, Thum AS. The Serotonergic Central Nervous System of the Drosophila Larva: Anatomy and Behavioral Function. PLoS ONE. 2012; 7(10):e47518. doi: 10.1371/journal.pone.0047518.

1142 Hwang RY, Zhong L, Xu Y, Johnson T, Zhang F, Deisseroth K, Tracey WD. Nociceptive Neurons Protect Drosophila Larvae from Parasitoid Wasps. Current Biology. 2007; 17(24):2105-2116. doi: 10.1016/j.cub.2007.11.029.

1144 Jefferis GSXE, Potter CJ, Chan AM, Marin EC, Rohlfing T, Maurer, Jr CR, Luo L. Comprehensive Maps of Drosophila Higher Olfactory Centers: Spatially Segregated Fruit and Pheromone Representation. Cell. 2007; 128(6):1187-1203. doi: 10.1016/j.cell.2007.01.040.

1147 Jenett A, Rubin GM, Ngo TTB, Shepherd D, Murphy C, Dionne H, Pfeiffer BD, Cavallaro A, Hall D, Jeter J, Iyer N, Fetter D, Hausenfluck JH, Peng H, Trautman ET, Svirskas RR, Myers EW, Iwinski ZR, Aso Y, DePasquale GM, et al. A GAL4-Driver Line Resource for Drosophila Neurobiology. Cell Reports. 2012; 2(4):991-1001. doi: 10.1016/j.celrep.2012.09.011.

1151 Jin X, Costa RM. Start/stop signals emerge in nigrostriatal circuits during sequence learning. Nature. 2010; 466(7305):457-462. doi: 10.1038/nature09263.

1153 Joel D. The signal attenuation rat model of obsessive-compulsive disorder: a review. Psychopharmacology. 2006; 186(4):487-503. doi: 10.1007/s00213-006-0387-2.

1155 Johnson O, Becnel J, Nichols CD. Serotonin receptor activity is necessary for olfactory learning and memory in Drosophila melanogaster. Neuroscience. 2011; 192:372-381. doi: 10.1016/j.neuroscience.2011.06.058.

1157 Jones SV, Heldt SA, Davis M, Ressler KJ. Olfactory-Mediated Fear Conditioning in Mice: Simultaneous Measurements of Fear-Potentiated Startle and Freezing. Behavioral Neuroscience. 2005; 119(1):329-335. doi: 10.1037/0735-7044.119.1.329.

1160 Jovanic T, Schneider-Mizell CM, Shao M, Masson JB, Denisov G, Fetter RD, Mensh BD, Truman JW, Cardona A, Zlatic M. Competitive Disinhibition Mediates Behavioral Choice and Sequences in Drosophila. Cell. 2016; 167(3):858-870.e19. doi: 10.1016/j.cell.2016.09.009.

1163 Jovanic T, Winding M, Cardona A, Truman JW, Gershow M, Zlatic M, Jovanic T, Winding M, Cardona A, Truman JW, Gershow M. Neural Substrates of Drosophila Larval Anemotaxis Article Neural Substrates of Drosophila Larval Anemotaxis. Current Biology. 2019; 29(4):554-566. doi: 10.1016/j.cub.2019.01.009.
1166 Joynes RL, Janjua K, Grau JW. Instrumental learning within the spinal cord: VI: The NMDA receptor antagonist, AP5, disrupts the acquisition and maintenance of an acquired flexion response. Behavioural Brain Research. 2004; 154(2):431-438. doi: 10.1016/j.bbr.2004.03.030.

1169 Kabra M, Robie AA, Rivera-Alba M, Branson S, Branson K. JAABA: interactive machine learning for automatic annotation of animal behavior. Nature Methods. 2013; 10(1):64-67. doi: 10.1038/nmeth.2281.

1171 Kane EA, Gershow M, Afonso B, Larderet I, Klein M, Carter AR, de Bivort BL, Sprecher SG, Samuel ADT. Senso-rimotor structure of Drosophila larva phototaxis. Proceedings of the National Academy of Sciences. 2013; 110(40):E3868-E3877. doi: 10.1073/pnas.1215295110.

1174 Karagyozov D, Mihovilovic Skanata M, Lesar A, Gershow M. Recording Neural Activity in Unrestrained Animals with Three-Dimensional Tracking Two-Photon Microscopy. Cell Reports. 2018; 25(5):1371-1383.e10. doi: 10.1016/j CELREP.2018.10.013.

1177 Katsov AY, Clandinin TR. Motion Processing Streams in Drosophila Are Behaviorally Specialized. Neuron. 2008; 59(2):322-335. doi: 10.1016/j.neuron.2008.05.022.

1179 Keene AC, Krashes MJ, Leung B, Bernard JA, Waddell S. Drosophila Dorsal Paired Medial Neurons Provide a General Mechanism for Memory Consolidation. Current Biology. 2006; 16(15):1524-1530. doi: 10.1016/j.cub.2006.06.022.

1182 Keene AC, Stratmann M, Keller A, Perrat PN, Vosshall LB, Waddell S. Diverse odor-conditioned memories require uniquely timed dorsal paired medial neuron output. Neuron. 2004; 44(3):521-533. doi: 10.1016/j.neuron.2004.10.006.

1185 Kernan M, Cowan D, Zuker C. Genetic dissection of mechanosensory transduction: Mechanoreception-defective mutations of drosophila. Neuron. 1994; 12(6):1195-1206. doi: 10.1016/0896-6273(94)90437-5.

1187 Khurana S, Robinson BG, Wang Z, Shropshire WC, Zhong AC, Garcia LE, Corpuz J, Chow J, Hatch MM, Precise EF, Cady A, Godinez RM, Pulpanyawong T, Nguyen AT, Li Wk, Seiter M, Jahanian K, Sun JC, Shah R, Rajani S, et al. Olfactory Conditioning in the Third Instar Larvae of Drosophila melanogaster Using Heat Shock Reinforcement. Behavior Genetics. 2012; 42(1):151-161. doi: 10.1007/s10519-011-9487-9.

1191 Kitamoto T. Conditional modification of behavior in Drosophila by targeted expression of a temperature-sensitive shibire allele in defined neurons. Journal of Neurobiology. 2001; 47(2):81-92. doi: 10.1002/neu.1018.

1194 Klapoetke NC, Murata Y, Kim SS, Pulver SR, Birdsey-Benson A, Cho YK, Morimoto TK, Chuong AS, Carpenter EJ, Tian Z, Wang J, Xie Y, Yan Z, Zhang Y, Chow BY, Surek B, Melkonian M, Jayaraman V, Constantine-Paton M, Wong GKS, et al. Independent optical excitation of distinct neural populations. Nature Methods. 2014; 11(3):338-346. doi: 10.1038/nmeth.2836.

1198 Klibaite U, Berman GJ, Cande J, Stern DL, Shaevitz JW. An unsupervised method for quantifying the behavior of paired animals. Physical Biology. 2017; 14(1):015006. doi: 10.1088/1478-3975/aa5c50.

1200 Krajbich I. Accounting for attention in sequential sampling models of decision making. Current Opinion in Psychology. 2019; 29:6-11. doi: 10.1016/j.copsyc.2018.10.008.

1202 Krynitsky J, Legaria AA, Pai JJ, Garmendia-Cedillos M, Salem G, Pohida T, Kravitz AV. Rodent arena tracker (Rat): A machine vision rodent tracking camera and closed loop control system. eNeuro. 2020; 7(3). doi: 10.1523/ENEURO.0485-19.2020.

1205 Kudow N, Miura D, Schleyer M, Toshima N, Gerber B, Tanimura T. Preference for and learning of amino acids in larval Drosophila. Biology Open. 2017; 6(3):365-369. doi: 10.1242/bio.020412.

1207 Lahiri S, Shen K, Klein M, Tang A, Kane E, Gershow M, Garrity P, Samuel ADT. Two Alternating Motor Programs Drive Navigation in Drosophila Larva. PLoS ONE. 2011; 6(8):e23180. doi: 10.1371/journal.pone.0023180.

1209 Lai CSL, Fisher SE, Hurst JA, Vargha-Khadem F, Monaco AP. A forkhead-domain gene is mutated in a severe speech and language disorder. Nature. 2001; 413(6855):519-523. doi: 10.1038/35097076.

1211 Larderet I, Fritsch PMJ, Gendre N, Neagu-Maier GL, Fetter RD, Schneider-Mizell CM, Truman JW, Zlatic M, Cardona A, Sprecher SG. Organization of the Drosophila larval visual circuit. eLife. 2017; 6:e28387. doi: 10.7554/eLife.28387.
1214 Lee PT, Lin HW, Chang YH, Fu TF, Dubnau J, Hirsh J, Lee T, Chiang AS. Serotonin-mushroom body circuit modulating the formation of anesthesia-resistant memory in Drosophila. Proceedings of the National Academy of Sciences. 2011; 108(33):13794-13799. doi: 10.1073/pnas.1019483108.

1217 Lee T, Luo L. Mosaic analysis with a repressible cell marker for studies of gene function in neuronal morphogenesis. Neuron. 1999; 22(3):451-461. doi: 10.1016/S0896-6273(00)80701-1.

1219 Li H, Chaney S, Forte M, Hirsh J. Ectopic G-protein expression in dopamine and serotonin neurons blocks cocaine sensitization in Drosophila melanogaster. Current Biology. 2000; 10(4):211-214. doi: 10.1016/S0960-9822(00)00340-7.

1222 Li HH, Kroll JR, Lennox SM, Ogundeyi O, Jeter J, Depasquale G, Truman JW. A GAL4 driver resource for developmental and behavioral studies on the larval CNS of Drosophila. Cell Reports. 2014; 8(3):897-908. doi: 10.1016/j.celrep.2014.06.065.

1225 Li Y, Yao Q, Tian B, Xu W. Fast double-parallel image processing based on FPGA. In: *IEEE International Conference on Vehicular Electronics and Safety* IEEE; 2011. p. 97-102. doi: 10.1109/ICVES.2011.5983754.

1227 Lima SQ, Miesenböck G. Remote control of behavior through genetically targeted photostimulation of neurons. Cell. 2005; 121(1):141-152. doi: 10.1016/j.cell.2005.02.004.

1229 Lin S, Owald D, Chandra V, Talbot C, Huetteroth W, Waddell S. Neural correlates of water reward in thirsty Drosophila. Nature Neuroscience. 2014; 17(11):1536-1542. doi: 10.1038/nn.3827.

1231 Liu C, Plaçais PY, Yamagata N, Pfeiffer BD, Aso Y, Friedrich AB, Siwanowicz I, Rubin GM, Preat T, Tanimoto H. A subset of dopamine neurons signals reward for odour memory in Drosophila. Nature. 2012; 488(7412):512-516. doi: 10.1038/nature11304.

1234 Liu Z, Zhou J, Li Y, Hu F, Lu Y, Ma M, Feng Q, Zhang Je, Wang D, Zeng J, Bao J, Kim JY, Chen ZF, El Mestikawy S, Luo M. Dorsal Raphe Neurons Signal Reward through 5-HT and Glutamate. Neuron. 2014; 81(6):1360-1374. doi: 10.1016/j.neuron.2014.02.010.

1237 Lorenzetti FD, Baxter DA, Byrne JH. Molecular Mechanisms Underlying a Cellular Analog of Operant Reward Learning. Neuron. 2008; 59(5):815-828. doi: 10.1016/j.neuron.2008.07.019.

1239 Lovell JM, Mylius J, Scheich H, Brosch M. Stimulation of the dopaminergic midbrain as a behavioral reward in instrumentally conditioned monkeys. Brain Stimulation. 2015; 8(5):868-874. doi: 10.1016/j.brs.2015.04.007.

1241 Lovinger DM. Neurotransmitter roles in synaptic modulation, plasticity and learning in the dorsal striatum. Neuropharmacology. 2010; 58(7):951-961. doi: 10.1016/j.neuropharm.2010.01.008.

1243 Luan H, Peabody NC, Vinson CR, White BH. Refined Spatial Manipulation of Neuronal Function by Combinatorial Restriction of Transgene Expression. Neuron. 2006; 52(3):425-436. doi: 10.1016/j.neuron.2006.08.028.

1245 Lundell MJ, Hirsh J. Temporal and Spatial Development of Serotonin and Dopamine Neurons in the Drosophila CNS. Developmental Biology. 1994; 165(2):385-396. doi: 10.1006/dbio.1994.1261.

1247 Luo L, Gershow M, Rosenzweig M, Kang K, Fang-Yen C, Garrity PA, Samuel ADT. Navigational Decision Making in Drosophila Thermotaxis. Journal of Neuroscience. 2010; 30(12):4261-4272. doi: 10.1523/JNEUROSCI.4090-09.2010.

1250 Luxem K, Fuhrmann F, Kürsch J, Remy S, Bauer P. Identifying behavioral structure from deep variational embeddings of animal motion. bioRxiv. 2020; doi: 10.1101/2020.05.14.095430.

1252 Marin EC, Jefferis GSXE, Komiyama T, Zhu H, Luo L. Representation of the Glomerular Olfactory Map in the Drosophila Brain. Cell. 2002; 109(2):243-255. doi: 10.1016/S0092-8674(02)00700-6.

1254 Masson JB, Voisinne G, Wong-Ng J, Celani A, Vergassola M. Noninvasive inference of the molecular chemotactic response using bacterial trajectories. Proceedings of the National Academy of Sciences. 2012; 109(5):1802-1807. doi: 10.1073/pnas.1116772109.

1257 Masson JB, Laurent F, Cardona A, Barré C, Skatchkovsky N, Zlatic M, Jovanic T. Identifying neural substrates of competitive interactions and sequence transitions during mechanosensory responses in Drosophila. PLoS Genetics. 2020; 16(2):e1008589. doi: 10.1371/journal.pgen.1008589.

1260 Mathis A, Mamidanna P, Cury KM, Abe T, Murthy VN, Mathis MW, Bethge M. DeepLabCut: markerless pose estimation of user-defined body parts with deep learning. Nature Neuroscience. 2018; 21(9):1281-1289. doi: 10.1038/s41593-018-0209-y.
1263 Mendoza E, Colomb J, Rybak J, Pflüger HJ, Zars T, Scharff C, Brembs B. Drosophila FoxP mutants are deficient in operant self-learning. PLoS ONE. 2014; 9(6):e100648. doi: 10.1371/journal.pone.0100648.

1265 Meneses A, Liy-Salmeron G. Serotonin and emotion, learning and memory. Reviews in the Neurosciences. 2012; 23(5-6):543-553. doi: 10.1515/revneuro-2012-0060.

1267 Mirat O, Sternberg JR, Severi KE, Wyart C. ZebraZoom: an automated program for high-throughput behavioral analysis and categorization. Frontiers in Neural Circuits. 2013; 7:107. doi: 10.3389/fncir.2013.00107.

1269 Mischiati M, Lin HT, Herold P, Imler E, Olberg R, Leonardo A. Internal models direct dragonfly interception steering. Nature. 2015; 517(7534):333-338. doi: 10.1038/nature14045.

1271 Nargeot R, Baxter DA, Byrne JH. Contingent-Dependent Enhancement of Rhythmic Motor Patterns: An In Vitro Analog of Operant Conditioning. The Journal of Neuroscience. 1997; 17(21):8093-8105. doi: 10.1523/JNEUROSCI.17-21-08093.1997.

1274 Nargeot R, Le Bon-Jego M, Simmers J. Cellular and Network Mechanisms of Operant Learning-Induced Compulsive Behavior in Aplysia. Current Biology. 2009; 19(12):975-984. doi: 10.1016/j.cub.2009.05.030.

1276 Nern A, Pfeiffer BD, Rubin GM. Optimized tools for multicolor stochastic labeling reveal diverse stereotyped cell arrangements in the fly visual system. Proceedings of the National Academy of Sciences. 2015; 112(22):E2967-E2976. doi: 10.1073/pnas.1506763112.

1279 Neuser K, Husse J, Stock P, Gerber B. Appetitive olfactory learning in Drosophila larvae: effects of repetition, reward strength, age, gender, assay type and memory span. Animal Behaviour. 2005; 69(4):891-898. doi: 10.1016/j.anbehav.2004.06.013.

1282 Neuser K, Triphan T, Mronz M, Poeck B, Strauss R. Analysis of a spatial orientation memory in Drosophila. Nature. 2008; 453(7199):1244-1247. doi: 10.1038/nature07003.

1284 Niewalda T, Singhal N, Fiala A, Saumweber T, Wegener S, Gerber B. Salt Processing in Larval Drosophila: Choice, Feeding, and Learning Shift from Appetitive to Aversive in a Concentration-Dependent Way. Chemical Senses. 2008; 33(8):685-692. doi: 10.1093/chemse/bjn037.

1287 Nottebohm F. Reassessing the mechanisms and origins of vocal learning in birds. Trends in Neurosciences. 1991; 14(5):206-211. doi: 10.1016/0166-2236(91)90107-6.

1289 Nuwal N, Stock P, Hiemeyer J, Schmid B, Fiala A, Buchner E. Avoidance of Heat and Attraction to Optogenetically Induced Sugar Sensation as Operant Behavior in Adult Drosophila. Journal of Neurogenetics. 2012; 26(3-4):298-305. doi: 10.3109/01677063.2012.700266.

1292 Ohyama T, Jovanic T, Denisov G, Dang TC, Hoffmann D, Kerr RA, Zlatic M. High-Throughput Analysis of Stimulus-Evoked Behaviors in Drosophila Larva Reveals Multiple Modality-Specific Escape Strategies. PLoS ONE. 2013; 8(8):e71706. doi: 10.1371/journal.pone.0071706.

1295 Ohyama T, Schneider-Mizell CM, Fetter RD, Aleman JV, Franconville R, Rivera-Alba M, Mensh BD, Branson KM, Simpson JH, Truman JW, Cardona A, Zlatic M. A multilevel multimodal circuit enhances action selection in Drosophila. Nature. 2015; 520(7549):633-639. doi: 10.1038/nature14297.

1298 Olds J, Milner P. Positive reinforcement produced by electrical stimulation of septal area and other regions of rat brain. Journal of Comparative and Physiological Psychology. 1954; 47(6):419-427. doi: 10.1037/h0058775.

1300 Owald D, Felsenberg J, Talbot CB, Das G, Perisse E, Huetteroth W, Waddell S. Activity of defined mushroom body output neurons underlies learned olfactory behavior in Drosophila. Neuron. 2015; 86(2):417-427. doi: 10.1016/j.neuron.2015.03.025.

1303 Owald D, Waddell S. Olfactory learning skews mushroom body output pathways to steer behavioral choice in Drosophila. Current Opinion in Neurobiology. 2015; 35:178-184. doi: 10.1016/j.conb.2015.10.002.

1305 Park J, Lee SB, Lee S, Kim Y, Song S, Kim S, Bae E, Kim J, Shong M, Kim JM, Chung J. Mitochondrial dysfunction in Drosophila PINK1 mutants is complemented by parkin. Nature. 2006; 441(7097):1157-1161. doi: 10.1038/nature04788.

1308 Pavlov IP. Conditioned reflexes: an investigation of the physiological activity of the cerebral cortex. Oxford: Oxford University Press; 1927. doi: 10.2307/1134737.
1310 Perisse E, Owald D, Barnstedt O, Talbot CB, Huetteroth W, Waddell S. Aversive Learning and Appetitive Motivation Toggle Feed-Forward Inhibition in the Drosophila Mushroom Body. Neuron. 2016; 90(5):1086-1099. doi: 10.1016/j.neuron.2016.04.034.

1311
1312 Pfeiffer BD, Jenett A, Hammonds AS, Ngo TTB, Misra S, Murphy C, Scully A, Carlson JW, Wan KH, Laverty TR, Mungall C, Svirskas R, Kadonaga JT, Doe CQ, Eisen MB, Celniker SE, Rubin GM. Tools for neuroanatomy and neurogenetics in Drosophila. Proceedings of the National Academy of Sciences. 2008; 105(28):9715-9720. doi: 10.1073/pnas.0803697105.

1313 Pfeiffer BD, Ngo TTB, Hibbard KL, Murphy C, Jenett A, Truman JW, Rubin GM. Refinement of Tools for Targeted Gene Expression in Drosophila. Genetics. 2010; 186(2):735-755. doi: 10.1534/genetics.110.119917.

1319 Plaçais PY, Trannoy S, Friedrich AB, Tanimoto H, Preat T. Two pairs of mushroom body efferent neurons are required for appetitive long-term memory retrieval in drosophila. Cell Reports. 2013; 5(3):769-780. doi: 10.1016/j.celrep.2013.09.032.

1322 Reddy G, Desban L, Tanaka H, Roussel J, Mirat O, Wyart C. A lexical approach for identifying behavioral action sequences. bioRxiv. 2020; doi: 10.1101/2020.08.27.270694.

1324 Redgrave P, Vautrelle N, Reynolds JNJ. Functional properties of the basal ganglia's re-entrant loop architecture: selection and reinforcement. Neuroscience. 2011; 198:138-151. doi: 10.1016/j.neuroscience.2011.07.060.

1326 Rescorla RA. Behavioral Studies of Pavlovian Conditioning. Annual Review of Neuroscience. 1988; 11:329-352. doi: 10.1146/annurev.neuro.11.1.329.

1328 Reynolds JNJ, Wickens JR. Dopamine-dependent plasticity of corticostriatal synapses. Neural Networks. 2002; 15(4-6):507-521. doi: 10.1016/S0893-6080(02)00045-X.

1330 Robertson JL, Tsubouchi A, Tracey WD. Larval Defense against Attack from Parasitoid Wasps Requires Noci-ceptive Neurons. PLoS ONE. 2013; 8(10):e78704. doi: 10.1371/journal.pone.0078704.

1332 Robie AA, Hirokawa J, Edwards AW, Umayam LA, Lee A, Phillips ML, Card GM, Korff W, Rubin GM, Simpson JH, Reiser MB, Branson K. Mapping the Neural Substrates of Behavior. Cell. 2017; 170(2):393-406. doi: 10.1016/j.cell.2017.06.032.

1335 Rohwedder A, Pfitzenmaier JE, Ramsperger N, Apostolopoulou AA, Widmann A, Thum AS. Nutritional Value-Dependent and Nutritional Value-Independent Effects on Drosophila melanogaster Larval Behavior. Chemical Senses. 2012; 37(8):711-721. doi: 10.1093/chemse/bjs055.

1338 Rohwedder A, Wenz NL, Stehle B, Huser A, Yamagata N, Zlatic M, Truman JW, Tanimoto H, Saumweber T, Gerber B, Thum AS. Four Individually Identified Paired Dopamine Neurons Signal Reward in Larval Drosophila. Current Biology. 2016; 26(5):661-669. http://linkinghub.elsevier.com/retrieve/pii/S0960982216000622, doi: 10.1016/j.cub.2016.01.012.

1342 Rosenegger D, Lukowiak K. The participation of NMDA receptors, PKC, and MAPK in the formation of memory following operant conditioning in Lymnaea. Molecular Brain. 2010; 3:24. doi: 10.1186/1756-6606-3-24.

1344 Roy B, Singh AP, Shetty C, Chaudhary V, North A, Landgraf M, VijayRaghavan K, Rodrigues V. Metamorphosis of an identified serotonergic neuron in the Drosophila olfactory system. Neural Development. 2007; 2:20. doi: 10.1186/1749-8104-2-20.

1347 Saumweber T, Husse J, Gerber B. Innate attractiveness and associative learnability of odors can be dissociated in larval Drosophila. Chemical Senses. 2011; 36(3):223-235. doi: 10.1093/chemse/bjq128.

1349 Saumweber T, Rohwedder A, Schleyer M, Eichler K, Chen Yc, Aso Y, Cardona A, Eschbach C, Kobler O, Voigt A, Durairaja A, Mancini N, Zlatic M, Truman JW, Thum AS, Gerber B. Functional architecture of reward learning in mushroom body extrinsic neurons of larval Drosophila. Nature Communications. 2018; 9(1):1104. doi: 10.1038/s41467-018-03130-1.

1353 Sawin-McCormack EP, Sokolowski MB, Campos AR. Characterization and Genetic Analysis of Drosophila Melanogaster Photobehavior During Larval Development. Journal of Neurogenetics. 1995; 10(2):119-135. doi: 10.3109/01677069509083459.

1356 Scherer S, Stocker RF, Gerber B. Olfactory Learning in Individually Assayed Drosophila Larvae. Learning & Memory. 2003; 10(3):217-225. doi: 10.1101/lm.57903.
1358 Schipanski A, Yarali A, Niewalda T, Gerber B. Behavioral Analyses of Sugar Processing in Choice, Feeding, and Learning in Larval Drosophila. Chemical Senses. 2008; 33(6):563-573. doi: 10.1093/chemse/bjn024.

1360 Schlegel P, Texada MJ, Miroschnikow A, Schoofs A, Hückesfeld S, Peters M, Schneider-Mizell CM, Lacin H, Li F, Fetter RD, Truman JW, Cardona A, Pankratz MJ. Synaptic transmission parallels neuromodulation in a central food-intake circuit. eLife. 2016; 5:e16799. doi: 10.7554/eLife.16799.

1363 Schleyer M, Miura D, Tanimura T, Gerber B. Learning the specific quality of taste reinforcement in larval Drosophila. eLife. 2015; 4:e04711. doi: 10.7554/eLife.04711.001.

1365 Schleyer M, Saumweber T, Nahrendorf W, Fischer B, von Alpen D, Pauls D, Thum A, Gerber B. A behavior-based circuit model of how outcome expectations organize learned behavior in larval Drosophila. Learning & Memory. 2011; 18(10):639-653. doi: 10.1101/lm.2163411.

1368 Schroll C, Riemensperger T, Bucher D, Ehmer J, Völler T, Erbguth K, Gerber B, Hendel T, Nagel G, Buchner E, Fiala A. Light-Induced Activation of Distinct Modulatory Neurons Triggers Appetitive or Aversive Learning in Drosophila Larvae. Current Biology. 2006; 16(17):1741-1747. doi: 10.1016/j.cub.2006.07.023.

1371 Schulze A, Gomez-Marin A, Rajendran VG, Lott G, Musy M, Ahammad P, Deogade A, Sharpe J, Riedl J, Jarriault D, Trautman ET, Werner C, Venkadesan M, Druckmann S, Jayaraman V, Louis M. Dynamical feature extraction at the sensory periphery guides chemotaxis. eLife. 2015; 4:e06694. doi: 10.7554/eLife.06694.

1374 Schwaerzel M, Monastirioti M, Scholz H, Friggi-Grelin F, Birman S, Heisenberg M. Dopamine and Octopamine Differentiate between Aversive and Appetitive Olfactory Memories in Drosophila. The Journal of Neuroscience. 2003; 23(33):10495-10502. doi: 10.1523/JNEUROSCI.23-33-10495.2003.

1377 Séjourné J, Plaçais PY, Aso Y, Siwanowicz I, Trannoy S, Thoma V, Tedjakumala SR, Rubin GM, Tchénio P, Ito K, Isabel G, Tanimoto H, Preat T. Mushroom body efferent neurons responsible for aversive olfactory memory retrieval in Drosophila. Nature Neuroscience. 2011; 14(7):903-910. doi: 10.1038/nn.2846.

1380 Selcho M, Pauls D, Han KA, Stocker RF, Thum AS. The Role of Dopamine in Drosophila Larval Classical Olfactory Conditioning. PLoS ONE. 2009; 4(6):e5897. doi: 10.1371/journal.pone.0005897.

1382 Shen W, Hamilton SE, Nathanson NM, Surmeier DJ. Cholinergic Suppression of KCNQ Channel Currents Enhances Excitability of Striatal Medium Spiny Neurons. Journal of Neuroscience. 2005; 25(32):7449-7458. doi: 10.1523/JNEUROSCI.1381-05.2005.

1385 Shirvaikar M, Bushnaq T. A comparison between DSP and FPGA platforms for real-time imaging applications. In: Kehtarnavaz N, Carlsohn MF, editors. Real-Time Image and Video Processing, vol. 7244 International Society for Optics and Photonics; 2009. p. 724406. doi: 10.1117/12.806099.

1388 Shyu WH, Chiu TH, Chiang MH, Cheng YC, Tsai YL, Fu TF, Wu T, Wu CL. Neural circuits for long-term water-reward memory processing in thirsty Drosophila. Nature Communications. 2017; 8:15230. doi: 10.1038/ncomms15230.

1391 Sitaraman D, LaFerriere H, Birman S, Zars T. Serotonin is Critical for Rewarded Olfactory Short-Term Memory in Drosophila. Journal of Neurogenetics. 2012; 26(2):238-244. doi: 10.3109/01677063.2012.666298.

1393 Sitaraman D, Zars M, LaFerriere H, Chen YC, Sable-Smith A, Kitamoto T, Rottinghaus GE, Zars T. Serotonin is necessary for place memory in Drosophila. Proceedings of the National Academy of Sciences. 2008; 105(14):5579-5584. doi: 10.1073/pnas.0710168105.

1396 Skeath JB, Thor S. Genetic control of Drosophila nerve cord development. Current Opinion in Neurobiology. 2003; 13(1):8-15. doi: 10.1016/S0959-4388(03)00007-2.

1398 Skinner BF. The Behavior of Organisms: An Experimental Analysis. New York: NY: Appleton-Century-Crofts; 1938.

1400 Soares dos Santos MP, Ferreira JAF. Novel intelligent real-time position tracking system using FPGA and fuzzy logic. ISA Transactions. 2014; 53(2):402-414. doi: 10.1016/j.isatra.2013.09.003.

1402 Stephens GJ, Johnson-Kerner B, Bialek W, Ryu WS. Dimensionality and Dynamics in the Behavior of C. elegans. PLoS Computational Biology. 2008; 4(4):e1000028. doi: 10.1371/journal.pcbi.1000028.

1404 Stowers JR, Hofbauer M, Bastien R, Griessner J, Higgins P, Farooqui S, Fischer RM, Nowikovsky K, Haubensak W, Couzin ID, Tessmar-Raible K, Straw AD. Virtual reality for freely moving animals. Nature Methods. 2017; 14(10):995-1002. doi: 10.1038/nmeth.4399.
1407 Straw AD, Branson K, Neumann TR, Dickinson MH. Dimensional Tracking of Multiple Flying Animals. Journal of the Royal Society Interface. 2011; 8(56):395-409. doi: 10.1098/rsif.2010.0230.

1408 Straw AD, Dickinson MH. Motmot, an open-source toolkit for realtime video acquisition and analysis. Source Code for Biology and Medicine. 2009; 4:5. doi: 10.1186/1751-0473-4-5.

1411 Sun R, Delly J, Sereno E, Wong S, Chen X, Wang Y, Huang Y, Greenspan RJ. Anti-instinctive Learning Behavior Revealed by Locomotion-Triggered Mild Heat Stress in Drosophila. Frontiers in Behavioral Neuroscience. 2020; 14:41. doi: 10.3389/fnbeh.2020.00041.

1414 Surmeier DJ, Ding J, Day M, Wang Z, Shen W. D1 and D2 dopamine-receptor modulation of striatal glutamatergic signaling in striatal medium spiny neurons. Trends in Neurosciences. 2007; 30(5):228-235. doi: 10.1016/j.tins.2007.03.008.

1417 Swierczek NA, Giles AC, Rankin CH, Kerr RA. High-throughput behavioral analysis in C. elegans. Nature Methods. 2011; 8(7):592-598. doi: 10.1038/nmeth.1625.

1419 Tadres D, Louis M. PiVR: An affordable and versatile closed-loop platform to study unrestrained sensorimotor behavior. PLOS Biology. 2020; 18(7):e3000712. doi: 10.1371/journal.pbio.3000712.

1421 Takeda K. Classical conditioned response in the honey bee. Journal of Insect Physiology. 1961; 6(3):168-179. doi: 10.1016/0022-1910(61)90060-9.

1423 Thorndike EL. Animal intelligence; experimental studies. New York: The Macmillan company; 1911. doi: 10.5962/bhl.title.1201.

1425 Tonegawa S, Pignatelli M, Roy DS, Ryan TJ. Memory engram storage and retrieval. Current Opinion in Neurobiology. 2015; 35:101-109. doi: 10.1016/j.conb.2015.07.009.

1427 Topál J, Byrne RW, Miklósi Á, Csányi V. Reproducing human actions and action sequences: "Do as I do!" in a dog. Animal Cognition. 2006; 9(4):355-367. doi: 10.1007/s10071-006-0051-6.

1429 Tracey WD, Wilson RI, Laurent G, Benzer S. painless, a Drosophila Gene Essential for Nociception. Cell. 2003; 113(2):261-273. doi: 10.1016/S0092-8674(03)00272-1.

1431 Tully T, Cambiazo V, Kruse L. Memory through Metamorphosis. Journal of Neuroscience. 1994; 14(1):68-74. doi: 10.1523/JNEUROSCI.14-01-00068.1994.

1433 Turner GC, Bazhenov M, Laurent G. Olfactory Representations by Drosophila Mushroom Body Neurons. Journal of Neurophysiology. 2008; 99(2):734-746. doi: 10.1152/jn.01283.2007.

1435 Uzun IS, Amira A, Bouridane A. FPGA implementations of fast Fourier transforms for real-time signal and image processing. IEE Proceedings - Vision, Image, and Signal Processing. 2005; 152(3):283-296. doi: 10.1049/ip-vis.20041114.

1438 Veeraraghavan A, Chellappa R, Srinivasan M. Shape-and-Behavior Encoded Tracking of Bee Dances. IEEE Transactions on Pattern Analysis and Machine Intelligence. 2008; 30(3):463-476. doi: 10.1109/TPAMI.2007.70707.

1441 Vinauger C, Lutz EK, Riffell JA. Olfactory learning and memory in the disease vector mosquito Aedes aegypti. Journal of Experimental Biology. 2014; 217(Pt 13):2321-2330. doi: 10.1242/jeb.101279.

1443 Vogelstein JT, Park Y, Ohyama T, Kerr R, Truman JW, Priebe CE, Zlatic M. Discovery of Brainwide Neural-Behavioral Maps via Multiscale Unsupervised Structure Learning. Science. 2014; 344(6182):386-392. doi: 10.1126/science.1250298.

1446 Vogt K, Schnaitmann C, Dylla KV, Knapek S, Aso Y, Rubin GM, Tanimoto H. Shared mushroom body circuits underlie visual and olfactory memories in Drosophila. eLife. 2014; 3:e02395. doi: 10.7554/eLife.02395.

1448 Waddell S. Reinforcement signalling in Drosophila; dopamine does it all after all. Current Opinion in Neurobiology. 2013; 23(3):324-329. doi: 10.1016/j.conb.2013.01.005.

1450 Webb B. Neural mechanisms for prediction: Do insects have forward models? Trends in Neurosciences. 2004; 27(5):278-282. doi: 10.1016/j.tins.2004.03.004.

1452 Weiglein A, Gerstner F, Mancini N, Schleyer M, Gerber B. One-trial learning in larval Drosophila. Learning & Memory. 2019; 26(4):109-120. doi: 10.1101/lm.049106.118.
1454 Wen JYM, Kumar N, Morrison G, Rambaldini G, Runciman S, Rousseau J, van der Kooy D. Mutations that prevent associative learning in C. elegans. Behavioral Neuroscience. 1997; 111(2):354-368. doi: 10.1037/0735-7044.111.2.354.

1457 Wirtz RA, Semey HG. The Drosophila kitchen-equipment, media preparation, and supplies. Drosophila Information Service. 1982; 58:176-180.

1459 Wolf R, Heisenberg M. Basic organization of operant behavior as revealed in Drosophila flight orientation. Journal of Comparative Physiology A. 1991; 169(6):699-705. doi: 10.1007/BF00194898.

1461 Wolf R, Wittig T, Liu L, Wustmann G, Eyding D, Heisenberg M. Drosophila mushroom bodies are dispensable for visual, tactile, and motor learning. Learning & Memory. 1998; 5(1-2):166-78.

1463 Wong AM, Wang JW, Axel R. Spatial representation of the glomerular map in the Drosophila protocerebrum. Cell. 2002; 109(2):229-241. doi: 10.1016/S0092-8674(02)00707-9.

1465 Wright GA, Mustard JA, Simcock NK, Ross-Taylor AAR, McNicholas LD, Popescu A, Marion-Poll F. Parallel reinforcement pathways for conditioned food aversions in the honeybee. Current Biology. 2010; 20(24):2234-2240. doi: 10.1016/j.cub.2010.11.040.

1468 Wu MC, Chu LA, Hsiao PY, Lin YY, Chi CC, Liu TH, Fu CC, Chiang AS. Optogenetic control of selective neural activity in multiple freely moving Drosophila adults. Proceedings of the National Academy of Sciences. 2014; 111(14):5367-5372. doi: 10.1073/pnas.1400997111.

1471 Yasukawa S, Okuno H, Ishii K, Yagi T. Real-time object tracking based on scale-invariant features employing bio-inspired hardware. Neural Networks. 2016; 81:29-38. doi: 10.1016/j.neunet.2016.05.002.

1473 Yu D, Keene AC, Srivatsan A, Waddell S, Davis RL. Drosophila DPM neurons form a delayed and branch-specific memory trace after olfactory classical conditioning. Cell. 2005; 123(5):945-957. doi: 10.1016/j.cell.2005.09.037.

1476 Zemelman BV, Lee GA, Ng M, Miesenböck G. Selective photostimulation of genetically chARGed neurons. Neuron. 2002; 33(1):15-22. doi: 10.1016/S0896-6273(01)00574-8.

1478 Zhang C, Liang T, Mok PKT, Yu W. FPGA Implementation of the Coupled Filtering Method and the Affine Warping Method. IEEE Transactions on Nanobioscience. 2017; 16(5):314-325. doi: 10.1109/TNB.2017.2705104.
<figure><img src="image_17.png" /><figcaption>Figure 1-Figure supplement 1. Contour calculation on field-programmable gate array (FPGA).</figcaption></figure>

A simplified example is shown using a 10 x 10 pixel box containing a small object. **a.** The object (black) was detected against the background (white) using binary thresholding. Edge pixels were detected by combining the results of vertical and horizontal image convolution with a 2 x 1 XOR kernel using an OR operator. **b.** The contour points were reconstructed in an iterative process, starting with the edge pixel closest to the centre of the box. The next contour point was defined as the first neighbouring pixel that was found to be an edge pixel. Neighbouring pixels were assessed clockwise from the pixel directly above the contour point. The process ended when no eligible edge pixels could be found.
<figure><img src="image_18.png" /><figcaption>**Figure 1-Figure supplement 2. Detecting head and tail.** The larval contour (black outline) and head and tail (green) are shown. **a.** Initial detection of head and tail. The head was the contour point with the sharpest curvature. The tail was the contour point with the next-sharpest curvature which did not lie in close proximity to the head. **b.** The initial detection of head and tail was incorrect in some cases. False detection could be corrected by swapping head and tail, thereby minimising the distances from head and tail in the current frame (solid contour) to head and tail in the previous frame (transparent contour). **c.** The correction described in **b** failed if larvae curled up such that the contour appeared circular ("ball"). To eliminate this source of false head and tail detection, these events were detected using a ball classifier.</figcaption></figure>

<figure><img src="image_19.png" /><figcaption>**Figure 1-Figure supplement 3. Calculating a smooth spine and landmark points.** The larval contour is shown (black outline). The spine *S* was comprised of eleven points (black), including head and tail (green). **a.** The raw spine points were obtained by finding the centres between equally spaced contour points on either half of the contour as defined by head and tail. The first spine point was the head, the last spine point was the tail. **b.** The smooth spine was obtained by exponentially smoothing the raw spine. **c.** Four additional landmark points, *neck_top*, *neck*, and *neck_down* (blue), and the contour *centroid* (grey), were calculated.</figcaption></figure>
<figure><img src="image_20.png" /><figcaption>**Figure 1-Figure supplement 4. Calculating direction vectors.** Three direction vectors were calculated based on head, tail, and the landmark points. a. *direction_vector* was the normalised vector from *neck_down* to neck. b. *direction_head_vector* was the normalised vector from *neck_top* to head. c. *direction_tail_vector* was the normalised vector from tail to *neck_down*.</figcaption></figure>

<figure><img src="image_21.png" /></figure>

<figure><img src="image_22.png" /><figcaption>**Figure 1-Figure supplement 5. Features describing body shape.** a. Outline of a larva with contour C (black) and its convex hull H (blue). b. Shown here are the eigenvectors (blue) of the larval contour (black) structure tensor with respect to neck and their corresponding eigenvalues λ₁ and λ₂. c. *θ*ᵢ was defined as the angle between *direction_vector* (blue) and the vector *ā*ᵢ that passed through spine points *S*ᵢ and *S*ᵢ₊₁ (black). d. *θ*<sub>head</sub> was defined as the angle between *direction_vector* and *direction_head_vector*. head and tail are shown in green.</figcaption></figure>
<figure><img src="image_23.png" /><figcaption>**Figure 1-Figure supplement 6. Velocity features.** The larval contour is shown in black while head and tail are shown in green. a. crab_speed (blue) was defined as the component of neck_-speed (grey) that was orthogonal to direction_vector_filtered (black). b. parallel_speed (blue) was defined as the component of neck_speed_filtered (grey) that was parallel to direction_vector_filtered (black). c. parallel_speedAnimal velocity tail (blue) was defined as the component of tail_-speed_filtered (grey) that was parallel to directionAnimal velocity tail (black). d. $\theta_{tail}$ was defined as the angle between tail_speed_filtered (grey) and directionAnimal velocity_filtered (black).</figcaption></figure>
<figure><img src="image_24.png" /><figcaption>**Figure 1-Figure supplement 7. Temporal smoothing of features.** a-b. Example graphs of raw (dark blue) and filtered (mid blue) asymmetry (a) and eig_reduced (b) values over time. c-d. Example graphs of raw (dark blue), filtered (mid blue), and long-time filtered (light blue) v_norm values over a short (c) and a long (d) period of time.</figcaption></figure>

<figure><img src="image_25.png" /><figcaption>**Figure 1-Figure supplement 8. Differentiation by convolution.** Example graphs of raw (dark blue) and convolved squared (green) asymmetry (a), eig_reduced (b) and v_norm (c) values over time.</figcaption></figure>
<figure><img src="image_26.png" /><figcaption>**Figure 3-Figure supplement 1.** *Ddc-Gal4* expression pattern without and with *tsh-Gal80* restriction. Maximum intensity projections of confocal images obtained after immunohistochemical staining. **a, e;** green in **d** and **h**. Targeting a green fluorescent protein (GFP) antibody to the *mVenus* tag of *CsChrimson*. **b, f;** red in **d** and **h**. Staining against BP104. **c, g;** blue in **d** and **h**. Staining against N-cadherin. **a–d.** *Ddc-Gal4* x *UAS-CsChrimson* larvae. Manually counting the cell bodies in the image stacks revealed more than 200 GFP-positive neurons located in the brain, subesophageal zone (SEZ), and ventral nerve cord (VNC), including the PAM cluster dopaminergic neurons innervating the mushroom body (n = 2). This confirmed that *Ddc-Gal4* drives broad expression across the central nervous system (CNS) (Lundell and Hirsh, 1994; Li et al., 2000). **e–h.** *Ddc-Gal4* x *UAS-CsChrimson; tsh-LexA, LexAop-Gal80* larvae. As expected, no GFP-positive neurons were found in the VNC (n = 6). *Ddc-Gal4* brain and SEZ expression remained largely unaffected by GAL80, as the GFP-positive neurons in both areas that could be consistently identified in *Ddc-Gal4* x *UAS-CsChrimson* larvae (n = 3) were also present in *Ddc-Gal4* x *UAS-CsChrimson; tsh-LexA, LexAop-Gal80* larvae (n = 3). **a–h.** Plan-Apochromat 20x objective, resolution: 592 x 800 pixels, scale bar: 100 µm. Images courtesy of the HHMI Janelia FlyLight team.</figcaption></figure>
<figure><img src="image_27.png" /></figure>

1489

**Figure 4-Figure supplement 1. Tph-Gal4 expression pattern without and with tsh-Gal80 restriction.** Maximum intensity projections of confocal images obtained after immunohistochemistry. **a–d.** Tph-Gal4 x UAS-CsChrimson larvae, **e–h.** Tph-Gal4 x UAS-CsChrimson; tsh-LexA, LexAop-Gal80 larvae. **a, e;** green in **d** and **h**. Staining against green fluorescent protein (GFP) antibody targeting the *mVenus* tag of CsChrimson. **b, f;** red in **d** and **h**. Staining against BP104. **c, g;** blue in **d** and **h**. Staining against N-cadherin. **a–h.** Plan-Apochromat 20x objective, resolution: 592 x 800 pixels, scale bar: 100 µm. Image courtesy of the HHMI Janelia FlyLight team.

<figure><img src="image_28.png" /></figure>

1490

**Figure 4-Figure supplement 2. SS01989 exclusively drives expression in the CSD neuron.**
**a.** Confocal image of a third-instar SS01989 x UAS-GFP larva CNS, derived from maximum intensity projections, obtained after immunohistochemical staining against *GFP*. C-Apochromat 40x objective, resolution: 975 x 651 pixels, scale bar: 100 µm. Image courtesy of the HHMI Janelia FlyLight team. **b.** Electron microscopy reconstruction of the contralaterally projecting serotonin-immunoreactive deutocerebral (CSD) neuron from the central nervous system of a first-instar larva (*Berck et al., 2016*), scale bar: 50 µm.
<figure><img src="image_29.png" /><figcaption>**Figure 4-Figure supplement 3. Paired and unpaired group data for olfactory conditioning experiments.** The data shown here underlies the performance indices depicted in Figure 4B. Gal4 expression depicted as color-coded central nervous system. Preference scores for paired (light/odour, dark/air) and unpaired (dark/odour, light/air) groups are shown in red and grey, respectively.</figcaption></figure>