Skip to main content

flycns

ci license: MIT

Compile a fly connectome release into a graph a simulator can run, model the two compound eyes over the release's own optic-lobe columns, and simulate the whole central nervous system with the published neuron models, in Python and in the browser, with the two implementations held to each other by parity tests.

  • Release: MaleCNS v1.0, the complete male Drosophila CNS (166,700 neurons, brain and ventral nerve cord; Berg et al., Cell 189:5504-5526, 2026, doi:10.1016/j.cell.2026.08.015; data CC BY 4.0). Both optic lobes are mapped column by column in the release (879 columns left, 892 right), which is what lets two eyes feed it.
  • Neuron models: the published leaky integrate-and-fire model of the fly brain (Shiu et al., Nature 634:210-219, 2024, doi:10.1038/s41586-024-07763-9), and a graded optic lobe in the form of the connectome-constrained visual model (Lappalainen et al., Nature 2024, doi:10.1038/s41586-024-07939-3).
  • Two implementations, one set of equations: a Python reference (NumPy, and PyTorch on a GPU) and a browser engine (@fasl-work/flycns, WebGPU with a worker fallback).

What it is not

A general neural simulator, a learned model of the fly, or a claim about behaviour. Synapse counts and signs are data and never change; the package integrates published equations over them and says where those equations are known to fall short.

Status

Version 0.06.001: the MaleCNS v1.0 compiler and compiled format; the two compound eyes over the release's own columns, their vertical set by the dorsal rim; the published spiking model, identical to a literal Brian2 transcription, on a NumPy reference and a GPU engine; the graded visual neurons as flyvis computes them, held to flyvis itself, with its 50 trained networks shipped as data; and flyvis's numbers transferred onto the neuron-level wiring of both MaleCNS optic lobes, where T4 cells, measured through the modelled eyes, prefer their known directions; and the whole CNS coupled, in four engines (the published model everywhere, which does not see; the graded optic lobes with the spiking CNS, which carries a flash to the motor neurons; flyvis's own networks mapped onto MaleCNS; and the stabilised version, which leaves the published model one state). Next: the browser engine. This README lists capabilities only as they land.

Compile MaleCNS v1.0

Download the four tables listed in docs/releases/01_malecns-v1.md into one folder, then:

from pathlib import Path
from flycns.release import compile_malecns_v1
from flycns.compiled import read_compiled

compile_malecns_v1(Path("malecns-tables"), Path("compiled/malecns-v1.0"), progress=print)
graph = read_compiled(Path("compiled/malecns-v1.0"))      # every array verified against its SHA-256
print(graph.n_neurons, graph.n_edges, graph.counts["columns"])

A table whose SHA-256 differs from the locked value is refused. Compilation streams the 13 GB synapse table in record batches and takes a few minutes on a desktop.

Simulate

from pathlib import Path

from flycns.compiled import read_compiled
from flycns.dynamics import Drive, LIFReference, synaptic_weights

graph = read_compiled(Path("compiled/malecns-v1.0"))
weights = synaptic_weights(graph["csr_indptr"], graph["csr_indices"], graph["csr_count"], graph["neuron_sign"], 0.275)
engine = LIFReference(graph["csr_indptr"], graph["csr_indices"], weights)      # or LIFTorch on a GPU
run = engine.run(10_000, Drive(activate={1234: 150.0}), seed=0)                   # one second of model time
print(run.spike_counts().sum(), "spikes")

The graded visual neurons run through flycns.dynamics.GradedReference (or GradedTorch), with the trained flyvis parameters from flycns.flyvis.load_ensemble(); see docs/models/03_graded.md.

Install

pip install flycns              # Python 3.11+; flycns[gpu] adds PyTorch, flycns[release] reads release files

The Python package is on PyPI as flycns, published from this repository's releases through trusted publishing. The browser engine, @fasl-work/flycns on npm, is not published: it is the next unit, and until it lands the TypeScript package exports only its version.

Install (development)

python -m venv .venv
.venv/Scripts/python -m pip install -e ".[dev,release,parity]"     # add ,gpu for PyTorch; .venv/bin/python elsewhere
.venv/Scripts/python -m pytest -rs
npm ci && npm test

Documentation

The wiki starts at docs/README.md.

License

Code: MIT. Connectome data are not redistributed here; they are fetched from the release with their hashes checked, and remain under their own licence (MaleCNS: CC BY 4.0). The trained parameters of flyvis's pretrained networks ship inside the package under flyvis's MIT licence, whose notice travels with them (src/flycns/data/flyvis-1.2.0-ensemble/LICENSE-flyvis.txt).

Release files for flycns 0.6.1

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

Source distribution (sdist)

Source distribution for flycns 0.6.1
File Size Uploaded
flycns-0.6.1.tar.gz 231.3 kB Details

Built distribution (wheel)

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

Total release size: 437.9 kB

Release files / flycns-0.6.1.tar.gz

Download URL flycns-0.6.1.tar.gz
Size 231.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e810fc3573ad5688b77de6bf0c30de5273a847ec487b8c9e6e4508e5d285e2d2
BLAKE2b-256 checksum
How to use checksums
ccf76c3e3f0b5253446f0e3ef5686e9be955555bdc938e49c8c413cc9202fe63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / flycns-0.6.1-py3-none-any.whl

Download URL flycns-0.6.1-py3-none-any.whl
Size 206.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c25f3ce66d16eb92197dac7dca378825a5607012d378ca7fa7aa2a594ef8638c
BLAKE2b-256 checksum
How to use checksums
0351fd5a269648a7aaab19c74e1c5f02bd740b48119fec754eabca59b6f34357
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.6.0

2 release 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