Open Biology
Open AccessResearch articles

High-resolution analysis of individual Drosophila melanogaster larvae uncovers individual variability in locomotion and its neurogenetic modulation

Michael Thane

Michael Thane

Department Genetics of Learning and Memory, Leibniz Institute for Neurobiology, Magdeburg, Germany

Department of Simulation and Graphics, Otto von Guerike University, Magdeburg, Germany

Contribution: Conceptualization, Formal analysis, Methodology, Software, Visualization, Writing – original draft

Google Scholar

Find this author on PubMed

,
Emmanouil Paisios

Emmanouil Paisios

Department Genetics of Learning and Memory, Leibniz Institute for Neurobiology, Magdeburg, Germany

Contribution: Conceptualization, Formal analysis, Methodology, Software, Writing – original draft

Google Scholar

Find this author on PubMed

,
Torsten Stöter

Torsten Stöter

Combinatorial NeuroImaging Core Facility, Leibniz Institute for Neurobiology, Magdeburg, Germany

Contribution: Methodology, Software, Writing – original draft, Writing – review & editing

Google Scholar

Find this author on PubMed

,
Anna-Rosa Krüger

Anna-Rosa Krüger

Department Genetics of Learning and Memory, Leibniz Institute for Neurobiology, Magdeburg, Germany

Institute of Biology, Free University of Berlin, Berlin, Germany

Contribution: Data curation, Formal analysis, Investigation

Google Scholar

Find this author on PubMed

,
Sebastian Gläß

Sebastian Gläß

Department Genetics of Learning and Memory, Leibniz Institute for Neurobiology, Magdeburg, Germany

Contribution: Formal analysis, Methodology, Software

Google Scholar

Find this author on PubMed

,
Anne-Kristin Dahse

Anne-Kristin Dahse

Division of General Biochemistry, Rudolf Schönheimer Institute of Biochemistry, Medical Faculty, Leipzig University, Leipzig, Germany

Contribution: Data curation, Investigation

Google Scholar

Find this author on PubMed

,
Nicole Scholz

Nicole Scholz

Division of General Biochemistry, Rudolf Schönheimer Institute of Biochemistry, Medical Faculty, Leipzig University, Leipzig, Germany

Contribution: Funding acquisition, Supervision, Writing – review & editing

Google Scholar

Find this author on PubMed

,
Bertram Gerber

Bertram Gerber

Department Genetics of Learning and Memory, Leibniz Institute for Neurobiology, Magdeburg, Germany

Institute of Biology, Otto von Guericke University Magdeburg, Magdeburg, Germany

Center for Behavioral Brain Sciences, Magdeburg, Germany

Contribution: Conceptualization, Funding acquisition, Supervision, Writing – review & editing

Google Scholar

Find this author on PubMed

,
Dirk J. Lehmann

Dirk J. Lehmann

Department of Simulation and Graphics, Otto von Guerike University, Magdeburg, Germany

Department for Information Engineering, Faculty of Computer Science, Ostfalia University of Applied Science, Brunswick-Wolfenbuettel, Germany

Contribution: Methodology, Supervision, Visualization, Writing – review & editing

Google Scholar

Find this author on PubMed

and
Michael Schleyer

Michael Schleyer

Department Genetics of Learning and Memory, Leibniz Institute for Neurobiology, Magdeburg, Germany

[email protected]

Contribution: Conceptualization, Data curation, Formal analysis, Funding acquisition, Project administration, Supervision, Visualization, Writing – original draft, Writing – review & editing

Google Scholar

Find this author on PubMed

Abstract

Neuronally orchestrated muscular movement and locomotion are defining faculties of multicellular animals. Due to its simple brain and genetic accessibility, the larva of the fruit fly Drosophila melanogaster allows one to study these processes at tractable levels of complexity. However, although the faculty of locomotion clearly pertains to the individual, most studies of locomotion in larvae use measurements aggregated across animals, or animals tested one by one, an extravagance for larger-scale analyses. This prevents grasping the inter- and intra-individual variability in locomotion and its neurogenetic determinants. Here, we present the IMBA (individual maggot behaviour analyser) for analysing the behaviour of individual larvae within groups, reliably resolving individual identity across collisions. We use the IMBA to systematically describe the inter- and intra-individual variability in locomotion of wild-type animals, and how the variability is reduced by associative learning. We then report a novel locomotion phenotype of an adhesion GPCR mutant. We further investigated the modulation of locomotion across repeated activations of dopamine neurons in individual animals, and the transient backward locomotion induced by brief optogenetic activation of the brain-descending ‘mooncrawler’ neurons. In summary, the IMBA is an easy-to-use toolbox allowing an unprecedentedly rich view of the behaviour and its variability of individual larvae, with utility in multiple biomedical research contexts.

1. Introduction

Understanding the neuronal control of movement and locomotion, that is of how we do what we do, is an important and rewarding task for basic research in the behavioural and neural sciences. Furthermore, such an understanding can inspire the development of medical and technical applications, for example regarding gait analysis for medical diagnosis, or bioinspired robotics [13]. A comprehensive analysis of neuromuscular control in humans remains a formidable challenge, however, not least because of the complexity of our brains and bodies, complexity that is scarcely less in other mammals. In the past few years, the larva of the fruit fly Drosophila melanogaster has emerged as a model organism for studying many aspects of these processes [4]. The combination of a rich toolbox for cell-specific transgenic manipulation, a nervous system of only about 10 000 neurons, and the availability of an electron-microscope-based synaptic connectome allows neuronal processes to be studied in unrivalled detail. The utility of the larva for behavioural neuroscience has been further aided both by its relatively simple body and the relatively moderate level of complexity in its locomotion. Locomotion in Drosophila larvae can, simplifying somewhat, be described as consisting of periods of relatively straight runs characterized by peristaltic waves of muscle contraction along the body wall that alternate with occasional lateral head movements [414]. This results in a zig-zagging pattern of locomotion towards their target, similarly observed in adult flies and mosquitoes.

Most studies of locomotion in larval Drosophila either use en-masse, group assays and measurements aggregated across individual animals, or they need to measure single animals one at a time, which practically precludes larger-scale analyses. It has thus remained difficult to come to grips with the causes and consequences of the variability in locomotion both between and within individual animals (henceforth called inter-individual and intra-individual variability, respectively). Yet individual idiosyncrasies in behaviour are described across the animal kingdom, including Drosophila [1517]. Such inter-individual variance in behaviour may be regarded not as noise, but as an inroad to studying the determinants and implications of such variability and (if these are heritable) as raw material for natural selection. Likewise, intra-individual variability in behaviour is essential to initiate operant learning, that is to generate novel actions capable of bringing about desired outcomes. To study behavioural differences within and across individuals efficiently, we need to be able to (i) observe behaviour in individual animals, (ii) measure large numbers of animals in a short period of time and (iii) manipulate the candidate cellular and molecular substrates of the observed behaviour easily and precisely. An increasing number of video-tracking approaches have been developed in the past decade to facilitate such analyses in larval Drosophila. Some of these were designed to track the behaviour of individually assayed animals, e.g. [1820]. These usually provide a very high temporal and spatial resolution, but are extravagantly time-consuming if high sample sizes are required. Other approaches were designed to track groups of animals (e.g. [2129]). These focus on the average behaviour of groups of animals and thus do not allow for individuals to be followed. More recent approaches have tried to combine the advantages of both types of tracking [30,31]. The major challenge in these cases is that individual Drosophila larvae look very much alike. As a result, when two larvae collide, their identity is lost, resulting in a multitude of separated tracks and no opportunity for the experimenter to disentangle which tracks belong to which of the animals. Two different strategies have been followed in tackling this problem: one relies on the parallel tracking of many separated individual animals [30]; the other tries to resolve the collisions between larvae and thus to keep track of the identity of individual larvae within a group of animals [31] (for an earlier approach not specific to Drosophila larvae, see [32]; for a similar approach in Caenorhabditis elegans, see [33]). The latter solution is so far not implemented in any ready-to-use tracking software. The first approach is suitable to track and analyse high numbers of individual animals, but has specific requirements regarding the physical setup for video-recording, and therefore requires extensive redesigns of established behavioural assays in order to be used. We follow a different approach by starting from an established standard behavioural assay and developing a tracking solution that works for that assay and that non-expert users can easily implement in their research programmes using that assay or its derivatives.

Here, we present the IMBA. It consists of the IMBAtracker and the IMBAvisualizer. Together, these can track and analyse the behaviour of individual larvae within groups. They allow collisions to be resolved between individual larvae using a combination of statistical and computational approaches that can be applied to videos obtained by non-expert users in standard experimental assays. They do not require any specific hardware beyond a camera and stable lighting, and can therefore be easily applied to various derivatives of these standard behavioural assays, including ones that are commonly used for olfactory, gustatory or visual choice [3438], or associative learning [3941]. We further show the utility of the IMBA as a research tool by deepening our insights into the modulations of behaviour by associative training, by discovering a novel, complex locomotion phenotype in mutants of an adhesion G protein-coupled receptor gene (Latrophilin/Cirl) [42] and by studying the effects of repeatedly activating dopamine neurons (as covered by the TH-Gal4 driver) on locomotion. The utility of the IMBA is further demonstrated for patterns of locomotion it was not originally designed to study, using as an example the backward movements induced by optogenetic activation of the so-called ‘mooncrawler’ neurons (as covered by the R53F07-Gal4 driver). In all these cases, we pay particular attention to the inter-individual and intra-individual variability in behaviour.

2. Results

In this study, we investigate the behaviour of individuals within groups of Drosophila larvae. Our approach to the problem of losing track of individual identities upon collisions involves two critical steps: first, for our analysis we only considered tracks that were more than half the length of the recorded video, so we were sure that no two tracks in our analysis belonged to the same individual animal; second, we tried to stitch together tracks from the same individual across collisions in order to maximize the number of individual animals that we could include within our analysis. To this end, we employed a combination of a computational approach modelling the shape of larvae and keeping their identities during a collision, and a statistical approach comparing larvae before and after a collision. We used the shape model approach for short collisions involving either two larvae or a single larva briefly touching a larger assembly, and the statistical approach for longer collisions involving either two or three larvae. We did not attempt to resolve collisions of larger groups as the success rate was extremely low in preliminary experiments (not shown). For more details, see the Material and methods section.

2.1. The IMBA allows the behaviour of individuals within groups to be studied

In order to evaluate our approach, we compared the results with manual assessments of collisions by an experienced experimenter. In 48 videos with approximately 20 larvae each (for an example video, see electronic supplementary material, movie S1), 1844 collisions were found by the experimenter. We attempted to resolve 1531 by means of the IMBAtracker, and of these, 1511 were correctly resolved (electronic supplementary material, figure S1a). In total, 83.7% of all tracked data belonged to tracks that fulfiled our criterion of being at least half the length of the video after collision resolution and were used in the analysis (electronic supplementary material, figure S1b–d). Notably, without the collision resolution implemented, this fraction dropped to 46.7%, demonstrating the importance of this processing step (electronic supplementary material, figure S1d).

To further evaluate IMBAtracker, we applied it to videos from different sources: (i) to videos gathered with the same setup but with smaller Petri dishes (9 cm diameter instead of 15 cm), used for figures 813, (ii) to videos gathered at the University of Leipzig with an independently developed setup, used for figures 57, (iii) to videos of the dataset ‘LCD2A’ published at www.uni-muenster.de/Geoinformatics.cvmls/media/datasets.shtml, based on [43], and (iv) to videos published along with [26]. The videos from all these sources could successfully be tracked. Electronic supplementary material, movies S2–S5 show the annotated output of the IMBAtracker for one example of each video type, and demonstrate the range of video types and qualities handled by the IMBAtracker. The dataset (iv) was recorded with the popular FIMtrack setup [25,43] and provides short videos, each depicting a collision of two larvae, sorted into three classes of increasing complexity of the collision. We manually assessed the output of the IMBAtracker on these videos and found high rates of correct assessments in all three classes (electronic supplementary material, figure S1e). This demonstrates that the IMBAtracker is able to reliably track and resolve collisions between larvae.

In the next step, we developed an R-based shiny application to analyse and visualize the behaviour of these individual larvae. This application, called the IMBAvisualizer, calculates a total of 95 attributes for each animal that can be explored and visualized in an interactive manner (for all attributes used in this study, see tables 14). For an overview of the process, see electronic supplementary material, figure S2. Both the code and a full documentation of this application can be accessed via GitHub at https://github.com/mthane/IMBA and will be regularly updated and further developed in the future.

Table 1. Description of all basic body attributes used in this study.

name unit description random forest
spine points (x, y) mm The 12 spine points of the animal from tail to head. The first spine point is the position of the rear end and the twelfth spine point indicates the front end of the animal. All spine point positions are convoluted by 0.3 s. no
contour points (x, y) mm The 24 contour points of the animal's body. All contour point positions are convoluted by 0.3 s. no
body length mm The sum of distances between all 12 spine points of the animal. no
head vector (x, y) The vector between the ninth and the eleventh spine point. no
tail vector (x, y) The vector between the second and the sixth spine point. no

Table 2. Description of all bending- and head cast-related behavioural attributes used in this study.

name unit description random forest
bending angle ° The angle between the larva's tail vector and a vector from the middle of the larva to its head. Positive values indicate the larva bending to the left, negative values bending to the right. yes
absolute bending angle ° The absolute value of the bending angle. yes
CV absolute bending angle The coefficient of variation (CV) of the absolute bending angle, calculated as 100×s(ABA)/ABA¯, where s(ABA) is the standard deviation, and ABA¯ is the mean of the absolute bending angle. yes
HV angular speed ° s−1 The angular speed of the head vector (HV). Positive values indicate movement of the head to the right, negative values to the left. yes
absolute HV angular speed ° s−1 The absolute value for the HV angular speed. yes
CV absolute HV angular speed The coefficient of variation (CV) of the absolute HV angular speed, calculated as exemplified above for the absolute bending angle yes
HV angular acceleration ° s−2 The angular acceleration of the head vector (HV). Positive values indicate movement of the head to the right, negative values to the left. yes
TV angular speed ° s−1 The angular speed of the tail vector (TV). Positive values indicate movement of the tail to the right, negative values to the left. yes
absolute TV angular speed ° s−1 The absolute value for the TV angular speed. yes
CV absolute TV angular speed The coefficient of variation (CV) of the absolute TV angular speed, calculated as exemplified above for the absolute bending angle. yes
TV angular acceleration ° s−2 The angular acceleration of the tail vector (TV). Positive values indicate movement of the tail to the right, negative values to the left. yes
IS angle ° The inter-step (IS) angle indicates how much the orientation of the animal changes within one cycle of peristaltic forward movement. It is defined as the angle between a larva's head vector at one step minus the head vector at the previous step. A step is defined as the local maximum of the tail forward velocity during runs. Positive values indicate that the larva changes its orientation to the left, negative values that it changes its orientation to the right. yes
absolute IS angle ° The absolute value of the IS angle. yes
CV absolute IS angle The coefficient of variation (CV) of the absolute IS angle, calculated as exemplified above for the absolute bending angle. yes
HC rate HC s−1 The number of head casts (HC) per second. yes
HC angle ° The head cast (HC) angle indicates how much the orientation of the animal changes upon each HC. It is defined as the difference between the bending angle at the end and the beginning of the HC. Positive values indicate that the larva changes its orientation to the left, negative values that it changes its orientation to the right. yes
absolute HC angle ° The absolute value of the HC angle. yes
CV absolute HC angle The coefficient of variation (CV) of the absolute HC angle, calculated as exemplified above for the absolute bending angle. yes

Table 3. Description of all speed-related attributes used in this study.

name unit description random forest
midpoint speed (mm) mm s−1 The speed of the larva's midpoint, independent of direction. The midpoint is defined as the sixth spine point. no
midpoint speed (body length) bl s−1 The speed of the larva's midpoint (measured in body lengths (bl) per second), independent of direction. no
CV midpoint speed The coefficient of variation (CV) of the midpoint speed, calculated as exemplified above for the absolute bending angle. no
head forward velocity bl s−1 The velocity of the larva's head point in a forward direction, that is in the direction of the head vector. yes
CV head forward velocity The coefficient of variation (CV) of the head forward velocity, calculated as exemplified above for the absolute bending angle. yes
tail forward velocity bl s−1 The velocity of the larva's tail point in a forward direction, that is in the direction of the tail vector. yes
CV tail forward velocity The coefficient of variation (CV) of the tail forward velocity, calculated as exemplified above for the absolute bending angle. yes
IS distance (mm) mm The inter-step (IS) distance measures the distance of the larva's midpoint between two steps. A step is defined as the local maximum of the tail forward velocity during runs. no
IS distance (body length) bl The inter-step (IS) distance, measured in body lengths (bl). yes
CV IS distance The coefficient of variation (CV) of the IS distance, calculated as exemplified above for the absolute bending angle. yes
IS interval s The inter-step (IS) interval measures the time between two steps. A step is defined as the local maximum of the tail forward velocity during runs. yes
CV IS interval The coefficient of variation (CV) of the IS interval, calculated as exemplified above for the absolute bending angle. yes
IS speed (mm) mm s−1 The average midpoint speed between two steps. no
IS speed (body length) bl s−1 The average midpoint speed between two steps, measured in body lengths (bl) per second. yes
CV IS speed The coefficient of variation (CV) of the IS speed, calculated as exemplified above for the absolute bending angle. yes
distance travelled bl The distance of the complete path a larva travels during the observation period. yes
distance from start point bl The maximal distance a larva reaches from its starting point during the observation period. The starting point is the location of the larva when it is first identified by the tracker. yes

Table 4. Description of all odour-related attributes used in this study.

name unit Description Random Forest
bearing angle ° The angle between the larva's tail vector and a vector from the tail to the position of the odour source. Positive values indicate that the odour is to the right, negative values that it is to the left. no
absolute bearing angle ° The absolute value of the bearing angle. Values below 90° indicate that the larva is oriented towards the odours source, above 90° that it is oriented away. no
heading angle ° The angle between the larva's head vector and a vector from spine point 9 to the position of the odour source. Positive values indicate that the odour is to the right, negative values that it is to the left. no
absolute heading angle ° The absolute value of the heading angle. Values below 90° indicate that the larva's head is oriented towards the odours source, above 90° that it is oriented away. no
HC rate-modulation The head cast rate while heading away from the odour minus the HC rate while heading towards the odour, divided by the sum of both HC rates. Positive values indicate that the larva made more HCs while heading away, negative values that the larva made more HCs while heading towards the odour source. no
HC reorientation ° The absolute heading angle after an HC minus before the HC. Positive values indicate that the larva changes its orientation towards the odour source, negative values that it changes its orientation away from it. no
IS speed-modulation The IS speed while heading towards the odour minus the IS speed while heading away from the odour, divided by the sum of both IS speeds. Positive values indicate that the larva was faster while heading towards, negative values that the larva was faster while heading away from the odour source. no
distance from odour source mm The distance of a larva from the odour source. no

The locomotion of Drosophila larvae has been studied in detail in the past decade [57]. In brief, the locomotion can be described as sequences of run phases, consisting of relatively straight, forward peristaltic movement and reorientation manoeuvres, consisting of lateral head casts (HCs), which are usually associated with a strong reduction in speed and are followed by changes in direction (figure 1a) [8]. Accordingly, we first defined HC phases by the above-threshold angular velocity of the animal's head vector (HV) (figure 1b,c) (for details, see the Material and methods section). Animals were considered to be in a run phase whenever they were not in a HC phase. A period of 1.5 s before and after each HC was excluded from the run phases to prevent the potential effects of HCs on run behaviour. All these definitions are in line with our previous work [28,44]. For a more detailed analysis of run periods, we defined the cycles of peristaltic movement by means of the animal's forward velocity (figure 1d). Each local maximum of forward velocity during a run was defined as one ‘step’, with the period between two steps (inter-step, IS) capturing one complete cycle of peristaltic movement (for a similar approach, see [19]).

Figure 1.

Figure 1. Principles of the analysis. (a) The track of the midpoint of a sample larva. Green and red dots indicate left and right HCs, respectively. The arrow head indicates the end of the track. (b) (left) 12 equidistant spine points are determined along the spine of each larva, including the back and front ‘tip’ (spine points 1 and 12, respectively). The second spine point from the front (i.e. number 11) is taken as indicative of the head, the second point from the rear as indicative of the tail (i.e. number 2). (right) A head vector (HV) is determined from spine points 9–11, and a tail vector (TV) from spine points 2–6. (c) The angular speed of the head vector of the sample larva displayed in (a). Negative values indicate movement to the left, positive values movement to the right. A HC is detected when the HV angular speed exceeds a threshold of ±35° s−1 (stippled lines). In this and the following figures, left and right HCs are indicated by green and red shadings, respectively. (d) The forward velocity of the tail, in body lengths per second (bl s−1), of the sample larva displayed in (a). During runs, the velocity oscillates regularly. Each oscillation marks one cycle of peristaltic forward movement. Therefore, we define each peak of the tail forward velocity during runs as one ‘step’, indicated by grey lines in this and analogous figures. During HCs, the regular forward movement is stopped. Therefore, 1.5 s before and after each HC, no steps are detected.

2.2. Attributes of basic locomotion in larvae are variable across individuals

On the basis of these observations, and considering the innate, i.e. experimentally naive, behaviour of 875 animals in an odour gradient, we determined a set of six behavioural attributes to describe the basic locomotion of larvae: the IS speed, indicating the average speed across all peristaltic cycles (figure 2a); the IS distance, indicating the average size of the steps (figure 2b); the IS interval, indicating the average time between two steps (figure 2c); the absolute bending angle, indicating how much the body of a larva was bent throughout the whole observation period (figure 2d); the HC rate, indicating how many HCs an animal performed per second (figure 2e); and the absolute HC angle, indicating the average size of an animal's HCs (figure 2f). To determine the variability in each behavioural attribute, we calculated the coefficient of variation (CV), which indicates the standard deviation as a percentage of the mean and allows the inter-individual variability to be compared across different behavioural attributes. The CV was lowest for the IS distance (15.6%) and highest for the HC rate (47.4%).

Figure 2.

Figure 2. Variability of basic locomotor attributes of individual Drosophila larvae. Six basic locomotor attributes were determined: (a) the inter-step (IS) speed (i.e. the average speed of each larva's midpoint during runs), (b) the IS distance (i.e. the average distance travelled within one peristaltic cycle for each larva), (c) the IS interval (i.e. the average time required for one peristaltic cycle for each larva), (d) the absolute bending angle (i.e. how much each larva was bent throughout the observation period), (e) the HC rate (i.e. the number of HCs per second of each larva) and (f) the absolute HC angle, measuring the average size of each larva's HCs. Displayed are histograms of each behavioural attribute per individual, together with the coefficient of variation (CV), which indicates the standard deviation of the attribute, divided by its mean, across all individuals. (g) Three sample tracks of individuals showing different patterns of behaviour: (top) a stretch of relatively straight-forward locomotion, followed by a series of rather large HCs and turns, (middle) a stretch of curved forward locomotion, flanked by HCs, (bottom) continuous, small HCs. (h) Absolute HC angles of the top sample individual from (g) range from close to zero up to 60°. (i) The CV of each attribute within each individual animal (box plot), and across animals (blue diamonds). The median is displayed as the middle line, the 25% and 75% quantiles as boxes and the 10% and 90% quantiles as whiskers. The underlying source data can be accessed in electronic supplementary material, source data file S1. ‘bl’, individual body lengths; ‘bl s−1’, body lengths per second.

One important reason for variability across animals is known from previous studies: the size of animals [19]. We therefore investigated the impact of animals’ size on the six behavioural locomotion attributes and found that both IS speed and IS distance were correlated with the body length of a larva, whereas other attributes were not affected (electronic supplementary material, figure S3). This finding is in line with previous work [19]. We therefore decided to correct for the body length in all following analyses by dividing any distance measured by the average body length of the individual larva in question. Distances are reported in body lengths (bl), speeds and velocities in body lengths per second (bl s−1).

2.3. Bending and head-casting behaviour is more variable within individuals than peristaltic forward locomotion

After investigating the inter-individual variability, we explored the intra-individual variability in behaviour (figure 2gi). We found that attributes related to the peristaltic forward movement such as the IS speed, IS distance and IS interval were much less variable than attributes associated with directional changes such as the absolute bending and HC angles (figure 2i; as the HC rate is calculated as a single value per individual it is excluded from this analysis). This finding suggests that peristaltic forward movement is a highly stable, regular behaviour with little variation, whereas directional changes are much more variable. Interestingly, the directional changes, but not the peristaltic forward movement, were much more variable within each individual than across individuals (figure 2i).

As animals in this dataset were exposed to an odour source, it is conceivable that their behaviour, in particular the variability in their directional changes, may be affected by the individuals’ distance from the odour as well as their orientation with respect to the odour. To account for these potential effects, we analysed the animals’ behaviour separately for low and high distances from the odour source (below and above 60 mm, respectively) and found the same pattern of results, with low variability for the IS speed, IS distance and IS interval, and high variability for the absolute bending and HC angles (electronic supplementary material, figure S4a,b). Likewise, animals oriented towards the odour source (defined as an absolute bearing angle of below 90°) and animals oriented away from the odour source (absolute bearing angle of above 90°) showed the same result (electronic supplementary material, figure S4c,d). Finally, we tested experimentally naive animals in absence of any odour source and found once more the same result (electronic supplementary material, figure S4e).

2.4. Attributes of peristaltic forward locomotion are stable over time within individuals

Next, we wondered how stable the behaviour of individual animals was over time. To this end, we determined each of the six behavioural attributes for each individual in the first and in the third minute of the 3 min video, and asked whether the behaviour in either minute would be correlated with that in the other. We detected mild correlations of the HC rate as well as the absolute bending and HC angles, and strong correlations of the IS speed, the IS distance and the IS interval (figure 3). This suggests that the behaviour of individual animals, though variable, was nevertheless remarkably consistent over time: the fastest animals in the first minute were also the fastest in the third minute, and the animals making the largest HCs in the first minute tended to do the same in the third minute. Next, we extended this analysis with respect to the distance from the odour source as well as the orientation to the odour source. We found strong correlations of the IS speed, IS distance and IS interval, and weaker correlations of the HC rate, the absolute bending and HC angles, when comparing behaviour while the animals were near or far from the odour source (electronic supplementary material, figure S5a–f). A similar result was observed when comparing behaviour while the animals were oriented towards or away from the odour source (electronic supplementary material, figure S5g–l). Finally, we probed for the stability of the behaviour over time using animals that were tested without any odour source. We detected overall weaker correlations in this dataset, with moderate correlations of the IS speed, IS distance and IS interval and virtually no correlations of the HC rate, the absolute bending and the absolute HC angle (electronic supplementary material, figure S6). Across all these analyses, attributes of peristaltic forward locomotion were more stable within individuals than attributes of directional changes.

Figure 3.

Figure 3. Basic locomotor attributes differ in how consistent they are over time. We determined each behavioural attribute for each individual independently for the first and the third minute of the video. We uncovered differences across behavioural attributes: we found moderate to strong correlations for (a) the IS speed, (b) the IS distance and (c) the IS interval, but only very weak, yet significant correlations for (d) the absolute bending angle, (e) the HC rate and (f) the absolute HC angle. Correlations are determined by SC tests. The underlying source data, as well as the results of the statistical tests, can be accessed in electronic supplementary material, source data file S1. bl, individual body lengths; bl s−1, body lengths per second.

To put the newly developed technology to the test, we next performed a number of experiments and detailed analyses to quantify modulations of locomotor behaviour. Our strategy was to start from a previously described or expected effect on locomotion, and challenge our software to uncover novel aspects to the data and deeper insights into the organization of locomotion.

2.5. Previous training modulates HC behaviour

First, we preformed detailed analyses of larval locomotion and its modulations in response to previous associative odour-sugar training. Such associative learning experiments are established for about two decades and used in many laboratories [3941,4547]. In brief, groups of larvae were trained to associate an odour with a sugar reward by repeated pairings and subsequently tested with the odour source on one side of the Petri dish. Other groups were trained in an explicit unpaired fashion, with odour and sugar being presented in separate trials (figure 4a). We compared the behaviour of those trained animals with experimentally naive animals tested in the same way. Please note that this ‘innate’ condition is the same data as used in figures 2 and 3. All three experiments were done in parallel for a previous study [28]. As expected, the three experimental conditions differ in their preference for the odour: after paired training the larvae approached the odour, after unpaired training they avoided it, and experimentally naive animals showed an intermediate preference (figure 4b).

Figure 4.

Figure 4. Previous associative training decreases activity and the variability of locomotion. (a) We compared the basic locomotor attributes of animals tested for their odour preference either naively (innate), or after paired or unpaired training with odour and a sugar reward. (b) After paired training, the animals were attracted the most, after unpaired training they were attracted least to the odour. Compared to trained larvae, naive larvae displayed (c) a higher IS speed, (d) a higher intra-individual variability (as indicated by the coefficient of variation (CV)) of the IS speed, (e) a higher IS distance, (f), a higher CV IS distance, (g) an unchanged IS interval, (h) and a higher CV IS interval. (i) The absolute bending angle was highest in naive animals and lowest after paired training. Compared to trained larvae, naive larvae showed (j) an unchanged CV absolute bending angle, (k) a higher HC rate, (l) an unchanged absolute HC angle and (m) a higher CV absolute HC angle. The median is displayed as the middle line, the 25% and 75% quantiles as boxes and the 10% and 90% quantiles as whiskers. Asterisks indicate significant differences in MW tests. The underlying source data, as well as the results of the statistical tests, can be accessed in electronic supplementary material, source data file S1. bl, individual body lengths; bl s−1, body lengths per second.

Previously, we investigated the modulations of behaviour by learning using group averages, and found that mainly two aspects of behaviour were modulated: the HC rate and the HC direction [28,44,48]. Here, we first replicated these results using individual animals (electronic supplementary material, figure S7). Specifically, we found that after paired training larvae (i) were on average more oriented towards the odour source than after unpaired training (electronic supplementary material, figure S7a), (ii) modulated their HC rate to be lower when heading towards the odour source and higher when heading away from it, compared to larvae after unpaired training (electronic supplementary material, figure S7b,c) (iii) and directed their HCs more towards the odour source than after unpaired training (electronic supplementary material, figure S7d). Experimentally naive animals displayed intermediate behaviour in all these cases. In addition, just like in previous studies, we found a non-significant trend of higher speed when heading towards the odour than when heading away from it after paired training (electronic supplementary material, figure S7e,f) [28,44].

Previous studies suggested that odour preference is controlled by a single motor output that integrates all innate and learned behavioural tendencies and causes constant left-right oscillations that are modulated by the presence of attractive or aversive stimuli such as trained odours [28,49,50]. According to this hypothesis, the behavioural attributes in our study, in particular the modulations of the HC rate and HC direction, should be strongly correlated with each other because they are materializations of the same motor output. We indeed found correlations in all three experimental conditions (electronic supplementary material, figure S7g). However, the correlations were rather weak overall, and relatively strongest between the modulations of the HC rate and HC direction. This rather weak correlation may suggest that the HC rate and HC direction, at least partially, can be modulated independently from each other.

2.6. Previous training reduces intra-individual variability

Next, we wondered how the six basic attributes of locomotion would be modulated by previous training. We found several small but significant differences between naive and trained animals, but only in one case a significant difference between animals after paired and unpaired training. Specifically, we found a decreased IS speed and IS distance, but not IS interval, in trained animals compared to experimentally naive animals (figure 4c,e,g). Furthermore, the intra-individual variability in these three attributes was reduced after training (figure 4d,f,h). Regarding the directional changes, naive animals displayed larger absolute bending angles and HC rates, as well as more variable absolute HC angles, compared to trained animals (figure 4i–m). Thus, experimentally naive animals were overall faster, stronger bent and made more HCs than trained animals, and the behaviour of naive animals was overall more variable than that of trained animals. The kind of training, paired or unpaired, made no difference in these aspects of locomotion behaviour, with the exception of a slightly lower absolute bending angle after paired than after unpaired training (figure 4i). Thus, previous training had two fundamental effects: it guided the animals towards or away from the trained odour source by modulating the respective behaviour in opposite ways after paired and unpaired training (electronic supplementary material, figure S7), and it reduced overall activity and variability independent of the kind of training received (figure 4).

2.7. The Cirl mutation reduces speed, bending and head-casting behaviour

After investigating the modulations by training, we performed detailed analyses of larval locomotion and its modulations upon genetic manipulation. To this end, we first chose the Latrophilin homolog Cirl, which is broadly expressed throughout the larval nervous system. Importantly, CirlKO mutant larvae are known to exhibit a strong locomotion deficit compared to wild-type animals as well as a genomic CirlRescue control [42], which has not, however, been studied in detail thus far.

We tracked and analysed the behaviour of 225 mutant and 147 rescue control larvae (figure 5). First, we confirmed the previously observed phenotype in crawling speed (figure 5b) [42]. Then, we analysed mutant and control animals regarding the six behavioural attributes described above. We found that the IS speed of the mutants was less compared to the control (figure 5c). Notably, a lower speed can come about in two ways: the larvae may make a slower peristaltic movement, resulting in a higher IS interval, or they may move less per peristaltic cycle, resulting in a lower IS distance. In the present case, we found only a small difference in the IS distance and a large difference in the IS interval (figure 5d,e). An even closer look into the run behaviour revealed that mutant animals are disturbed in their regular peristaltic cycle (see below). In addition to the expected phenotype in speed, we detected a reduced absolute bending (figure 5f), which was accompanied by a reduced HC rate, as well as a reduced absolute HC angle, in the CirlKO mutant larvae (figure 5g,h). That is, the mutants made fewer and smaller HCs, and were bending less. This suggests that mutant larvae are generally impaired in the bending of the body and in directional changes, possibly due to impaired functioning of the chordotonal organs. This result was surprising, as in a previous study a qualitative description of the CirlKO mutant locomotion implied an increased number of HCs [42].

Figure 5.

Figure 5. Genetic removal of Cirl reduces speed, bending and head-casting behaviour. We analysed basic locomotor properties of the CirlKO mutant and a CirlRescue control. (a) Representative sample tracks of five individual mutant and five control larvae. Green and red dots indicate left and right HCs, respectively. (b) The mutants displayed a strongly reduced midpoint speed compared to the control animals, confirming earlier results. (c) Also limited to run phases, the speed of mutants was reduced. (d) The IS distance was decreased and (e) the IS interval increased. (f) In addition, the mutants were on average bending less than the control animals, which manifested itself as a decreased (g) HC rate and (h) absolute HC angle. The median is displayed as the middle line, the 25% and 75% quantiles as boxes and the 10% and 90% quantiles as whiskers. Asterisks indicate significant differences in MW tests. The underlying source data, as well as the results of the statistical tests, can be accessed in electronic supplementary material, source data file S1. bl, individual body lengths; bl s−1, body lengths per second.

We also analysed the variability of each of the behavioural attributes within individuals, and observed increased variability in the IS speed and the IS interval in CirlKO mutant larvae compared to the controls (electronic supplementary material, figure S8).

2.8. A machine-learning approach reveals additional modulations of locomotion in CirlKO mutants

So far, our analysis had focused on the six basic locomotion attributes. But the loss of Cirl may affect behaviour in further ways. We therefore extended our analysis to include additional behavioural attributes, including angular velocities of the head and tail, accelerations of head and tail, as well as the coefficients of variation whenever applicable. A full list of the 30 behavioural attributes used can be found in tables 2 and 3. We then employed an unbiased, machine-learning-based approach to determine the most decisive attributes that differentiated mutants and control larvae. Random forests work by building a large number of decision trees, each of them trying to classify each individual animal according to either one genotype or the other. Importantly, random forests are not only useful in classifying data, but also in estimating which attributes are most important for the classification. For more details, see the Material and methods section. Applying this approach to our dataset, we were able to discriminate mutant and control larvae with an accuracy of 0.91 (figure 6a). Our assessment of which of the behavioural attributes were the most important in discriminating the behaviour of the two genotypes found that most of the top behavioural attributes were those already covered in our previous analysis: the IS speed, the IS interval, the absolute bending and HC angle, as well as the CV of the IS speed and the IS interval (figure 6b). This result confirmed our analyses so far. However, the random forest method also revealed four additional behavioural attributes: the distance travelled by the larva, the absolute angular speeds of the HV and tail vector (TV), as well as the CV of the forward velocity. A closer look revealed that the CirlKO mutant larvae travelled shorter distances (figure 6c), consistent with their reduced speed. Furthermore, the mutants had decreased absolute HV and TV angular speeds (figure 6d,e), consistent with the general observation of decreased bending and turning rates in the mutant. Finally, we did not observe any clear difference in intra-individual variability in the tail forward velocity between mutant and rescue (figure 6f). The last result implies that the random forest can use attributes to differentiate individual animals that do not display obvious differences when plotted as box plots.

Figure 6.

Figure 6. Discriminating CirlKO mutant and control animals by means of a random forest. We applied the random forest approach to discriminate CirlKO mutant animals from control animals. (a) Using a set of 30 behavioural attributes, the random forest was able to discriminate the two genotypes with an accuracy of 0.91. Displayed is the confusion matrix showing predicted versus actual affiliations of individual larvae to the two genotypes. The accuracy is calculated as the average of the two correct assignment rates (0.88 and 0.94). (b) The top ten most important behavioural attributes for discriminating the two genotypes with the random forest, sorted by the average importance rank across 10 repetitions of the random forest approach. (c–f) Four additional behavioural attributes found by the random forest were (c) the distance travelled by the larvae, (d) the angular speed of the head vector (HV), (e) the angular speed of the tail vector (TV), as well as (f) the coefficient of variation (CV) of the velocity of the tail in a forward direction. Displayed are the mean and the 95% confidence interval in (b), and the median as the middle line, the 25% and 75% quantiles as boxes and the 10% and 90% quantiles as whiskers in (c–f). Asterisks indicate significant differences in MW tests. The underlying source data, as well as the results of the statistical tests, can be accessed in electronic supplementary material, source data file S1. bl, individual body lengths.

To confirm that these top ten behavioural attributes were indeed the critical ones for describing the behaviour of CirlKO mutants and control animals, we ran the random forest algorithm again, but this time with only those ten attributes. The algorithm was able to discriminate the two genotypes with an accuracy of 0.91, just as high as with the full set of behavioural attributes. The ten attributes in question were thus fully sufficient to discriminate between the genotypes. In turn, when we ran the random forest algorithm with the remaining 20 attributes and excluding the top ten, the accuracy was still 0.83. This suggests some redundancy in our analysis, with multiple attributes providing related information such that the algorithm can employ substitute attributes to discriminate between the genotypes even when the most decisive attributes are excluded.

2.9. CirlKO mutant larvae have an altered rhythmic peristaltic cycle

In order to understand the origin of the CirlKO phenotype in crawling speed, we analysed the temporal behavioural patterns of individual animals (figure 7). Just like wild-type larvae (figure 1d), CirlRescue controls displayed a very regular rhythm in their forward velocity, indicated by a smooth, wave-like curve with local maxima of very similar heights that we detected as steps, and always one local minimum between two steps (figure 7a, top; electronic supplementary material, movie S6). CirlKO mutants, in contrast, regularly exhibited a pattern of two local minima with one very small local maximum between two steps (figure 7a, bottom; electronic supplementary material, movie S7), resulting in IS intervals that were longer and more variable than those of CirlRescue controls (figure 5e, electronic supplementary material, figure S8c). For further analyses, we defined each period between two steps with only one local minimum in the tail forward velocity as normal stepping, and each period with two local minima as ‘stumble’ stepping. A quantification revealed that stumble stepping was much more common in mutant than in control larvae, and that their proportion increased with increased IS intervals (figure 7b,c).

Figure 7.

Figure 7. CirlKO mutant larvae display an altered rhythmic peristaltic cycle. (a) The forward velocity of the tail in each one sample CirlRescue (top) and CirlKO larva (bottom). Periods of normal stepping are indicated by a coloured stripe on top of the curve, periods of stumble stepping by a hatched stripe. (b) Distribution of the IS interval between the normal and stumble stepping cycles for each genotype. (c) CirlKO individuals have a much lower ratio of normal stepping cycles (and thus a higher ratio of stumble stepping) than CirlRescue individuals. (d–i) Within-animal comparison of various behavioural attributes of mutant animals during normal or stumble stepping, and between-animal comparison between mutant and control animals during normal stepping. Periods of stumble stepping in control animals were omitted due to their low number. (d) IS speed, (e) IS distance, (f) IS interval, (g) absolute bending angle, (h) absolute head vector (HV) angular speed, (i) absolute tail vector (TV) angular speed. Displayed are the median as the middle line, the 25% and 75% quantiles as boxes and the 10% and 90% quantiles as whiskers. Asterisks indicate significant MW tests, hash symbols significant WS tests. The underlying source data, as well as the results of the statistical tests, can be accessed in electronic supplementary material, source data file S1. bl, individual body lengths; bl s−1, body lengths per second.

Next, we directly compared the animals’ behaviour specifically during normal stepping and stumble stepping. We found that larvae were slower and had longer IS intervals, but unchanged IS distances during stumble stepping compared to normal stepping (figure 7d–f). In other words, stumble steps took longer to complete, but were not larger. Moreover, neither the animals’ bending nor the angular speed of their HV was different between normal and stumble steps; only the angular speed of the TV was slightly decreased (figure 7g–i). This suggests that the phenotype in bending and turning that we observed was largely independent of the irregular stepping behaviour of the CirlKO mutants.

In summary, we found that the CirlKO mutants’ phenotype in crawling speed can be at least partially attributed to an unusual stepping pattern that causes a slower peristaltic forward locomotion, and a largely independent phenotype in bending and turning.

2.10. Optogenetic activation of dopamine neurons triggers stopping and bending

Next, we investigated how the acute activation of genetically defined sets of neurons affected the locomotion of individual larvae. First, we applied our unbiased approach to the behaviour of Drosophila larvae upon optogenetic activation of dopamine neurons. To this end, we used larvae that expressed the highly sensitive effector Channelrhodopsin2-XXL (ChR2-XXL) [51] in a broad subset of dopaminergic neurons, as defined by the TH-Gal4 driver strain (experimental genotype). Groups of larvae were allowed to move freely over a Petri dish for 30 s in darkness, followed by 30 s of blue light in order to trigger the activation of the dopaminergic neurons, and another 60 s of darkness. The behaviour of the animals was compared to that of heterozygous driver and effector controls that did not express ChR2-XXL (figure 8). Upon light stimulation, animals of all three genotypes increased their absolute bending, suggesting that this was a response to the sudden light. However, the experimental genotype did so to a much greater extent than the genetic controls, suggesting that this stronger reaction was caused by the activation of the dopaminergic neurons (figure 8b, electronic supplementary material, movie S8).

Figure 8.

Figure 8. Optogenetic activation of dopamine neurons triggers stopping and bending. Larvae of the experimental genotype (TH > ChR2-XXL), the driver control (TH/+) and the effector control (+/ChR2-XXL) were recorded during free locomotion for 30 s in darkness, followed by 30 s of light stimulation and 60 s of darkness. (a) Sample tracks of three individuals, colour-coded according to the absolute bending angle. Phases of stopping and increased bending are indicated by brighter colour (arrows). (b) The absolute bending angle over time. Black and blue stripes on the x-axis indicate periods of darkness and blue light stimulation, respectively. (c) 30 behavioural attributes during light stimulation were normalized to each individual's behaviour before light activation (called Δ-values). Shown are the top ten most important Δ-values for discriminating the three genotypes by means of random forest, sorted by the average importance rank across 10 repetitions. The top ten Δ-values provided by random forest were (d) the distance each larva travelled, (e) the velocity of the tail in a forward direction, (f) the speed of the midpoint, as well as (g) its coefficient of variation (CV), (h) the bending angle, (i) the absolute bending angle, as well as (j) its CV, (k) the absolute angular speed of the head vector (HV), (l) the absolute angular speed of the tail vector (TV), as well as (m) its CV. Displayed are the mean and the 95% confidence interval in (b,c), and the median as the middle line, the 25% and 75% quantiles as boxes and the 10% and 90% quantiles as whiskers in (dm). Asterisks indicate significant differences in MW tests. The underlying source data, as well as the results of the statistical tests, can be accessed in electronic supplementary material, source data file S1. bl, individual body lengths; bl s−1, body lengths per second.

In order to evaluate the reaction of the animals to the light stimulation and the light-induced neuronal activation, we normalized each individual animal's behaviour during the 30 s of light stimulation by subtracting its behaviour in the 30 s of darkness before. The normalized values of 30 behavioural attributes (called Δ-values) were fed into the random forest. The random forest classified the three genotypes with an accuracy of 0.90 and provided the top ten most important attributes that differed between the three genotypes in their change in response to the light stimulation (figure 8c). In detail, we found a more strongly reduced distance travelled by larvae of the experimental genotype than of the genetic controls and accordingly a more strongly reduced tail forward velocity and midpoint speed (figure 8d–f). Interestingly, the intra-individual variability in the midpoint speed, as determined by the CV, was increased in all three genotypes, but more in the experimental genotype (figure 8g). In addition, the random forest approach provided three behavioural attributes regarding the animals’ bending. For the bending angle, which is positive if a larva is bent to the left and negative if bent to the right, we found no significant differences, but a strongly increased scatter of the data in the experimental genotype (figure 8h). Fittingly, the absolute bending angle, not taking the direction into account, was increased in all three genotypes, but much more so in the experimental genotype (figure 8i). The intra-individual variability in the absolute bending angle was increased only in the genetic controls, but not in the experimental genotype (figure 8j). Finally, the angular speeds of the animals’ head and TVs also differed between the genotypes: both angular speeds were increased more strongly in the experimental genotype than in the controls (figure 8k,l). Regarding the TV angular speed, the intra-individual variability was also more strongly increased in the experimental genotype (figure 8m).

Figure 9.

Figure 9. Individuals reduce speed consistently upon repeated optogenetic activation of dopamine neurons. Larvae of the experimental genotype (TH > ChR2-XXL) were recorded during free locomotion for 30 s in darkness, followed by three cycles of 10 s of light stimulation and 60 s of darkness. (a) The tail forward velocity over time. Black and blue stripes on the x-axis indicate periods of darkness and blue light stimulation, respectively. (b) The tail forward velocity during light stimulation was normalized to each individual's behaviour in the 10 s before light activation (called Δ-values). The Δ-velocities of the first and third activation were positively correlated. (c,d) As in (a,b), but for the midpoint speed. (e,f) As in (a,b), but for the absolute bending angle. (g,h) As in (a,b), but for the HV absolute angular speed. Displayed are the mean and the 95% confidence interval in (a,c,e,g), and the individual Δ-values in (b,d,f,h). Correlations were determined by SC tests. The underlying source data, as well as the results of the statistical tests, can be accessed in electronic supplementary material, source data file S1. bl, individual body lengths; bl s−1, body lengths per second.

In summary, activating a broad set of dopaminergic neurons caused the animals to slow down markedly and to bend and rotate their bodies (for a time-resolved view of the three genotypes’ behaviour, see electronic supplementary material, figure S9).

2.11. Individuals reduce speed consistently upon repeated activation of dopamine neurons

In wild-type animals we observed that behavioural attributes associated with peristaltic forward crawling were more consistent within each animal than attributes associated with bending and HC behaviour (figures 2 and 3; electronic supplementary material, figures S3–S6). We therefore wondered whether this would also be true for the dopamine-induced changes in behaviour that we had observed. To tackle this question, we repeated the previous experiment with the experimental genotype expressing ChR2-XXL in TH-Gal4 neurons, but this time we activated the neurons three times for 10 s, each time followed by 60 s of darkness (figure 9). Then we determined the changes in the four behavioural attributes that had previously been found to be most important by the random forest method (figure 8c): tail forward velocity, midpoint speed, absolute bending angle and absolute angular speed of the HV. On average, the animals reacted very similarly to the three neuronal activations (figure 9). As regards the changes in behaviour within each animal, however, we found differences between the behavioural attributes. We observed mild to moderate correlations across the three neuronal activations for the tail forward velocity and the midpoint speed (figure 9b,d; electronic supplementary material, figure S10a–d), but no correlations for the absolute bending angle and the absolute angular speed of the HV (figure 9f,h; electronic supplementary material, figure S10e–h).

Thus, we indeed found that the reduction in speed upon activation of dopamine neurons was consistent within individual animals, whereas the increases in bending and lateral head movement were not. This further stresses the distinction between forward crawling and bending behaviour with respect to intra-individual variability.

2.12. Optogenetic activation of ‘mooncrawler’ neurons triggers backward crawling

In order to probe the utility of our approach further, we applied it to an analogous experiment to that described above, but activating a very different set of neurons. This time we chose the driver strain R53F07-Gal4, which reportedly covers a rather broad set of interneurons in the ventral nerve cord (VNC), the insects’ functional analogue of the spinal cord, including the so-called moonwalker descending neurons (MDNs) [52]. Optogenetically activating these neurons (henceforth called ‘mooncrawler’ neurons) had caused larvae to crawl backwards in a previous study [52], but an in-depth analysis of their behaviour is lacking. Therefore, we crossed R53F07-Gal4 to the UAS-ChR2-XXL effector strain, performed the same experiment as described above, and compared the animals’ behaviour with the respective genetic controls (figure 10). Light stimulation did indeed cause backward crawling, as indicated by a negative forward velocity, in animals of the experimental genotype but not of the genetic controls (figure 10b, electronic supplementary material, movie S9).

Figure 10.

Figure 10. Optogenetic activation of ‘mooncrawler’ neurons triggers backward crawling. Larvae of the experimental genotype (R53F07 > ChR2-XXL), the driver control (R53F07/+) and the effector control (+/ChR2-XXL) were recorded during free locomotion for 30 s in darkness, followed by 30 s of light stimulation and 60 s of darkness. (a) Sample tracks of two larvae, colour-coded according to their tail forward velocity. Phases of backward locomotion are indicated by darker colour (arrows). (b) The tail forward velocity over time. Black and blue stripes on the x-axis indicate periods of darkness and blue light stimulation, respectively. (c) 30 behavioural attributes during light stimulation were normalized to the individual's behaviour before light activation (called Δ-values). Shown are the top ten most important Δ-values. The top ten Δ-values were (d) the distance each larva travelled, (e) the velocity of the tail in a forward direction, (f) the speed of the midpoint, as well as (g) its coefficient of variation (CV), (h) the IS speed, (i) the IS interval, (j) the absolute bending angle, as well as (k) its CV, (l) the absolute angular speed of the head vector (HV) and (m) the HC rate. Displayed are the mean and the 95% confidence interval in (b,c), and the median as the middle line, the 25% and 75% quantiles as boxes and the 10% and 90% quantiles as whiskers in (dm). Asterisks indicate significant differences in MW tests. The underlying source data, as well as the results of the statistical tests, can be accessed in electronic supplementary material, source data file S1. bl, individual body lengths; bl s−1, body lengths per second.

We applied the same strategy as before, fed the Δ-values of behavioural attributes into the random forest (accuracy 0.83), and obtained the top ten attributes that differed between the three genotypes in their change in response to the light stimulation (figure 10c). Similarly to the case of dopaminergic neurons, we found the distance travelled, the tail forward velocity and the midpoint speed to be more strongly decreased in the experimental genotype than in the genetic controls, and the intra-individual variability of the midpoint speed to be more strongly increased (figure 10d–g). By contrast to the previous experiment, however, the IS speed and the IS interval were also among the top ten attributes: we found the IS speed to be strongly reduced, and the IS interval to be strongly increased, in the experimental genotype but not the genetic controls (figure 10h,i). Again, we found the animals’ bending to be important, yet in a different way from the previous experiment: the absolute bending angle was reported as an important attribute by random forest, but the experimental genotype was different only from the effector control, not from the driver control (figure 10j). Thus, there was no evidence that the activation of the R53F07-Gal4 neurons were responsible for the change in the absolute bending angle. Interestingly, the intra-individual variability in the absolute bending angle was increased in the genetic controls but decreased in the experimental genotype (figure 10k). Although the change in the average bending was not significantly different from the genetic controls, thereby activating the R53F07-Gal4 neurons made the bending less variable. Finally, the angular speed of the HV as well as the HC rate were reported by the random forest. However, for the angular speed we found a significant difference in the experimental genotype only in relation to the driver, but not the effector control (figure 10l), and no significant differences in the HC rate at all (figure 10m).

2.13. Individuals differ in the timing of their switching gears from backward to forward locomotion

A closer look at the temporal patterns of the behavioural attributes induced by the two sets of neurons activated revealed striking differences. The activation of dopaminergic neurons triggered a number of behavioural changes that quickly reverted back to normal as soon as the light stimulation ended (electronic supplementary material, figure S9). By contrast, activating the R53F07-Gal4 neurons triggered behavioural changes of very different, more complex dynamics (electronic supplementary material, figure S11). For example, the tail forward velocity dropped quickly to the negative upon light onset and started to become more positive gradually over the course of 90 s (electronic supplementary material, figure S11a). The midpoint speed and IS speed, in contrast, continued to drop slowly until a minimum was reached about 30–40 s after light onset (electronic supplementary material, figure S11b,c). The absolute bending angle was increased in all three genotypes during light stimulation. But whereas it reverted back to normal upon light offset in the genetic controls, it remained high for another 30 s in the experimental genotype before gradually decreasing (electronic supplementary material, figure S11e). What is the cause of these complex temporal patterns?

We compared the temporal pattern of the tail forward velocity across individual animals (electronic supplementary material, figure S12). Whereas all the individuals switched to backward crawling within a few seconds after light onset, the reverse switch to forward crawling was highly variable, with some animals not reverting at all within the recording time (figure 11a). In other words, most larvae continued to crawl backwards even after the optogenetic activation of the R53F07-Gal4 neurons had finished, and each reverted to forward crawling in its own time. On average, those animals that did revert to forward locomotion within the recording time crawled backwards for about 51 s (figure 11b). This also means that our previous analysis was confounded by mixing unknown numbers of forward and backward crawling individuals at any given time point. Therefore, we determined the switching points in each individual animal (electronic supplementary material, figure S12) and compared the individual animals’ behaviour while the animals were crawling backward (i.e. between the switching points) with their behaviour while crawling forward (figure 11c).

Figure 11.

Figure 11. Backward locomotion is characterized by reduced yet more variable speed, and increased yet less variable bending. (a) Distribution of the switching points to backward crawling (white) and forward crawling (grey). n = 97, 64. (b) Distribution of backward crawling durations, only taking those animals into account that perform both switches, i.e. that start to crawl backward and revert to forward crawling later (n = 58). (c–k) Within-animal comparison of the backward crawling phase (i.e. between the switching points) and the forward crawling phases, regarding (c) the tail forward velocity, (d) the midpoint speed, (e) its coefficient of variation (CV), (f) the IS speed, (g) the IS interval, (h) the absolute bending angle, (i) its CV, (j) the HV absolute angular speed, and (k) the HC rate. Displayed are the median as the middle line, the 25% and 75% quantiles as boxes and the 10% and 90% quantiles as whiskers. Hash symbols indicate significant differences in WS tests. The underlying source data, as well as the results of the statistical tests, can be accessed in electronic supplementary material, source data file S1. bl, individual body lengths; bl s−1, body lengths per second.

We found that the midpoint speed was reduced, but its intra-individual variability was increased, while animals crawled backwards (figure 11d,e). Taking only run phases into account, the IS speed was reduced and the IS interval was accordingly increased, during backward crawling (figure 11f,g). The absolute bending angle was increased, with reduced intra-individual variability, while larvae crawled backwards (figure 11h,i). Finally, we found no differences between forward and backward crawling regarding the angular speed of the HV, but a reduced HC rate during backward crawling (figure 11j,k).

In summary, backward crawling was characterized by longer IS intervals, leading to a reduced and more variable speed, and by increased but less variable bending of the larvae, compared to forward crawling.

2.14. Switches between forward and backward locomotion are characterized by changes in speed, and peaks in bending and head-casting behaviour

Finally, we wondered how specifically the animals’ behaviour was altered during the switches between forward and backward locomotion. To this end, we aligned the data of all the animals either to the switch to backward crawling, or to the switch to forward crawling (figure 12a). This alignment revealed that both midpoint speed and IS speed rapidly dropped at the switch to backward crawling, followed by a slow further decrease in the following seconds. Both speeds decreased until a few seconds before the switch to forward crawling and quickly rose again after the switch (figure 12b,c). Fittingly, the IS interval increased after the backward switch and decreased again after the forward switch (figure 12d). The absolute bending angle rapidly increased precisely at the backward switch and stayed constant afterwards. At the forward switch, the absolute bending angle peaked and then dropped quickly back to normal levels (figure 12e). The absolute angular speed of the HV did not change at all at the backward switch but peaked at the forward switch (figure 12f). Finally, the HC rate peaked at both switching points, albeit on different absolute levels (figure 12g).

Figure 12.

Figure 12. Switching between forward and backward locomotion (and vice versa) is characterized by changes in speed and peaks in bending and head casting. (a–g) The tracks of animals from the experimental genotype (R53F07 > ChR2-XXL) were aligned either to the switch from forward to backward crawling (left, ‘backward switch’), or to the switch from backward to forward crawling (right, ‘forward switch’). Only animals that performed the respective switch were considered (n = 97, 64). (a) Tail forward velocity, (b) midpoint speed, (c) IS speed, (d) IS interval, (e) absolute bending angle, (f) absolute head vector (HV) angular speed, (g) HC rate. Displayed are the mean and 95% confidence intervals of all data within each 2 s bin, except for the HC rate which was calculated within each 2 s bin by dividing all frames with a HC by all frames in the bin. (h) The orientation of the animal's body, indicated by the tail vector, was compared in the 10 s before and after a switch. Displayed is the percentage of animals that changed their orientation by the respective absolute angle, in brackets of 20°. The underlying source data can be accessed in electronic supplementary material, source data file S1. bl, individual body lengths; bl s−1, body lengths per second.

In order to determine how the direction of crawling changed at each switching point, we calculated the change in the TV in the 10 s before and after each switch (figure 12h). We found that in both cases the larvae changed their crawling direction by about 100°, suggesting that either switch was followed by a movement approximately orthogonal to the previous direction.

We characterized backward switches by a decrease in speed and an increase in absolute bending angle, and forward switches by an increase in speed, and peaks in absolute bending angle and absolute angular speed of the HV. How stable were these changes for repeated switches across and within individuals? To address this question, we stimulated the R53F07-Gal4 neurons three times for 10 s and aligned all animals either to the backward or to the forward switch (figure 13). We found that the average behaviour of the animals was astonishingly consistent across all three backward and forward switches. Looking at individual behaviour with regard to the changes in tail forward velocity and midpoint speed, we observed mild to moderate correlations across repeated backward switches (figure 13a,c; electronic supplementary material, figure S13a,c), but not across repeated forward switches (figure 13b,d; electronic supplementary material, figure S13b,d). A notable exception was a significant moderate correlation in the midpoint speed between the second and third forward switch (electronic supplementary material, figure S13d). By contrast, no correlations were found for the absolute bending angle and the absolute angular speed of the HV (figure 13e,f,h; electronic supplementary material, figure S13e,f,h). The IS speed, IS interval and HC rate were not included in this analysis, as steps and HCs occur too rarely within the short observation periods used for this analysis.

Figure 13.

Figure 13. Individuals change speed consistently upon repeated backward, but not forward switches. Larvae of the experimental genotype (R53F07 > ChR2-XXL) were recorded during free locomotion for 30 s in darkness, followed by three cycles of 10 s of light stimulation and 60 s of darkness. Individual data were aligned either to the switch from forward to backward crawling (a,c,e), or to the switch from backward to forward crawling (b,d,f,h). (a) (left) The tail forward velocity over time, aligned to the first, second and third backward switch. (right) The tail forward velocity during the 10 s after the switch was normalized to each individual's behaviour in the 10 s before the switch (called Δ-values). The Δ-velocity of the first and third activation was positively correlated. (b) As in (a), but for the forward switches. (c,d) As in (a,b), but for the midpoint speed. (e) As in (a), but for the absolute bending angle. (f) To quantify the peak of the absolute bending angle at forward switches, we normalized the behaviour in the 10 s around the switch with the 5 s before and the 5 s after (called peak values). (g) (left) The duration of the backward crawling phases following the first, second and third neuronal activation. (right) The durations of the first and third backward phases were positively correlated, despite statistically non-significant due to the low number of larvae that completed all backward and forward switches. (h) As in (f), but for the HV absolute angular speed. As no particular change in the angular speed is seen upon backward switches, we quantify only the forward switches. Displayed are the mean and the 95% confidence interval in (a,c,e), and the individual Δ-values, or peak values, in (b,d,f,h). Correlations were determined by SC tests. The underlying source data, as well as the results of the statistical tests, can be accessed in electronic supplementary material, source data file S1. bl, individual body lengths; bl s−1, body lengths per second.

In addition, we determined the duration of each of the three backward crawling phases upon each activation of R53F07-Gal4 neurons in individual animals, and found positive correlations that were significant between the first and the second, as well as between the second and third backward phases (electronic supplementary material, figure S13g). Between the first and third backward phase too, a positive correlation was observed; this remained non-significant due to the sample size of only seven animals that completed both backward phases (figure 13g).

In summary, we again found that changes in speed upon neuronal activation were more consistent within individuals than changes in bending or lateral head movement, just as we found to be the case with respect to dopamine neurons.

3. Discussion

In this study, we demonstrate the utility of the IMBA with five examples: our findings provide new insights into variability in locomotor behaviour, the modulations of behaviour by associative training, the complex behavioural phenotypes of an adhesion G protein-coupled receptor (GPCR) mutation, the effects of repeatedly activating dopamine neurons on locomotion, and the ‘switching of gears’ between forward and backward locomotion. In the following paragraphs, we first discuss the implications of our findings and the possible future directions for each of these cases, before summarizing the more general potential of the IMBA.

3.1. Bending and head-casting behaviour is variable; peristaltic locomotion is stable

Our analysis revealed that peristaltic forward locomotion is characterized by very low intra-individual variability and high consistency over time (figures 2 and 3; electronic supplementary material, figures S4–S6). Bending and head-casting behaviour, in contrast, is much more variable, and less stable. We note that, while similar findings have led to the suggestion that peristaltic forward locomotion would thus be best suitable for high-throughput phenotyping [19], we found reliable effects of transgenic manipulations on bending and HC behaviour, too (figures 5f–h, 8i–m and 10j–m). In any event, when we repeatedly activated the same set of neurons in the same individual animals, we found mild yet significant correlations for these repetitions for peristaltic forward locomotion, but not for bending and head-casting behaviour. This was true for both dopamine neurons and mooncrawler neurons (as covered by the R53F07-Gal4 driver) (figures 9 and 13). This suggests that individual larvae not only have a fairly stable, inherent rhythm of peristaltic locomotion, but they also modify this rhythm in a relatively idiosyncratic manner upon repeated neuronal activation. Bending and head-casting behaviour, on the other hand, appear highly variable and are modulated not only by previous experience (electronic supplementary material, figure S7) but also in an unpredictable manner upon repeated neuronal activation.

The reason for this apparent difference in variability between peristaltic locomotion on the one hand and bending and head-casting behaviour on the other hand is not known. Interestingly, however, previous studies have found that peristaltic locomotion originates in both the anterior and posterior segments of the VNC, whereas head-casting behaviour and bending originate more anteriorly [53,54]. In both cases, input from the brain is reportedly not required. Input from the brain is required, in contrast, for organizing peristalsis, bending and head-casting behaviour in a goal-directed manner [53]. Consistently with this, we repeatedly found that ‘higher’ brain functions, such as associative memories, almost exclusively modulate head-casting behaviour, but not peristaltic runs (electronic supplementary material, figure S7) [28,44,48]. Overall therefore it seems that the characteristics of peristaltic runs that are particularly relevant for speed are relatively stable features of a given individual animal, ‘hard-wired’ in the VNC, whereas bending and head-casting behaviour, and thus changes in direction, are more flexible features that can be adaptively modulated by external stimuli and internal goals, modulations that apparently take place via the brain. We are curious whether such a distinction between speed-related, hard-wired, stable motor outputs from the VNC and direction-related, flexible, brain-modulated behaviours may turn out to be a general principle of behavioural control.

We note that intra-individual variability itself can be affected by specific experimental manipulations: for example, we found that the CirlKO mutants show an increased variability in their IS interval (electronic supplementary material, figure S8). The optogenetic activation of select sets of neurons can also elicit changes in the variability of behaviour (figures 8g,j,m and 10g,k). One might therefore expect there to be cases in which experimental manipulation specifically affects the variability of a behavioural measure, but not its average. This was indeed the case when comparing innate locomotion with locomotion after a previous associative training (figure 4). We found a couple of differences, for example in the speed and the HC rate that likely reflected some level of fatigue after the training procedures. Importantly, in four out of five locomotor attributes, trained larvae displayed a lower intra-individual variability than experimentally naive animals, including in the IS interval and the absolute HC angle which did not differ in their average (figure 4g,h,l,m). Such decreased levels of variability may reflect a loss of degrees of freedom by a training during which animals learn how to pursue their goal (i.e. finding food). Similar effects on the variability of behaviour would be interesting in particular in relation to processes for which behavioural variability is of particular value, e.g. for generating unpredictable actions during escape, for generating novel actions in pursuit of desired outcomes in operant learning, or for adapting to changed environmental contingencies during reversal learning.

Our findings suggest that individual larvae may have behavioural traits that are different between, but consistent within, individual animals. However, given that we only included videos of a maximal length of 4 min, it is possible that even the attributes that are relatively stable within animals, such as those related to peristaltic locomotion, reflect transient internal states or ‘moods’ rather than permanent behavioural idiosyncrasies. To detect such idiosyncrasies, longer recordings and ideally repeated recordings of the same individual over several days or even across metamorphosis would be required. In adult Drosophila, repeated behavioural measurements demonstrated such behavioural idiosyncrasies even in strongly inbred fly populations [16,17]. In principle, inter-individual behavioural variation can originate from genetic, developmental and environmental factors. A previous study found highly significant correlations between the expression patterns of many genes and a broad array of behavioural attributes [17]. A particularly striking example of a genetic factor causing inter-individual differences in behaviour is the polymorphism of the rover gene that causes different foraging strategies in larvae [15]. On the other hand, non-heritable, random asymmetries in the wiring of a specific set of visual interneurons were found responsible for inter-individual variability in a visual task studied in adult Drosophila [16]. Whether the inter-individual differences we report in this study reflect behavioural idiosyncrasy, and what would be their causes, remains to be determined.

3.2. CirlKO mutants exhibit ‘stumble’ steps

We discovered a new, complex behavioural phenotype of Latrophilin/Cirl mutants. Cirl constitutes an aGPCR (adhesion G protein-coupled receptor) expressed in larval mechanosensory organs crucial for proprioception [42]. Previously, it was known only that mutants were slower, as was confirmed by our analysis (figure 5b). Here we found that the reason for the reduced speed was the abnormal ‘stumble’ stepping of the mutant animals, in which the peristaltic cycle was interrupted, and the time required to complete one cycle was therefore prolonged (figure 7). Interestingly, this different way of stepping was in itself rather regular, such that some mutant individuals always performed stumble steps (figure 7a).

The stumble stepping explained parts of the observed behavioural phenotype: the IS interval was increased, and the IS speed was thus decreased during stumble stepping compared to ‘normal’ stepping in the same individual mutant animals (figure 7d,f). However, the normal stepping phases of mutant and control animals also differed in these behavioural attributes, suggesting that the peristaltic cycles that we classified as ‘normal’ were partially impaired as well. Moreover, we found that mutant animals bent and turned less than control animals, a phenotype that was completely independent of the kind of stepping the animals performed (figure 7g,h).

The molecular mechanisms through which aGPCRs exert their function remain incompletely understood. However, it is known that chordotonal neuron-located Cirl suppresses cAMP levels to shape larval proprioception and thus behaviour [42,55]. If and how Cirl has an impact in other cells that are part of the neuronal circuits that modulate locomotion remains elusive. Our analysis suggests that the correct functioning of the receptor is required for a normal, uninterrupted peristaltic cycle, but that even without the receptor larvae can eventually crawl forward. This is in line with published accounts showing decreased but existent proprioceptive capability [42]. It will be interesting to study larval locomotion in animals that express genetically modified Cirl proteins or specific Cirl isoforms [56], and the ability of Cirl mutants to successfully reach goals such as odours or tastants despite their impairment in crawling.

3.3. Activation of dopamine neurons makes larvae stop and turn

Across the animal kingdom, the dopaminergic system is closely associated with locomotion and the generation of movement [57,58]. In humans, the progressive death of dopaminergic neurons is widely accepted as a cause of Parkinson's disease, which results in difficulties in initiating movement [5961]. Based on studies mostly of rodents, locomotion has been found to be controlled by interactions of several dopamine receptors in the ventral striatum, with some of them increasing, others inhibiting forward locomotion [62]. Turning behaviour can be induced by the unilateral administration of dopamine receptor agonists [63]. The administration of cocaine, which strongly activates the dopaminergic system, causes complex, concentration-dependent modulations of locomotion, including increased forward locomotion upon administration of lower concentrations of cocaine, and circling behaviour as well as a reduced forward movement upon repeated, or highly concentrated cocaine administration [6466].

In Drosophila too, the dopaminergic system is linked to locomotion. Genetic fly models for Parkinson's disease show similar impairments in locomotion, as well as the death of dopaminergic neurons as found in mammals [67]. Cocaine administration leads successively to a reduction in forward movement, circling behaviour and rotating, before the animals stop moving at all, similar to the case in mammals [68]. In a pioneering optogenetic study, activation of the dopamine neurons covered by TH-Gal4 resulted in increased locomotion in flies that were little active before, and decreased locomotion in flies that were highly active [69]. Recently, a study has found the activity of specific dopamine neurons to be correlated with speed and turning of flies, suggesting that dopamine neurons both report and change specific movements [70].

Much less is known about the impact of dopamine on locomotion in Drosophila larvae. In this study, we optogenetically activated most dopamine neurons, and found that larvae stop forward locomotion and start strong bending (figure 8). Such behaviour would correspond to the behaviour of adult flies and mice after cocaine administration [6466,68], and to what was observed in highly active flies upon activation of dopamine neurons [69]. Our results are also in line with one of the very few studies that link dopamine function with locomotion in larvae: a transgenic knockdown of the dopamine receptor Dop1R1, one of the two Drosophila homologues of the vertebrate D1-type dopamine receptors, was reported to increase locomotion in larvae [71]. Our experimental treatment, in contrast, acutely increased dopamine signalling, leading to reduced forward locomotion.

Interestingly, the effects of the Dop1R1-knockdown were also observed when it occurred locally only in the mushroom body, one of the central brain regions in insects [71]. The dopamine neurons innervating the mushroom body play a crucial role in signalling reward or punishment information in associative learning [30,7276]. The mushroom body-innervating neurons covered by TH-Gal4 are mostly linked to punishment signalling, with the reward-signalling dopamine neurons notably missing in the expression pattern [72,77,78]. This raises the question of what the activation of these neurons ‘means’ to the animals. On the one hand, stopping and turning can be interpreted as an avoidance behaviour in response to a sudden punishment signal (for a similar interpretation regarding the activation of dopamine-downstream neurons, see [79]). On the other hand, an excessive release of dopamine, as probably happens in our experiment, may cause malfunctions in the motor control pathways, similar to what was observed upon cocaine administration in adults [68]. The fine genetic tools available make the Drosophila larva an ideal study case to answer this question. Dopamine neurons can be manipulated in small subsets and even one by one [7375] to find out which neuron causes which behavioural reaction.

3.4. Switching from forward to backward locomotion, and back again

In free, undisturbed locomotion, Drosophila larvae normally crawl forward, and backward crawling is very rarely observed. They do, however, perform short bouts of backward locomotion on encountering an obstacle or receiving a noxious stimulus to their head [80,81]. Thus, backward locomotion can be seen as part of an avoidance reaction. In recent years, several Gal4 driver strains have been described that cover neurons which induce backward locomotion upon activation [52,81,82]. One of them, R53F07-Gal4, we used in the present study [52]. We described many facets of the behaviour of individual animals over extended phases of backward locomotion, including the bending and head-casting behaviour that had not been looked at in previous studies [52,81,82]. We found, for example, that during backward locomotion bending was increased in amplitude, but decreased in variability, and that the HC rate was decreased compared to forward locomotion (figure 11h–k). Moreover, we found that larvae did not revert to forward locomotion immediately after the optogenetic activation terminated. Rather, they continued to crawl backward for various time periods, and then quickly switched to forward locomotion (electronic supplementary material, figure S12). Both kinds of switches were accompanied by characteristic changes in speed and bending behaviours (figures 12 and 13). The reason for the inter-individual variability in reverting to forward locomotion is unknown. In this specific case, in addition to general genetic variation, differences in transient internal states or behavioural idiosyncrasies (see above), also differences in transgene expression strength may contribute to the inter-individual variability.

At the neuronal level, both forward and backward locomotion are characterized by waves of activity in the motor neurons and interneurons of the segmented VNC, which travel from anterior to posterior during forward locomotion, and the other way around during backward locomotion [8,53,83,84]. More specifically, two pairs of command-like neurons have been identified in the rather broad expression pattern of R53F07-Gal4, called mooncrawler descending neurons (MDNs), which inhibit forward and induce backward locomotion [82]. It is likely that the effects of activating R53F07-Gal4 neurons come about through these MDNs. Two main effects of activating the MDNs have been proposed: on the one hand, one of their main downstream partners, called Pair1, stops forward locomotion by inhibiting the forward movement-inducing A27h neuron; on the other hand, another downstream partner, A18b, induces backward locomotion specifically in the most anterior segment of the VNC [11,14,82]. Remarkably, both the MDNs and Pair1 neurons persist through metamorphosis, and induce analogous behavioural effects in adult flies [82,85,86].

It is a straight-forward assumption that the switches between forward and backward locomotion that we describe here may be caused by the backward movement-inducing A18b and the forward movement-inducing A27h neurons, respectively. The observation that larvae did not revert to forward locomotion as soon as the optogenetic activation ended suggests that activating the MDN → A18b pathway leads to backward locomotion that continues until forward locomotion is triggered again, potentially by A27h. Our behavioural approach, together with the available tools for fine circuit analysis, is suited to test this hypothesis.

3.5. Utility for analysing individual behaviour

The IMBA software introduced here can serve to track, visualize and analyse the behaviour of individual Drosophila larvae within groups. The IMBA is compatible with well-established, standard Petri dish assays and requires no specific additional hardware beyond reasonable light conditions and a camera. In this study, we only used videos of up to 4 min, as many standard Petri dish assays are performed in a similar time frame. Longer videos can be processed by the IMBA, but larvae tend to follow the Petri dish walls where they are very difficult to track. Therefore, attempts to use longer videos require precautions such as larger behavioural arenas, or borders that do not reflect light and therefore allow for the tracking of the larvae. In any case, the present study features data from setups located both at the Leibniz Institute for Neurobiology and the University of Leipzig, which use different means of lighting, cameras and video quality. We also successfully tracked videos from previous publications from other laboratories [26,43]. In total, we used five kinds of videos with different resolutions, cameras and light settings which we could successfully track. Electronic supplementary material, movies S1–S5 show the results of these tracking attempts and demonstrate the wide variety of video qualities that could be handled. Such robustness makes the IMBA a useful tool for studying a broad range of research questions using derivatives of this standard assay. In the present study, we focused on locomotion and used the IMBA to compare innate and learned behaviour in odour gradients (figures 24, electronic supplementary material, figures S4–S7), phenotype a mutant (figures 57) and study the effects of optogenetic neuronal activation (figures 813). Other future applications may include the screening of pharmacological effectors [87] and libraries for RNAi knockdown, and comparisons across inbred strains of Drosophila or across species.

A critical property of the IMBA that allows for such broad use is that we included a large number of behavioural attributes that can be adapted and extended by the user (the full list is available online under https://github.com/mthane/IMBA). Among them are 22 attributes describing behaviour relative to a local stimulus. This makes the IMBA useful for experiments on behaviour towards stimuli such as odours, tastants, light or temperature, as well as for analysing stimulus-related behaviour after various types of learning experiment (as we exemplified in electronic supplementary material, figure S7). Importantly, we combine this large number of behavioural attributes with an approach to selecting the most relevant ones for each particular dataset in an unbiased way. Random forest analysis provides a ranking of behavioural attributes according to their importance for differentiating animals in the particular experimental conditions of the particular dataset under study (compare figures 8c and 10c). This includes attributes that do not differ in their centres of distribution (and thus result in non-significant standard statistical tests) but rather in the distribution of the data (figures 6f and 8h).

The IMBA is versatile for analysing relatively fine-grained temporal patterns of behaviour. This has led us to discover stumble stepping in CirlKO mutants (figure 7). Indeed, the IMBA allows for the analysis of even more extreme kinds of ‘silly walks’ that it was not designed to study, such as the backward locomotion elicited by activation of MDN neurons (figures 1013). Furthermore, the IMBA lends itself to protocols that involve repeated experimental stimulation, as in the case of the repeated activation of select sets of neurons (figures 9 and 13). This should make it possible to establish larval versions of paradigms such as prepulse inhibition or repetition priming, which are workhorse paradigms in the experimental neuropsychology of rodents and humans. Last but not least, the IMBA allows data to be aligned to changes in behaviour (that is, to the time of action initiation rather than stimulus application), revealing effects that would otherwise be masked by differences in action-timing between individuals (figures 12 and 13).

A crucial step for the above-mentioned applications is the ability to resolve collisions. Obviously, some of the results we reported here could also have been obtained at the level of sub-individual tracks or group averages. But many of our findings required to analyse the behaviour of individuals, such as the comparison between inter- and intra-individual variability, the repeated neuronal activation experiments or the alignment to the switches between forward and backward locomotion. Without collision resolution, such analyses would either require recording animals one by one, or would need to be made on a much smaller database, restricted to those few animals that happen to not collide with others, which is potentially not representative of the whole population of the experiment (electronic supplementary material, figure S1d). We are not aware of any other ready-to-use tracking software that can perform similar analyses for animals tested in groups. The arguably most complete and widely used tracking approach for larvae so far, the FIMtrack, does not yet include such collision resolution [24,25,31]. In addition, the FIMtrack software provides basic attributes like bending and velocity, but no more detailed attributes like the inter-step distance and interval, HC angles or angular speeds that we employed here. Modifying the FIMtrack is possible but requires at least basic programming skills. In table 5, we compare the capabilities between the FIMtrack and the IMBA.

Table 5. Comparison between FIMtrack and IMBA. The column about FIMtrack is based on [24,25,31]. The cross-platform tracking was done as described in the results part of this study.

feature FIMtrack IMBA
hardware requirements (setup) custom-made FIM-table for illumination (instructions available online) none except an even background (black or white) and a constant lighting
hardware requirements (camera) different cameras work, mounted below different cameras work (including simple webcams), mounted above or below
computer requirements tested for Linux, Windows and Mac OS computers tested for Linux and Windows 10 or higher; RAM memory greater than 8 GB recommended
programming language C++ C++, Python, R
graphical user interface yes, for tracking and displaying results yes, for tracking, displaying results, statistics and random forest application
installation ready-to-use binary packages are available online a simple installation guide is available at https://github.com/mthane/IMBA that will install IMBA and all dependencies
input series of TIFF or PNG image files MP4 video files
output an image with all tracks, a CSV file and a YML file with all attributes per larva and frame a MP4 video file annotated with contours, IDs, heads and tails of all larvae, a CSV and RDS file with all attributes per larva and frame; optional: CSV files with further analyses, PNG files of created plots
objects contour detected, spine calculated (5–7 ‘landmarks’ on spine) contour detected, spine calculated (12 spine points)
collision resolution only for very brief collisions yes, see Material and methods section
basic attributes x,y coordinates of landmarks, angles between landmarks, angles between landmarks and surface area of contour X,Y coordinates of spine points, body length, head vector, tail vector (table 1)
derived attributes distance, accumulated distance, distance to origin, velocity and acceleration of head and tail, bending angle, stop and go phases see tables 2 and 3, plus additional ones (see https://github.com/mthane/IMBA)
external stimulus detection stimulus markers can be set by the user in the interface up to two objects (e.g. odour cups) are automatically detected, other options require changes in the code
attributes regarding stimuli distance to stimulus, bearing angle to stimulus, ‘is-in-stimulus-region?’ table 4, plus additional ones (see https://github.com/mthane/IMBA)
cross-platform tracking was able to track larvae from our videos was able to track and resolve collisions between larvae from FIMtrack-derived videos (electronic supplementary material, figure S1e and movie S4)

In summary, the IMBA is an easy-to-use toolbox providing an unprecedentedly rich view of behaviour and behavioural variability across the multitude of biomedical research contexts in which larval Drosophila can be used.

4. Material and methods

4.1. Datasets

We used seven different datasets for our analysis:

A set of 102 videos with 1852 individual animals entering the analysis was used for figures 14, electronic supplementary material, figures S1a–d, S3, S4a–d, S5 and S7. Wild-type larvae of the Canton-S strain were tested for odour preference, either innately or after odour-sugar training, on Petri dishes of 15 cm over 3 min. Note that figures 2 and 3, electronic supplementary material, figures S1, S3, S4a–d and S5 only use the innate condition (48 videos, 875 individuals). These data were previously published in [28], and are re-analysed in this study regarding individual animals. The used wild-type Canton-S strain originated at the University of Würzburg and was continuously inbred since at least 2009.

A set of 31 videos with 397 individual animals entering the analysis was used for electronic supplementary material, figures S4e and S6. Experimentally naive wild-type larvae of the Canton-S strain were recorded without any stimuli on Petri dishes of 15 cm over 3 min. These data were previously published as open dataset [88]. The used fly strain originated at the University of Würzburg and was continuously inbred since at least 2009.

A set of 126 videos with 372 individual animals entering the analysis was used for figures 57 and electronic supplementary material, figure S8. CirlKO and CirlRescue larvae were tested for locomotion over 1 min. For details, see below.

A set of 50 videos with 253 individual animals entering the analysis was used for figure 8 and electronic supplementary material, figure S9. Larvae expressing ChR2-XXL in TH-Gal4 neurons, together with the respective genetic controls, were tested for locomotion upon optogenetic activation over 2 min in total. For details, see below.

A set of 56 videos with 257 individual animals entering the analysis was used for figures 1012 and electronic supplementary material, figures S11 and S12. Larvae expressing ChR2-XXL in R53F07-Gal4 neurons, together with the respective genetic controls, were tested for locomotion upon optogenetic activation over 2 min in total. For details, see below.

A set of 22 videos with 122 individual animals entering the analysis was used for figure 9 and electronic supplementary material, figure S10. Larvae expressing ChR2-XXL in TH-Gal4 neurons were tested for locomotion upon repeated optogenetic activation over 4 min in total. For details, see below.

A set of 20 videos with 115 individual animals entering the analysis was used for figure 13 and electronic supplementary material, figure S13. Larvae expressing ChR2-XXL in R53F07-Gal4 neurons were tested for locomotion upon repeated optogenetic activation over 4 min in total. For details, see below.

4.2. Behavioural experiments

4.2.1. Animals

Third-instar feeding-stage larvae (D. melanogaster), aged 5 days after egg laying, were used throughout. Flies were maintained on standard medium, in mass culture at 25°C, 60–70% relative humidity and a 12/12 h light/dark cycle. We took a spoonful of food medium from a food vial, randomly selected the desired number of larvae, briefly rinsed them in tap water and started the experiment.

For the experiments regarding the Cirl mutant, we used two genotypes: the CirlKO null mutant and a genomic rescue strain, CirlRescue. For a detailed description of the genotypes, see [42].

For optogenetic experiments, we used transgenic larvae to express the ChR2-XXL light-gated ion channel in DANs. To this end, the effector strain UAS-ChR2-XXL (Bloomington Stock Center no. 58374) [51] was crossed to one of two driver strains: either TH-Gal4 (Bloomington Stock Center no. 8848) or R53F07-Gal4 (Bloomington Stock Center no. 50442) to obtain double-heterozygous offspring. As driver controls, the driver strains were crossed to a local copy of w1118 (Bloomington Stock Center no. 3605, 5905, 6326). As effector controls, either w1118, or a strain carrying the landing site used for the Gal4 (attP2), yet without a Gal4 domain inserted (empty) [89], was crossed to UAS-ChR2-XXL. Because ChR2-XXL is sensitive enough to be activated by daylight (not shown), the flies were raised in vials constantly darkened by black cardboard wrapping.

4.2.2. CirlKO experiments

For the experiments regarding the Cirl mutant, the larvae were placed in the centre of Petri dishes of 9 cm inner diameter (Sarstedt, Nümbrecht, Germany), filled with 1% agarose (Biozym Scientific GmbH, Hessisch Oldendorf, Germany). The Petri dish was placed in a custom-built arena lit up with infrared light (PeakTech DC Power Supply 6080). Always five larvae were placed on a Petri dish, and their behaviour was recorded for 1 min with a camera (Logitech C920 HD Pro).

4.2.3. Optogenetic activation experiments

For optogenetic experiments, the larvae were placed on Petri dishes of 9 cm inner diameter, filled with 1% agarose. Experiments were performed inside a 43 × 43 × 73 cm surrounding box equipped with a custom-made light table featuring a 24 × 12 LED array (470 nm; Solarox, Dessau-Roßlau, Germany) and a 6 mm thick diffusion plate of frosted plexiglass on top to ensure uniform blue light for ChR2-XXL activation (2000 µW cm−2). The Petri dishes were placed directly on top of the diffusion plate. They were surrounded by a polyethylene diffusion ring; behind the diffusion ring 30 infrared LEDs (850 nm; Solarox, Dessau-Roßlau, Germany) were mounted to provide illumination that was invisible to the larvae, yet allowed the recording and tracking of their behaviour for offline analysis. To this end, a camera (Basler acA204090umNIR; Basler, Ahrensburg, Germany) equipped with an infrared-pass filter was placed above the Petri dish.

Experiments were performed by placing seven to eight larvae in the middle of a Petri dish, and letting them walk freely for 2 or 4 min. The first 30 s were in darkness, followed either by a 30 s light stimulation period and another 60 s of darkness, or by three cycles of 10 s light stimulation and 60 s of darkness.

4.3. Tracking

We developed the IMBAtracker to track multiple larvae on a single Petri dish while keeping track of their identity. Although several tracking solutions have been developed in recent years [1828], the development of new tracking software seemed necessary to ensure two important aspects: first, increasing and controlling the overall measurement precision according to the needs of the analysis; second, reducing the data fragmentation caused by collisions or by the larvae leaving the region of interest. This attempt to reduce fragmentation is especially important since it paves the way for the individual-level analysis.

4.3.1. Architecture

The tracker is designed to process a region of interest (the Petri dish area), which is defined per video. We do not require the region to contain all the objects of interest at all times (i.e. larvae can exit the region of interest). Videos should be made from above or below with a minimum resolution of 30 pixels per animal (although higher resolutions improve accuracy). Either a light background with dark objects or a dark background with light objects is supported, and any colour information is discarded as the image is converted to greyscale. In order to deal efficiently with the issue of fragmentation, it is crucial to separate the tracking into three distinct phases (see below). The general architecture is depicted in figure 14.

Figure 14.

Figure 14. Overview of the tracking process. The IMBAtracker works through a sequence of three phases. (a) In the first phase, the image is processed; for example, by background subtraction, objects (blobs) are detected by thresholding, and initial assignments of individual larvae are made (before collision resolution). (b) In the second phase, the head and tail of each larva is determined, and a contour-based model of colliding larvae is applied to undertake a first round of collision resolution. (c) For collisions that could not be resolved in the second phase, the third phase adds a statistical collision resolution approach that compares attributes such as the size of the larvae to match individuals before and after the collision.

4.3.2. Implementation

The software is written in C++ using OpenCV [90] as a base for input-output and image processing, lpsolve for linear optimization, and further standard algorithms and data structures. This ensures fast processing of the videos, which can be performed on a commodity PC. A simple user interface (written in Python) is provided.

4.3.3. First phase

The first tracking phase works similarly to other tracking software: we perform image processing, segmentation and extraction of objects of interest as connected components. However, instead of discarding objects during collisions, the contours are used to detect and record the types and objects involved in those collisions. An overview of the process can be seen in figure 14a.

We perform the following image-processing steps to extract the foreground from the background and to separate our objects of interest:

Background subtraction. We opt for a very simple background subtraction. The background model consists simply of the pixel-wise average value of 100 equidistantly spaced frames of the central third of the video to increase robustness against sudden video changes towards the beginning or end of the video.

Thresholding. A threshold separates the image into two classes: the objects of interest in the foreground, and the background. To perform this thresholding in an automated fashion we make use of Otsu's method [91], which selects the threshold that minimizes the in-class variance.

Blob extraction. This step tries to extract all connected components of the foreground as objects, which we refer to as blobs. For this step we use a library called cvBlob. The algorithm used by the library is derived from Chang et al. [92].

At each video frame we receive new blobs from the blob extraction routine. In order to see how well the blobs match the blobs from the previous frame, we test each blob from the new frame on its overlap with all blobs from the previous frame. Here, we have the following categories:

1 1: 1 blob from the old frame matches 1 blob from the new frame.

1 ∼ 1: 1 blob from the old frame partially matches 1 blob from the new frame.

1 − N: 1 blob from the old frame matches N blobs from the new frame.

N − 1: N blobs from the old frame match 1 blob from the new frame.

N − M: N blobs from the old frame match M blobs from the new frame.

The latter three cases point to collisions of larvae, as they occur, for example, when larvae merge with one object from a given frame (N − 1), as well as when they split again (1 − N). In this way, blobs that consist of several larvae can be separated from blobs that probably only consist of a single larva. This information can be visualized in a collision graph with parental nodes (blobs that split into several new blobs) and child nodes (blobs that emerge from the parental node) that will be used in the second phase of the tracking.

For those blobs that could be single larvae we try to extract some key information on the shape. To do this, we first reconstruct the contour using parametric cubic smoothing splines. We generate a contour of 200 points for each blob based on the splines. We then compute curvatures of the reconstructed contour points and, after applying a multiple-pass moving average filter over the contour for noise reduction, we detect the two biggest local maxima. These indicate the endpoints (head, tail) of the larva and are the base for the spine reconstruction. We always match the endpoints across frames based on distance, thereby storing the trajectories of each endpoint during the track. For cases where the continuation is unclear (such as where there is curling or a spine cannot be reconstructed), the track is interrupted and split into subtracks in which the endpoints’ trajectories are continuous.

4.3.4. Second phase

After the basic processing of the video, we attempt to clarify and reduce the fragmentation of the data by merging subtracks. We initially work on two aspects, the larva count in each blob and accurate head/tail detection. We then tackle the issue of fragmentation.

To clarify whether a blob is a larva or a cluster of colliding larvae, we observe that a good approximation of the contents is given by trying to find the minimum number of larvae needed to fulfil the parent–child constraints, namely that parental nodes have the same number of larvae as their children nodes. We formalize this as a linear optimization problem over a collision graph. Nodes store the uncertain number of colliding larvae, which is to be determined during optimization, and edges represent the parent–child relationship.

Given the collision graph G(V, E), where V are the nodes and E the set of edges (i, j) from node i to node j, we want to solve the following integer optimization problem:

min{1Tx|Axb,xinteger}
where vector x = (x1,…, xn) contains the number of larvae for every node i as components xi, vector 1 = (1,…, 1)∈{1}n and the system of inequalities Axb is constructed from the following two constraints with the sets of parent nodes Pi and child nodes Ci of a node i.

The number of larvae xi in a blob i is at least the number of incoming parent edges, outgoing child edges or 1, whichever is highest:

ximax{|Pi|,|Ci|,1}

The number of parent larvae and the number of child larvae of every blob, more specifically every internal node i, should be in balance:

jPixj=kCixk

Note that this equality constraint can be rewritten as two non-strict inequalities for the system of inequalities in the above minimization problem.

Matrix A is totally unimodular, which guarantees that the problem is tractable, that we can use linear optimization techniques to solve it, and that these techniques will return integral solutions only [93].

We can now proceed to disambiguate the head/tail assignment. As mentioned above, all larva tracks are split into subtracks in which the endpoints have clear and continuous trajectories. For these trajectories we calculate several metrics per endpoint (figure 14b, middle panel), such as

Average brightness around 10 pixels of the endpoint

Total distance covered

Total distance of the endpoint relative to the centroid in the previous frame, i.e. the endpoint moves towards or away from the centroid.

The head is then assigned according to votes from each of these measurements. We assign one head vote to endpoint A and one tail vote to endpoint B in each of the following cases (and the reverse otherwise):

Average brightness of A < Average brightness of B

Total distance covered of A > Total distance covered of B

A moves away from the centroid

We assign endpoint A to be the head if it has more head votes than endpoint B; otherwise we assign B to be the head.

As our main interest lies in studying the behaviour of freely moving larvae, we do not try to disentangle their behaviour within a collision. In order to decrease the fragmentation of tracks, we decided first to disentangle the ephemeral collisions. During these, behaviour should be minimally affected, and their elimination should allow for longer tracks and greater preservation of identity.

We define a larva shape model for tracking purposes based on orientation and four joint angles as depicted in figure 14b (right-most panel). In order to avoid wrong assignments, we restrict this larva model to ephemeral collisions (i.e. collisions of two larvae that last less than 8 s, or short touches of single larvae on larger blobs). This representation is initialized for the collision participants one frame before the collision, using the values that we have already calculated. For each frame of the collision, the contour of each larva in collision is approximated by subtracting the contours of the counterparts from the previous frame from the complete contour of the current frame. We then search, using a brute-force grid search, through the parameter space (i.e. orientation and joint angles) for the best neighbouring fit of our model to the approximated contour. When the collision is finished we compare the centroids of the collided models of the last frame of the collision to the new larvae coming out of it and assign the closest match.

4.3.5. Third phase: statistical collision resolution

The first approach for resolving collisions, described above, is limited to collisions of two larvae that do not take longer than 8 s. For collisions that involve up to three larvae, or take longer, a second approach for collision resolution based on statistical attributes is adopted. In brief, for each larva entering a collision that was not already resolved by the first approach, the distributions of its body length, width, area and perimeter values are compared by non-parametric testing with those of each larva leaving the collision (figure 14c).

Taking a collision of two larvae as an example, we first perform a principal component analysis (PCA) over the standardized values of the body length, width, area and perimeter, using only the first resulting principal component, which explains about 83–94% of all variance in a test dataset, for all further steps. Then we perform Mann–Whitney U-tests between the two ingoing and the two outgoing larvae, and compare the resulting p-values. The rationale is that a high p-value indicates little difference between the data, so the higher the p-value, the higher the chance that an ingoing and an outgoing larva are actually the same individual. Such comparison is legitimate if all the tests include the identical sample size [94]. Therefore, we restrict the tests to the minimal number of frames for any larva involved (i.e. the frames before the collision for the ingoing larvae, and the frames after the collision for the outgoing larvae), up to a maximum of 45 frames, as higher frame numbers decreased the rate of correct assignments in a test dataset (not shown). With two ingoing (larvae 1 and 2) and two outgoing (larvae A and B) animals, there are only two logical assignments: either 1-A and 2-B is correct, or 1-B and 2-A. A collision is resolved if both p-values for one assignment are higher by a factor of 1000 (i.e. the larvae are more similar) than both p-values for the other assignment. If no logical assignment can be made, or the difference between the p-values is too small, the collision remains unresolved. Collisions of three larvae are performed in an analogous way. We do not attempt to resolve collisions of four or more animals, as the chances of a resolution are extremely low.

We also apply this approach to asymmetrical collisions (e.g. when a single larva leaves a collision of three animals or when the tracker loses track of larvae either at the Petri dish wall or at objects such as odour containers in olfactory experiments). In the latter cases, whenever a larva re-enters the arena from the Petri dish wall, for example, it is statistically compared to all larvae that were previously lost at the wall. In these asymmetrical cases, we perform additional U-tests between all ingoing larvae (e.g. all larvae that have been lost at the wall). Such a collision is resolved if the p-value of a test between the outgoing and one of the ingoing larvae is higher by a factor of 1000 than all other p-values. If no logical assignment can be made, or the difference between the p-values is too small, the collision remains unresolved.

4.4. Data analysis

The main output of the IMBAtracker is a time series of 12 spine points that reach from the head of the animal to its tail, as well as 24 contour points (figure 1). These data are the basis for all further data analyses and visualizations with the IMBAvisualizer. To prevent multiple tracks from the same individual animal from entering the analysis, we discarded all tracks shorter than half of the video length after the collision resolution.

The spatial resolution in our video recordings was not sufficient to resolve the peristaltic wave along individual body segments. However, we noted that the rhythmic velocity changes of the tail point provided a reliable indicator for the occurrence of one peristaltic forward movement (figure 1). We therefore defined each local maximum in the tail forward velocity as one step, and the period between two maxima, i.e. one complete peristaltic cycle, as an inter-step (IS) period (figure 1d). Since the local-maxima detection algorithm we employed also produced false maxima during intervals of little or no forward motion, we discarded maxima detected whenever the tail speed in a forward direction was less than 0.6 mm s−1.

Lateral HCs are a very prominent feature during larval chemotaxis on a plain agarose surface. We quantified these head movements based on the angular speed of the HV, where the HV was defined as the vector between the ninth and the eleventh spine point (figure 1b). In order to detect HCs to the left (or right) we first detected all intervals of angular speed smaller than −35° s−1 (or larger than 35° s−1) (figure 1c). The start and endpoints of these intervals correspond to salient movements of the head part of the animal to the left or right side. We next introduced two criteria in order to discard incorrectly assigned HCs. (1) We discarded any initially detected HC whenever the angular speed of the TV during head casting exceeded 45° s−1. This criterion takes account of the visual observation that whenever the tail parts of the animal reorient, these periods most likely do not coincide with an active lateral head casting movement, but rather a stretching out of the body bending angle when stepping is resumed. (2) We discarded any initially detected HC whenever more than one step was detected during head casting. This criterion takes account of the observation that any active lateral head casting interval can coincide with at most one forward stepping detection point.

After the detection of runs, steps and HCs, we calculated a number of behavioural attributes. In the following we provide a detailed description of all the attributes used in this study. A full list of attributes implemented by the IMBAvisualizer is available online (https://github.com/mthane/IMBA). Please note that for some attributes two versions exist, using either mm or individual body lengths (bl) as the unit. Unless explicitly mentioned in the results, it was always the version using body lengths that was applied.

4.4.1. Attributes

We summarize all attributes in this study in tables 14. Whenever the behaviour of an individual larva is displayed over time (figure 1; electronic supplementary material, figure S12), the respective attributes are calculated per video frame. Whenever the average behaviour of a group of larvae is displayed over time (figures 8b, 9a,c,e,g, 10b, 12 and 13; electronic supplementary material, figures S9 and S11), the mean and the 95% confidence intervals of the respective attribute are calculated per 2 s time bin. Whenever data are displayed in box plots to compare across experimental conditions, or in scatter plots to determine correlations, the mean of each attribute is calculated for each individual larva across the whole observation period.

For the optogenetic experiments, we were interested in the difference in a given attribute X between different time intervals. In these cases we calculated Δ-values as the difference in X during each of the time intervals. For figures 8 and 10, we calculated X during the 30 s of light stimulation minus X during the 30 s before light stimulation. For figure 9, we calculated X during the 10 s of light stimulation minus X during the 10 s before. In figure 13, we calculated X in the 10 s after a switching point minus X in the 10 s before the switching point. In figure 13, we additionally calculated so-called peak values of the absolute bending angle and the absolute HV angular speed in order to quantify the local maxima of these values at the forward switching points. The peak values were calculated as X during the 10 s interval around the switching point minus X during the 5 s before and the 5 s after that interval.

4.4.2. User interface for visual analysis

The interactive IMBAvisualizer is a visual analytics concept [95]. Visual analytics generally includes approaches such as visually supported dimension reduction techniques [9698] or visual parameterization support [99,100] in order to support a human-centred context-related analysis cycle [101]. The IMBAvisualizer was created using the R programming language [102] and the Shiny library, which allows user interfaces to be built for data visualization [103]. For this, the analysed datasets are saved in RDS files which are serialized R objects. These RDS files can be uploaded in order to plot various visualizations based on the attributes that are calculated. In addition, the data are saved in CSV files that can easily be opened and further processed by other software. In the following paragraphs, we very briefly introduce the essential functions of the software. A detailed documentation can be found online along with the code.

In the ‘Individual Mode’ the user has the possibility to visualize individual tracks, compare different time series attributes, and compare different tracks. The track selection menu allows multiple tracks to be selected. This way of analysing the data permits a detailed analysis of the time dependent attributes for individual animals which allowed us to find anomalies in the behaviour of the larvae.

Data aggregation allows attributes to be calculated, usually as means or variance, from all the data either on the Petri dish or the individual animal. Using different sliders, it is possible to filter the aggregated data by time, absolute bearing angle, absolute HC angle and the distance from the source of a stimulus, e.g. an odour (in experiments using such a stimulus). For the analysis of backward-walking larvae, it is also possible to filter the data based on the run direction (forwards, backwards). These filtering options permit a detailed analysis for different subsets of the data.

We used random forest models, which were established by Leo Breiman and are based on CART (classification and regression trees) [104,105]. The random forest algorithm works by building N number of decision trees and then predicting the class label of an instance using a majority voting. Each tree is trained on a random subspace of the data, only using a sample of the instances. To evaluate the random forest classification, we used five-fold cross validation, which was repeated three times. Five-fold cross validation means that the test set for the model is used from five different, disjoint sets of the dataset. The dataset is then shuffled, and the procedure is repeated three times. Cross validation is used to make sure that the model is not based merely on the selected data, but can explain the full dataset.

For the applications of the random forest in this study, we pre-selected 30 behavioural attributes to be included (tables 2 and 3). The pre-selection was warranted to avoid using largely redundant attributes (such as the IS speed in both bl s−1 and in mm s−1), and to exclude non-behavioural attributes such as the size of the larvae. In order to provide a good estimate of the importance of each attribute, the complete random forest model (including the cross validation) was performed 10 times for any given dataset, and the importance rank of each attribute was noted.

4.5. Statistical tests

Two-tailed non-parametric tests were used throughout. When multiple comparisons were performed within one analysis, a Bonferroni–Holm correction was applied to keep the experiment-wide error rate below 5% [106]. Values were compared across multiple independent groups with Kruskal–Wallis tests (KW tests). In the case of significance, subsequent pair-wise comparisons used Mann–Whitney U-tests (MW tests). In cases of within-animal comparisons we used Wilcoxon signed-rank tests (WS tests). For correlations, we employed Spearman's rank correlation test (SC tests).

Data accessibility

All raw data used for analyses and figures in this study are available as electronic supplementary material to this article [107]. The complete code of the IMBA software is available via https://github.com/mthane/IMBA.

Authors' contributions

M.T.: conceptualization, formal analysis, methodology, software, visualization, writing—original draft; E.P.: conceptualization, formal analysis, methodology, software, writing—original draft; T.S.: methodology, software, writing—original draft, writing—review and editing; A.-R.K.: data curation, formal analysis, investigation; S.G.: formal analysis, methodology, software; A.-K.D.: data curation, investigation; N.S.: funding acquisition, supervision, writing—review and editing; B.G.: conceptualization, funding acquisition, supervision, writing—review and editing; D.J.L.: methodology, supervision, visualization, writing—review and editing; M.S.: conceptualization, data curation, formal analysis, funding acquisition, project administration, supervision, visualization, writing—original draft, writing—review and editing.

All authors gave final approval for publication and agreed to be held accountable for the work performed therein.

Conflict of interest declaration

The authors declare no competing interests.

Funding

This study received institutional support from the Leibniz Institute for Neurobiology, the Wissenschaftsgemeinschaft Gottfried Wilhelm Leibniz and the University of Leipzig; as well as grant support from the Deutsche Forschungsgemeinschaft (DFG) (to B.G. and M.S.: GE 1091/4-1; to B.G.: FOR 2705; to N.S.: 265903901, FOR 2149/P01 (SCHO1791/1-2), 421152132, CRC 1423, project B06), the European Commission grant MINIMAL (to B.G.: FP7—618045) and the German-Israeli Foundation for Science (GIF) (to M.S.: G-2502-418.13/2018).

Acknowledgements

Technical assistance by A. Behrad, M. Dombach, F. Unterstab and the Combinatorial NeuroImaging Core Facility at the Leibniz Institute for Neurobiology, as well as discussions with C. König, M. Nawrot, P. Sakagiannis, J. Thoener, N. Toshima and B. Webb are gratefully acknowledged. We thank R. D. V. Glasgow (Zaragoza, Spain) for language editing. The publication of this article was funded by the Open Access Fund of the Leibniz Association.

Footnotes

Present address: MAGMA-AGRO S.A., Athens, Greece.

Present address: Valantic Transaction Solutions GmbH, Magdeburg, Germany.

Present address: Institute for the Advancement of Higher Education, Hokkaido University, Sapporo, Japan.

Electronic supplementary material is available online at https://doi.org/10.6084/m9.figshare.c.6476240.

Published by the Royal Society under the terms of the Creative Commons Attribution License http://creativecommons.org/licenses/by/4.0/, which permits unrestricted use, provided the original author and source are credited.

References