Title of thesis: Mechanisms of visual integration and competition in innate behaviours in Drosophila melanogaster

The background

For my PhD, I studied how the invertebrate visual system guides locomotion; in simpler terms, how do fruit flies (Drosophila melanogaster) see and walk. It might sound a bit strange to study how flies walk. Despite their name and their ability to execute impressive aerial maneuvers, fruit fles spend a surprising amount of their time not flying and perform a host of very interesting and complex behaviours while walking; so, its not as strange as it might seem at first glance.
As the title of my thesis suggests, I focused on how the fly’s brain assimilates visual stimuli—via integration or competition—to generate appropriate movement. Though I used fruit flies as a model, the underlying problem—how do animals make sense of the myriad stimuli that they encounter at every moment—is universal and one that must be solved by all animals, including human beings.

My PhD involved two main projects addressing complementary aspects of perception:

  1. Integration: How are visual stimuli from both halves of the visual field combined/integrated to produce appropriate behaviour?
    In the context of my PhD, visual stimuli = motion cues and appropriate behaviour = optomotor response.
  2. Competition: How does a fly, engaged in a visual task, respond when shown another distracting visual stimulus?
    In my PhD, visual task = visual tracking of female by male fly during courtship and distrating visual stimulus = a visual stimulus that triggers the optomotor response.

Methods

Behavioural setup

I first designed and built a behavioral setup to record locomotion and present visual stimuli to freely walking fruit flies in a closed-loop manner. This setup enabled the study of innate visually guided behaviors, such as the optomotor response and courtship.
The setup consisted of a flat horizontal plate on which the fly could walk. A camera placed underneath recorded its movements, while a projector mounted above displayed various visual patterns on the roof of the arena.

Left, Schematic of behavioural setup. The fly walks on a flat horizontal arena and the visual stimulus (in this case, a pinwheel) is projected onto the roof of the arena. Right, Example video of one trial in the behavioural setup

Code to run the experiments

The code to run the experiments and save the data were written in Python.
Python libraries used:

Schematic of the closed-loop visual experiment. Fly behavior was sampled at 60 Hz. There was a total delay of < 50 ms (3 frames) betweem capturing fly behaviour and presenting the updated stimulus.
define total_trial_num
define frames_per_trial

while trial<frames_per_trial
    while frame<frame_num
        grab image from camera
        extract location (loc) and orientaion (ori) of fly
        define parameters of stimulus using loc and ori
        send stimulus parameters to project
        projector shows updated stimulus
        save loc and ori to a csv file
        save image to a video
        frame=frame+1
    trial=trial+1

Each loop to correspondeds to one frame of the video. For a more in-depth explanation of the python script used for running the exeriments, you can go here

Data

Each experimental session was divided into multiple trials with randomized stimulus parameters. The raw output included:

  • A cropped video centered on the fly (to save space)
  • A CSV file with frame-by-frame location, orientation, and timestamps
  • A JSON file with session and trial metadata (e.g., date, time, fly sex, stimulus parameters) For preprocessing, data from the CSV and JSON files were merged into 2D NumPy arrays, with each row representing a trial and each column a video frame. These numpy arrays were then used for further analysis.

To know more about the details of the data formats that I used and my thoughts regarding data please go here

Optomotor response in walking fruitflies

While walking in a straight line might seem trivial, it is anything but. Constant adjustments are required to maintain a straight trajectory. And constant feedback, in the form of visual cues, is needed to perform these adjustments. Visual cues help us judge our motion and make the necessary corrections in real time. This process has been studied extensively in insects, particularly in fruit flies, through a behavior known as the optomotor response. When an insect is exposed to global rotational motion, it begins to turn in the direction of that motion. This happens because the visual system is tricked into interpreting external motion as self-motion. In response, the fly turns to cancel out the perceived motion and thereby maintain a straight path.

Left (Top), Example video showing an optomotor response in our behavioural setup. Right (Bottom), Quantification of optomotor response with data pooled from 10 flies. Once the stimulus starts (dashed line), the flies consistently turn in the direction of the rotating pinwheel

Fruitfly courtship

When a male and female fruit fly are introduced into the behavioral arena, the male begins to track or chase the female in an attempt to mate. This courtship behavior relies on multiple sensory modalities (visual, olfactory, and gustatory) but is primarily guided by visual cues.

Left (Top), Example video showing the male fly tracking the female. The two flies are shown in the inset at the top. Right (Bottom), Quantification of tracking behaviour with data pooled from 15 flies.

Optogenetically induced fruitfly courtship

Interestingly, the same behaviour can be induced by optogenetically activating the P1 neurons in the fly’s brain. This triggers such a high level of arousal in the male that it begins to chase any visual stimulus even vaguely resembling a female. We exploit this response to make the male track a simple black dot.

Left (Top), Example video showing an optogenetically stimulated male fly tracking a dot. Right (Bottom), Quantification of tracking behaviour with data pooled from 10 flies.