Skip to main content

flybrain

The complete central nervous system of an adult male fruit fly, Drosophila melanogaster, as a spiking network you can run on your own computer: 166,700 neurons and 25.6 million connections from the MaleCNS v1.0 connectome, wired as electron microscopy found them.

Nothing inside the brain is trained. You drive some of the fly's own neurons, step the network forward, and read out what its descending neurons (the brain's commands to the body) do.

pip install flybrain              # CPU (numba)
pip install "flybrain[gpu]"       # plus CuPy for an NVIDIA GPU (CUDA 12)
from flybrain import FlyBrain

brain = FlyBrain(device="auto")          # first run downloads the brain files (~260 MB) to ~/fly-data
left_loom = brain.cells(["LC4", "LPLC2"], side="L")   # looming detectors, left eye
giant_fiber = brain.cells(["DNp01"], side="L")        # the escape command neuron

for step in range(50):                   # one second at 20 ms per step
    fired = brain.step(inject=[(left_loom, 0.8)])
    if set(giant_fiber) & set(fired):
        print(f"left giant fiber fired at {step * brain.dt:.2f} s")

What's in it

  • FlyBrain: leaky integrate-and-fire over the whole connectome. device="cpu" | "cuda" | "auto", batch=8 runs 8 independent flies at once, plus dt, sensory_input and refractory options. brain.cells([...]) finds neurons by cell type or superclass ("descending_neuron").
  • Trace, run, Readout: reservoir computing. Collect a spike trace of any neuron population over your task, then fit a cross-validated linear or logistic PCA readout to your labels.
  • Eyes, FeatureDetectors: a visual encoder that drives the fly's visual projection neurons.

Data

The brain files live in $FLY_DATA (default ~/fly-data). The first FlyBrain() downloads them; you can also run it ahead of time:

flybrain download                 # prebuilt files, sha256-checked
flybrain build                    # or build them from the MaleCNS release (~1.1 GB; pip install "flybrain[build]")
flybrain info                     # data folder and GPU status

The first step on CPU is slow while numba compiles; later steps take about 12–15 ms on 24 threads. On an RTX 4060 a step takes 1.4 ms.

Credits and license

Code: MIT. The connectome data is MaleCNS v1.0 by FlyEM (HHMI Janelia), the University of Cambridge, the MRC Laboratory of Molecular Biology and Google Research, used under CC BY 4.0. If you use it, cite Berg, S. et al. (2026), Sexual dimorphism in the complete connectome of the Drosophila male central nervous system, Cell. The neuron model follows Fly64 by Jessica Paquette.

Source, experiments and results: github.com/alextitonis/fly.ai

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flybrain-0.1.0.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flybrain-0.1.0-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file flybrain-0.1.0.tar.gz.

File metadata

  • Download URL: flybrain-0.1.0.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for flybrain-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a136ed2fe8f0ec79cc353148b027636d93cfe8c951c3c58534f9db9459d15ac4
MD5 d7796a4c91b03b659ceda1736aaa5fab
BLAKE2b-256 b55e8405563a5091198347f320d00aad1585f9cc1c73151107d122e2747a4e68

See more details on using hashes here.

File details

Details for the file flybrain-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: flybrain-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for flybrain-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0fd665df6f4f834e6c85eb25482e82ef0be505ecb63004387d4be9ea787a0a1f
MD5 a02ae9130477b4e0293f0da3c4c447a1
BLAKE2b-256 8cf04918d0c2128dbebce21bb30574ed2370ac3b646187d4893fac9edf322757

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page