Home / About

How the lab works

A connectome is a wiring diagram: which neuron connects to which, and through how many synapses. Connectome Lab asks a simple question of each one. How much behaviour can the wiring produce on its own?

One format for every animal

Each species is stored as three files: species.json (metadata, transmitter signs, model settings, ready made experiments), neurons.csv and connections.csv. Importers turn published datasets into this format, and the same files feed a PostgreSQL database for analysis and the website for simulation. Adding an animal means writing one importer, not a new app.

The model

Every neuron is a leaky integrate and fire unit, following the whole brain fly model of Shiu and colleagues (Nature, 2024). A spike travels to every partner after 1.8 ms and nudges its membrane by a fixed amount times the number of synapses. Whether the nudge excites or inhibits depends only on the sender's transmitter (Dale's law). Stimulated neurons receive strong random input, which stands in for a sensory stimulus. Worm gap junctions add a weak electrical coupling. In the experiments, nothing in the circuit is trained: the wiring, synapse counts and signs are exactly as measured.

Real circuits cut from FlyWire

The whole FlyWire brain (v783, about 139,000 neurons and 54 million synapses) runs on the local runner. For the browser we cut circuits out of it: all neurons of chosen input and output types, plus every neuron on strong one or two step paths between them, with every synapse among the selected neurons kept. The escape circuit has 1,067 neurons, the visuomotor circuit 1,325. Neurons outside a circuit are missing, and each circuit page says so.

The Fly Gym uses a third, multisensory circuit of 1,846 neurons: the sugar and bitter taste neurons of the labellum, two olfactory receptor neuron types (DM1 and DA2), the motion sensing HS cells and four visual projection neuron types (LPLC1, LC4, LPLC2, LC16), wired to ten descending neuron types on both sides and to MN9 (CB0701), the proboscis motor neuron. In this circuit, as in the whole brain model of Shiu et al. (2024), sugar drives MN9 at about 126 Hz and adding bitter silences it, with no tuning; the degree preserving rewired circuit leaves MN9 silent.

The Fly Gym

Eight tasks in four families run on that one circuit: two reflexes that need no training (feeding, backing away from a wall), two games (Kuhn poker, Pong), two cognitive tests (an odour T-maze with a delay, a two armed bandit) and two tasks of body and movement (holding a course in gusty flight, chasing a moving target). For the six trained tasks, web/scripts/gym-benchmark.ts trains the real circuit and each control with the same seed, population and number of generations, keeps the readout of the last generation (never the one with the best held out score) and tests it on five held out episodes. Sensory encodings in the games are arbitrary, and tasks that need memory are expected to fail in a circuit without learning; the scoreboard shows both.

Training

In the training lab the circuit stays fixed and only a linear readout learns: a few dozen numbers that turn the firing rates of chosen output neurons into movement. The optimiser is the cross entropy method, the recipe of Fly Dino and similar demos. Every generation is scored on episodes it trains on and on held out episodes it never sees, and the same training can be run on rewired, random and silenced circuits. A trained readout can often exploit any network, so a learning curve on its own proves little; the comparison with the controls is the result. Training uses a 0.25 ms step instead of 0.1 ms, which changes firing rates in these circuits by about 2 percent.

Readouts

Firing rates are summarised into behaviour readouts chosen from the literature, for example crawling direction in the worm (forward command neurons AVB and PVC against backward command neurons AVA, AVD and AVE) or take off in the fly (the Giant Fiber). They are proxies for behaviour, not behaviour itself.

Controls

A result only means something next to a baseline. The lab offers three control brains:

  • Same degrees. Repeated edge swaps keep every neuron's number of inputs and outputs but scramble partners.
  • Random wiring. Same number of connections and the same weights, placed at random.
  • Shuffled transmitters. The real map, but excitation and inhibition are handed out at random.

When the real brain produces a response the controls do not, the behaviour depends on the specific wiring. When it does not, the model is missing something, which is just as informative.

Honest limits

  • Real neurons differ in size, receptors and dynamics. Here they are all the same simple unit.
  • Neuromodulators, learning and body feedback are absent.
  • Most worm neurons are graded rather than spiking, so the worm model is a strong simplification. It reproduces the nose touch reversal and the effect of removing AVA, and it does not reproduce the forward response to tail touch.
  • The FlyWire circuits lack the rest of the brain. The local runner removes that limit at the cost of speed.
  • Transmitter identities in FlyWire are predicted from images; glutamate is treated as inhibitory, as in the published model.
  • In this spiking model some worm head circuits (RIA and the head motor neurons) lock into persistent firing after a strong input, which real graded worm neurons do not do.
  • The synthetic teaching fly has a textbook circuit layout and invented numbers. Only the parking demo still uses it, and it is labelled.

Seeing the circuit in 3D

The neural activity panel places every neuron of a FlyWire circuit at its measured position (a point on the neuron from the FlyWire annotations, in micrometres). Around it, a faint shell shows the envelope of the whole fly brain: a surface fitted to the positions of all 138,639 FlyWire neurons (smoothed on a 6 micrometre grid). It shows where neurons are; it is not an anatomical neuropil mesh.

Real shapes. On request, the panel loads the real skeletons of up to 48 neurons of the circuit (descending neurons first) from the FlyWire v783 skeletons published by the Cambridge fly connectome group, the same source used by the fafbseg library. They are fetched by your browser and never stored by us.

Simulated calcium imaging. Real experiments rarely see spikes directly; they watch a fluorescent calcium indicator. The calcium view turns the simulated spikes into what such a microscope would show: each spike raises the indicator along a rising and a decaying exponential, the signal saturates, and shot noise is added. Kinetics are approximate single spike values for GCaMP6s, GCaMP6f and jGCaMP8f (Chen et al. 2013, Zhang et al. 2023). The idea follows the virtual calcium imaging in BrainGenix-NES; the implementation is our own.

The fly. The fly in the scenes is the body model of flybody (Vaxenburg et al. 2025, Nature; Apache 2.0), rebuilt for the web by pipeline/build_fly_model.py: its 85 meshes placed on the model's joint tree, simplified to about 84,000 triangles (28,000 on phones), and dressed with macro textures of a compound eye, a wing, the thorax and the abdomen. Legs walk with a tripod gait, the wings fold flat at rest and beat in flight; the pose is animation for the eye, not a physics simulation of the body.

The looming arena. The escape experiment is drawn the way it is done in the lab: a fly inside a curved LED display, where the threat is a dark disc that expands with angular size 2·atan(r/d), the stimulus that drives LPLC2 and the Giant Fiber (von Reyn et al. 2014; Klapoetke et al. 2017). The glossy grid floor mirrors the scene. On slow or software graphics the reflection and the finer materials switch off; add ?quality=high or ?quality=low to a page to choose.

Preview clips. The short videos on the project cards are not animations made by hand. Each one is recorded from the same simulation the live page runs, one frame at a time with a fixed seed, by web/scripts/capture-thumbs.mjs. The dataset pictures in the library plot the measured FlyWire neuron positions (pipeline/make_anatomy_thumbs.py).

Running a circuit in BrainGenix-NES

BrainGenix-NES, from the Carboncopies Foundation, simulates neurons with geometry and renders virtual electron microscopy and calcium imaging. local/nes_bridge.py builds any FlyWire circuit of the library inside a running NES: a soma at each neuron's position, a ball and stick neuron, one receptor per connection (strongest first, signed by transmitter), spontaneous input to chosen cell types, then it runs, records and saves the result. It is our own client, written from NES's published JSON protocol, so no AGPL code enters this MIT project. It has been checked against a mock server but not yet against a live NES; field names may need updating as their API evolves.

Who else works on this, and where we fit

We looked for people and institutions building a library like this one. Nobody offers exactly this combination, but several projects cover parts of it, and we build on or point to them. The full, dated list is on the research landscape page; the main ones:

  • Open Source Brain and NeuroML: the closest existing library of runnable neuroscience models, aimed at modellers. Exporting our circuits to NeuroML is on the roadmap.
  • OpenWorm: open worm connectome data and simulation. Our worm data comes from their ConnectomeToolbox.
  • FlyWire and Codex, and Janelia's MaleCNS and neuPrint: the fly datasets and their explorers.
  • Shiu et al.: the whole brain fly model we follow. NeuroMechFly and FlyGym and flybody: simulated fly bodies.
  • Eon Systems: a company emulating the whole fly brain in a simulated body.
  • The 2026 wave of demos (Fly Dino, Swat, the Minecraft and Beat Saber flies and dozens more), collected in awesome-fly and credited on our community page.

Our niche is the one constraint we fix for every experiment: a result is only shown next to its controls. Everything else can change (species, task, readout), but no behaviour appears on this site without the rewired, random or silenced version beside it. That makes the library useful for teaching and for quick hypothesis checks, and keeps it honest about what the popular demos can and cannot show.

Run it yourself

git clone https://github.com/berkeyc/connectome-lab.git
cd connectome-lab
pip install -r requirements.txt
python pipeline/build_web_bundle.py
cd web && npm install && npm run dev

The repository also contains the SQL layer, the importers, the local runner and a guide to adding a new species. Start from the training lab or the worm lab if you just want to experiment.