Skip to main content
eLife logoLink to eLife
. 2026 Aug 17;14:RP104262. doi: 10.7554/eLife.104262

A behavioral architecture for realistic simulations of Drosophila larva locomotion and foraging

Panagiotis Parthenios Sakagiannis 1,†,✉, Anna-Maria Jürgensen 1,†, Martin Paul Nawrot 1,†,✉
Editors: Albert Cardona2, Albert Cardona3
PMCID: PMC13480992  PMID: 42605607

Abstract

The Drosophila larva is extensively used as a model organism in neuroethological studies where precise behavioral tracking enables the statistical analysis of individual and population-level behavioral metrics that can inform mathematical models of larval behavior. Here, we propose a hierarchical model architecture comprising three layers to facilitate modular model construction, closed-loop simulations, and direct comparisons between empirical and simulated data. At the motor layer, the autonomous locomotory model is capable of performing exploration. Based on novel kinematic analyses, our model features intermittent forward crawling that is phasically coupled to lateral bending. At the second layer, navigation is achieved via active sensing in a simulated environment, and top-down modulation of locomotion. At the top layer, behavioral adaptation entails associative learning. We evaluate virtual larval behavior across agent-based simulations of autonomous free exploration, chemotaxis, and odor preference testing. Our behavioral architecture is ideally suited for the modular combination of neuromechanical, neural, or mere statistical model components, facilitating their evaluation, comparison, extension, and integration into multifunctional control architectures.

Research organism: D. melanogaster

Introduction

Drosophila larvae express a fairly tractable behavioral repertoire that is consistent across the 4–5 days of the larval life stage (Almeida-Carvalho et al., 2017). Most of the larval lifetime is dedicated to foraging for suitable nutrients while avoiding threats via stereotyped evasive behaviors. Behavioral control is achieved via neural circuits conserved throughout development (Gerhard et al., 2017), that span the entire tripartite CNS consisting of the brain, the subesophageal zone (SEZ), and the ventral nerve cord (VNC), making the larva a formidable system for studying control, execution, and adaptation of behavior (Zarin et al., 2019; Jovanic, 2020; Eschbach and Zlatic, 2020; Imambocus et al., 2022). After reaching critical mass for pupation, homeostatic signals switch behavior toward food aversion, hypermobility, and collaborative burrowing (Wu et al., 2003), terminating the feeding state and leading to pupation and metamorphosis.

High-resolution methods for behavioral tracking (Ohyama et al., 2013; Risse et al., 2017; Schumann and Triphan, 2020; Tadres and Louis, 2020; Thane et al., 2023; Laurent et al., 2024), now routinely used in neuroethological experiments, have revealed detailed insight into the organization of larval foraging behavior. In the absence of food resources, larvae engage in free exploration to locate food patches (Sims et al., 2019) with a characteristic alternation of locomotory activity and brief pauses (Sakagiannis et al., 2020), a property also reported for adult-fly behavior (Ueno et al., 2012; Reynolds et al., 2015). Food consumption involves repetitive feeding motion and digging into the substrate (Kim et al., 2017). Statistical regularities that govern foraging behavior have been unveiled by analysis at the microscale of body kinematics and at the macroscale of larva trajectories (Denisov et al., 2013; Risse et al., 2017; Karagyozov et al., 2018). Locomotion combines the basic sensorimotor primitives of crawling and turning, and has been in the main focus of recent studies (Heckscher et al., 2012; Wystrach et al., 2016; Sims et al., 2019), whereas studies of feeding behavior remain scarce (Ruiz-Dubreuil et al., 1996). Both crawling and feeding consist of recurring sensorimotor cycles controlled by central pattern generating circuits (Heckscher et al., 2012; Mantziaris et al., 2020; Miroschnikow et al., 2018).

Salient olfactory cues can trigger appetitive or aversive chemotaxis, during which larvae navigate up or down a chemical gradient (Gomez-Marin et al., 2011; Slater et al., 2015; Schleyer et al., 2015a; Klein et al., 2017). During appetitive chemotaxis, the detection of minor concentration changes during lateral bending causes a directional bias in the turning movement, establishing a mechanism of active sensing (Gomez-Marin and Louis, 2012; Wystrach et al., 2016; Thane et al., 2019). Encounters with novel odorants in the presence of a food reward or a negative reinforcement such as the bitter taste substance quinine can induce olfactory learning, enabling short- and long-term behavioral adaptations (Schleyer et al., 2015b; Schleyer et al., 2011; Gerber and Stocker, 2007; Diegelmann et al., 2013; Widmann et al., 2018; Weiglein et al., 2019; Jürgensen et al., 2024). For quantification of choice behavior, widely used standard group assays for behavioral preference testing have been established (Gerber and Stocker, 2007; Gerber et al., 2014; Schleyer et al., 2015a; Schleyer et al., 2015b; Schleyer et al., 2011).

The routine availability of detailed behavioral data and the broad experimental repertoire in neuroethology make the Drosophila larva an ideal model system for computational studies of behavioral control. Existing generative models typically address isolated aspects of larval behavior and vary widely in type and abstraction level, ranging from basic neuromechanics to abstract mathematical formulations.

To unify such diverse approaches, we introduce the concept of a behavioral architecture: a three-layered, hierarchical, and modular framework that organizes models from low-level behavioral primitives to high-level functions (Figure 1A). At the motor layer, we implement a refined coupled-oscillator model of larval locomotion capable of autonomous exploratory behavior, supported by a detailed kinematic analysis of larval tracking data during free exploration. Sensory modulation introduced at the intermediate (reactive) layer enables the model to reproduce key experimental findings of appetitive chemotaxis.

Figure 1. Behavioral architecture for larva foraging.

Figure 1.

(A) In the three-layer hierarchical architecture, the bottom layer (motor) consists of three basic sensorimotor effectors that constitute the locomotory model. The intermediate layer (reactive) features innate reactive behavior in response to sensory input that reflects changes in the environment. The top layer (adaptive) allows for behavioral adaptation through experience. Framed areas denote more complex behaviors that require subsumption of subordinate behaviors. The signal from feeding to the above layers is neuromodulatory, as indicated by the purple arrowhead. (B) The intermittent coupled-oscillator locomotory model implemented at the motor layer. The turner and crawler module are phasically coupled during forward locomotion (head casts and weathervaning are not separate modules; both emerge from this crawl–bend interference), while crawling and feeding are implemented as mutually exclusive sensorimotor primitives. Initiation or cessation of crawling is controlled by the intermittency module. Darker shades mark modules used in the present simulations; faded modules indicate possible extensions.

Finally, by combining the locomotory and sensory layers with a biologically realistic spiking neural network model of the mushroom body (MB) at the adaptive layer, the architecture reproduces empirical population-level learning scores across multi-trial associative conditioning protocols. Together, these modules allow agent-based, potentially closed-loop simulations of virtual larvae in virtual environments and generate behavior-level data comparable to experiments, facilitating model calibration, validation, and extension.

Model

Behavioral architecture

Larval behavior is hierarchically structured: basic sensorimotor primitives such as crawling, bending, and feeding can be combined into more complex functions such as exploration, taxis, or exploitation. A longstanding idea in neuroethology is that this behavioral hierarchy reflects a corresponding hierarchy of nested sensorimotor loops in the nervous system (Prescott et al., 1999; Wilson and Prescott, 2022; Prescott and Wilson, 2023). Within this view, low-level reflexive or rhythmic behaviors are generated locally by peripheral motor circuits, while more central brain areas recruit, modulate, or coordinate these primitives when more global or context-dependent integration is required. The subsumption architecture (Brooks, 1986) provides a functional modeling paradigm for such hierarchies: lower layers generate autonomous, stereotyped activity, while multisynaptic loops involving more centralized neural circuits act as descending modulators on the local circuits in order to coordinate global and complex behavior. The central idea is that energy-efficient decentralized neural control is the rule, while higher centers are recruited only when more extensive integration is needed, for example in order to start, stop, accelerate, decelerate, or invert the activity of local loops (Sen et al., 2017; Feng et al., 2020; Bidaye et al., 2020). Importantly, the dimensionality of these descending pathways is much lower than the internal complexity of each layer. Layered control architectures have been widely used in behavior-based robotics (Bicho, 1999; Prescott et al., 1999) and offer a natural conceptual scaffold for integrating mechanistic, kinematic, and abstract models of behavior. Here, we adopt this paradigm as a simplifying organizing principle aligned with, rather than claiming to perfectly represent, the complete larval neuroanatomy.

We propose a three-layered behavioral architecture for Drosophila larval foraging (Figure 1A). The bottom, motor layer comprises the fundamental behaviors of crawling, turning, and feeding (Figure 1B). Each is implemented as a local sensorimotor loop between motor effectors and sensory feedback. Combinations of these primitives yield composite behaviors: for example, free exploration arises from integrating crawling and turning, and variation in their microstructure produces a continuum from local search to long-range dispersal. Consistent with this view, the VNC alone can sustain exploratory locomotion without descending input (Sims et al., 2019).

The intermediate layer integrates salient sensory cues across modalities and provides a unified descending modulation to the motor layer. This follows the subsumption principle of premotor convergence, where multisensory information is integrated into a common modulatory drive that shapes locomotion (Wystrach et al., 2016; Eschbach and Zlatic, 2020). Modulation of the motor layer by this single pathway enables reactive navigation along sensory gradients. In this study, we focus on odor-driven chemotaxis, interpreted as an active sensing process in which larvae sample concentration changes during lateral bending to discover and ascend odor gradients. The same architectural principle generalizes to other modalities; for example, we have previously applied it to simulate active sensory sampling in thermotaxis across different Drosophila species (Kafle et al., 2025).

The top, adaptive layer implements associative learning, allowing larvae to modify innate stimulus valence and bias approach or avoidance decisions based on experience. The MB is well established as the substrate for such learned valence in both larval and adult Drosophila (Gerber and Stocker, 2007; Gerber et al., 2014; Schleyer et al., 2015a; Schleyer et al., 2015b; Schleyer et al., 2011; Owald and Waddell, 2015). In line with these findings, the descending signal from the adaptive layer in our architecture is intentionally restricted to modulating approach versus avoidance tendencies, without altering lower-level motor primitives directly.

The behavioral architecture itself is agnostic to the level of abstraction or mechanistic detail within each module. Its purpose is to provide a modular framework in which diverse models—mechanistic, mathematical, or hybrid—can be positioned, interchanged, compared, or incrementally refined. To ensure compatibility despite differing internal complexities or timescales, every module exposes a clearly defined set of inputs and outputs. This design supports agent-based simulations of virtual larvae in virtual environments and allows seamless integration of mechanistic components as new empirical findings become available. To facilitate modeling within this framework, we provide the larvaworld Python package (https://pypi.org/project/larvaworld/), which implements the architecture, offers multiple instantiations of its modules, and enables direct comparison between simulated and experimental behavior.

Locomotory model

We model larval locomotion in the two-dimensional plane by specifying forward velocity v and angular velocity ω as generated by crawling and bending, respectively. Building on previous oscillator-based approaches, our kinematic analysis motivates two key extensions: (1) intermittent crawling composed of runs and pauses, and (2) stride-phase-dependent attenuation of angular motion. Together these yield an intermittent coupled-oscillator locomotory model (Figure 1B); its mathematical formulation is provided in the Materials and methods, and the calibration pipeline in Appendix 2.

To balance biological interpretability and computational tractability, we represent the body as two connected segments. The body state is therefore fully described by three variables: the midpoint position (Appendix 1—figure 1), the front-segment orientation θ, and the bending angle θb between segments. This abstraction follows common practice in larval kinematics (Gomez-Marin et al., 2011; Lahiri et al., 2011; Paisios et al., 2017) and avoids the complexity of a full neuromechanical model (see ‘Limitations of the study’). Crawling advances the midpoint along θ, whereas bending rotates the front segment; forward motion gradually restores θb toward zero by realigning the rear segment.

The locomotory model consists of two interacting oscillators. The crawler oscillator generates stride cycles that produce forward velocity v, with a tonic input IC setting the crawling frequency fC. The turner oscillator, based on Wystrach et al., 2016, generates alternating left–right bending with amplitude AT. To capture the empirically observed crawl–bend interference, the bending amplitude is modulated by a Gaussian-shaped function of crawler phase, fitted to the data (red profile in Figure 3D). In our implementation, weathervaning (continuous curvature changes during stridechains) and head casting (large reorientations during crawl-pauses) are not encoded as distinct modules. Instead, both arise from the same coupled-oscillator system, reducing model degrees of freedom while preserving the two canonical reorientation modes.

Intermittency is incorporated by alternating between crawling epochs (stridechains) and pauses, with stridechain length and pause duration sampled from empirical log-normal distributions (Figure 3B). This stochastic state switching enables the model to reproduce the temporal organization of run–pause behavior observed in real larvae.

Within the subsumption-style architecture, higher layers can modulate the oscillators through only a few channels. For the crawler, top-down input may adjust the tonic drive IC—thereby altering frequency—or initiate or terminate stride cycles. For the turner, top-down modulation of its tonic input affects both oscillation amplitude and frequency.

Results

Kinematic analysis of larval locomotion

To extract the core structure of larval locomotion, we analyzed experimental trajectories and body postures at both the single-animal (Figure 2) and population levels (Figure 3). These analyses reveal (1) the stride-based oscillation of forward velocity and the slower rhythm of lateral bending, (2) a robust phase relationship between crawling and turning, and (3) the intermittent organization of locomotion into stridechains and crawl-pauses.

Figure 2. Kinematic analysis of a single Drosophila larva in locomotion.

Figure 2.

(A) Individual larva trajectory tracking a posterior point along the midline of the animal. Trajectory color denotes the forward velocity v from 0 (red) to maximum (green). Inset focuses on a shorter track epoch analyzed in C and G. The full-length trajectory and the epoch in the inset are shown in Videos 1 and 2, respectively. Dark green rectangle denotes the single stride described in B. (B) Sketch of the single crawling stride indicated in A. The larva first stretches its head forward, anchors it to the substrate, and then drags its body forward via peristaltic contraction. Scaled stride displacement dS˚ is defined as the resulting displacement d divided by the body-length l. (C) Scaled forward velocity v during the 40-s track epoch selected in A (inset). Green and red markers denote the local maxima and minima used for stride annotation. Individual strides are tiled by vertical dashed lines. Successive strides constitute uninterrupted stridechains (white). Epochs that do not show any strides are annotated as crawl-pauses (gray). (D) Scaled forward velocity v of head, midpoint, and tail as a function of the stride cycle phase Φ. All detected strides have been interpolated to a stride oscillation cycle of period 2π. Solid lines denote the median, shaded areas the lower and upper quartiles across strides. (E) Same trajectory as in (A) now tracking the head segment. Color denotes the absolute orientation angular velocity ω from 0 (red) to maximum (green). The full-length trajectory and the epoch in the inset are shown in Videos 1 and 2, respectively. (F) Definition of bending angle θb and orientation angle θ for the original 12-segment (blue) and the simplified 2-segment (red) larvae. (G) Three angular parameters during the same track epoch shown in (C). Bending angle θb, bend and orientation angular velocities ωb, ω are shown. Background shadings denote left and right turning bouts. For illustration purposes only turns resulting in a change of orientation angle Δθ > 20° are shown. (H) Absolute orientation angular velocity ω during the stride cycle, as shown for v in (D).

Figure 3. Population-level analysis.

Figure 3.

(A) Fourier analysis of the forward v (red) and angular ω (blue) velocity across 100 larvae. Inset shows the respective dominant frequencies within suitable ranges 1⩽fC⩽2.5 and 0.1⩽fT⩽0.8 for v and ω, respectively. Crawling exhibits a dominant frequency of around 1.4, while lateral bending has a slower, more variable rhythm of around 0.4. (B) Epoch-duration distribution. Dots describe the cumulative probability density over logarithmic bins for the length of stridechains and the duration of crawl-pauses pooled across the larva population. Lines indicate the distribution with the lowest Kolmogorov–Smirnov distance among the best-fitting power-law, exponential, log-normal, and Lévy distributions. Stridechain length and pause duration are best approximated by log-normal distributions. (C, D) Crawl–bend interference. The stride cycle kinematics are depicted for a single individual. All detected strides have been interpolated into a 64-bin oscillation cycle of period 2π. (C) Forward velocity of five points along the larva midline. Velocity is scaled to the larva body-length. (D) Absolute angular velocity ω (blue) normalized by the average value ω¯P computed during the pause epochs. Fitted Gaussian function (red) describes well the phase-dependent attenuation imposed on ω and is used for the implementation of the coupled-oscillator locomotory model. Solid lines denote the median, shaded areas the lower and upper quartiles. Vertical dashed lines denote the cycle phase where the respective velocity reaches its maximum value. Inset: Phase offset Δϕ between the peak phase of each midline point’s forward velocity ϕCvi and the peak phase of angular velocity ϕCω across a dataset of 100 tracked larvae. Notably, ω reaches its maximum just before the head forward velocity reaches its maximum.

Single-larva kinematics

We first quantified translational and angular kinematics along individual trajectories. Tracking the forward velocity v of a posterior midline point (Figure 2A) shows that locomotion consists of consecutive peristaltic strides: v alternates between elevated (green) and reduced (red) values as the larva advances. A single stride is sketched in Figure 2B, illustrating the extend–anchor–contract sequence whose amplitude is quantified by the scaled stride displacement d˚S=d/l. A 40-s epoch from the same trajectory (Figure 2C) shows stride maxima and minima (green and red) and how individual strides tile into stridechains (white) separated by crawl-pauses (gray). Videos of the full and inset trajectories are provided in Videos 1 and 2.

Video 1. Full-length larva trajectory.
Download video file (878.1KB, mp4)

The full-length trajectory shown in Figure 2A, E; colored according to angular and forward velocity.

Video 2. Short larva trajectory epoch.
Download video file (1MB, mp4)

The short track epoch depicted in the insets of Figure 2A, E; colored according to forward and angular velocity.

To compare stride kinematics across occurrences, all detected strides were aligned to a normalized oscillation cycle of period 2π. The resulting forward-velocity profiles for head, midpoint, and tail segments (Figure 2D) reveal a stereotyped waveform consistent with a propagating peristaltic contraction.

Angular kinematics exhibit similar structure. Tracking the head’s angular velocity ω (Figure 2E) shows gradual reorientations during stridechains (weathervaning) and larger turns during crawl-pauses (head casts). The bending geometry of the original 12-segment and simplified 2-segment representations is illustrated in Figure 2F. During the same 40-s epoch, the bending angle θb and angular velocities ωb and ω follow consistent temporal patterns (Figure 2G). Projecting ω onto the stride cycle (Figure 2H) reveals a smooth unimodal dependence peaking early in the cycle, indicating that turning amplitude varies systematically over the stride.

Population-level rhythmicity, phase dependence, and intermittency

Across 100 larvae, Fourier analysis of forward and angular velocities (Figure 3A) reveals two dominant rhythms: a peristaltic crawling frequency around fC≈1.4 Hz and a slower bending rhythm around fT≈0.4 Hz, consistent with prior work (Heckscher et al., 2012; Mantziaris et al., 2020; Thane et al., 2023; Wystrach et al., 2016). These rhythms structure how larvae advance and reorient across time.

Larval crawling is intermittent, consisting of variable-length stridechains alternating with short crawl-pauses. Pooling stridechain lengths and pause durations across the dataset (Figure 3B) shows that both are best described by log-normal distributions among the candidate power-law, exponential, log-normal, and Lévy fits.

To quantify the phase relationship between crawling and bending, strides from all larvae were interpolated into a common 64-bin phase cycle. The progression of forward velocity from head to tail during the peristaltic cycle is illustrated in Figure 3C. The angular velocity normalized by the mean pause-epoch value, ω/ω¯P, exhibits a clear stride-phase-dependent modulation (Figure 3D): bending is suppressed for most of the stride but briefly relieved early in the cycle. A Gaussian function (red) captures this unimodal attenuation profile and forms the basis for the phase-coupling mechanism incorporated in our locomotory model. The inset quantifies the phase offset Δϕ between the stride-phase peaks of forward and angular velocity across animals. Notably, the angular velocity peaks just before the head forward velocity reaches its maximum, suggesting a simple mechanistic explanation (see Discussion).

Together, the single-animal and population-level analyses reveal that larval locomotion is governed by a fast stride rhythm, a slower bending rhythm, a systematic phase relationship between them, and a stochastic alternation of runs and pauses. These empirical constraints directly motivate the intermittent coupled-oscillator model introduced below.

Simulation of behavioral experiments

In this section, we simulate increasingly complex behavioral experiments. We start with free exploration in the absence of navigation-guiding gradients, which does not imply absence of all sensory input but rather mirrors standard free-exploration lab assays. Then we advance to chemotactic navigation and finally to adaptive odor preference experiments. We simulate individual larvae using the model as calibrated in Appendix 2, and all model parameters are shown in Appendix 2—figure 1A. Larval populations are constructed by pooling individual virtual larvae that behave independently as they move through the spatial arena and odorscape (Niewalda et al., 2014). In the present simulations, interlarval interactions are not modeled, but rather each agent moves independently, consistent with the calibration datasets.

Exploration

In the first virtual experiment, we consider free exploration (Figure 4) and evaluate our simulation results against an empirical dataset (see Materials and methods). To this end, we simulate a population of 200 virtual larvae during 3 min while freely exploring a non-nutritious substrate in a Petri dish, mimicking the experimental lab conditions (Figure 4). Because larvae typically reach the arena boundary within this time window, this experimental configuration only captures short-horizon exploratory dynamics. Consequently, the proposed intermittent coupled-oscillator locomotory model at the motor layer is sufficient to autonomously generate realistic exploration on these timescales, whereas assessment of long-horizon dispersal statistics reported in extended recordings (Sims et al., 2019) will require future simulations in larger or unbounded arenas.

Figure 4. Free exploration in simulation and experiment.

Figure 4.

(A) Dispersal of 200 larvae in experiment (left) and simulation (right) during 40 s. Individual tracks have been transposed to originate from the center of the arena. The entire temporal course is shown in Video 4. (B) Dispersal from origin (Euclidean distance during the initial 40 s; larvae approach arena edges thereafter). Line indicates the group median while the shaded area denotes first and third quartiles. (C) Histograms for total number of strides, time ratio allocated to crawling, and pathlength (cumulative distance). (arena dimensions = 500 × 500 mm, N = 200 larvae, experiment duration = 3 min, simulation timestep = 1/16).

Larvae are initially placed at the center of the dish, each with a random body orientation. Over the course of the experiment, both the simulated and the real larval population freely explores a Petri dish (Video 3) and disperses in space (Figure 4A, Video 4).

Video 3. Free-exploration simulation.
Download video file (8.7MB, mp4)

A population of 25 real (left) or virtual (right) larvae is placed on a dish and left to freely explore. The body of the real larvae has been simplified into two segments as described in Video Bisegmental body.

Video 4. Dispersal simulation.
Download video file (2.1MB, mp4)

The temporal course of dispersal for real (left) and virtual (right) larvae is shown in Figure 4A.

Among others, we report two complementary spatial metrics: radial dispersal (Euclidean distance from the origin at the end of the trajectory) and pathlength (cumulative distance traveled). Dispersal is shown during the initial 40 s because larvae typically reach the arena edge afterwards. The quantitative comparison shows good agreement between the simulated and empirical data with respect to the radial dispersal from the initial position (Figure 4B). Dispersal serves as an individual-level displacement metric from which population-level measures such as the mean-squared displacement (MSD) can be directly derived. Importantly, variability between individual animals is well captured by the variability between individual model instances, as shown for the number of strides, crawling time, and pathlength (Figure 4C).

Chemotaxis

Chemotaxis describes the process of exploiting an odor gradient in space to locate an attractive or avoid a repelling odor source. An olfactory sensor (olfactor) placed at the front end of the virtual body enables active sensing during body bending and allows detection of concentration changes that modulate turning behavior by acting on the lateral oscillator (turner). Specifically, instantaneous odor sampling during lateral bending modulates its frequency and amplitude, while the peristaltic oscillator (crawler) remains unaffected, as proposed in Wystrach et al., 2016.

To assess the chemotactic efficiency of our coupled-oscillator model, we reconstruct the arena and odor landscape (odorscape) of two behavioral experiments described in Gomez-Marin et al., 2011. In the first, larvae are placed on the left side of the arena facing to the right. An appetitive odor source is placed on the right side. The virtual larvae navigate up the odor gradient approaching the source (Figure 5A, C, E), reproducing the experimental observation in Figure 1C in Gomez-Marin et al., 2011. In the second, both the odor source and the virtual larvae are placed at the center of the arena. The larvae perform localized exploration, generating trajectories across and around the odor source. (Figure 5B, D, F), again replicating the observation in Figure 1D in Gomez-Marin et al., 2011. Two sample simulations can be seen in Video 5. These chemotaxis simulations are intended as proof-of-concept demonstrations rather than quantitative fits; see ‘Limitations of the study’ for a discussion. Note that all parameters of the motor layer (crawling, lateral bending, crawl–bend interference, and crawl-pause intermittency) were fitted on exploration data only and then kept fixed for chemotaxis and odor preference simulations.

Figure 5. Simulation of chemotaxis.

Figure 5.

(A) Experiment 1: A single odor source of µM peak concentration is placed on the right side of the rectangular arena creating a chemical gradient as indicated by the color scale. Larvae are placed on the left side facing to the right. Larvae are expected to navigate up the gradient approaching the source. A single-larva trajectory is shown. This setup mimics the first experiment in Gomez-Marin et al., 2011. (B) Experiment 2: A single odor source of µM peak concentration is placed at the center of the rectangular arena. Larvae are placed in close proximity to the odor source. Larvae are expected to locally explore generating trajectories around and across the source. A single-larva trajectory is shown. This setup mimics the second experiment in Gomez-Marin et al., 2011. (C, D) The trajectories of 25 virtual larvae during the two experiments. (E, F) The odor concentration encountered by the virtual larvae as a function of time, measured in µM. Red curves refer to the single larva in A and B. Gray denotes the mean and quartiles of all 25 larvae in C and D. The simulation results fit well to the experimental estimates of concentration sensing during larval chemotaxis in Gomez-Marin et al., 2011 (arena dimensions = 100 × 60 mm, N = 30 larvae, experiment duration = 3 and 5 min, respectively, simulation timestep = 1/16). Because the present chemotaxis implementation is a qualitative reproduction of the behavioral patterns reported by Gomez-Marin et al., 2011 and not a quantitatively calibrated model, we do not report success rates, approach distances, or track-length statistics; these metrics depend strongly on the specific odorscape geometry and experimental constraints and therefore lie outside the scope of the proof-of-concept simulations presented here. Parameterization of the motor layer was kept identical to exploration simulations.

Video 5. Chemotaxis simulations.
Download video file (3.3MB, mp4)

Time course of the two simulated chemotaxis experiments described in Figure 5.

Odor preference test

We simulated the standard odor preference assay described in the Maggot Learning Manual (Michels et al., 2017). Larvae were initialized at the center of a circular arena containing two odor sources placed on opposite sides. Each odor source was modeled as a Gaussian concentration field, producing partially overlapping attractive or aversive gradients. After 3 min of exploration, larval positions were used to compute the population-level Preference Index (PI) of the left odor,

PIl=Nl−NrN,

where Nl and Nr are the numbers of larvae on the left and right halves of the dish, respectively.

Because the turning modulation depends on an odor-specific gain G, expressed in arbitrary units, we first determined a suitable behavioral operating range. We performed a parameter sweep over 252 combinations of left- and right-odor gains in G∈[−100,100] using 30 simulated larvae per condition. The resulting PIs form the landscape shown in Figure 6A. Example simulations for appetitive and aversive odors are shown in Video 6.

Figure 6. Simulation of innate and learned odor preference.

Figure 6.

(A) A total of 252 simulations are shown with the resulting Preference Index for different gains of the left and right odor. On the top left, the initial state is shown with the larvae randomly generated at the center of the dish. The final state of three additional simulations is depicted on the top right and bottom left and right. See Video 6 for videos of two sample simulations. (B) The pipeline used for coupling the mushroom body (MB) model with the behavioral simulation. First, an MB model is trained via a classical conditioning experiment where olfactory input is combined with reward. The resulting odor valence MBout is then converted to odor gain G via a simple linear transformation and used to generate a virtual larva. Finally, the odor preference of a virtual larva population is evaluated in a behavioral simulation. (C) The spiking neural network comprising the MB model. The number of neurons comprising each layer is indicated. (D) The resulting PIs for 100 simulations per number of training trials. In each of the 100 simulations per condition a population of 30 virtual larvae was generated and evaluated using a different random seed, always bearing the exact same 30 odor gains derived from the respective group of 30 trained MB models (arena dimensions = 100 × 100 mm, N = 30 larvae, experiment duration = 3 min, simulation timestep = 0.1).

Video 6. Odor preference simulations.
Download video file (1.8MB, mp4)

Two odor preference simulations, one with an appetitive and one with an aversive odor source placed on the left side of the dish. A non-valenced odor source is placed on the right side.

To simulate learned odor preference, we coupled the behavioral simulations to the spiking MB model of Jürgensen et al., 2024 (see Methods). In brief, the MB model was trained using the classical conditioning protocol of Michels et al., 2017, where an odor (CS+) was paired with sugar reward for 5 min. Five groups of 30 MB models underwent one to five conditioning trials (Weiglein et al., 2019). Each trained MB model returned an odor-valence signal MBout, which we converted to an odor gain G via a linear transformation (pipeline shown in Figure 6B). This produced 30 odor gains per training condition, each used to generate one virtual larva.

Each virtual population of 30 larvae was then tested in an odor preference assay with the previously rewarded odor (CS+) on one side and a neutral odor on the other (Video 6). To obtain robust population-level statistics, we repeated each condition 100 times with different random seeds, yielding 600 simulations in total. The resulting PIs (Figure 6D) increase with the number of conditioning trials and saturate after several pairings, in agreement with empirical observations (Weiglein et al., 2019).

Although group assays provide only population-level PIs and not individual trajectories, each simulated PI in Figure 6D arises from explicit larval movement dynamics. Thus, while no experimental single-larva trajectories are available for direct comparison, model-generated trajectories can be inspected on demand. The variability observed across the 100 repeats per condition originates solely from the behavioral simulation and resembles the variability seen across repeated real experiments.

The present implementation sequentially couples a trained MB model to the behavioral simulation. In the Discussion, we outline how a future closed-loop integration could enable full simulation of both conditioning and testing phases within a unified virtual environment.

Discussion

Experimental evidence for layered behavioral architecture

The behavioral architecture rests on two principles: (1) horizontal decomposition into functional modules that each generate a well-defined behavior, and (2) vertical layering into semi-independent control levels, where higher layers modulate—rather than replace—the autonomous activity of lower ones. Here, we summarize the neuroanatomical and behavioral findings that support this modular and hierarchical organization.

The basic larval behaviors captured at the motor layer (Figure 1A) have well-characterized neural substrates. Crawling consists of stereotyped repetitive strides, combining head–tail contractions driven by a ‘visceral piston’ mechanism with a bilaterally symmetric peristaltic wave propagating from posterior to anterior segments (Heckscher et al., 2012; Figure 2B). This motion is produced by segmental central pattern generators (CPGs) interconnected through short- and long-range premotor and interneuronal motifs (Kohsaka et al., 2019; Zarin et al., 2019; Mantziaris et al., 2020). Lateral bending arises from asymmetric activation of body-wall musculature initiated at thoracic segments (Berni, 2015). Feeding behavior is generated by mono- and multisynaptic sensorimotor loops linking enteric, pharyngeal, and external sensory organs to motor neurons controlling mouth-hook movement, head tilt, and pharyngeal pumping (Miroschnikow et al., 2018; Schoofs et al., 2024). These circuits can operate without descending input: larvae continue to explore even after brain ablation (Sims et al., 2019). Because exploitation of food integrates locomotion with continuous ingestion and repositioning, we postulate that consummatory circuits in the SEZ can sustain autonomous exploitation.

Higher brain centers modulate these basic behaviors through diverse neuromodulatory pathways. Dopamine, serotonin, acetylcholine, and octopamine play key roles at multiple levels of sensorimotor integration (Berni et al., 2012; Zhang et al., 2013; Miroschnikow et al., 2018; Malloy et al., 2019; Eschbach et al., 2020; Vogt et al., 2021). Exploration–exploitation transitions can be acutely induced by dopaminergic signaling (Schleyer et al., 2020), while long-term balancing between the two states is mediated by hugin-dependent homeostatic neuromodulation (Schoofs et al., 2014). Anatomical mapping of sensory pathways to motor neuropils further highlights the contribution of interoceptive signals to behavioral regulation (Qian et al., 2018).

Olfactory modulation of locomotion also conforms to this layered view. Innate approach or avoidance to odors relies on a largely hard-wired pathway involving the antennal lobe (AL) and its projection to the lateral horn (LH), in both larvae (Schulze et al., 2015; Vogt et al., 2021) and adults (de Belle and Heisenberg, 1994; Strutz et al., 2014; Dolan et al., 2018). Learned odor valence, by contrast, strongly depends on descending control from the MB in larvae (Saumweber et al., 2018; Eschbach et al., 2020) and adults (Slater et al., 2015). These innate and learned pathways converge onto premotor networks downstream of the AL (Schleyer et al., 2015a; Eschbach et al., 2020), where they shape locomotory decisions. For example, LH-dependent descending input can transiently suppress crawling to trigger larger reorientation events when navigating down-gradient, aiding chemotaxis (Tastekin et al., 2018). Finally, the internal homeostatic state (e.g. starvation vs. satiation) modulates behavior via transmitter release and neuropeptide signaling at multiple processing stages—including AL, LH, and MB—linking metabolic needs to sensorimotor control (Vogt et al., 2021; de Tredern et al., 2025).

Previous computational models of larva locomotion

Larva locomotion has been modeled extensively. Generative models of peristaltic crawling feature neural and/or neuromuscular dynamics. Sequential neural activity patterns across the segmental body can be generated by longitudinally repeated CPGs of paired excitatory and inhibitory population rate units, possibly involving proprioceptive feedback (Gjorgjieva et al., 2013; Pehlevan et al., 2016). This relatively abstract CPG model has been elaborated into a connectome-based circuitry of premotor and motor neurons. Under tonic activation, the model exhibits two functionally distinct, though structurally overlapping, recurring patterns of neuromuscular activity, responsible for forward and backward peristalsis, respectively (Zarin et al., 2019). At the other end of the modeling spectrum, the contribution of the visceral-piston mechanism to the peristaltic cycle has been assessed in a biomechanical model (Ross et al., 2015). A more elaborate neuromechanical model, based on segmental localized reflexes and substrate frictional forces and assuming empirically informed axial and transverse oscillatory frequencies, has been shown to generate forward and backward crawling without the need for any neural activation pattern (Loveless et al., 2019).

Lateral bending has also been captured in statistical (Davies et al., 2015) or generative models (Wystrach et al., 2016; Loveless et al., 2019; Loveless and Webb, 2018). In the context of free exploration, it has been shown to be a byproduct of chaotic body neuromechanics underlying peristalsis (Loveless et al., 2019). In the context of chemotaxis, it has been attributed to a distinct oscillatory process, autonomous (Wystrach et al., 2016) or semi-autonomous to crawling (Davies et al., 2015). In the former case, oscillation is driven by mutual inhibition between excitatory–inhibitory circuits. In the latter, bending behavior is dissected into low-amplitude weathervaning while crawling and high-amplitude headcasting during crawl-pauses, an approach essentially equivalent to an attenuation of the lateral oscillation amplitude due to crawling. Autonomous exploration and chemotaxis can be generated by an integration of the neuromechanical and the independent lateral oscillator models (Loveless and Webb, 2018).

Apart from the rare occasion where such models implement mutually exclusive mechanistic hypotheses and are indubitably incompatible with each other, in most cases they are indeed complementary, overlapping, nested, or disconnected in terms of the generative mechanisms they aim to capture and could potentially coexist under a broader control system. In this context, our unifying architecture for larval behavior in which any partial model can be positioned can be valuable for modelers and roboticists interested in a behavior-based synthetic approach.

Our design deliberately trades segmental neuromechanical detail for computational efficiency and modularity in the motor layer. The framework is explicitly designed so that more detailed neuromechanical or connectome-derived modules can replace the current ones without altering inter-layer contracts.

Intermittent coupled-oscillator model for realistic locomotion

Each of the above models could be adjusted so that at minimum it generates the 2D translational and angular motion of a virtual body and could therefore populate the motor layer of the behavioral architecture. In this study, we propose such a model, assembled in a synthetic approach by distinct modules, which either extend previously proposed locomotory models or integrate novel findings derived from our analysis of kinematic parameters. Given a simplified bisegmental body, a simple oscillator under frequency-regulating tonic activation is adequate for generating recurrent strides, efficiently summarizing the complex underlying neural and neuromechanical dynamics (Heckscher et al., 2012; Mantziaris et al., 2020). Concerning angular motion, the previously introduced lateral oscillator model (Wystrach et al., 2016) meets the requirements and can therefore be coupled to the forward oscillator.

Our proposed model contributes two novel features. First, the intermittent nature of crawling as transitions between runs and pauses (Figure 3B). And, second, the peristaltic cycle-phase-dependent attenuation of angular motion (Figure 3D). By combining these two features, the two bending behavioral modes termed weathervaning and head casting are naturally generated via a phasic coupling between the two oscillators.

Behavioral intermittency

Larval locomotion is intermittent, meaning that crawling runs are transiently intermitted by brief pauses. Transitions between these two behavioral states occur autonomously during free exploration. Traditionally, in the context of movement ecology, intermittency has been studied in the spatial regime by characterizing the distributions of run distances and turn amplitudes occurring during brief stationary reorientation events (pauses). Power-law distributed runs in line with Lévy-walk theoretical models (Günther et al., 2016; Sims et al., 2019) and diffusion-like kinematics have been reported (Klein et al., 2017). On the other hand, the turn amplitude distribution diverges from the original Lévy-walk-predicted uniform distribution, as it is highly skewed toward small amplitudes, even if only significant reorientation events are taken into account (Sims et al., 2019). Moreover, the speed–curvature power-law relationship has been disputed (Zago et al., 2016; Marken and Shaffer, 2017; Zago et al., 2018; Marken and Shaffer, 2018). Regarding the temporal dynamics of intermittency, the duration distribution of these pauses is commonly neglected in traditional Lévy-walk literature as they are usually characterized via the amplitude distribution of their resulting turning events. A recent analysis of larval tracks reported that the duration of pauses follows a power-law while that of activity bouts a log-normal distribution (Sakagiannis et al., 2020), partly in line with findings in adult-fly studies (Ueno et al., 2012; Reynolds et al., 2015). In our current study, we found log-normal best fits for both pause duration and stridechain length. The disagreement over the pause duration might be attributed to the different timescale assessed in the two studies. Contrary to the high-resolution 180-s tracks in this study, those analyzed previously lasted at minimum 1024 s and up to 1 hr, allowing for the detection of longer pauses and imposing the necessity to fit over four orders of magnitude bypassing the apparent drop around 10 s, also seen in Figure 3 of Sakagiannis et al., 2020.

Concerning computational modeling, the contribution of behavioral intermittency to locomotion has not been adequately appreciated. Candidate generative models can either simply sample statistical distributions (Sims et al., 2019) or feature a generative mechanism that yields state transitions. Stochastic state-transitions have been included in a model of larva exploration yielding exponentially distributed epochs of both runs and stationary head casts (Davies et al., 2015). At a mechanistic level, a recent study presented a simple binary-neuron model exhibiting state transitions between power-law and non-power-law regimes via self-limiting neuronal avalanches and proposed a plausible underlying mechanism that explains initiation/cessation of crawling (Sakagiannis et al., 2020). All these attempts can be considered instantiations of a behavioral intermittency module (Figure 1B) controlling cessation and re-initiation of crawling, central for generating epoch transitions. In the present study, we chose stochastic sampling from the empirically fitted parametric distribution models.

Crawl–bend interference

Crawling includes mouth hook motion. Specifically, the first phase of a crawling stride consists of concurrent forward motion of head and tail segments, aided by a ‘visceral pistoning’ mechanism that generates forward displacement of the gut. Subsequently, the mouth hooks anchor the head to the substrate so that the second phase of peristaltic motion can drag all other segments forward as well, completing the stride (Heckscher et al., 2012). With respect to turning, it is still debated whether individual turns should be considered as discrete reorientation events that are temporally non-overlapping with crawling bouts (Sims et al., 2019), or whether lateral bending occurs in an oscillatory fashion generating turns both during crawling (weathervaning) and during pauses (headcasts) (Wystrach et al., 2016; Thane et al., 2019). The latter is supported by detailed eigenshape analysis confirming that larvae rarely crawl straight; rather, forward locomotion is always accompanied by continuous small amplitude lateral bending (Szigeti et al., 2015). It follows that crawling does not exclude bending; rather, the two strictly co-occur.

Crawling and bending partially recruit the same effector neural circuitry and body musculature at least at the level of the thorax. Peristaltic motion during crawling includes sequential symmetric bilateral contraction of all segments, while bending occurs due to asymmetric unilateral contraction of the thoracic segments. This partial effector overlap could result in interference between the two processes. Indeed, here we report a phase-dependent attenuation of angular velocity (Figure 3C). Attenuation reaches a minimum at a specific phase of the cycle, closely preceding the increase of head forward velocity (Figure 3C, inset). This coincides with the stride phase when the head stops being anchored to the substrate and is therefore free to move laterally. When applying a phase-dependent Gaussian attenuation kernel on angular velocity, we managed to accurately reproduce the empirical relation (Appendix 2—figure 1C).

A reasonable hypothesis would then be that the asymmetric thoracic contraction generating lateral bending becomes easier when the head is not anchored to the substrate; therefore, during a specific phase interval of the stride cycle. We propose that crawling phasically interferes with lateral bending because of these bodily constraints. A consequence of this hypothesis is that the amplitude of turns generated during crawl-pauses (headcasts) is larger in comparison to those generated during crawling (weathervaning) because during pauses the crawling interference to lateral bending is lifted. It is this phenomenon that dominates the description of larva exploration as a Lévy walk with non-overlapping straight runs and reorientation events, where weathervaning is neglected (Günther et al., 2016; Sims et al., 2019). Nevertheless, it has been included in a previous stochastic model of larva exploration, where it has been treated as entirely distinct from headcasts, occurring during crawl-pauses, via the application of differential constraints on both the angular velocity and the resulting turn amplitude (Davies et al., 2015). By implementing a coupled-oscillator locomotory model, we avoid such dual treatment of headcasts and weathervaning.

Olfactory learning in closed-loop behavioral simulations

We have integrated a previously developed biologically realistic spiking MB model to demonstrate modularity: models with very different abstraction levels can be combined under the same architecture. This is not a bias toward modeling depth of the MB per se, but a stress-test of architectural flexibility. We have reproduced the results of a basic associative learning experiment in the fruit fly larva (Schleyer et al., 2018; Jürgensen et al., 2024) by the open-loop simulation of classical conditioning trials and subsequent closed-loop behavioral simulation during the memory retention test for individual virtual larvae (Figure 6B–D). This modeling approach can be extended in multiple ways. First, the larva demonstrates a number of additional learning capabilities such as differential conditioning (Schleyer et al., 2011; Schleyer et al., 2018), extinction learning (Felsenberg and Waddell, 2019; Lesar et al., 2021), and relief learning (Saumweber et al., 2018; Weiglein et al., 2019; Gerber et al., 2014; König et al., 2018). Interfacing neural network simulations with candidate circuit and synaptic mechanisms of plasticity with our behavioral model allows us to directly compare virtual and empirical behavioral experiments, both at the level of individual and group assays. Second, while information about odor concentration is provided through active sensing, simultaneous input from a feeder module could activate the dopaminergic reward pathway required for synaptic plasticity in the MB. At the same time, simulation of food uptake and energy expenditure will regulate the agent’s energy homeostasis. This would further allow realistic foraging scenarios with food depletion and competition among animals.

Closing the loop from active sensing to associative memory formation and behavioral control requires synchronizing a (spiking) neural network at the adaptive layer with the sensory module (reactive layer), and the locomotory and feeding modules at the motor layer (Figure 1A). This will enable the simulation of virtual larvae experiencing spatial and temporal dynamics in a virtual environment or on a robotic platform (Helgadottir et al., 2013), and it will allow us to test model hypotheses on sensory-motor integration and to infer predictions for experimental interventions such as optogenetic stimulation (Saumweber et al., 2018) or genetic manipulation (Saumweber et al., 2011; Michels et al., 2011; Widmann et al., 2016; Springer and Nawrot, 2021).

Limitations of the study

Several limitations mentioned throughout the study are summarized here: (1) The crawl–bend interference is statistically implemented, based on the kinematic analysis, without a complete segmental neuromechanical derivation. (2) The intermittency module uses sampling from data-fitted stridechain and pause distributions, without an explicit neural switch model. (3) Chemotaxis simulations are proof-of-concept and qualitatively fitted, not quantitatively calibrated to any published datasets. (4) The intermittent coupled-oscillator model presented here does not attempt to cover the full larval repertoire, such as hunching, digging, backward crawling, or rolling, nor does it explicitly implement handedness as a directional bias. (5) Larva–larva interactions are not modeled here; nonetheless, the larvaworld software supports tactile sensors for future interaction studies.

Our framework emphasizes modularity and computational tractability, which necessarily imposes several limitations. First, the locomotory model operates at a coarse kinematic level. Crawl–bend interference is implemented as a fitted, phase-dependent attenuation rather than being derived from segmental neuromechanics, and the intermittency module samples stridechains and pauses from empirical distributions without modeling the underlying neural mechanisms. Furthermore, behaviors requiring detailed musculature or segment-specific coordination (e.g. backward crawling, rolling, and digging) are not modeled and long-term exploration statistics are not considered, nor is interindividual variability in turning preference (handedness).

Second, the navigation layer provides qualitative demonstrations of chemotaxis but is not quantitatively calibrated to odor-guided trajectories. Odor-driven modulation acts through a single pathway to the turning oscillator, and weathervaning and headcasts emerge from the same mechanism, which may under-represent the diversity of reorientation strategies. Third, at the adaptive layer, the MB model is coupled to behavior sequentially rather than in a closed loop: learning is performed independently of movement, and only the resulting odor valence is passed to the behavioral simulation.

Finally, the present study focuses on solitary larvae. Larva–larva interactions are not modeled explicitly, although the larvaworld framework supports tactile sensors for future interaction studies. These simplifications reflect deliberate design choices that maintain accessibility while allowing more mechanistic modules to be integrated in subsequent work.

Materials and methods

We first describe the experimental dataset and the software package used in this study. Then we explicitly describe each of the computational modules that comprise the proposed behavioral architecture. The metrics used throughout the analyses of both real and simulated datasets are described in Appendix 1.

Dataset description

The larva-tracking dataset was acquired by M. Schleyer and J. Thoener at the Leipzig Institute of Neurobiology. It comprises 31 experimental groups, each containing approximately 30 third-instar Drosophila larvae (Canton S). Larvae were placed on agarose-filled Petri dishes of 15 cm diameter without any added stimuli and video-recorded from above at 16 Hz for 3 min.

During tracking, 12 points were detected along the longitudinal body axis of each larva. For the present study, all groups were pooled into a single population, and timepoints involving detected collisions were removed. From this cleaned dataset, we selected the 200 most complete, uninterrupted trajectories for subsequent analysis.

The recorded x–y coordinate time series were smoothed with a first-order Butterworth low-pass filter (cutoff frequency 2 Hz) to suppress tracking-related noise while preserving the behaviorally relevant crawling frequency of fC≃1.4 Hz. The effects of insufficient and excessive filtering are illustrated in Video 7.

Video 7. Filter selection.

Download video file (50.3MB, mp4)

The effect of inadequate or excessive filtering of the empirical larva recordings is illustrated. The left video shows the jittery original recording while the effect of lowpass filtering at cutoff frequencies of 4, 2, and 0.5 Hz is shown on the rest. Selection of an intermediate 2 Hz cutoff frequency eliminates the unrealistic jitter while preserving the behaviorally relevant crawling frequency.

Software package and code availability

All data processing, analysis, and model simulations were performed using our open-source Python package Larvaworld (https://pypi.org/project/larvaworld/), a unified platform for behavioral analysis and simulation of Drosophila larvae. In Larvaworld, empirical and simulated data are handled identically: the same analysis pipeline and behavioral metrics are applied to both, ensuring methodological consistency throughout.

The behavioral architecture introduced in this manuscript provides the backbone for constructing, extending, configuring, and fitting behavioral models within Larvaworld. The intermittent coupled-oscillator model developed here is included, alongside other preconfigured models.

A separate publication describes the software architecture and usage in detail and provides practical tutorials for science and teaching (Sakagiannis et al., 2025). Comprehensive documentation is available at https://larvaworld.readthedocs.io.

Inter-individual variability in virtual populations

Traditional approaches in computational ethology typically use generative models tuned to reproduce the behavior of an average animal, thereby neglecting the substantial inter-individual variability observed within real populations. Here, we adopt a complementary, population-level approach that explicitly preserves individuality. Instead of instantiating a single representative model larva, we simulate a group of non-identical animats whose parameters are sampled from a fitted multivariate normal distribution that captures the empirical variability and pairwise correlations between parameters.

To construct this distribution, we quantified several endpoint behavioral and morphological parameters for 200 larvae and fitted a multivariate Gaussian model to the resulting measurements. A subset of three representative parameters—body-length l, crawling frequency fC, and mean scaled stride displacement d˚S—is shown in Figure 7. Empirical univariate and bivariate distributions (blue) closely match the projections of the fitted multivariate Gaussian (red), which provides a compact generative model for individual variability. We further note that handedness represents an additional axis of individual variation in Drosophila larvae (Wosniack et al., 2022) and may be incorporated in future work.

Figure 7. Individuality: empirical (blue) and fitted (red) parameter distributions.

Figure 7.

Diagonal panels show histogram and kernel density estimates (KDEs) for body-length l, crawling frequency fC, and mean scaled displacement per stride d˚S across a population of 200 larvae in the experimental dataset. Lower off-diagonal panels depict bivariate projections of the empirical three-dimensional KDE. Upper off-diagonal panels show the corresponding projections of the fitted multivariate Gaussian distribution, with ellipses indicating 0.5, 1, 2, and 3 standard deviations. In the virtual population, parameter sets for individual larvae are generated by sampling from this multivariate Gaussian. Blue dots represent empirically measured larvae.

Module definition

The building blocks comprising the behavioral architecture are described as separate modules of defined input and output. The modular architecture only specifies the required placeholders and remains agnostic to the specific module implementations. Nevertheless, in what follows, the specific modular implementation for the proposed intermittent coupled-oscillator locomotory model will be described alongside the general module-placeholder definition. The parameters of the final model configuration are shown in Table 1 and its modular function is illustrated in Video 8. Calibration of each module on the empirical dataset and parameter specification is described in detail in Appendix 2.

Table 1. Locomotory model configuration.

The parameters of the calibrated average locomotory model, organized per module.

Parameter Symbol Value Unit
Physics Torque coefficient cT 0.5 s−2
Angular damping z 1.0 s−1
Body spring constant k 1.0 s−2
Bend correction coefficient cb 1.0 –
Body Length l 4.0 mm
Number of body segments – 2 # segments
Turner Tonic input IT0 21.43 –
Input range [ITmin,ITmax] [10, 40] –
Time constant tauT 0.1 s
Spike response steepness nT 2.37 –
Crawler Crawling frequency fc 1.42 Hz
Maximum scaled velocity v˚max 0.51 body-lengths/s
Stride distance mean d˚¯s 0.24 body-lengths
Stride distance std d˚~s 0.04 body-lengths
Max velocity phase ϕCV 3.49 rads
Interference Suppression coefficient CCT0 0.46 –
Suppression relief coefficient CCT1 0.54 –
Max relief phase ϕcω 2.05 rads
Intermitter Run length distribution NR Log-normal (m = 1.4, s = 1.15) –
Run length range [NRmin,NRmax] [1, 142] # strides
Pause duration distribution tP Exp(b = 1.0) –
Pause duration range [tPmin,tPmax] [0.12, 16.0] s

Video 8. Locomotory model for Drosophila larva.

Download video file (7.4MB, mp4)

The function of the intermittent coupled-oscillator locomotory model in Figure 1B is illustrated by adding its four modules stepwise: (1) crawler only, (2) turner only, (3) crawler + turner uncoupled, (4) crawler + turner coupled (stride-phase attenuation of bending), (5) crawler + turner uncoupled + crawl intermittency (runs/pauses), and (6) crawler + turner coupled + crawl intermittency (complete intermittent coupled-oscillator model). The inset indicates active modules per clip.

Bisegmental body

The virtual body provides the interface between the behavioral architecture and the simulated environment. Its motion in the plane is defined by a forward velocity v and an angular velocity ω, which together determine the displacement and orientation of the larva. Any locomotory model that dynamically generates these two quantities is sufficient for a point-body or single-segment implementation.

For the coupled-oscillator model proposed here, we adopt a bisegmental body consisting of a front and a rear segment connected by a single bending degree of freedom (see Video 9). The posture of the body is therefore described by the bending angle θb between the two segments. Following Wystrach et al., 2016, lateral bending dynamics are modeled using a torsional analogue of a mass–spring–damper system. In the standard formulation, translational and torsional systems are defined as

mv˙=Fext−zv−kx,Iω˙=Text−Zω−Kθb,

where I is the moment of inertia, Z is the angular damping, and K is the torsional stiffness resisting deformation.

Video 9. Bisegmental larva-body simplification.
Download video file (49.3MB, mp4)

The first panel shows the original tracked larval body with 12 midline points and a 22-point contour. Subsequent panels illustrate successive simplifications: removal of the contour, replacement with rectangular segment proxies, and finally a two-segment representation. The absolute head orientation angle θ is preserved, and the single bending angle θb is defined as θb=∑i=15θi across the anterior body.

For convenience, we express these dynamics in terms of angular acceleration per unit inertia by introducing the reduced coefficients

z=ZI,k=KI,ω˙ext=TextI.

The external drive ω˙ext is generated by the turner module (described below). During crawling, angular motion is further modulated by a crawl-phase-dependent suppression coefficient cCT(t)=cCT(ϕC) (see Crawler–turner coupling). Together, these contributions yield

ω˙=ω˙ext−kθb−zω−(1−cCT)ω. (1)

The original torsional model of Wystrach et al., 2016 omits two aspects of larval turning. First, it does not distinguish between bending velocity ωb (change of θb) and whole-body orientation velocity ω. Second, it does not correct the bending angle during forward motion. The bisegmental model resolves the first limitation by making ω and ωb distinct variables. To address the second, we introduce a simple linear correction that gradually realigns the rear segment to the orientation of the front segment during forward displacement:

θb={θˇb⁢(1-cbmax),0≤cbmax<1,0,cbmax≥1,  cbmax=2⁢d⁢cbl,

where d is the forward displacement during a timestep, l is the body-length, θˇb is the bending angle before correction, and cb=1 is the bend-correction coefficient.

Forward motion itself is generated independently by the crawler module, which directly supplies the instantaneous velocity v without additional biomechanical dynamics.

Crawler module

The crawler module generates forward velocity v under a tonic activation signal IC, which is supplied by the intermittency module. Specifically, during crawling epochs the intermittency module provides a constant tonic input IC>0, whereas during pauses it sets IC=0. The tonic input directly regulates crawling frequency, such that

fC=fC(IC), (2)

with fC taking its empirically measured value when IC is held constant during the short-duration simulations performed here.

Forward velocity generation depends on three parameters: the larval body-length l, the scaled displacement per stride d˚S, and the crawling frequency fC. For each individual virtual larva, the parameters l, d˚¯S, d˚~S, and the baseline fC are assigned during initialization, where d˚¯S and d˚~S denote the mean and standard deviation of each larva’s stride displacement.

Crawling is modeled as an oscillatory process. Each oscillation cycle produces one forward stride of average length l⋅d˚S, representing the net effect of a single peristaltic contraction cycle. After each stride a new d˚S value is sampled from the empirically fitted distribution:

d˚S∼N(d˚¯S,d˚~S). (3)

Across the oscillation, forward velocity follows a phase-dependent profile fitted to the average empirical stride waveform (see Appendix 2—figure 1B). The resulting generative equation for instantaneous forward velocity is

v(t)=l⋅d˚S⋅fC(IC)(v˚maxcos(ϕC(t)−ϕCv)+1), (4)

where ϕC(t) is the current phase of the crawler oscillator, v˚max is the maximal scaled velocity, and ϕCv is the phase at which this maximum occurs.

Thus, the intermittency module controls whether the crawler oscillates (run) or remains inactive (pause), while fC(IC) and d˚S jointly determine the stride-by-stride forward progression of the virtual larva.

Turner module

The turner module generates a torque-like lateral bending command AT(t) under a continuous activation input IT(t). This non-dimensional output is scaled to an external angular acceleration by the coefficient cT (in s–2) and applied to the body as a bending drive (see Equation 1):

ω˙ext(t)=cTAT(t), (5)

which produces the instantaneous angular velocity ω(t) and angular acceleration ω˙(t) of the larva’s lateral body motion.

Oscillatory process

Previous work has proposed that larval turning is driven by an underlying oscillatory process generating alternating left–right bends (Wystrach et al., 2016). We confirmed the presence of such a slow rhythm empirically by detecting a dominant frequency of approximately fT≈0.4 Hz in the angular velocity time series of freely moving larvae. Motivated by this observation, we model the turner as a lateral oscillator extending the framework introduced in Wystrach et al., 2016.

The oscillator consists of two mutually inhibiting units, a left component (EL,CL) and a right component (ER,CR), where each pair includes an excitatory neuron Ex and an inhibitory neuron Cx. The instantaneous firing response of each neuron to a cumulative input x is given by:

R(x,h)={mxnhn+xn,x≥0,0,x<0, (6)

where h denotes the half-response threshold.

Neuromodulatory control

The tonic activation input IT(t) excites both sides of the oscillator and modulates its gain and adaptation dynamics. Specifically, IT(t) alters the gain g(IT) and the adaptation time constant τH(IT) of each neuron’s adaptation variable Hx according to:

g⁢(IT)=6+(0.09⁢IT)2,τH⁢(IT)=31+0.04⁢IT2.

The resulting dynamics of the left-side excitatory and inhibitory neurons are:

τT⁢E˙L=-EL+R⁢(IT+We⁢e⁢EL-We⁢c⁢ER, 64+g⁢(IT)⁢HE⁢L),
τT⁢C˙L=-CL+R⁢(IT+Wc⁢e⁢EL-Wc⁢c⁢CR, 64+g⁢(IT)⁢HC⁢L),
H˙E⁢L=EL-HE⁢LτH⁢(IT),H˙C⁢L=EL-HC⁢LτH⁢(IT).

(The dynamics of the right-side neurons are defined analogously.)

Mutual inhibition between left and right components drives the system into stable antiphase oscillations, while the adaptation variables ensure periodic switching between sides. Under the baseline input IT0 the oscillator generates alternating bending with dominant frequency fT. Perturbations of IT(t) modulate both the amplitude and frequency of the oscillations, which allows the turner to express context-dependent behaviors such as weathervaning and head casting.

The instantaneous lateral bending command is defined as the difference in excitatory activity:

AT⁢(t)=EL⁢(t)-ER⁢(t).
Parameter calibration

Achieving realistic angular motions requires joint calibration of the turner parameters and the biomechanical body parameters—namely, the angular damping z, the bend deformation resistance k, and the torque scaling coefficient cT. The complete calibration procedure is provided in Appendix 2.

Crawler–turner coupling

To capture the empirically observed interaction between forward crawling and lateral bending, we couple the crawler and turner oscillators by imposing a crawler-phase-dependent attenuation cCT(ϕC) on the angular velocity ω (see Equation 1). During each stride cycle, the turning drive is suppressed by a baseline attenuation coefficient cCT0, reflecting the mechanical constraint exerted by the ongoing peristaltic wave. Our kinematic analysis shows that this suppression is partially relieved during a specific phase interval of the stride, corresponding to moments when the anterior body is maximally free to bend laterally.

The degree of additional relief is governed by the relief coefficient cCT1, and the transition between full suppression and partial relief can be implemented in two alternative ways. In square mode, an abrupt transition, where maximum relief is applied only within a fixed phase window [ϕCω0,ϕCω1] of the stride. In phase mode, a smooth Gaussian kernel centered at phase ϕCω, representing gradual lifting and reinstatement of attenuation around the phase of maximal bending freedom.

These two alternatives are implemented through the attenuation factor

cCT(ϕC)={cCT0+cCT1⋅ACT(ϕC),during runs,1,during pauses, (7)

where the relief profile ACT(ϕC) is defined as

ACT(ϕC)={exp(−(ϕC−ϕCω)22),phase mode,1,ϕCω0≤ϕC≤ϕCω1,0,otherwise,square mode. (8)

During pauses, the attenuation is removed (cCT=1), reflecting the empirical observation that large-amplitude head casts occur only when the larva is not executing a stride and thus the cranial body segments are free to bend without interference from peristalsis.

The coupling parameters cCT0, cCT1, ϕCω (phase mode) or [ϕCω0,ϕCω1] (square mode) are optimized to reproduce the experimentally measured average angular displacement as a function of stride phase. The full calibration procedure is described in Appendix 2, and the resulting optimal Gaussian kernel is shown in Figure 3.

Intermittency module

The intermittency module governs transitions between runs and pauses and serves as a placeholder for any mechanistic or statistical model capable of generating such switching dynamics (Figure 1B). In the present implementation, the module provides the tonic input IC to the crawler module: during runs, IC is held at a positive constant value that maintains oscillatory crawling, whereas during pauses the module sets IC=0, immediately suppressing forward velocity (v=0) and allowing large-amplitude head casts to occur.

For this study, run–pause switching is modeled statistically. At each transition, the duration of the upcoming state is sampled from empirical distributions fitted to experimental data. Pause durations are naturally measured in time units. For runs, we employ an equivalent metric by expressing run duration in terms of the number of consecutive crawling strides (stridechains), which reflects the stride-based structure of larval locomotion.

The fitted distributions for both pause durations and stridechain lengths are provided in Table 1. These statistics fully determine the state durations used in the intermittency module for the simulations reported here.

Odorscape and olfactory sensor

Olfaction is introduced at the intermediate layer of the behavioral architecture to enable chemotactic behavior. The virtual larva carries a single olfactory sensor at its anterior tip; thus, both reorientation and forward displacement immediately affect the sensory input it receives. Odor sources are represented as Gaussian concentration fields C(r), where r denotes the distance from the odor center, the concentration peaks at C0 (in µM), and spreads with standard deviation σ:

C(r)=C012πσ2exp(−r22σ2). (9)

Following Gomez-Marin et al., 2011, we assume that olfactory perception responds to relative changes in odor concentration according to a Weber–Fechner-like relationship: increases or decreases in concentration modulate the perceptual variable AO in proportion to C˙/C. In addition, AO relaxes back toward zero with a slow decay, yielding the dynamical equation

A˙O=−cOAO+∑iGiC˙iCi,−1≤AO≤1, (10)

where cO=1 is the decay coefficient, Ci is the instantaneous concentration of odor i at the larval sensor, and Gi is its odor-specific gain.

To translate olfactory perception into motor modulation, we adopt the mechanism proposed by Wystrach et al., 2016 (Figure 5). Here, AO perturbs the turner activation IT away from its baseline value IT0 within the admissible range ITrange=[ITmin,ITmax]=[10,40]:

IT=IT0+AO(ITlim−IT0), (11)

with

ITlim={ITmax,AO≥0,ITmin,AO≤0.

Positive AO values thus enhance turning (approach), while negative values suppress it (avoidance), providing a unified modulation rule for attractive and aversive odors.

MB module

The MB module implements the spiking network model of the larval olfactory pathway and MB published by Jürgensen et al., 2024. It consists of conductance-based leaky integrate-and-fire neurons and includes 21 olfactory receptor neurons (ORNs), 21 projection neurons (PNs), 21 local interneurons (LNs), 72 Kenyon cells (KCs), the anterior paired lateral neuron (APL), two mushroom body output neurons (MBONs), and two dopaminergic neurons (DANs) mediating reward and punishment. ORNs connect one-to-one to PNs and LNs; PNs provide sparse, random excitatory input to the KCs, while the APL provides global inhibitory feedback. All KCs excite both MBONs; each MBON in turn drives excitatory or inhibitory feedback onto the corresponding DAN.

Learning occurs at the KC::MBON synapses and is driven by a two-factor plasticity rule. A presynaptic KC spike sets an exponentially decaying eligibility trace ei(t) at synapse i, defining a window in which reinforcement can influence plasticity. When a DAN spike occurs, it provides a reinforcement signal R(t) that reduces synaptic strength proportionally to the current eligibility:

ΔwiL(t)=−αei(t)R(t), (12)

where α>0 is the learning rate. The eligibility trace follows:

e˙i(t)=−ei(t)τe,ei(t)←1upon KC spike. (13)

To balance learning-induced synaptic depression and to implement experimentally observed forgetting during odor-only trials, each KC::MBON synapse also undergoes homeostatic plasticity:

ΔwiH(t)=(winit−wi(t))M(t)η, (14)

where M(t) is the postsynaptic MBON activity and η is the homeostatic rate. The total weight update at each integration step is:

wi(t+Δt)=wi(t)+ΔwiL(t)+ΔwiH(t),wi(t)≥0. (15)

The MBON outputs encode the larva’s learned odor valence. We compute it from the spike counts of the approach-encoding MBON+ and avoidance-encoding MBON− (Owald et al., 2015; Owald and Waddell, 2015):

MBout=MB+−MB−MB++MB−∣MBoutϵ[−1,1]

This output directly provides the modulatory gain used by the motor layer to bias orientation and chemotactic steering following learning.

Acknowledgements

This project received funding from the Ministry of Culture and Science of the State of Northrhine Westphalia through the science network ‘iBehave’ (https://ibehave.nrw/) within the program ‘Netzwerke 2021’, and from the German Research Foundation through the Research Unit ‘Structure, Plasticity and Behavioral Function of the Drosophila mushroom body’ (DFG-FOR 2705, Grant No. 365082554, https://www.uni-goettingen.de/en/601524.html). PS received a stipendship within the Research Training Group ‘Neural Circuit Analysis’ (DFG-RTG 1960, Grant No. 233886668). We would like to thank Michael Schleyer and Juliane Thoener for providing the tracking dataset and for valuable discussions on the data analyses. We thank Bertram Gerber for valuable discussion and Anna Morozova for substantial support with the generation of the video and figure material.

Appendix 1

Metric definition

Body-length

The instantaneous body-length of an individual larva fluctuates during crawling due to subsequent stretching and contraction. Its histogram is well fitted by a Gaussian distribution (data not shown). Therefore individual larva length l is defined as the median of the midline length across time (total length of the line connecting all 12 midline points). All spatial parameters, including displacement and velocity, can be scaled to this body-length, converting spatial units m or mm to dimensionless body-length units. Scaled spatial metrics are denoted by an additional ° over the metric symbol.

Segmentation and angular metrics

To specify the body segmentation providing the most suitable contact/rotation point for the definition of the bending ωb and orientation ω angular velocities, we analyze their relationship in a subset of 40 larvae. Tracking of 12 midline points allows computation of the absolute orientation of 11 body-segments and the respective 10 angles θ1−10 between successive body segments (Figure 2F). We define θ as the head-segment absolute orientation in reference to the x-axis because this defines the movement orientation of the animal. We ask how ω results from the bending of the body as this is captured by the 10 angular velocities ω1−10. The regression analysis depicted in Appendix 1—figure 1B shows, as expected, that ω depends primarily on the front angular velocities, while this dependence decays as we move toward the rear segments, in line with previous studies (Lahiri et al., 2011). Timeshift analysis also shows that the front 3 angles change concurrently, while angles further down the midline are increasingly lagging behind (data not shown). The correlation analysis depicted in Appendix 1—figure 1C shows that the sum of the front 5 angular velocities best correlates to ω. In other words, the cumulative body bend of the front 5 segments best predicts head reorientation. Therefore we define the reorientation-relevant bending angle as θb=∑i=15θi (Figure 2F). The remaining 5 angles between the rear body segments can safely be neglected as they do not contribute to reorientation. This analysis results in a segmentation of the body in a front and a rear segment of length ratio 5:6. The segmentation process is demonstrated in Video 9.

Forward velocity

To define forward velocity, we need to choose which midline point is most suitable to track and which velocity metric to use for defining the start and end of a stride. To this end, we perform stride annotation of 3-min tracks of a population of 20 larvae using each of 24 candidate instantaneous velocity metrics, namely the velocities of the 12 points, the component velocities of the rearest 11 points parallel to their front segment’s absolute orientation, and finally the centroid velocity. To compare the candidate metrics, we compute the spatial cvs and temporal cvt coefficient of variation of the annotated strides for each larva to assess how variant their time duration and displacement is. We finally compute the mean cv¯s and cv¯t across individuals. In Appendix 1—figure 1A, the spatiotemporal stride variance is shown for each candidate metric. We choose the metric that provides the minimal spatial and temporal stride variance, assuming that strides of an individual larva are more or less stereotypical in both duration and displacement (Heckscher et al., 2012). Our study reveals that the centroid velocity is the most suitable metric for stride annotation. All spatial metrics are therefore computed via this point’s displacement.

Appendix 1—figure 1. Segmentation and velocity definition.

Appendix 1—figure 1.

(A) Forward velocity definition. Thirteen candidate velocity metrics are compared for use in stride annotation of 3-min tracks of a population of 30 larvae. For each candidate, the mean coefficient of variation of temporal duration cv¯t and spatial displacement cv¯s of the annotated strides is shown. Midline point 9 velocity provides the most temporally and spatially stereotypical strides; therefore, it is selected as the reference forward velocity for stride annotation and model fitting. vcen : centroid velocity, v1−v12 : 1st-12th point’s velocity. (B) Regression analysis of individual and cumulative angular velocities ωi=1−10 to orientation angular velocity ω. When considered individually, ω2 best predicts reorientation, with the ω3 and ω1 following. When considered cumulatively, the anterior 4 ωi allow optimal prediction of reorientation velocity. (C) Correlation analysis of the sum of all possible ωi combinations to ω. The sum ∑i=14ωi shows the highest correlation; therefore, we define θb=∑i=14θi as shown in A. For illustration purposes, only the five highest correlations are shown.

Track tortuosity

Track tortuosity is quantified by the straightness index (S.I.), a metric previously used in larva-track analysis (Sims et al., 2019), computed by advancing a fixed time window along the track and calculating at each point the ratio of the straight line distance to the actual distance traveled. This index, which varies from 0 (no movement) to 1 (straight line movement), can capture very well the complexity of the movement at various scales (set by the window time frame) throughout the track. As the time window decreases, the smoothing effect is also reduced, revealing increasing track details. Different window sizes have been used, ranging from 2 to 20 s to capture both large-scale spatial trajectories and small-scale local movements. Tortuosity was computed for each larva through time and revealed changes in movement as larva alternated between straight line relocation, changes of direction, and different degrees of tortuosity. Hence, a change in the S.I. along a larva’s track captures the magnitude of the change in movement pattern from intensive, area-restricted searching movements (higher tortuosity) to extensive, straighter line movements (lower tortuosity), and vice versa, across a wide range of spatial scales.

Epoch annotation

Strides (S) are annotated using the scaled forward velocity v˚. First, we apply Fourier analysis to detect the dominant crawling frequency within a suitable range 1⩽fC⩽2.5 (Figure 3A). From this, we derive the reference stride duration tS=fC−1. Then epochs are annotated under a number of constraints (Figure 2C):

  • Each stride is contained between two v˚ local minima.

  • The v˚ local maxima contained in the epoch need to exceed a threshold: v˚max⩾0.3.

  • The duration of the epoch t needs to range within 0.75⩽tS/⩽⁢2. This allows individual strides to temporally vary without overlapping so that adjacent strides can be concatenated in stridechains.

After stride annotation, the displacement due to each individual stride is computed for each larva and divided by the larva’s body-length (Figure 2A–C). The individual distributions are well fitted by Gaussians (data not shown). Therefore d˚¯S,d˚~S are defined as the average and standard deviation of the scaled displacement per stride for each larva.

Crawling runs (R) are defined as uninterrupted sequences of successive strides, also termed stridechains (Figure 2C). Stridechain length is the number of concatenated strides in a run and is a discrete metric equivalent to the continuous crawling run duration. If the locomotory model under evaluation does not generate v oscillations and therefore strides cannot be detected, runs are annotated using the plain forward velocity v time series as in a previous study (Sakagiannis et al., 2020). We first define a suitable threshold vthr by detecting the minima of the pooled v bimodal distribution. Then we define runs as epochs where constantly v⩾vthr. Pauses are then defined as epochs containing no strides (or equivalently not overlapping with runs) and during which v˚≤0.3 (or v≤vthr).

The turn epochs (T) are contained between pairs of successive sign changes of the orientation angular velocity ω. Annotated epochs of the left (TL) and right (TR) turns yield the respective amplitudes of the turn-angle θTL and θTR as the absolute total change in the orientation angle θ (Figure 2G), which can then be pooled into the overall absolute amplitudes of the turn-angle θT. Notably, by this definition, turns include both head casts (H) occurring during crawl-pauses and weathervaning (W) occurring during runs. Turns occurring exclusively during runs and pauses yield the turn-angle amplitudes of weathervaning θW and head casts θH, respectively.

Appendix 2

Model calibration

Here, we describe in detail the calibration procedure for a locomotory model of an average idealized individual based on a reference dataset of 150 larvae tracked while freely exploring a Petri dish over 3 min. The pipeline consists of three initial steps, which can be performed independently of each other and set the configuration parameters of the crawler, intermittency, and turner modules, respectively. In a final step that builds upon the results of the initial three, the parameters of the crawl–bend phase-locked interference are set. The first two steps are directly defined by the kinematic analysis results. The third and the final steps involve an optimization process to reach the parameter set best fitting the empirical data. Notably, along with the intrinsic parameters of a module, a number of additional module-related parameters might need to be defined, such as the body-length for the crawler module and the angular motion relevant physical parameters for the turner module.

Appendix 2—figure 1. Average locomotory model summary.

Appendix 2—figure 1.

(A) Distribution of stride-cycle-related parameters over the empirical dataset. Red dotted line denotes the median value used in the crawler module of the average locomotory model. (B) Normalized average curves of angular metrics during the stride cycle for each individual larva. Red line denotes the group median. (C) Pooled distribution of runs and pauses over the entire dataset (blue). Runs are detected as chains of concatenated strides (stridechains). Stridechains and pauses generated by the fitted distributions are shown in red. These distributions are used in the Intermitter module of the average locomotory model. (D) Sample simulation of the model with all modules active. The model features additionally bend correction due to forward motion and crawling phase-coupled suppression of angular motion.

For the hereby described average-larva model no noise is introduced to any module input or output and no parameter variability is allowed across the population of the generated virtual larvae. The sole source of stochasticity then is due to the random distribution sampling processes operated during the behavioral simulations. For the analysis of the generated datasets the exact same pipeline is used as for the empirical dataset. The configuration of the final locomotory model is illustrated in Table 1.

Forward motion

For the crawler module a set of five parameters need to be defined, along with a default body-length. This parameter set is adequate to dynamically generate realistic forward velocity v oscillations as defined in Equation 4. All parameters are set to the median value across the empirical larva group. In Appendix 2—figure 1A, the empirical distributions of the five crawler-module parameters are shown along with the median value selected for the average module.

Crawl intermittency

For the intermittency module, the sampling distributions for the run and pause epochs need to be defined. For both a continuous time-duration distribution is defined while for the former an additional discrete distribution of number of concatenated strides per stridechain (run) is computed. In all cases, the pooled distribution of the given epoch across the entire dataset is approximated by power-law, exponential, Lévy, log-normal, and combined log-normal/power-law distributions. All distributions are truncated within an empirically observed range and are fully defined by their usual arguments. The best-fitting candidates from each class are sorted according to their Kolmogorov–Smirnov distance DKS from the empirical distribution and the one exhibiting the minimum DKS is selected for use in the model’s intermittency module (Table 1). A validation is shown in Appendix 2—figure 1D where the distributions of the generated epochs (blue) match the empirical ones (red).

Angular motion

Realistically calibrating the locomotory model in the angular domain is more demanding. The turner module only generates a torque-equivalent output while the torsional-spring body model applies both angular damping and restorative force due to the body-bend angle (Equation 1). We need to calibrate the three involved physics parameters, namely the angular damping z in s−1, the bend deformation resistance k in s−2, and the torque coefficient cT in s−2. Additionally, the parameters of the turner module itself need to be specified. Here we study two implementations. The first is the above described neural oscillator, for which we need to define the baseline tonic input IT0, the spike-response steepness coefficient nT, and the time constant τT. The second is a simple sinusoidal oscillator, for which we need to define the baseline amplitude AT0 and frequency fT. In order to have an empirical reference for isolated angular-only motion while avoiding the effect of crawling on the angular motion, we select the detected pause epochs exceeding 3 s and derive the pooled distributions for three angular metrics, namely the bending angle θb, the angular velocity ω, and the angular acceleration ω˙. We run an optimization algorithm aiming to minimize the Kolmogorov–Smirnov distance between the simulated and empirical distributions for these three angular metrics. In each iteration, a turner module of a given configuration is simulated for 3 min while Equation 1 is applied to derive θb and ω. The obtained optimal turner and physics parameters are shown in Table 1.

Crawl–bend interference

For the crawl-phase-dependent attenuation of angular motion, we study two implementations, each having three parameters that define the attenuation coefficient cCT(ϕC) during the stride cycle (Equation 7). To achieve this, we use a genetic algorithm (GA) optimization process to reach a best-fitting parameter set for this module. Although optimization is only allowed to search the parameter space for these three parameters, each configuration is evaluated using a complete virtual larva model, combined with the optimal configurations of all other modules defined in the previous three calibration steps. During each iteration of the GA process, a group of 30 model configurations is simulated for 3 min in free-exploration conditions. The best six configurations are then mutated and/or combined in a novel generation. The evaluation function minimized is twofold. First, the distributions of the three angular metrics derived from the simulated track, namely the bending angle θb, the angular velocity ω, and the angular acceleration ω˙ are compared to the empirically measured target distributions via the Kolmogorov–Smirnov distance as described above for the angular motion. Second, stride cycle analysis is carried out for each simulated larva. Detected strides are interpolated in over n=64 bins in a 2π cycle and direction normalized by inverting the right-turning strides. The average stride cycle curve x^ is then computed for each of the three metrics and compared to the average empirically measured curve x via the evaluation metric defined below. The metric has been selected so that the different scales of angles, angular velocities, and accelerations are normalized before being summed. The final evaluation metric to be minimized is defined as the cumulative error across the three angular metrics for both the distributions and the average stride cycle curves.

Error(x,x^)=1n∑i=1n(xi−x^i)2|max(x)−min(x)|2 (16)

Here, we study two configurations for the crawl-phase-dependent suppression of the angular motion, namely a smooth Gaussian relief curve and an acute square transition as described in Equation 7. The target empirical and optimal model’s average curve for the angular velocity ω are shown in Appendix 2—figure 1B.

A sample simulation of the complete model is shown in Appendix 2—figure 1D. The crawler-generated forward velocity oscillations (first row) attenuate the angular motion in a phase-locked manner (second row) resulting in low angular velocity during runs and acute headcasts during pauses (third row). The bending angle is additionally restored to 0 during forward motion (fourth row).

Funding Statement

The funders had no role in study design, data collection, and interpretation, or the decision to submit the work for publication.

Contributor Information

Panagiotis Parthenios Sakagiannis, Email: p.sakagiannis@uni-koeln.de.

Martin Paul Nawrot, Email: mnawrot@uni-koeln.de.

Albert Cardona, University of Cambridge, United Kingdom.

Albert Cardona, University of Cambridge, United Kingdom.

Funding Information

This paper was supported by the following grants:

  • Ministry of Culture and Science of the state of North Rhine-Westphalia iBehave network to Panagiotis Parthenios Sakagiannis, Anna-Maria Jürgensen.

  • German Research Foundation "Structure, Plasticity and Behavioral function of the Drosophila Mushroom Body" DFG-FOR 2705 grant no. 365082554 to Panagiotis Parthenios Sakagiannis, Anna-Maria Jürgensen.

  • RTG "Neural Circuit Analysis" DFG-RTG 1960 grant no. 233886668 to Panagiotis Parthenios Sakagiannis.

Additional information

Competing interests

No competing interests declared.

Author contributions

Conceptualization, Data curation, Software, Formal analysis, Validation, Visualization, Methodology, Writing – original draft, Writing – review and editing.

Methodology, Writing – review and editing.

Conceptualization, Supervision, Funding acquisition, Project administration, Writing – review and editing.

Additional files

MDAR checklist

Data availability

The current manuscript is a computational study, so no data have been generated for this manuscript. Data analysis, behavioral modeling, and simulations have been carried out using the larvaworld Python package: https://pypi.org/project/larvaworld/.

The following previously published dataset was used:

Thoener J, Schleyer M. 2021. Locomotion of naive Drosophila larvae. GIN.

References

  1. Almeida-Carvalho MJ, Berh D, Braun A, Chen Y, 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, Paisios E, Pankratz MJ, Petersen M, Ramsperger N, Randel N, Risse B, Saumweber T, Schlegel P, Schleyer M, Soba P, Sprecher SG, Tanimura T, Thum AS, Toshima N, Truman JW, Yarali A, Zlatic M. The Ol1mpiad: concordance of behavioural faculties of stage 1 and stage 3 Drosophila larvae. Journal of Experimental Biology. 2017;220:2452–2475. doi: 10.1242/jeb.156646. [DOI] [PubMed] [Google Scholar]
  2. Berni J, Pulver SR, Griffith LC, Bate M. Autonomous circuitry for substrate exploration in freely moving Drosophila larvae. Current Biology. 2012;22:1861–1870. doi: 10.1016/j.cub.2012.07.048. [DOI] [PMC free article] [PubMed] [Google Scholar]
  3. Berni J. Genetic dissection of a regionally differentiated network for exploratory behavior in Drosophila larvae. Current Biology. 2015;25:1319–1326. doi: 10.1016/j.cub.2015.03.023. [DOI] [PMC free article] [PubMed] [Google Scholar]
  4. Bicho E. University of Minho; 1999. PhD thesis: Dynamic approach to behavior-based robotics: design, specification, analysis, simulation and implementation. [Google Scholar]
  5. Bidaye SS, Laturney M, Chang AK, Liu Y, Bockemühl T, Büschges A, Scott K. Two brain pathways initiate distinct forward walking programs in Drosophila. Neuron. 2020;108:469–485. doi: 10.1016/j.neuron.2020.07.032. [DOI] [PMC free article] [PubMed] [Google Scholar]
  6. Brooks R. A robust layered control system for a mobile robot. IEEE Journal on Robotics and Automation. 1986;2:14–23. doi: 10.1109/JRA.1986.1087032. [DOI] [Google Scholar]
  7. Davies A, Louis M, Webb B. A model of Drosophila larva chemotaxis. PLOS Computational Biology. 2015;11:e1004606. doi: 10.1371/journal.pcbi.1004606. [DOI] [PMC free article] [PubMed] [Google Scholar]
  8. de Belle JS, Heisenberg M. Associative odor learning in Drosophila abolished by chemical ablation of mushroom bodies. Science. 1994;263:692–695. doi: 10.1126/science.8303280. [DOI] [PubMed] [Google Scholar]
  9. Denisov G, Ohyama T, Jovanic T, Zlatic M. Model-based Detection and Analysis of Animal Behaviors using Signals Extracted by Automated Tracking. International Conference on Bio-inspired Systems and Signal Processing; Barcelona, Spain. 2013. [DOI] [Google Scholar]
  10. de Tredern E, Manceau D, Blanc A, Parameswaran A, Sakagiannis P, Barre C, Sus V, Viscido F, Akiki P, Hasan MA, Autran S, Laurent F, Nawrot MP, Masson JB, Jovanic T. Feeding state-dependent neuropeptidergic modulation of reciprocally interconnected inhibitory neurons biases sensorimotor decisions in Drosophila. Nature Communications. 2025;16:8198. doi: 10.1038/s41467-025-61805-y. [DOI] [PMC free article] [PubMed] [Google Scholar]
  11. Diegelmann S, Klagges B, Michels B, Schleyer M, Gerber B. Maggot learning and synapsin function. The Journal of Experimental Biology. 2013;216:939–951. doi: 10.1242/jeb.076208. [DOI] [PubMed] [Google Scholar]
  12. Dolan M-J, Belliart-Guérin G, Bates AS, Frechter S, Lampin-Saint-Amaux A, Aso Y, Roberts RJV, Schlegel P, Wong A, Hammad A, Bock D, Rubin GM, Preat T, Plaçais P-Y, Jefferis GSXE. Communication from learned to innate olfactory processing centers is required for memory retrieval in Drosophila. Neuron. 2018;100:651–668. doi: 10.1016/j.neuron.2018.08.037. [DOI] [PMC free article] [PubMed] [Google Scholar]
  13. 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:544–555. doi: 10.1038/s41593-020-0607-9. [DOI] [PMC free article] [PubMed] [Google Scholar]
  14. Eschbach C, Zlatic M. Useful road maps: studying Drosophila larva’s central nervous system with the help of connectomics. Current Opinion in Neurobiology. 2020;65:129–137. doi: 10.1016/j.conb.2020.09.008. [DOI] [PMC free article] [PubMed] [Google Scholar]
  15. Felsenberg J, Waddell S. Switching gears, structuring the right search strategy. Neuron. 2019;102:273–275. doi: 10.1016/j.neuron.2019.03.040. [DOI] [PubMed] [Google Scholar]
  16. Feng K, Sen R, Minegishi R, Dübbert M, Bockemühl T, Büschges A, Dickson BJ. Distributed control of motor circuits for backward walking in Drosophila. Nature Communications. 2020;11:6166. doi: 10.1038/s41467-020-19936-x. [DOI] [PMC free article] [PubMed] [Google Scholar]
  17. Gerber B, Stocker RF. The Drosophila larva as a model for studying chemosensation and chemosensory learning: a review. Chemical Senses. 2007;32:65–89. doi: 10.1093/chemse/bjl030. [DOI] [PubMed] [Google Scholar]
  18. Gerber B, Yarali A, Diegelmann S, Wotjak CT, Pauli P, Fendt M. Pain-relief learning in flies, rats, and man: basic research and applied perspectives. Learning & Memory. 2014;21:232–252. doi: 10.1101/lm.032995.113. [DOI] [PMC free article] [PubMed] [Google Scholar]
  19. Gerhard S, Andrade I, Fetter RD, Cardona A, Schneider-Mizell CM. Conserved neural circuit structure across Drosophila larval development revealed by comparative connectomics. eLife. 2017;6:e29089. doi: 10.7554/eLife.29089. [DOI] [PMC free article] [PubMed] [Google Scholar]
  20. Gjorgjieva J, Berni J, Evers JF, Eglen SJ. Neural circuits for peristaltic wave propagation in crawling Drosophila larvae: analysis and modeling. Frontiers in Computational Neuroscience. 2013;7:24. doi: 10.3389/fncom.2013.00024. [DOI] [PMC free article] [PubMed] [Google Scholar]
  21. Gomez-Marin A, Stephens GJ, Louis M. Active sampling and decision making in Drosophila chemotaxis. Nature Communications. 2011;2:410–441. doi: 10.1038/ncomms1455. [DOI] [PMC free article] [PubMed] [Google Scholar]
  22. Gomez-Marin A, Louis M. Active sensation during orientation behavior in the Drosophila larva: more sense than luck. Current Opinion in Neurobiology. 2012;22:208–215. doi: 10.1016/j.conb.2011.11.008. [DOI] [PubMed] [Google Scholar]
  23. Günther MN, Nettesheim G, Shubeita GT. Quantifying and predicting Drosophila larvae crawling phenotypes. Scientific Reports. 2016;6:27972. doi: 10.1038/srep27972. [DOI] [PMC free article] [PubMed] [Google Scholar]
  24. Heckscher ES, Lockery SR, Doe CQ. Characterization of Drosophila larval crawling at the level of organism, segment, and somatic body wall musculature. The Journal of Neuroscience. 2012;32:12460–12471. doi: 10.1523/JNEUROSCI.0222-12.2012. [DOI] [PMC free article] [PubMed] [Google Scholar]
  25. Helgadottir LI, Haenicke J, Landgraf T, Rojas R, Nawrot MP. Conditioned behavior in a robot controlled by a spiking neural network. 2013 6th International IEEE/EMBS Conference on Neural Engineering (NER); San Diego, CA, USA. 2013. pp. 891–894. [DOI] [Google Scholar]
  26. Imambocus BN, Zhou F, Formozov A, Wittich A, Tenedini FM, Hu C, Sauter K, Macarenhas Varela E, Herédia F, Casimiro AP, Macedo A, Schlegel P, Yang CH, Miguel-Aliaga I, Wiegert JS, Pankratz MJ, Gontijo AM, Cardona A, Soba P. A neuropeptidergic circuit gates selective escape behavior of Drosophila larvae. Current Biology. 2022;32:149–163. doi: 10.1016/j.cub.2021.10.069. [DOI] [PubMed] [Google Scholar]
  27. Jovanic T. Studying neural circuits of decision-making in Drosophila larva. Journal of Neurogenetics. 2020;34:162–170. doi: 10.1080/01677063.2020.1719407. [DOI] [PubMed] [Google Scholar]
  28. Jürgensen AM, Sakagiannis P, Schleyer M, Gerber B, Nawrot MP. Prediction error drives associative learning and conditioned behavior in a spiking model of Drosophila larva. iScience. 2024;27:108640. doi: 10.1016/j.isci.2023.108640. [DOI] [PMC free article] [PubMed] [Google Scholar]
  29. Kafle T, Grub M, Sakagiannis P, Nawrot MP, Arguello JR. Evolution of temperature preference behaviour among Drosophila larvae. iScience. 2025;28:112809. doi: 10.1016/j.isci.2025.112809. [DOI] [PMC free article] [PubMed] [Google Scholar]
  30. 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:1371–1383. doi: 10.1016/j.celrep.2018.10.013. [DOI] [PMC free article] [PubMed] [Google Scholar]
  31. Kim D, Alvarez M, Lechuga LM, Louis M. Species-specific modulation of food-search behavior by respiration and chemosensation in Drosophila larvae. eLife. 2017;6:e27057. doi: 10.7554/eLife.27057. [DOI] [PMC free article] [PubMed] [Google Scholar]
  32. Klein M, Krivov SV, Ferrer AJ, Luo L, Samuel AD, Karplus M. Exploratory search during directed navigation in C. elegans and Drosophila larva. eLife. 2017;6:e30503. doi: 10.7554/eLife.30503. [DOI] [PMC free article] [PubMed] [Google Scholar]
  33. Kohsaka H, Zwart MF, Fushiki A, Fetter RD, Truman JW, Cardona A, Nose A. Regulation of forward and backward locomotion through intersegmental feedback circuits in Drosophila larvae. Nature Communications. 2019;10:2654. doi: 10.1038/s41467-019-10695-y. [DOI] [PMC free article] [PubMed] [Google Scholar]
  34. König C, Khalili A, Ganesan M, Nishu AP, Garza AP, Niewalda T, Gerber B, Aso Y, Yarali A. Reinforcement signaling of punishment versus relief in fruit flies. Learning & Memory. 2018;25:247–257. doi: 10.1101/lm.047308.118. [DOI] [PMC free article] [PubMed] [Google Scholar]
  35. 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:e23180. doi: 10.1371/journal.pone.0023180. [DOI] [PMC free article] [PubMed] [Google Scholar]
  36. Laurent F, Blanc A, May L, Gándara L, Cocanougher BT, Jones BMW, Hague P, Barré C, Vestergaard CL, Crocker J, Zlatic M, Jovanic T, Masson JB. LarvaTagger: manual and automatic tagging of Drosophila larval behaviour. Bioinformatics. 2024;40:btae441. doi: 10.1093/bioinformatics/btae441. [DOI] [PMC free article] [PubMed] [Google Scholar]
  37. Lesar A, Tahir J, Wolk J, Gershow M. Switch-like and persistent memory formation in individual Drosophila larvae. eLife. 2021;10:e70317. doi: 10.7554/eLife.70317. [DOI] [PMC free article] [PubMed] [Google Scholar]
  38. Loveless J, Webb B. A neuromechanical model of larval chemotaxis. Integrative and Comparative Biology. 2018;58:906–914. doi: 10.1093/icb/icy094. [DOI] [PubMed] [Google Scholar]
  39. Loveless J, Lagogiannis K, Webb B. Modelling the mechanics of exploration in larval Drosophila. PLOS Computational Biology. 2019;15:e1006635. doi: 10.1371/journal.pcbi.1006635. [DOI] [PMC free article] [PubMed] [Google Scholar]
  40. Malloy CA, Somasundaram E, Omar A, Bhutto U, Medley M, Dzubuk N, Cooper RL. Pharmacological identification of cholinergic receptor subtypes: modulation of locomotion and neural circuit excitability in Drosophila larvae. Neuroscience. 2019;411:47–64. doi: 10.1016/j.neuroscience.2019.05.016. [DOI] [PubMed] [Google Scholar]
  41. Mantziaris C, Bockemühl T, Büschges A. Central pattern generating networks in insect locomotion. Developmental Neurobiology. 2020;80:16–30. doi: 10.1002/dneu.22738. [DOI] [PubMed] [Google Scholar]
  42. Marken RS, Shaffer DM. The power law of movement: an example of a behavioral illusion. Experimental Brain Research. 2017;235:1835–1842. doi: 10.1007/s00221-017-4939-y. [DOI] [PubMed] [Google Scholar]
  43. Marken RS, Shaffer DM. The power law as behavioral illusion: reappraising the reappraisals. Experimental Brain Research. 2018;236:1537–1544. doi: 10.1007/s00221-018-5208-4. [DOI] [PubMed] [Google Scholar]
  44. Michels B, Chen Y, Saumweber T, Mishra D, Tanimoto H, Schmid B, Engmann O, Gerber B. Cellular site and molecular mode of synapsin action in associative learning. Learning & Memory. 2011;18:332–344. doi: 10.1101/lm.2101411. [DOI] [PubMed] [Google Scholar]
  45. Michels B, Saumweber T, Biernacki R, Thum J, Glasgow RDV, Schleyer M, Chen Y-C, Eschbach C, Stocker RF, Toshima N, Tanimura T, Louis M, Arias-Gil G, Marescotti M, Benfenati F, Gerber B. Pavlovian conditioning of larval Drosophila: an illustrated, multilingual, hands-on manual for odor-taste associative learning in maggots. Frontiers in Behavioral Neuroscience. 2017;11:45. doi: 10.3389/fnbeh.2017.00045. [DOI] [PMC free article] [PubMed] [Google Scholar]
  46. Miroschnikow A, Schlegel P, Schoofs A, Hueckesfeld S, Li F, Schneider-Mizell CM, Fetter RD, Truman JW, Cardona A, Pankratz MJ. Convergence of monosynaptic and polysynaptic sensory paths onto common motor outputs in a Drosophila feeding connectome. eLife. 2018;7:e40247. doi: 10.7554/eLife.40247. [DOI] [PMC free article] [PubMed] [Google Scholar]
  47. Niewalda T, Jeske I, Michels B, Gerber B. “Peer pressure” in larval Drosophila? Biology Open. 2014;3:575–582. doi: 10.1242/bio.20148458. [DOI] [PMC free article] [PubMed] [Google Scholar]
  48. 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:e71706. doi: 10.1371/journal.pone.0071706. [DOI] [PMC free article] [PubMed] [Google Scholar]
  49. 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:417–427. doi: 10.1016/j.neuron.2015.03.025. [DOI] [PMC free article] [PubMed] [Google Scholar]
  50. 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. [DOI] [PMC free article] [PubMed] [Google Scholar]
  51. Paisios E, Rjosk A, Pamir E, Schleyer M. Common microbehavioral “footprint” of two distinct classes of conditioned aversion. Learning & Memory. 2017;24:191–198. doi: 10.1101/lm.045062.117. [DOI] [PMC free article] [PubMed] [Google Scholar]
  52. Pehlevan C, Paoletti P, Mahadevan L. Integrative neuromechanics of crawling in D. melanogaster larvae. eLife. 2016;5:e11031. doi: 10.7554/eLife.11031. [DOI] [PubMed] [Google Scholar]
  53. Prescott TJ, Redgrave P, Gurney K. Layered control architectures in robots and vertebrates. Adaptive Behavior. 1999;7:99–127. doi: 10.1177/105971239900700105. [DOI] [Google Scholar]
  54. Prescott TJ, Wilson SP. Understanding brain functional architecture through robotics. Science Robotics. 2023;8:eadg6014. doi: 10.1126/scirobotics.adg6014. [DOI] [PubMed] [Google Scholar]
  55. Qian CS, Kaplow M, Lee JK, Grueber WB. Diversity of internal sensory neuron axon projection patterns is controlled by the POU-domain protein Pdm3 in Drosophila larvae. The Journal of Neuroscience. 2018;38:2081–2093. doi: 10.1523/JNEUROSCI.2125-17.2018. [DOI] [PMC free article] [PubMed] [Google Scholar]
  56. Reynolds AM, Jones HBC, Hill JK, Pearson AJ, Wilson K, Wolf S, Lim KS, Reynolds DR, Chapman JW, Reynolds AM. Evidence for a pervasive “idling-mode” activity template in flying and pedestrian insects. Royal Society Open Science. 2015;2:150085. doi: 10.1098/rsos.150085. [DOI] [PMC free article] [PubMed] [Google Scholar]
  57. Risse B, Berh D, Otto N, Klämbt C, Jiang X. FIMTrack: An open source tracking and locomotion analysis software for small animals. PLOS Computational Biology. 2017;13:e1005530. doi: 10.1371/journal.pcbi.1005530. [DOI] [PMC free article] [PubMed] [Google Scholar]
  58. Ross D, Lagogiannis K, Webb B. In: Biomimetic and Biohybrid Systems. Wilson SP, Verschure PF, Mura A, Prescott TJ, editors. Cham: Springer International Publishing; 2015. A model of larval biomechanics reveals exploitable passive properties for efficient locomotion; pp. 1–12. [DOI] [Google Scholar]
  59. Ruiz-Dubreuil G, Burnet B, Connolly K, Furness P. Larval foraging behaviour and competition in Drosophila melanogaster. Heredity. 1996;76:55–64. doi: 10.1038/hdy.1996.7. [DOI] [PubMed] [Google Scholar]
  60. Sakagiannis P, Aguilera M, Nawrot MP. In: Biomimetic and Biohybrid Systems. Vouloutsi V, Mura A, Tauber F, Speck T, Prescott TJ, Verschure PFMJ, editors. Cham: Springer International Publishing; 2020. A plausible mechanism for drosophila larva intermittent behavior; pp. 288–299. [DOI] [Google Scholar]
  61. Sakagiannis PP, Rapp H, Jovanic T, Nawrot MP. Larvaworld: a behavioral simulation and analysis platform for Drosophila larva. bioRxiv. 2025 doi: 10.1101/2025.06.15.659765. [DOI]
  62. Saumweber T, Weyhersmüller A, Hallermann S, Diegelmann S, Michels B, Bucher D, Funk N, Reisch D, Krohne G, Wegener S, Buchner E, Gerber B. Behavioral and synaptic plasticity are impaired upon lack of the synaptic protein SAP47. The Journal of Neuroscience. 2011;31:3508–3518. doi: 10.1523/JNEUROSCI.2646-10.2011. [DOI] [PMC free article] [PubMed] [Google Scholar]
  63. Saumweber T, Rohwedder A, Schleyer M, Eichler K, Chen Y-C, 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:1104. doi: 10.1038/s41467-018-03130-1. [DOI] [PMC free article] [PubMed] [Google Scholar]
  64. 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:639–653. doi: 10.1101/lm.2163411. [DOI] [PubMed] [Google Scholar]
  65. Schleyer M, Miura D, Tanimura T, Gerber B. Learning the specific quality of taste reinforcement in larval Drosophila. eLife. 2015a;4:e04711. doi: 10.7554/eLife.04711. [DOI] [PMC free article] [PubMed] [Google Scholar]
  66. Schleyer M, Reid SF, Pamir E, Saumweber T, Paisios E, Davies A, Gerber B, Louis M. The impact of odor–reward memory on chemotaxis in larval Drosophila. Learning & Memory. 2015b;22:267–277. doi: 10.1101/lm.037978.114. [DOI] [PMC free article] [PubMed] [Google Scholar]
  67. Schleyer M, Fendt M, Schuller S, Gerber B. Associative learning of stimuli paired and unpaired with reinforcement: evaluating evidence from maggots, flies, bees, and rats. Frontiers in Psychology. 2018;9:1494. doi: 10.3389/fpsyg.2018.01494. [DOI] [PMC free article] [PubMed] [Google Scholar]
  68. Schleyer M, Weiglein A, Thoener J, Strauch M, Hartenstein V, Kantar Weigelt M, Schuller S, Saumweber T, Eichler K, Rohwedder A, Merhof D, Zlatic M, Thum AS, Gerber B. Identification of dopaminergic neurons that can both establish associative memory and acutely terminate its behavioral expression. The Journal of Neuroscience. 2020;40:5990–6006. doi: 10.1523/JNEUROSCI.0290-20.2020. [DOI] [PMC free article] [PubMed] [Google Scholar]
  69. Schoofs A, Hückesfeld S, Schlegel P, Miroschnikow A, Peters M, Zeymer M, Spieß R, Chiang AS, Pankratz MJ. Selection of motor programs for suppressing food intake and inducing locomotion in the Drosophila brain. PLOS Biology. 2014;12:e1001893. doi: 10.1371/journal.pbio.1001893. [DOI] [PMC free article] [PubMed] [Google Scholar]
  70. Schoofs A, Miroschnikow A, Schlegel P, Zinke I, Schneider-Mizell CM, Cardona A, Pankratz MJ. Serotonergic modulation of swallowing in a complete fly vagus nerve connectome. Current Biology. 2024;34:4495–4512. doi: 10.1016/j.cub.2024.08.025. [DOI] [PMC free article] [PubMed] [Google Scholar]
  71. 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. [DOI] [PMC free article] [PubMed] [Google Scholar]
  72. Schumann I, Triphan T. The PEDtracker: an automatic staging approach for Drosophila melanogaster Larvae. Frontiers in Behavioral Neuroscience. 2020;14:612313. doi: 10.3389/fnbeh.2020.612313. [DOI] [PMC free article] [PubMed] [Google Scholar]
  73. Sen R, Wu M, Branson K, Robie A, Rubin GM, Dickson BJ. Moonwalker descending neurons mediate visually evoked retreat in Drosophila. Current Biology. 2017;27:766–771. doi: 10.1016/j.cub.2017.02.008. [DOI] [PubMed] [Google Scholar]
  74. Sims DW, Humphries NE, Hu N, Medan V, Berni J. Optimal searching behaviour generated intrinsically by the central pattern generator for locomotion. eLife. 2019;8:e50316. doi: 10.7554/eLife.50316. [DOI] [PMC free article] [PubMed] [Google Scholar]
  75. Slater G, Levy P, Chan KLA, Larsen C. A central neural pathway controlling odor tracking in Drosophila. The Journal of Neuroscience. 2015;35:1831–1848. doi: 10.1523/JNEUROSCI.2331-14.2015. [DOI] [PMC free article] [PubMed] [Google Scholar]
  76. Springer MA, Nawrot MP. A mechanistic model for reward prediction and extinction learning in the fruit fly. eNeuro. 2021;8:ENEURO.0549-20.2021. doi: 10.1523/ENEURO.0549-20.2021. [DOI] [PMC free article] [PubMed] [Google Scholar]
  77. Strutz A, Soelter J, Baschwitz A, Farhan A, Grabe V, Rybak J, Knaden M, Schmuker M, Hansson BS, Sachse S. Decoding odor quality and intensity in the Drosophila brain. eLife. 2014;3:e04147. doi: 10.7554/eLife.04147. [DOI] [PMC free article] [PubMed] [Google Scholar]
  78. Szigeti B, Deogade A, Webb B. Searching for motifs in the behaviour of larval Drosophila melanogaster and Caenorhabditis elegans reveals continuity between behavioural states. Journal of the Royal Society, Interface. 2015;12:20150899. doi: 10.1098/rsif.2015.0899. [DOI] [PMC free article] [PubMed] [Google Scholar]
  79. Tadres D, Louis M. PiVR: An affordable and versatile closed-loop platform to study unrestrained sensorimotor behavior. PLOS Biology. 2020;18:e3000712. doi: 10.1371/journal.pbio.3000712. [DOI] [PMC free article] [PubMed] [Google Scholar]
  80. Tastekin I, Khandelwal A, Tadres D, Fessner ND, Truman JW, Zlatic M, Cardona A, Louis M. Sensorimotor pathway controlling stopping behavior during chemotaxis in the Drosophila melanogaster larva. eLife. 2018;7:e38740. doi: 10.7554/eLife.38740. [DOI] [PMC free article] [PubMed] [Google Scholar]
  81. Thane M, Viswanathan V, Meyer TC, Paisios E, Schleyer M. Modulations of microbehaviour by associative memory strength in Drosophila larvae. PLOS ONE. 2019;14:e0224154. doi: 10.1371/journal.pone.0224154. [DOI] [PMC free article] [PubMed] [Google Scholar]
  82. Thane M, Paisios E, Stöter T, Krüger AR, Gläß S, Dahse AK, Scholz N, Gerber B, Lehmann DJ, Schleyer M. High-resolution analysis of individual Drosophila melanogaster larvae uncovers individual variability in locomotion and its neurogenetic modulation. Open Biology. 2023;13:220308. doi: 10.1098/rsob.220308. [DOI] [PMC free article] [PubMed] [Google Scholar]
  83. Ueno T, Masuda N, Kume S, Kume K. Dopamine modulates the rest period length without perturbation of its power law distribution in Drosophila melanogaster. PLOS ONE. 2012;7:e32007. doi: 10.1371/journal.pone.0032007. [DOI] [PMC free article] [PubMed] [Google Scholar]
  84. Vogt K, Zimmerman DM, Schlichting M, Hernandez-Nunez L, Qin S, Malacon K, Rosbash M, Pehlevan C, Cardona A, Samuel ADT. Internal state configures olfactory behavior and early sensory processing in Drosophila larvae. Science Advances. 2021;7:eabd6900. doi: 10.1126/sciadv.abd6900. [DOI] [PMC free article] [PubMed] [Google Scholar]
  85. Weiglein A, Gerstner F, Mancini N, Schleyer M, Gerber B. One-trial learning in larval Drosophila. Learning & Memory. 2019;26:109–120. doi: 10.1101/lm.049106.118. [DOI] [PMC free article] [PubMed] [Google Scholar]
  86. Widmann A, Artinger M, Biesinger L, Boepple K, Peters C, Schlechter J, Selcho M, Thum AS. Genetic dissection of aversive associative olfactory learning and memory in Drosophila larvae. PLOS Genetics. 2016;12:e1006378. doi: 10.1371/journal.pgen.1006378. [DOI] [PMC free article] [PubMed] [Google Scholar]
  87. Widmann A, Eichler K, Selcho M, Thum AS, Pauls D. Odor-taste learning in Drosophila larvae. Journal of Insect Physiology. 2018;106:47–54. doi: 10.1016/j.jinsphys.2017.08.004. [DOI] [PubMed] [Google Scholar]
  88. Wilson SP, Prescott TJ. Scaffolding layered control architectures through constraint closure: insights into brain evolution and development. Philosophical Transactions of the Royal Society B. 2022;377:20200519. doi: 10.1098/rstb.2020.0519. [DOI] [PMC free article] [PubMed] [Google Scholar]
  89. Wosniack ME, Festa D, Hu N, Gjorgjieva J, Berni J. Adaptation of Drosophila larva foraging in response to changes in food resources. eLife. 2022;11:e75826. doi: 10.7554/eLife.75826. [DOI] [PMC free article] [PubMed] [Google Scholar]
  90. Wu Q, Wen T, Lee G, Park JH, Cai HN, Shen P. Developmental control of foraging and social behavior by the Drosophila neuropeptide Y-like system. Neuron. 2003;39:147–161. doi: 10.1016/s0896-6273(03)00396-9. [DOI] [PubMed] [Google Scholar]
  91. Wystrach A, Lagogiannis K, Webb B. Continuous lateral oscillations as a core mechanism for taxis in Drosophila larvae. eLife. 2016;5:e15504. doi: 10.7554/eLife.15504. [DOI] [PMC free article] [PubMed] [Google Scholar]
  92. Zago M, Lacquaniti F, Gomez-Marin A. The speed-curvature power law in Drosophila larval locomotion. Biology Letters. 2016;12:20160597. doi: 10.1098/rsbl.2016.0597. [DOI] [PMC free article] [PubMed] [Google Scholar]
  93. Zago M, Matic A, Flash T, Gomez-Marin A, Lacquaniti F. The speed-curvature power law of movements: a reappraisal. Experimental Brain Research. 2018;236:69–82. doi: 10.1007/s00221-017-5108-z. [DOI] [PubMed] [Google Scholar]
  94. Zarin AA, Mark B, Cardona A, Litwin-Kumar A, Doe CQ. A multilayer circuit architecture for the generation of distinct locomotor behaviors in Drosophila. eLife. 2019;8:e51781. doi: 10.7554/eLife.51781. [DOI] [PMC free article] [PubMed] [Google Scholar]
  95. Zhang T, Branch A, Shen P. Octopamine-mediated circuit mechanism underlying controlled appetite for palatable food in Drosophila. PNAS. 2013;110:15431–15436. doi: 10.1073/pnas.1308816110. [DOI] [PMC free article] [PubMed] [Google Scholar]

eLife Assessment

Albert Cardona 1

This valuable study presents a hierarchical computational model that integrates locomotion, navigation, and learning in Drosophila larvae. The evidence supporting the model is convincing, as it qualitatively replicates empirical behavioral data. While some simplifications in neuromechanical representation and sensory-motor integration are limiting factors, the reported modular framework will be of interest for computational modeling of biological movement and adaptive behavior.

Reviewer #1 (Public review):

Anonymous

Summary:

The paper presents a three-layered hierarchical model for simulating Drosophila larva locomotion, navigation, and learning. The model consists of a basic locomotory layer that generates crawling and turning using a coupled-oscillator framework, incorporating intermittency in movement through alternating runs and pauses. The intermediate layer enables navigation by allowing larvae to actively sense and respond to odor gradients, facilitating chemotaxis. The adaptive learning layer integrates a spiking neural network model of the Mushroom Body, simulating associative learning where larvae modify their behavior based on past experiences. The model is validated through simulations of free exploration, chemotaxis, and odor preference learning, demonstrating close agreement with empirical behavioral data. This modular framework provides a valuable advance for modeling of larva behavior.

Strengths:

Every modeling paper requires certain assumptions and abstractions. The main strength of this paper lies in its modular and hierarchical approach to modeling behavior, making connections to influential theories of motor control in the brain. The authors also provide a convincing discussion of the experimental evidence supporting their layered behavioral architecture. This abstraction is valuable, offering researchers a useful conceptual framework and marking a significant step forward in the field. Connections to empirical larval movement are another major strength.

Weaknesses:

While the model represents a conceptual advance in the field, some of its assumptions and choices fall behind state-of-the-art approaches. One limitation is the paper's simplified representation of larval neuromechanics, in which the body is reduced to a two-segment structure with basic neural control. Another limitation is the absence of an explicit neuromuscular control system, which would better capture the role of segmental central pattern generators (CPGs) and neuronal circuits in regulating peristalsis and turning in Drosophila larvae. Many detailed neuromechanical models, as cited by the authors, have already been published. These abstractions overlook valuable experimental studies that detail segmental dynamics during crawling and the larval connectome.

The strength of the model could also be its weakness. The model follows a subsumption architecture, where low-level behaviors operate autonomously while higher layers modulate them. However, this approach may underestimate the complexity of real neural circuits, which likely exhibit more intricate feedback mechanisms between sensory input and motor execution.

Reviewer #2 (Public review):

Anonymous

The paper proposes a hierarchically layer approach to larval locomotion, chemotaxis and learning. The model consists of a basic locomotor layer with two coupled oscillators, one for crawls and one for turns. The intermediate layer modulates the frequency and amplitude of tunings to enables chemotaxis. The higher layer, integrates a spiking neural network model of the Mushroom Body to modify the door valence in response to experience as during learning.

The model is compared to experimental data with a good degree of agreement. This modular framework provides a valuable advance for modeling larva behavior.

Strengths:

A novel multilayer level model that reflects current thinking of the neuronal organisation of motor control. The model is very useful to investigate the neuronal architecture of central pattern generators

and higher order motor control circuits that could be linked to larval connectome data.

Weaknesses:

All the limitations of the model are discussed and therefore the paper perfectly fits its purpose.

eLife. 2026 Aug 17;14:RP104262. doi: 10.7554/eLife.104262.3.sa3

Author response

Panagiotis Parthenios Sakagiannis 1, Anna-Maria Jürgensen 2, Martin Paul Nawrot 3

The following is the authors’ response to the original reviews.

Public Reviews:

Reviewer #1 (Public review):

We are happy to read that this reviewer considers the proposed behavioral architecture ‘a significant step forward in the field’, and that she/he recognizes the strengths of our work in the modular and hierarchical approach that provides connections to influential theories of motor control in the brain, in the experimental evidence it is based on, and in the valuable abstractions that we have chosen for the larval behavioral modeling.

The reviewer raises important points about the simplifications we have made, both conceptually and in the specific implementation of larval behaviors. Our main goal in this study is to introduce a conceptual framework that integrates agent-based modeling with systems neuroscience models in a modular fashion. To serve this purpose, we aimed for a minimal yet representative implementation at the motor layer of the architecture, calibrated to larval locomotion kinematics. This choice enables efficient simulation while allowing us to test top-down modulation and adaptive mechanisms in higher layers without the computational overhead of a full neuromechanical model. In addition to chemotaxis, we have recently used this simplified approach to model thermotaxis in larvae (Kafle et al., 2025, iScience, DOI: https://doi.org/10.1016/j.isci.2025.112809).

The reviewer notes the absence of explicit segmental neuromuscular control or central pattern generators (CPGs). We deliberately abstracted from these mechanisms, representing the larval body as two segments with basic kinematic control, to focus on reproducing overall locomotor patterns. This bisegmental simplification, which we illustrate in Supplemental Video “Bisegmental larva-body simplification”, retains the behavioral features relevant to our current aims. However, the modular structure of the framework means that more detailed neuromechanical models—incorporating CPG dynamics or connectome-derived circuit models—can be integrated in future work without altering the architecture as a whole.

We fully agree that real neural circuits are more complex than a strict subsumption architecture implies. In the Drosophila larva, there is clear evidence for ascending sensory feedback from the motor periphery to premotor and higher brain circuits, as well as neuromodulatory influences. These add layers of complexity beyond the predominantly descending control in our present model. At the same time, both larval and adult connectome data show that across-level descending and ascending connections are sparse compared to the dense within-layer connectivity. We see value in casting our model as a hierarchical control system precisely to make the strengths and limitations of such an abstraction explicit. The revised manuscript will include further discussion of these points.

In summary, our design choices reflect a trade-off: by limiting the biological detail in the lower layers, we gain computational efficiency and maintain a clear modular structure that can host models at different levels of abstraction. This ensures that the architecture remains both a tool for immediate behavioral simulation and a scaffold for integrating richer neural and biomechanical models as they become available.

Reviewer #2 (Public review):

We thank the reviewer for recognizing the novelty of our locomotory model, particularly the implementation of peristaltic strides based on our new analyses of empirical larval tracks, and for providing constructive feedback that will help us improve the manuscript.

The reviewer highlights the need for clearer explanations of the chemotaxis and odor preference modules. We expand these sections in the revised manuscript with more explicit descriptions of model structure, parameterization, and calibration. As mentioned above, we have also prepared a separate preprint dedicated to the larvaworld Python package, which contains detailed implementation notes and hands-on tutorials that allow users to adapt or extend individual modules.

Regarding the comparison to empirical behavior in chemotaxis, our present analysis is indeed primarily qualitative. However, we would like to emphasize that the temporal profile of odor concentration at the larval head in our simulations matches that measured in Gomez-Marin et al. (Nature Comm., 2011, DOI: https://doi.org/10.1038/ncomms1455) using only one additional free parameter, while all parameters of the basic locomotory model had been fitted to a separate exploration dataset before and were kept fixed in the chemotaxis experiments. In addition to the simulation of chemotaxis in the present paper, we recently used larvaworld in a practical model application to estimate a species-specific parameter of thermotaxis from experiments across different drosophilids (Kafle et al., 2025, iScience, DOI: https://doi.org/10.1016/j.isci.2025.112809).

The preference index in our simulations was computed using the same definition as in the established experimental group assay for larval memory retention, enabling a direct quantitative comparison between simulated and empirical results. Variability in the simulated outcomes arose naturally from inter-individual differences in body length and locomotory parameters, derived from real larval measurements, as well as from the random initial orientation of each individual in the arena. These factors contributed to variation in individual tracks and ultimately produced preference index values that closely matched those observed experimentally. In the revised manuscript, we also discuss handedness, as highlighted by the reviewer, as another meaningful expression of inter-individual variability in Drosophila larvae and insects more generally.

Finally, we acknowledge the reviewer’s concern about the scalability and broader applicability of the model. While the present paper focuses on three specific behavioral paradigms (exploration, chemotaxis, odor preference), the modular structure of the architecture is designed for flexibility: modules at any layer can be exchanged for more detailed or alternative implementations, and new sensory modalities or behaviors can be integrated without redesigning the system. The larvaworld package, associated codebase, and documentation are openly available to encourage adoption and adaptation by the larval research community.

Reviewer #3 (Public review):

This public review provides an excellent account of our central aim to build an easily configurable, well-documented platform for organism-scale behavioral simulation and we are happy to read that the reviewer considers this an excellent goal.

We thank the reviewer for her/his account of our well-organized code using contemporary Python tooling. We are currently further improving code readability and code documentation, and we will release a new version of the larvaworld Python package. We further agree with the reviewer’s assessment that understanding the model calibration currently requires reading of the appendix. For the revised manuscript we thus aim at improving our description of all calibration and modeling steps along the way. We will also make sure to improve the description of the experimental datasets used for calibration.

We recognize that our description of the paper’s scientific contribution could be clearer. In revision, we will sharpen the Introduction and Discussion to highlight our main contributions:

(1) Promoting a shift from isolated neural circuit modeling to integrated agent-based simulations in realistic environments.

(2) Proposing the layered behavioral architecture, adopting the subsumption paradigm for modular integration.

(3) Providing the larvaworld software as a ready-to-use, extensible modeling platform.

(4) Implementing an empirically calibrated locomotory model and demonstrating its integration with navigation and learning modules in replicated behavioral paradigms.

We agree with the reviewer that the next challenge is to integrate the empirically based behavioral simulations presented here with functional brain models capable of reproducing or predicting experimental findings at the level of cellular neurophysiology, including the effects of cell-type-specific manipulations such as gene knock-down or optogenetic activation/inhibition. However, based on our experience with systems-level modeling, we deliberately invested in behavioral simulation because functional models of the nervous system—including our own—often lack translation into simulated agent behavior. In many cases, model output is limited to one or more variables that can at best be interpreted as a behavioral bias, and most often represents an “average animal” that fails to capture inter-individual differences. By linking our spiking mushroom body model to behavioral simulations in a group of individual agents during memory retention tests (Figure 6C,D), we were able to achieve a first successful direct comparison between simulated and experimental behavior metrics—in this case, the behavioral preference index reported in Jürgensen et al. (iScience, 2024, DOI:https://doi.org/10.1016/j.isci.2023.108640).

Finally, we reiterate that the layered behavioral architecture is designed to promote a modular modeling paradigm. Our adoption of a subsumption architecture does not conflict with the concept of behavioral primitives; on the contrary, the notion that such primitives follow (semi-)autonomous motor programs and can be combined into more complex behaviors was the starting point for our implementation of the architecture in the fly larva. In our view, a genuinely contradictory paradigm for neural control of behavior would require a non-modular, strictly non-hierarchical organization of the nervous system and, by extension, of behavioral control.

Recommendations for the authors:

Reviewer #1 (Recommendations for the authors):

See public review for main points. To summarize, I find the conceptual framework of the paper very valuable and an important advance. However, in this age of data, I would have expected that the authors would make an effort to build more realistic models that could relate directly to neural data (including connectome and activity) and muscular dynamics at the segmental level.

This point is addressed in detail in our public review response. In brief, we agree that a segmental neuromechanical model informed by connectome data would provide richer mechanistic insight. However, such an approach would greatly increase complexity and reduce accessibility. Our aim here is to present a coarse-grained, kinematic-level framework that is modular, extensible, and designed to accommodate models at different levels of abstraction. Importantly, extensions that incorporate realistic neuromechanics or connectome-derived circuits can be readily integrated, provided they conform to the modular principles of the proposed behavioral architecture.

The authors do not cite figures in order or appearance, which makes it hard to read.

This has been corrected. Figures are now cited in the correct order throughout the revised manuscript.

I would explain the model in more detail in the main text. Currently, the model is introduced through Figure 1 in an abstract way. It is really hard to make the connection between this figure to the nuts-and-bolts of neuromechanics. And, I believe, for this paper, the details of the modeling matter and are not just technical points to be hidden in the appendix. The video (video 1) is not helpful.

We have restructured the Model section to provide more detail directly in the main text, moving explanations that were previously confined to the Appendix. This includes explicit description of the locomotory oscillator model, the intermittency module, and their empirical calibration. At the same time, we retained mathematical and implementation details in Materials & Methods to keep the reading flow accessible. Additionally, we expanded the caption of Video 1 and clarified in the text what it illustrates, making the video more informative.

Modeling choices lead to further weaknesses. While the model can replicate observed locomotory patterns, it does not fully explain the underlying neurobiological mechanisms that govern behavioral intermittency. For example, the crawl-bend interference mechanism, while capturing observed phase-dependent attenuation of turning, is implemented in a simplified, statistical manner rather than being derived from detailed neuromuscular dynamics. The intermittent locomotion model, which generates alternating runs and pauses, relies on log-normal distributed stridechains but does not explicitly model neural mechanisms responsible for switching between movement states.

We agree with this point. A fully mechanistic implementation of crawl-bend interference would require a detailed segmental neuromechanical model, which we deliberately refrained from integrating in order to keep the current study tractable and focused on a coarse-grained, kinematic-level description. Likewise, the intermittency module is currently based on data-fitted distributions of stridechains and pause durations, without explicit modeling of the neural mechanisms responsible for switching between these states. To our knowledge, these mechanisms remain unresolved, though alternative approaches have been suggested, for example, an artificial neural network model of intermittency (Sakagiannis et al., 2020). To ensure this limitation is transparent to the reader, we now explicitly state it in a newly added “Limitations of the study” subsection in the Discussion.

We also highlight that the behavioral architecture is designed to be extensible, so that future work may incorporate such mechanistic models when available, while preserving the modular framework.

I am curious about why the authors chose to model the mushroom body with much more realism than other modules.

We clarified that this choice was not due to a bias in modeling depth, but to demonstrate the modularity and flexibility of the architecture. The mushroom body (MB) model we integrated was developed in our previous work as a biologically realistic spiking neural network. By incorporating it into the current framework, we show that models of very different abstraction levels – from simple statistical oscillators to detailed spiking networks – can coexist and interact under the same architecture. This rationale is now explicitly stated in the Discussion.

Reviewer #2 (Recommendations for the authors):

The manuscript from Sakagiannis et al. proposes a novel model for locomotion and foraging in Drosophila. Their ambition is to make a unified model that will incorporate distinct layers of complexity to describe and predict the locomotor behaviour of a larva, during exploration, chemotaxis and even learning. The paper fails in doing so, starting with a rather interesting exploratory model and becoming less and less convincing as it progresses, with thinner (chemotaxis) and thinner (learning) experimental and theoretical support. The model for chemotaxis is extremely simplified compared to the work of other laboratories. The associative learning paradigm is taken from another paper from the same research group and is not sufficiently explained. In its current form, the paper is of very limited theoretical and practical value. The analysis is insufficient to judge the overall quality and scalability of the model. It is hard to know if the model could be adopted by others in the larval community more widely in other animals. Would it be flexible and robust enough to be used to model other behavioural conditions?

We appreciate this critical perspective. Our aim is not to present a final, fully parameterized model of all larval behaviors, but to introduce a flexible, modular behavioral architecture that integrates models at different levels of abstraction and can be expanded by the community. To support adoption, we have revised the manuscript to highlight the availability of the framework as a Python package (larvaworld), supplemented with documentation, tutorials, and code examples. This makes it easier for other researchers to reuse, extend, and test the architecture under additional behavioral conditions. We also explicitly refer to modeling studies that have adopted the proposed framework and the locomotory model itself.

Below, we address the reviewer’s points layer by layer.

(1) Exploratory behaviour. The strongest part of the paper. The authors propose a new method to analyse locomotion. They take into consideration the instantaneous linear and angular velocity. They assume the existence of two oscillators, which is really interesting. They incorporate the distribution of pauses duration and number of the strides. The incorporation of the strides is very exciting. They do not include handedness with has already been studied and incorporated in a mode for exploration they seem to have missed (Wosniack et al 2022). Figure 4 shows the dispersion. At first glance, it is very obvious that the model larvae do not behave like the animal. The distance they move from the centre is wider (Figure 4A). What is measured in dispersion (Figure 4B)? Just the distance travelled during 40s? A better measure of the similarities or differences between the model and real larvae would be interesting, such as analysing the Mean Square Displacement. Would the model be good if compared to the long-term exploratory behaviour from Sims et al. 2020, that the author previously used?

The authors should convince the readers that their model is better, or at least as good than the ones already available.

We thank the reviewer for these constructive suggestions. In the revised manuscript we now reference and discuss handedness, citing Wosniack et al. (2022, eLife), and highlight its potential role as an additional axis of individual variability. We also clarified the distance metrics used in Figure 4: dispersal denotes the Euclidean distance from the origin at the end of the trajectory, while pathlength denotes the cumulative distance travelled. Since larvae typically encounter the arena boundary within the first 40 seconds of exploration, dispersal is shown only over this interval.

With respect to the reviewer’s suggestion of using mean-squared displacement (MSD), we now explicitly describe the relation between dispersal and MSD. Dispersal is an individual-level displacement measure from which population-level metrics such as MSD can be directly derived.

Regarding long-term exploration, we agree that extended trajectories—as reported by Sims et al. (2020) over timescales of up to one hour—constitute a valuable complementary regime. Our experimental dataset is limited to 3-minute recordings in a bounded Petri dish, which constrains the accessible timescales of dispersal analysis. We now explicitly note in the Results that comparison to long-horizon datasets such as Sims et al. (2020) represents an important future direction that will require larger or unbounded arenas.

Together, these revisions strengthen the presentation of the exploration results and clarify how our model relates to established statistical measures of larval foraging behaviour.

(2) Chemotaxis. The chemotaxis model is so briefly explained in the result section that it is hard to understand. A modulation of the frequency and amplitude of lateral oscillator as a function of the concentration? The authors cannot differentiate between weathervaning and turning in this model (at least I can't understand how). What happened with the distribution of pauses and the directions of turns in Figure 5? The authors do not use real behavioural data to contract their model. How do we know that the parameters they have used reflect the larval behaviour? For example: what is the success rate for larvae to reach the area of high concentration? How close do they get? What is the length of the tracks from start to a target area of high concentration? Where are the calibration data for chemotaxis? This information is critical to understand the model, it needs to be shown in the result section. The authors mention an 8.9uM peak concentration. Of what?

The model is oversimplified in comparison with Davies et al. 2015 and it is not clear at all how it reflects the real chemotaxis, which is a rather complex behaviour.

We thank the reviewer for these detailed comments. In the revised manuscript we substantially expanded the description of the chemotaxis model. We now provide an explicit mathematical formulation of how odor concentration modulates the lateral oscillator through the quantity A0, which perturbs both the frequency and amplitude of bending according to the mechanism proposed by Wystrach et al. (2016). We additionally clarify that the motor layer - including the intermittency module and all parameters governing crawling, pausing, and turning - remains fully identical to the configuration calibrated on the exploration dataset; no refitting was performed for the chemotaxis condition.

To address the reviewer’s question regarding the distinction between weathervaning and head casting, we now explain that both behaviours emerge naturally from the same coupled-oscillator structure via stride-phase–dependent crawl–bend interference. High-amplitude headcasts occur during pauses when crawl-induced attenuation is lifted, whereas low-amplitude weathervaning arises during runs when the interference is active.

This unified mechanism eliminates the need for separate modules.

The chemotaxis experiments were implemented to qualitatively replicate the behavioural patterns described in Gómez-Marín et al. (2011, Fig. 1A–1F), and we now include explicit figure references in the captions. Because the present implementation is a proof of concept rather than a quantitatively calibrated chemotaxis model, we do not report success rates, approach distances, or track-length statistics, as these depend strongly on odorscape geometry and calibration against quantitative single-animal datasets that were not available for the current work. This clarification has been added to the text and is stated explicitly again in the Limitations section.

Finally, we now specify that the reported odor concentrations (e.g. 8.9,µM) follow the values used in Gómez-Marín et al. (2011), and we added the precise Gaussian function used to generate the odorscape in the Materials & Methods. Together, these revisions provide a clear and transparent account of the chemotaxis model and its scope.

(3) Associative learning paradigm. I assume that the authors intended to incorporate a bias in chemotaxis behaviour towards a particular odorant (CS) that would have been associated with a reward food (US). However the model works slightly differently, it is represented by an aversive and an appetitive gradient.

Theoretically, this is already an assumption (unless there is evidence for it, that should be referenced). It would be more conservative to have one neutral side and one appetitive (attractive) side. Second, the use of a mushroom body model, (even though it has already been published) to decide on the valence adds a layer of complexity that seems unnecessary. The learning process is different from the output process. Finally, the model intends to show us a "realist simulation of Drosophila locomotion" and we do not know how the larvae reach the right side during the test. It would be useful to have some comparison of the larval and model behaviour towards the preferred side.

In this last section, the objective of the research unweaves and falls short of its ambition.

We thank the reviewer for these helpful comments. In the revised manuscript we clarified that our implementation follows the standard larval conditioning protocol in which a rewarded odor (CS+) is tested against a neutral odor, not against an aversive one. The previously contradictory phrasing has been corrected, and the text now consistently reflects the established experimental procedure.

We further explain that the mushroom body (MB) model is included not in order to increase biological complexity in this section, but to demonstrate the flexibility of the proposed behavioral architecture: detailed circuit models and more abstract motor modules can coexist under the same framework. The MB model implements associative plasticity independently of any behavioral simulation, and its output - a scalar odor valence - is transformed linearly into an odor-gain parameter that modulates turning during the test phase. This separation between learning and behavioral output mirrors the logic of the biological system while keeping the overall architecture modular.

Regarding the reviewer’s request for insight into “how larvae reach the right side,” we note that standard group assays used in larval olfactory learning provide only population-level preference indices rather than detailed individual trajectories. Our comparison to empirical data therefore relies on these established preference indices, which the model successfully reproduces across training trials, including the characteristic saturation reported in Jürgensen et al. (2024). We now state explicitly that although the behavioral simulation does generate full trajectories for each virtual larva, the lack of corresponding experimental single-animal tracks precludes a direct trajectory-level comparison. This clarification has been added to the revised text.

Together, we believe that these revisions improve clarity and better situate the learning simulations within both the behavioral architecture framework and the constraints of available experimental data.

Reviewer #3 (Recommendations for the authors):

Figure 1a is very dense and I am struggling with the terms "reactive" and "basic" due to a general lack of clarity about the details of the model organization. For example, why do all of the sensory inputs point to turning proprioception? Why is proprioception two different things for turning and crawling? Why are some senses in light green while olfaction is in dark green? Why is feedback only from feeding, when crawling, head casting, and turning will change the sensory environment as well? Why is head casting not a behavioral module here? Why focus on following/being constrained by the "subsumption architecture paradigm" over a focus on the known literature and neuroanatomy?

We thank the reviewer for this careful inspection of Figure 1. In the revised version we improved both the figure and its caption, as well as the corresponding description in the text.

Specifically:

- The “basic” layer has been renamed the “motor” layer for clarity, and the caption has been expanded to better describe each component.

- The sensory inputs are now shown to target the motor layer as a whole, rather than just the proprioceptive component of turning.

- Each motor module is conceptualized as a sensorimotor loop (green-red), which explains why proprioception appears in both crawling and turning.

- The color coding has also been clarified: modules used in the current simulations are shown in darker shades, while others are faded.

- Sensory perturbations caused by body locomotion – as in the case of crawling and turning – are not depicted in the figure as feedback between modules. We make this more explicit in the caption. The signal from feeding to the above layers is neuromodulatory – as indicated by the purple arrowhead.

Finally, we explain that head casting and weathervaning are not modeled as separate modules, since both behaviors emerge from the coupled oscillator mechanism through crawl-bend interference. Our adherence to the subsumption architecture paradigm is motivated by its success in robotics and its conceptual alignment with hierarchical sensorimotor loops, but we have now made clearer that this is a simplifying framework rather than a rigid constraint.

"Stimulus free conditions" (line 102) don't really exist. Substrate and temperature will always be present, light will have some intensity, etc. Does this really refer to fictive behaviors?

We thank the reviewer for raising this point. In the revised manuscript we have removed the term “stimulus-free conditions” entirely to avoid the misleading implication that larvae experience no sensory input. We now explicitly describe these experiments as free exploration in the absence of navigation-guiding gradients, which accurately reflects the laboratory assay while avoiding any suggestion of fictive behavior. This terminology has been updated consistently throughout the text.

The first results section is closer to an introduction than the intro itself is, owing to its focus on the context of the work the paper actually does rather than a broad review of larval behaviors that are not considered within this work.

We believe the reviewer is referring to the “Model” section rather than the “Results.” The Model section is deliberately separated to outline the theoretical background of the behavioral architecture and to make explicit the general modeling assumptions, which explains why it cites previous work in detail. By contrast, the Introduction is intended as a brief overview of the broader larval behavioral repertoire, since the larva serves here as the case study for our framework. Presenting this repertoire is important because it defines the behaviors that populate the different layers of the architecture, even if only a subset of them is implemented in the simulations presented in this study.

While the model components are described in the modeling section, no question is actually discussed. What is the goal of this model?

This broader question is addressed in the public review section

"Crawler" and "turner" are inconsistently described. They are described as "modules" in Figure 1, but they seem more like behavioral primitives.

The specific terms "crawler" and "turner" refer to the computational modules, but correctly the reviewer points out that these generate the respective “crawling” and “turning” behavioral primitives. This has been made explicit in the Materials & Methods.

Do larva-larva interactions matter here?

In the revised manuscript we now state explicitly that larva–larva interactions are not included in the present simulations, as each virtual larva is modeled independently in accordance with the single-animal datasets used for calibration. We also point the reader to the Limitations section, where we note that although social interactions lie outside the scope of this study, the Larvaworld software package already supports tactile sensing and collision handling, enabling such interactions to be incorporated in future work.

The description of the locomotor system, with coupled oscillators between crawling frequency and bending is very empirical. Is this because of the 2-segment model effectively limiting peristalsis to a single segment? What are the limits of this approach?

The stride-phase–dependent modulation of bending amplitude was identified through kinematic analysis of full 12-segment larval datasets and is therefore independent of our later decision to implement a two-segment simplification. This means that the empirical relationship we describe should hold for any multisegment model, regardless of the reduced representation used in the present implementation. Generally, we performed our detailed empirical analyses with the goal to uncover statistical relations, which in turn were use for our data-driven coupled oscillator model in combination with the stochastic element of stride-chain and pause duration.

Line 190: The paper starts discussing experimental larva tracks. These experiments need to be described.

The reviewer probably refers to the dataset analysed in this study. This is a public dataset as described in the Dataset Description section in Materials & Methods, along with a description of the experiment per se.

The purpose of Figure 2 is not entirely clear. Several panels are not referenced in the text (F,G,H) and all panels are referenced extremely out of order. Figure 3 is similarly hard to follow for the same reasons of being referenced out of order. In fact, this section is largely duplicated by the "Model calibration" appendix, which I find to be much more clearly written and with more directly relevant figure panels.

In the revised manuscript, all panels of Figures 2 and 3 are now cited in the correct order, and their roles in the narrative have been clarified. Figure 2 is explicitly presented as a summary of the empirical kinematic analyses that motivate the structure of the locomotory model, while Figure 3 illustrates the corresponding model components. To avoid redundancy with the “Model calibration” appendix, we streamlined the main text and replaced duplicated descriptions with cross-references to the appendix, which contains the full methodological detail.

The data describe larvae behaving with a range of parameters, presumably both as individuals and across time. However, the models described seem to employ a population of larvae that shares a common best-fit parameter and the equations presented in the methods are all ordinary differential equations without noise or stochasticity. Where is the inter-individual variation coming from?

The reviewer is correct to point out the importance of variability. Our approach is agent-based, and we model populations of non-identical individuals rather than replicates of a single average larva. The simulated larvae retain variability across several parameters, capturing the combined range observed in the data. This was described in the original manuscript, and to avoid possible misunderstandings, we have now expanded the “Inter-individual variability” section in the Materials & Methods and, where appropriate, clarified this point elsewhere in the text.

The absolute orientation of trajectories in Figure 4A is not meaningful in your model. I suspect it would be more informative to show aligned trajectories in order to better visually assess the behavioral similarity. Also, the biological experiment needs to be described here. Time crawling seems to not be a great fit, although the peaks are fairly well aligned. Do you have thoughts on why this is?

In Figure 4A, which is intended as a visual comparison between experimental and simulated trajectories, the experimental tracks were transposed so that all starting points coincide at the center of the arena. As the reviewer notes, they were not rotated to a common axis, since our subsequent analysis focuses on spatial dispersal rather than directional alignment. The description of the experimental dataset has been clarified in the revised text.

The reviewer is also correct that the distribution of time spent crawling is narrower in the simulations than in the experimental data. This reflects the fact that in the present study only three crawling-related parameters were sampled to generate inter-individual variability, and time spent crawling was not among them. We deliberately chose to assess how well the model reproduces distributions for behavioral metrics that were not explicitly fitted or parameterized. This point has now been made explicit in the revised manuscript.

How did you assess the agreement of chemotaxis results with Gomez-Martin et al? It would be useful for the comparison to be made explicit within this paper, as well. How were the chemotaxis parameters fit?

The agreement between experimental and simulated chemotaxis was assessed only qualitatively, as we did not perform quantitative locomotor analyses on chemotaxis datasets. For these simulations we used the same motor layer, including all its modules, as calibrated in the free-exploration condition (Fig. 4). The only additional adjustment was a single weighting parameter that translates the appetitive or aversive valence of odor sources into modulatory input for the bending module. This parameter was tuned manually using a visual criterion of performance, to ensure that both attractive and aversive chemotaxis were observable. We now make explicit in the text that for more complex simulations we retain the calibration obtained in simpler conditions and build upon it, rather than re-optimizing the model. Moreover, we now provide reference to the exact figure numbers in Gomez-Martin et al. for direct visual comparison also of the perceived concentration metrics in our Figure 5E&F where experimental and simulated data show a very good correspondence.

Similarly, what are the key parameters for the mushroom body model and how did you fit their relationship to behavior? Was there actually feedback between the behavior of the larva and the training or was the SNN only used to generate the odor gain constant?

The reviewer is correct to highlight this point. In the present study the mushroom body model was simulated independently to generate the odor-specific behavioral bias. This output was then translated into an odor gain constant, which served as input for the subsequent behavioral simulations of odor preference. There was no closed-loop interaction between the larval behavior and the training of the spiking network in this version. Establishing such a closed-loop connection is part of our future goals.

It is unclear where feeding (as introduced in Figure 1) entered into the work presented, if at all.

The reviewer is correct that the feeding module does not play a role in the present study. It was included in the behavioral architecture for completeness and because it is already implemented in the larvaworld package (see Sakagiannis et al., 2024). We have clarified this in the revised text.

"During pauses, the input to the crawler module I_c = 0 and therefore forward..." The equations presented for the crawler module do not contain I_c.

The inconsistency regarding the crawler module input has also been corrected. The equations now explicitly include the tonic input parameter, making them consistent with the descriptive text and our model implementation.

Larva do more than crawl forward, they can also hunch up, head cast with their head in the air, dig, crawl backward, roll, and other behaviors. Because the individual modules in this framework have been defined as coupled oscillators, how would you decide to implement such aspects? At what point does the oscillator approach break down? In this model, how does the larva decide whether to bend left or right, and how is that affected by the environment or internal state? Can a larva bend in the same direction twice in a row?

The intermittent coupled-oscillator model presented here does not attempt to cover the full larval repertoire, such as hunching, digging, backward crawling, or rolling. Nor does it explicitly implement handedness as a directional bias. Nevertheless, the framework already allows for sequences of repeated turns: from a stationary position a larva can execute successive bends of varying amplitude, which may occur in the same direction, mimicking repeated head casts to one side.

Extending the model to include additional locomotor primitives would require the development of new modules, which could expand the basic locomotor layer either alongside or in place of the current lateral oscillator module. As noted in the manuscript, the modules implemented here are not intended as definitive but as placeholders that demonstrate how the architecture can integrate more elaborate models in the future. In this context, future directions include introducing handedness as part of inter-individual variability and enriching the behavioral repertoire with additional modules to capture the broader range of larval actions.

I was not able to install `larvaworld` either through pip in a fresh environment on OS X 15 and various Python versions between 3.8 and 3.12. I ran into a range of issues, from `tables` (which is understandable) to issues installing the old NumPy in Python 3.12 where `setuptools` is no longer included. The packaging should be made more robust, or the working environment could be better defined. For example, the version pinning of dependencies seems much more strict than I would expect for a user-focused Python library, particularly with out-of-date versions of core tools like NumPy.

We thank the reviewer for going to length and testing the implementation and pointing these issues to us. We have recently updated the package (version 2.0.1, November 2025) to improve installation robustness, relaxed unnecessary dependency pinning, and provided an environment specification to facilitate reproducibility. The revised manuscript directs users to recently updated installation instructions.

Automated testing for python versions 3.10-3.11 for MacOS, Windows and Ubuntu is already implemented. Unfortunately we have not yet tried it on OS X15. Please post any issues on the larvaworld’s github page : https://github.com/nawrotlab/larvaworld.

Associated Data

    This section collects any data citations, data availability statements, or supplementary materials included in this article.

    Data Citations

    1. Thoener J, Schleyer M. 2021. Locomotion of naive Drosophila larvae. GIN. [DOI]

    Supplementary Materials

    MDAR checklist

    Data Availability Statement

    The current manuscript is a computational study, so no data have been generated for this manuscript. Data analysis, behavioral modeling, and simulations have been carried out using the larvaworld Python package: https://pypi.org/project/larvaworld/.

    The following previously published dataset was used:

    Thoener J, Schleyer M. 2021. Locomotion of naive Drosophila larvae. GIN.


    Articles from eLife are provided here courtesy of eLife Sciences Publications, Ltd

    RESOURCES