Download README.md from nynefold/flysim-malecns: direct link, hf CLI and curl.
- Browser
- Download file 21.7 kB
-
https://huggingface.co/datasets/nynefold/flysim-malecns/resolve/main/README.md
- Command line
-
hf download hf://datasets/nynefold/flysim-malecns/README.md
-
curl -L -o README.md https://huggingface.co/datasets/nynefold/flysim-malecns/resolve/main/README.md
license: cc-by-4.0
pretty_name: 'flysim-malecns: a whole-CNS spiking model of the male Drosophila connectome'
language:
- en
tags:
- neuroscience
- connectomics
- drosophila
- spiking-neural-network
- connectome
- biology
size_categories:
- 100K<n<1M
configs:
- config_name: neurons
data_files:
- split: train
path: data/connectome-v1/neurons.parquet
default: true
flysim-malecns: a whole-CNS spiking model of the male Drosophila connectome
This release contains a simulator-ready, hash-checked signed sparse weight matrix of the complete male fruit-fly central nervous system (MaleCNS v1.0: 165,122 traced neurons, 24.5 M edges, brain, optic lobes and ventral nerve cord). With it come a fast leaky integrate-and-fire engine that reimplements the Shiu et al. (Nature 2024) model, and the pre-registered validation record of that engine, failures included. With Brian2's own input trains, the engine reproduces Brian2 spike for spike over the whole FAFB brain. Its pre-registered engine check against Brian2 nevertheless recorded a FAIL, which a later null test traced to a badly calibrated rule. On MaleCNS, one of three visual-to-descending chains passes its pre-registered test (LC9 → DNp09). None of the culled (pruned) matrices behaves like the full one. The full brain runs at about 1.1 s of wall time per simulated second on one CPU core (provisional).
Status: frozen release. No further development is planned. Code is MIT; data, records, docs and figures are CC BY 4.0 (see Licence).
Contents
| Path | What |
|---|---|
data/connectome-v1/ |
neurons.parquet, matrix-{full,min2,min3,min5,min10}.tar.zst, manifest.json, SHA256SUMS (106 MB in total) |
flysim/ |
The Python package: engine (flysim.engine), connectome pipeline (flysim.pipeline), artefact download and loader (flysim.artifact), validation harnesses (flysim.validation), streaming worker (flysim.live), tests, scripts. pyproject.toml + uv.lock |
records/ |
The preregistration (preregistration.md), the validation log (validation-log.md), the results summary (results-summary.md), the structural pre-check (connectome-precheck.md) and the machine-written reports and per-trial summaries (results/). Written during development and edited for publication; see records/PREFACE.md |
docs/ |
connectome-artifact.md (the data format and build rules) and live-sim.md (the streaming worker) |
workflows/ |
The two GitHub Actions workflows that built the artefact and ran the Brian2 engine check, kept for reference |
figures/ |
The figures of this card and make_figures.py, which makes them from the files above |
Quick start
Download (the tag connectome-v1 pins this release):
hf download nynefold/flysim-malecns --repo-type dataset --revision connectome-v1 --local-dir flysim-malecns
# or only the code plus one matrix: add --include "flysim/*" "data/connectome-v1/neurons.parquet" \
# "data/connectome-v1/manifest.json" "data/connectome-v1/SHA256SUMS" "data/connectome-v1/matrix-full.tar.zst"
cd flysim-malecns/flysim && uv sync
Or, from the package alone, fetch one variant with SHA-256 checks. Every file is checked against SHA256SUMS, whose own hash is pinned in the code:
uv run python -m flysim.artifact fetch --variant full --dest ../data # -> ../data/connectome-v1/
Load the matrix and run one trial. This is trial 0 of the LC9 chain test at 100 Hz, and it reproduces the recorded result exactly. It takes about 3 s, including JIT compilation:
from pathlib import Path
import numpy as np
import pyarrow.parquet as pq
from flysim.artifact import load
from flysim.engine import CpuEngine, ModelParams, SynapseMatrix, poisson_schedule, trial_rng
from flysim.engine.params import W_SYN_MALE
d = Path("../data/connectome-v1")
c = load(d, "full") # CSC: column j = presynaptic neuron j
print(c.n, len(c.weights)) # 165122 24539704
nrn = pq.read_table(d / "neurons.parquet", columns=["type", "somaSide"]).to_pandas()
lc9_r = np.flatnonzero((nrn.type == "LC9") & (nrn.somaSide == "R")).astype(np.int32)
dnp09 = np.flatnonzero(nrn.type == "DNp09")
params = ModelParams(w_syn=W_SYN_MALE) # 0.1571 mV per synapse on MaleCNS
eng = CpuEngine(np.float32) # default kernel: vec
eng.load(SynapseMatrix.from_connectome(c), params)
eng.reset() # every trial starts at rest
rng = trial_rng("chain-tests", "LC9/100Hz", 0) # seed key of chain-test trial 0
eng.schedule_inputs(poisson_schedule(rng, lc9_r, 100.0, 0, 3000, params.dt)) # 0-300 ms
eng.advance_to(6000) # 600 ms in 0.1 ms steps
steps, neurons = eng.spikes_since(0)
in_window = steps < 3000
print(int(in_window.sum()), "spikes in 0-300 ms;", # 11039, as in the record
int(np.isin(neurons[in_window], dnp09).sum()), "from DNp09") # 33
The matrix is plain NumPy. Outgoing edges of neuron j are c.indices[c.indptr[j]:c.indptr[j+1]] (postsynaptic rows), with signed synapse counts c.weights[...]. For SciPy: scipy.sparse.csc_matrix((c.weights, c.indices, c.indptr), shape=(c.n, c.n)) gives W[post, pre].
Tests: uv run pytest -q (117 tests, about 30 s). Tests on the real connectome use ../data/connectome-v1/, or FLYSIM_CONNECTOME if set, and are skipped if neither has the data.
The data
| File | Contents | Size |
|---|---|---|
neurons.parquet |
One row per neuron, in matrix order (shown in the viewer) | 3.5 MB |
matrix-full.tar.zst |
All traced → traced edges from signed neurons | 40.7 MB |
matrix-min2.tar.zst |
Edges with ≥ 2 synapses (failed equivalence, study only) | 26.0 MB |
matrix-min3.tar.zst |
≥ 3 (failed equivalence, study only) | 18.7 MB |
matrix-min5.tar.zst |
≥ 5 (failed equivalence, study only) | 11.9 MB |
matrix-min10.tar.zst |
≥ 10 (failed equivalence, study only) | 5.7 MB |
manifest.json |
Source URLs and SHA-256 of the input tables, rules, counts, per-array SHA-256 | — |
SHA256SUMS |
File hashes | — |
Each matrix archive holds three .npy arrays forming a CSC matrix, one column per presynaptic neuron: indptr (int64, n + 1), indices (int32, postsynaptic rows, ascending within each column) and weights (int16, sign(pre) × synapse_count). The layout suits event-driven simulation: a step walks only the outgoing edges of the neurons that just spiked. No weight is trained or fitted. The global weight scale w_syn is a model parameter applied by the engine.
neurons.parquet columns: idx, bodyId, type, instance, superclass, class, somaSide, rootSide, transmitter, sign, x, y, z (voxels of 8 nm, for display only), pos_source (0 none, 1 soma, 2 "to soma" location, 3 synapse-weighted mean of partner positions).
Build rules
| Step | Rule |
|---|---|
| Source | MaleCNS v1.0 flat-connectome tables (annotations, neurotransmitters, weights at minconf-0.5), Janelia FlyEM, CC BY 4.0. URLs and SHA-256 in manifest.json |
| Neurons | status == "Traced": 165,122. Never culled, so every variant shares one index |
| Order | By (superclass, type, bodyId), so cell types sit together |
| Sign | From the presynaptic consensus_nt: ACh +1; GABA, glutamate, histamine −1; anything else 0. Result: 103,718 neurons +1, 57,261 −1, 4,143 zero |
| Edges | Traced → traced: 25,563,197 edges, 124,025,046 synapses |
| Omitted | 1,023,493 edges (3.2 M synapses) from sign-0 neurons, which have no fast effect in the model. These neurons still receive input and can spike |
| Quantization | int16 is lossless (largest count 2,591) |
| Culling | A variant keeps edges with count ≥ its threshold. Neurons are never removed |
| Variant | Edges | Edges kept | Synapses kept | Excitatory / inhibitory edges | In memory |
|---|---|---|---|---|---|
| full | 24,539,704 | 100% | 100% | 14.74 M / 9.80 M | 148.6 MB |
| min2 | 14,793,713 | 60.3% | 91.9% | 8.98 M / 5.81 M | 90.1 MB |
| min3 | 10,228,000 | 41.7% | 84.4% | 6.27 M / 3.96 M | 62.7 MB |
| min5 | 6,093,442 | 24.8% | 72.8% | 3.78 M / 2.32 M | 37.9 MB |
| min10 | 2,696,623 | 11.0% | 54.6% | 1.69 M / 1.01 M | 17.5 MB |
python -m flysim.pipeline.connectome fetch-raw RAW && ... build RAW OUT rebuilds the artefact from the public tables. Its checks: a synthetic-data unit test (signs, exclusions, culling, positions, deterministic rebuild); on the real data, summed LC4 → DNp01 and LC9 → DNp09 synapses equal an independent count (6,362 and 1,977); 200 random edges match the raw table; and the CSC structure is checked over every edge. Details: docs/connectome-artifact.md.
The model and engine
The model is Shiu et al.'s leaky integrate-and-fire network (their model.py), with the same parameters: rest/reset −52 mV, threshold −45 mV, τm 20 ms, τs 5 ms, refractory 2.2 ms, synaptic delay 1.8 ms, dt 0.1 ms, exact integration, no spontaneous activity. Stimulated neurons get independent Poisson trains (refractory period 0), and each input spike adds 0.275 mV × 250 = 68.75 mV to v, so they fire at the input rate. Synaptic input is w_syn × W[post, pre]. On MaleCNS, w_syn is the FAFB value 0.275 mV divided by the synapse-density ratio R (below). The input weight is not rescaled.
flysim.engine.CpuEngine is a numba kernel over the CSC matrix, with float32 state (float64 for diagnostics). It has three exact kernels: plain (the gated reference), skip_rest (visits only neurons off rest) and vec (the default: narrow refractory state, vectorized dense sweep). All three give bit-identical spikes and final state on all 1,520 chain-test trials. Seeds come from SeedSequence(20261103), spawned per (experiment, condition, trial), so a trial is a pure function of its key. flysim.live runs blocks (one 600 ms chain-test trial each) in 10 ms chunks over a process pool, with a replay cache. It was written for an interactive viewer that is not part of this release; see docs/live-sim.md.
Validation (pre-registered)
Every rule was committed in records/preregistration.md before the runs it judges. Every attempt, failure and decision is in records/validation-log.md, in order, under dated headings, and records/results-summary.md summarizes them. The machine-written reports in records/results/ are re-created exactly by the code from the per-trial summaries next to them.
Engine check against Brian2 on FAFB: recorded verdict FAIL
The pre-registered engine check compared our engine with Shiu et al.'s unmodified model.py under Brian2 2.5.1. It covered 17 conditions, with 60 Brian2 trials each, against our first 30 seeds. Result: FAIL. 63 of 68 condition checks passed, all 8 direction checks passed, and the cross-check against Shiu's shipped recording passed (validation log, Engine check, all 17 conditions, 2026-11-04). This is the recorded verdict, and it stands. We chose to continue with the FAIL on record, so every later result carries it.
The evidence that the failures are sampling noise, not an engine difference:
- Replay identity (validation log, Engine check, first attempt, 2026-11-04). Brian2's own Poisson trains, recovered from its output, were fed into our engine. In float64 it was identical to Brian2 for every spike of every neuron over the full FAFB brain for 1,000 ms, in 30 of 30 trials (about 17,000 spikes per trial). In the other direction, our trains fed into Brian2 through a
SpikeGeneratorGroupgave float64 runs identical to ours in 10 of 10 trials. The production float32 build matched the readout's first spike in every trial. - Null test of the rule itself (validation log, Validation of the recalibrated rule, 2026-11-04; exploratory, our engine only). A correct engine judged against itself fails the original pre-registered rule in 92% of replicates (184/200). Two things cause it: many per-check tolerances are set at the 95th percentile of noise, and the fixed slack on the Jaccard and Spearman similarities is far narrower than their sampling spread when few neurons are active. A recalibrated rule, added to the pre-registration as a disclosed amendment, replaces these with exact permutation tests and a Bonferroni correction. It brings the false-fail rate to 4.5% (9/200), and still fails 50/50 gates for each of two deliberately broken engines: a refractory-input bug, and all synaptic weights 5% too strong.
- Exploratory run under the recalibrated rule, on fresh seeds and a new Brian2 sample: PASS, with 68/68 condition checks, 8/8 direction checks and the cross-check. Under the original rule the same data fails 3 checks, but different ones from the gated run, as sampling noise predicts. This result is reported next to the FAIL, never instead of it.
- The engine has not changed behaviour since. The two faster kernels added later are bit-identical to the checked kernel on all 1,520 chain-test trials.
Weight-scale transfer from FAFB to MaleCNS
R is the median, over 4,513 cell types matched between MaleCNS and FAFB v630, of the ratio of mean input synapses per neuron. R = 1.7505. This is inside the pre-registered sanity band [1.2, 2.6], so w_syn_male = 0.275 / R = 0.1571 mV. On FAFB v783, R would be 1.7455 (reported, not used). Record: records/results/weight-scale.*, with one row per type.
Chain tests on MaleCNS
Poisson input goes into the right-side neurons of a visual population for 300 ms at 25–200 Hz, and descending-neuron readouts are measured. A chain passes if it meets five pre-registered criteria:
- the intended readout fires at ≥ 2 Hz;
- it fires above the 95th percentile of random-population controls;
- its rate rises with the input rate;
- the network is quiet after the stimulus;
- the intended readout beats the other readouts.
| Chain | Result |
|---|---|
| LC9 → DNp09 (approach) | PASS: 55.3 Hz at 100 Hz input, every criterion met |
| LC4 → DNp01, giant fiber (escape) | FAIL: activity persists after the stimulus (pooled late/early spike ratio 0.0245, limit 0.01) |
| LC16 → MDN (back away) | FAIL: the readout is too weak (0.14 Hz at 100 Hz) and not specific. The pre-registered alternative stimulus (LC16 + LPLC1 + LPLC2) fails the post-stimulus criterion |
Both post-stimulus failures come from the same self-sustaining loop of 49 VNC-side neurons (19 ascending, 13 VNC motor, 12 VNC intrinsic, and others). Strong giant-fiber drive switches the loop on. It then keeps firing about 550 spikes per 200 ms to the end of the trial, with no readout taking part (validation log, Chain tests on MaleCNS, 2026-11-04). Shiu et al.'s FAFB model is brain-only, so it has no VNC that could latch like this.
Pruning (culling) equivalence test: all four culled variants FAIL
Each culled matrix reran every chain-test condition with the same seeds. A variant passes only if every readout rate and latency stays within the noise floor of full and every chain keeps its verdict. Even min2, which keeps 91.9% of synapses, fails 11 of 97 checks. min5 flips a verdict: it breaks the VNC loop, so LC4 → DNp01 turns into a PASS. No culled variant is equivalent to full; the culled matrices are provided for study only. As a diagnostic, not a result: LC9 → DNp09 at 100 Hz stays between 54.4 and 55.4 Hz on every variant.
Speed benchmark: provisional
The pre-registered benchmark needs a target server, and none was set up. These numbers come from a shared 4-vCPU Xeon @ 2.80 GHz dev container, on one thread. The mean over the three chains at 100 Hz is 1.12 s of wall time per simulated second with the vec kernel, against 4.86 for plain in a paired run. That is about 0.7 s for a 600 ms whole-CNS trial. The slowest repeat is 1.62 s per simulated second, and peak RSS is about 590 MB per process.
Two reproduction traps
Both were found in a diagnostic run before the engine check (validation log, Diagnostic against Shiu's shipped recordings, 2026-11-03):
- Brian2 drops input to refractory and just-spiked neurons.
(unless refractory)puts a conditional write onvandg, and that write also covers synapticon_preandPoissonInput. The thresholder clearsnot_refractoryin the spiking step, even with a refractory period of 0. A reimplementation that only freezes integration, and letsgbuild up during refractoriness, fires up to about 2× faster downstream. - Shiu et al.'s shipped
sugarR.parquetwas run at 200 Hz, not at the 150 Hz default ofmodel.py: its stimulated neurons fire at 191–202 Hz. A comparison against it at 150 Hz fails for reasons unrelated to the engine. The pre-registration was amended before any Brian2 run to cross-check at 200 Hz.
What this release adds
This release provides:
- Whole-brain replay identity: given the same input trains, the engine matches Brian2 spike for spike over the full FAFB brain for 1 s, in both directions.
- A calibration result for engine-equivalence gates: the obvious per-check rule fails a correct engine 92% of the time. An exact permutation rule with Bonferroni correction holds about 5%, and still catches a 5% weight error.
- A negative result on pruning: no synapse-count threshold, even ≥ 2, keeps the network's readouts equivalent to the full matrix.
- The VNC loop: in a whole-CNS model with Shiu et al.'s parameters, strong giant-fiber drive switches on a self-sustaining loop of 49 VNC-side neurons.
- A published, hash-checked, simulator-ready MaleCNS matrix with its build rules, plus the preregistration and the validation log, failures included.
Limitations
- Point neurons. There are no dendrites, gap junctions, neuromodulation, plasticity or spontaneous activity. Every neuron, including the many graded-potential (non-spiking) neurons of the optic lobe and elsewhere, is modelled as a spiking LIF unit.
- Parameters fitted to FAFB. Shiu et al.'s parameters were tuned on the female brain-only FAFB connectome. Here they are carried to a male whole CNS with one global rescaling (R). The VNC and optic lobes are outside what those parameters were tested on.
- Machine-predicted transmitters set every sign (consensus where available). 4,143 neurons with no fast transmitter send no edges.
- The engine check's recorded verdict is FAIL under the original pre-registered rule. The evidence that this is a rule-calibration problem is strong, but it is exploratory.
- Only one of three behavioural chains passes. The chain results test the model's internal consistency with expected anatomy-to-behaviour mappings. They are not a fit to physiology.
- Speed figures are provisional (shared dev container, not the pre-registered target hardware).
- Not peer reviewed. The records were written by the developers during the work.
Software used
- philshiu/Drosophila_brain_model at commit
91bdd1e: Shiu et al.'s original model, run unmodified under Brian2 2.5.1 as the reference for the engine check.
Licence
- Data (
data/): derived from MaleCNS v1.0 by Janelia FlyEM (with Google and collaborators), which is released under CC BY 4.0. The derived matrices and neuron table are released under CC BY 4.0. Please cite Berg et al. (below). - Records, docs and figures (
records/,docs/,figures/*.png, this card): CC BY 4.0. The weight-scale records also contain per-cell-type statistics computed from FAFB / FlyWire tables, which keep their own terms (seeLICENSE). - Code (
flysim/,workflows/,figures/make_figures.py): MIT (LICENSE-CODE). The two notebooks inflysim/tests/fixtures/shiu/are vendored unchanged from Shiu et al. and keep their own MIT licence.
Citation
If you use the data, please cite the connectome:
- Berg, S., Beckett, I. R., Costa, M., et al. Sexual dimorphism in the complete Drosophila male central nervous system connectome. Cell 189(18), 5504–5526.e15 (2026). doi:10.1016/j.cell.2026.08.015. Preprint: bioRxiv (2025), doi:10.1101/2025.10.09.680999.
If you use the model or engine, please also cite:
- Shiu, P. K., Sterne, G. R., Spiller, N., et al. A Drosophila computational brain model reveals sensorimotor processing. Nature 634, 210–219 (2024). doi:10.1038/s41586-024-07763-9.
- Stimberg, M., Brette, R., Goodman, D. F. M. Brian 2, an intuitive and efficient neural simulator. eLife 8, e47314 (2019). doi:10.7554/eLife.47314.
Citing this dataset
@misc{flysim_malecns_2026,
title = {flysim-malecns: a whole-CNS spiking model of the male Drosophila connectome},
author = {{The flysim-malecns authors}},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/datasets/nynefold/flysim-malecns}},
url = {https://huggingface.co/datasets/nynefold/flysim-malecns},
doi = {10.57967/hf/11611}
}
DOI: 10.57967/hf/11611
The same entry is in CITATION.cff.





