Tech6 min read

Drosophila Connectome: 139k Neurons vs LLMs and Minimal Python Code

IkesanContents

In October 2024, the FlyWire Consortium—an international team led by Sebastian Seung and Mala Murthy at Princeton University—published the complete adult fruit fly (Drosophila melanogaster) synaptic connectome in a special issue of Nature.

Thirty-eight years after researchers mapped the 302-neuron nervous system of C. elegans in 1986, we now have a synapse-resolution wiring diagram for an animal that executes complex autonomous behaviors like flight control, visual target tracking, and associative learning. This article covers the scale of the dataset, four major research directions, structural differences compared to large language models (LLMs), and minimal Python code to inspect the circuits with navis and brian2.

Connectome Scale and Key Research Applications

Key metrics for the released connectome:

MetricScale
Total neurons139,255
Total synapses~54.5 million
Total neurite length~150 meters (packed into <1 mm³)
Classified cell types8,453 types (>4,500 identified for the first time)

Researchers segmented serial-section transmission electron microscopy images (the FAFB dataset) using AI, then corrected segmentation errors through a global collaborative effort involving researchers and citizen scientists on a web-based proofreading platform. Since its release, researchers have applied this wiring diagram across neuroscience, machine learning, and robotics.

Whole-Brain Leaky Integrate-and-Fire Simulation

Shiu et al. (Nature, 2024) built a whole-brain computational model that integrated 139k neurons, 54.5 million synapses, connection weights, and the excitatory or inhibitory neurotransmitter profiles (acetylcholine, GABA, glutamate).
Simulations of the feeding reflex (extending the proboscis in response to sugar) and grooming circuits matched in vivo neural activity from live flies with over 90% accuracy.

Deep Learning with Connectome Constraints

Researchers developed “Deep Mechanistic Networks,” a method that fixes the biological wiring topology of the visual system and optimizes only synaptic weights and time constants via deep learning.
When trained strictly on a motion-tracking task, the model naturally developed direction-selective neural responses that match classical electrophysiological measurements in living flies.

Integration with Embodied Physics Simulators

Teams have integrated connectome-derived neural circuits into MuJoCo-based physics environments, including EPFL’s “NeuroMechFly v2” and Google DeepMind’s “flybody.”
These virtual flies receive sensory inputs—such as visual motion and leg ground contact—to perform closed-loop walking and obstacle avoidance.

Whole-Brain Mapping onto Neuromorphic Hardware

A team at Sandia National Laboratories mapped the FlyWire connectome directly onto Intel’s Loihi 2 neuromorphic chip.
Using asynchronous, event-driven spikes, they demonstrated real-time execution of whole-brain firing dynamics at milliwatt-level power consumption.

Structural Differences: LLMs vs. the Drosophila Connectome

Major architectural and operational differences between LLMs and the fly connectome:

FeatureLarge Language Models (LLMs)Drosophila Whole-Brain Connectome
ScaleBillions to trillions of parameters (dense matrices)~139,255 neurons, ~54.5 million synapses
Power consumptionHundreds of kilowatts to megawatts (data centers)Sub-milliwatt (living organism)
ArchitectureHomogeneous layer stacks, unidirectional feedforward (Transformers)Dense recurrent loops (local and global feedback)
ComputationClock-synchronized dense matrix multiplication (GEMM)Asynchronous event-driven spiking (SNN), sparse firing
EmbodimentDisembodied autoregressive inference over token sequencesClosed-loop sensorimotor coupling
Knowledge acquisitionPost-hoc training on massive text corporaGenetically wired circuits refined by evolutionary selection

LLMs rely on stacked, uniform layers where parameters are optimized post-hoc across massive training corpora. In contrast, the fly brain hardwires motion detection and heading tracking directly into its circuit topology. It interacts with the physical world through structural wiring alone, without requiring pre-training.

Applications in Robotics and Edge Control

Insect neural circuits offer immediate blueprints for resource-constrained robotics and low-power edge systems where GPUs are impractical.

In micro air vehicles (MAVs) and sub-gram robots, payload limits preclude onboard GPUs. Wiring principles from the fly’s visual lobula plate run on microcontrollers and spiking neural network (SNN) chips for optic-flow attitude stabilization and obstacle avoidance.

Compass neurons in the central complex—specifically the ellipsoid body-protocerebral bridge-gall (E-PG) neurons—form a ring attractor network. These cells integrate polarized light and angular velocity to maintain an internal heading representation. Roboticists use this circuit architecture for GPS-denied dead reckoning in underground tunnels and indoor facilities.

Fly sensory circuits also fuse mechanical wind sensing from antennae, olfactory signals from odorant receptors, and visual flow from compound eyes within milliseconds. Engineers adapt these multimodal circuits for plume tracking—locating chemical or gas leak sources inside turbulent airflow.

Finally, rapid flight reflexes that adjust wing kinematics within milliseconds of a gust perturbation provide inspiration for latency-critical flight control in high-agility drones.

Fetching Open Data and Python Code Examples

The FlyWire dataset is open-access and accessible via both web browsers and Python packages. Common libraries for visualizing and analyzing neural connectivity data include navis, fafbseg, and brian2.

Inspecting Circuits in Browser and 3D Meshes

On the official FlyWire Codex platform (https://codex.flywire.ai), you can search neurons by cell type or ID, explore 3D morphologies, and inspect synapse counts. For instance, you can look up compass neurons like E-PG or motion detectors like T4 and T5.

Here is how to fetch and plot 3D neuron meshes using navis and fafbseg:

import navis
import fafbseg.flywire as fw

# Root IDs for heading compass neurons (E-PG neurons)
root_ids = [720575940614131064, 720575940625345758]

# Fetch 3D meshes and render interactively in a browser via Plotly
neurons = fw.get_mesh_neuron(root_ids)
fig = navis.plot3d(neurons, backend="plotly", inline=False)
fig.show()

Extracting Synaptic Connectivity Matrices

To extract synapse counts between specific neuron groups into a pandas DataFrame:

from fafbseg import flywire

# Query synaptic connections between the specified neurons
synapses = flywire.get_synapses(root_ids, pre=True, post=True)
matrix = synapses.groupby(["pre_pt_root_id", "post_pt_root_id"]).size().unstack(fill_value=0)
print(matrix)

Simulating Spiking Dynamics with Brian 2

The following minimal script assigns the connectome synapse count to synaptic weights (the magnitude of postsynaptic potentials) and simulates two-neuron spike propagation using brian2:

import matplotlib.pyplot as plt
from brian2 import *

start_scope()

# Leaky Integrate-and-Fire (LIF) model
tau = 10 * ms
eqs = """
dv/dt = (v_rest - v) / tau : volt (unless refractory)
v_rest : volt
"""

G = NeuronGroup(2, eqs, threshold="v > -50*mV", reset="v = -70*mV", refractory=2*ms, method="exact")
G.v = [-65, -70] * mV
G.v_rest = [-45, -70] * mV  # Drive neuron 0 to fire spontaneously

# Scale synaptic weight by connectome synapse counts
syn_weight = 3.5 * mV
S = Synapses(G, G, on_pre="v_post += syn_weight")
S.connect(i=0, j=1)

statemon = StateMonitor(G, "v", record=True)
run(100 * ms)

plt.figure(figsize=(9, 3.5))
plt.plot(statemon.t / ms, statemon.v[0] / mV, label="Neuron 0 (Pre)")
plt.plot(statemon.t / ms, statemon.v[1] / mV, label="Neuron 1 (Post)")
plt.axhline(-50, ls="--", color="gray", label="Threshold (-50mV)")
plt.xlabel("Time (ms)")
plt.ylabel("Voltage (mV)")
plt.legend()
plt.tight_layout()
plt.savefig("snn_test.png")