← Jordi Lluis / Projects

Fly Brain

Can the wiring of a fruit fly’s brain help a computer simulation carry a signal better than random wiring? I tested it on real data, wrote each test plan down before running it, and the final answer was no.

PYTHON · NUMPY · SCIPY · PYTEST · GITHUB ACTIONS

01 / Problem

The real problem

Scientists have mapped connections between a fruit fly’s neurons: 165,122 neurons and 25.6 million connections in the version I used. A map tells us what connects to what; it does not tell us whether a computer using those connections works better than one wired at random.

Comparing the two fairly is the hard part. Random wiring differs from the real map in many dull ways — size, how busy the network gets, how many connections each neuron has — and any of them can produce a difference that has nothing to do with the wiring itself.

03 / Ownership

My contribution

I built Python code that downloads and checks the published map, turns 500-neuron sections of it into simulated networks, and compares them with shuffled versions under the same conditions. Every run saves its settings and results, failures included.

Most of the work was checking my own tests. Six times a fault in the comparison changed the answer, including a shuffled network that silently lost 8% of its connections, settings tuned for the wrong input, a readout watching the wrong neurons, and a shuffled network where neurons both excited and inhibited, which real neurons do not do. After each fix I wrote the next test plan down and published it before running anything.

At one point the real wiring appeared to win. Repeated with a stricter test on two different groups of neurons, it did no better than a fair shuffle on one group and worse on the other. I published that result.

Skills this work used

Tools and what they did in this project
SkillWhere it was used
Python + NumPy/SciPyLoad a 25-million-connection map and simulate activity without storing every possible connection.
StatisticsPaired comparisons with confidence intervals over many repeats, and rules for when a run counts.
pytest + GitHub ActionsAbout 100 tests that pin down each fault so it cannot come back, run on every change.
ReproducibilityA fresh copy of the project reproduced 3,960 of 3,960 results exactly; rebuilding from the original data gives the same totals.

The experiment, step by step

  1. Load the published fruit-fly connection map and check its file hashes.
  2. Take a 500-neuron section and build shuffled versions that keep chosen properties of the real one.
  3. Tune every network to the same level of activity, then send the same noisy signals into each.
  4. Measure how well a simple readout can tell the signals apart from the network’s activity.
  5. Write the plan down and publish it first, run on fresh random seeds, and save every result.

04 / Architecture

How it works

From source data to a result
ComponentDepends onResponsibility
Connection mapPublished MaleCNS v1.0 dataKeeps the original wiring fixed and verified.
Shuffled networksThe map and a shuffling ruleKeep some properties of the real wiring and randomise the rest.
SimulationEach network and a written experiment planCalculates how activity changes after an input.
ChecksActivity from each simulationDecide whether the runs can be compared fairly.
Result recordSettings, checks and measurementsShows what ran, what failed and what was concluded.

05 / Data model

What gets saved

The original data, the experiment plans and the results are kept separate, and results are never overwritten.

Data and experiment records
RecordDepends onResponsibility
Source recordOriginal files and their hashesIdentifies the exact data used.
Experiment planQuestion, inputs and decision ruleRecords what will be tested, and how it will be judged, before running it.
Run resultsMeasurements and failure reasonsKeeps unsuccessful runs visible too.

06 / Postmortem

What works, and what is still missing

The code loads the full map, runs fair comparisons and reproduces its own results exactly. Against fully random wiring, the real map did better on one group of neurons and worse on another. Against a fair shuffle that keeps each neuron’s connection counts and signal type, it did no better on either group.

Still missing: a task that needs real memory (here a reader with no network at all already scores 83%), and groups of neurons chosen by brain region rather than by how connected they are. This is a research exercise, not a simulation of a living fly or a demonstrated AI product. The repository contains every plan and result.