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

Metadata

Release files for flybrain 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flybrain 0.1.0
File Size Uploaded Provenance Actions
flybrain-0.1.0.tar.gz 30.2 kB Without provenance Details for flybrain-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flybrain 0.1.0
File Interpreter ABI Platform Actions
flybrain-0.1.0-py3-none-any.whl Python 3 none any Details for flybrain-0.1.0-py3-none-any.whl

Total release size: 53.1 kB

Release files / flybrain-0.1.0.tar.gz

Download URL flybrain-0.1.0.tar.gz
Size 30.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a136ed2fe8f0ec79cc353148b027636d93cfe8c951c3c58534f9db9459d15ac4
BLAKE2b-256 checksum
How to use checksums
b55e8405563a5091198347f320d00aad1585f9cc1c73151107d122e2747a4e68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / flybrain-0.1.0-py3-none-any.whl

Download URL flybrain-0.1.0-py3-none-any.whl
Size 22.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0fd665df6f4f834e6c85eb25482e82ef0be505ecb63004387d4be9ea787a0a1f
BLAKE2b-256 checksum
How to use checksums
8cf04918d0c2128dbebce21bb30574ed2370ac3b646187d4893fac9edf322757
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for flybrain 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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