← The living map prototypes / b1-electrotonic / README

Track B1: electrotonic anchoring on FlyWire

Prototype for hypothesis H2 (spec/02-hypotheses.md): effective synaptic weight depends on where a synapse sits on the postsynaptic neuron, so morphology-derived weights should predict functional connectivity better than synapse counts (test F5). This is Track B in spec/09-roadmap.md. Per the "adopt first" decision (D25), it is a small standalone package, not part of the future CAKE platform.

Method

  1. Passive cable model of each neuron from its FlyWire skeleton: one compartment per skeleton node, cylinders between nodes using skeleton radii, specific membrane resistance Rm, axial resistivity Ra and capacitance Cm. Solved in the frequency domain as a sparse linear system Y(ω) V = I.

  2. Mean transfer impedance to the outputs. For each input synapse, the mean transfer impedance from its location to the neuron's own output (presynaptic) sites. By reciprocity this needs one sparse solve per neuron: inject current spread over the output sites and read the voltage everywhere.

  3. Effective weights. A presynaptic partner's effective weight is the sum of its synapses' transfer impedances, normalized so effective weights and synapse counts have the same total. If every synapse had the same impedance, effective weights would equal counts.

  4. Headroom metrics per neuron: before any functional data, measure how far effective weights depart from counts:

    • z_cv: coefficient of variation of transfer impedance over the input synapses;
    • spearman: rank correlation of counts vs. effective weights across partners;
    • tv: fraction of input weight that moves between partners (total variation distance).

    If headroom is near zero for realistic parameters, H2 can't matter and F5 is decided without functional data. If headroom is large, the next step (B1b) tests whether effective weights predict measured activity better than counts.

Verification

uv run pytest checks the solver against physics, not just against itself:

Usage

uv sync
uv run pytest

# Build the reproducible neuron panel (needs data/flywire_annotations.tsv and proofread root IDs)
uv run python scripts/make_panel.py

# Synapse table: download once, reduce, delete the raw file (see Data)
uv run cake-b1 reduce --feather data/flywire_synapses_783.feather --out data/synapses_783_c50.parquet

# H2 headroom per neuron, and the sensitivity sweep
uv run cake-b1 --cache data run data/panel_v1.txt --synapses data/synapses_783_c50.parquet --freq 100 \
    --out results/h2_panel_v1_f100.csv --weights-dir results/weights_f100
uv run cake-b1 --cache data sensitivity data/panel_v1.txt --synapses data/synapses_783_c50.parquet \
    --rm-grid 5000 20000 50000 --ra-grid 60 250 --r-min-grid 0.05 0.15 --freq-grid 0 20 100 \
    --out results/sensitivity_panel_v1.csv

# Spiking neurons: transfer to the estimated spike initiation zone
uv run cake-b1 --cache data run data/panel_v1.txt --synapses data/synapses_783_c50.parquet --freq 100 --target siz \
    --out results/h2_panel_v1_siz_f100.csv

# Pathway weights (input partner x output partner) and local routing
uv run cake-b1 --cache data pathways data/panel_v1.txt --synapses data/synapses_783_c50.parquet --freq 100 \
    --out results/pathways_panel_v1_f100.csv --matrix-dir results/pathways_f100

# Scale-up: neuron sets, skeleton prefetch, all analyses, summary tables
uv run python scripts/make_scaleup.py
uv run cake-b1 --cache data fetch data/types_all.txt --threads 16
uv run cake-b1 --cache data fetch data/brain_sample.txt --threads 16
./scripts/run_scaleup.sh && uv run python scripts/summarize_scaleup.py

# Proxy without synapse data: transfer impedance to the root across each arbor
uv run cake-b1 --cache data arbor-spread data/sample12.txt --out results/arbor_spread.csv

Cable options for arbor-spread and run: --rm, --ra, --cm, --r-min, --freq.

Data

All data are public, FlyWire materialization 783.

Data Source Size Access
Skeletons with radii flyem.mrc-lmb.cam.ac.uk/flyconnectome/flywire_skeletons_783/<root_id> (Neuroglancer precomputed; the source fafbseg uses) ~10–200 KB per neuron Downloaded on demand and cached
Proofread root IDs Zenodo 10676866, proofread_root_ids_783.npy 1 MB Downloaded
Synapse positions Zenodo 10676866, flywire_synapses_783.feather (md5 f8f1b97c9d4b0ea9b4c8b287f6b99091) 9.5 GB Download once (about 45 min with aria2c -x 8; ~0.5 MB/s single-stream), then cake-b1 reduce to data/synapses_783_c50.parquet (3.9 GB, 130,054,535 synapses; the public file has no synapses below cleft score 50) and delete the raw file

Synapse positions are in nanometres, in the same space as the skeletons. extract keeps synapses with cleft_score >= 50, the threshold used by FlyWire's connectivity releases.

Results: panel_v1 (2026-10-07)

26 right-side neurons from 16 cell types (scripts/make_panel.py, fixed seed), synapses from the full FlyWire 783 table, transfer impedance to each neuron's own output sites. TV is the fraction of a neuron's input weight that moves between presynaptic partners when synapse counts are replaced by location-weighted effective weights. Ranges cover the sensitivity grid: Rm ∈ {5×10³, 2×10⁴, 5×10⁴} Ω·cm², Ra ∈ {60, 250} Ω·cm, radius floor ∈ {0.05, 0.15} µm (results/sensitivity_panel_v1.csv).

Group Slow signals (DC): median TV (range) 20 Hz 100 Hz
HS/VS (lobula plate tangential cells) 0.001 (0.000–0.019) 0.001 (0.000–0.020) 0.004 (0.000–0.040)
T4a, Mi1 0.009 (0.001–0.080) 0.015 (0.001–0.086) 0.039 (0.003–0.171)
LC4 0.007 (0.001–0.055) 0.011 (0.001–0.060) 0.049 (0.008–0.146)
LPLC2 0.034 (0.005–0.174) 0.066 (0.009–0.192) 0.216 (0.082–0.375)
Descending neurons (DNp01, DNa02) 0.017 (0.003–0.073) 0.027 (0.006–0.081) 0.086 (0.028–0.180)
MBON01, PS180 0.025 (0.003–0.119) 0.041 (0.005–0.129) 0.145 (0.040–0.180)
APL 0.035 (0.021–0.044) 0.041 (0.037–0.044) 0.046 (0.043–0.049)
Olfactory projection neurons (DA1, DL5) 0.137 (0.021–0.514) 0.283 (0.076–0.552) 0.502 (0.346–0.760)

Most sensitive parameters: axial resistivity (median TV 0.013 at 60 vs. 0.051 at 250 Ω·cm) and membrane resistance (0.048 at 5×10³ vs. 0.012 at 5×10⁴ Ω·cm²). The radius floor barely matters.

What this shows:

  1. For slow signals, location barely matters in most cell types. Median TV is at most 3.5% in every group except projection neurons, across the whole parameter grid. For slow or graded signaling, synapse counts are a good proxy for effective weight. This supports count-based whole-brain models for slow dynamics and narrows where H2 can matter.
  2. H2's headroom grows with signal frequency and is cell-type specific. At 100 Hz it is large in LPLC2 (~22%), MBON01/PS180 (~15%) and projection neurons (~50%), and still negligible in HS/VS cells. F5 should therefore be tested on fast responses in these cell types, not averaged over the brain.
  3. The large projection-neuron values are partly an artifact. In a DA1 projection neuron, inputs from olfactory receptor neurons make 41% of synapses, but get 36% of effective weight for slow signals and 11% at 100 Hz, because they sit on dendrites far from the axonal outputs. Projection neurons spike, and active spike regeneration between the spike initiation zone and the outputs is absent from a passive model. For spiking neurons the transfer target should be the spike initiation zone, not the output synapses.

Method lessons:

Method fixes: spike initiation zones and pathway weights

Both lessons above are now implemented and run on the same panel with default cable parameters.

Spike initiation zone (SIZ) target (run --target siz). For spiking neurons, transfer is measured to an estimated SIZ instead of the output synapses. The SIZ is estimated with synapse flow centrality (Schneider-Mizell et al. 2016): the cable crossed by the most input-to-output synapse paths, which links dendrite and axon. This first version took the SIZ at the end of that cable nearest the outputs, which was wrong; see the correction below. The table shows first-version values. TV (fraction of input weight moved) at 100 Hz:

Spiking neuron Target: outputs Target: SIZ
DL5 projection neuron 0.47 0.08
PS180 0.15 0.05
Giant fiber (DNp01) 0.06 0.01
DNa02 0.10 0.07
MBON01 0.09 0.06
DA1 projection neurons (mean of 3) 0.61 0.34

Most of the projection-neuron effect came from omitting spikes. DA1 stays high and needs a check of where its SIZ estimate lands. The SIZ target is meaningless for non-spiking neurons (it gives APL an arbitrary TV of 0.3–0.5).

Pathway weights (pathways). For each neuron, transfer from every input partner to each of its 50 strongest output partners (one solve per output partner by reciprocity). nonsep is the distance from the best one-unit model, in which any input reaches every output in fixed proportions; it measures local routing:

Neuron nonsep, slow signals nonsep, 100 Hz Output synapses covered
APL 0.29 0.41 4%
DL5 projection neuron 0.08 0.35 16%
PS180 0.05 0.25 21%
DA1 projection neurons 0.03 0.18 19%
MBON01, DNp01 ≤ 0.01 0.07 20–35%
HS/VS, LPLC2, LC4, T4a, Mi1 ≤ 0.01 ≤ 0.05 11–50%

Takeaway for H2. The right effective-connectivity model depends on how a neuron transmits: spiking neurons need one weight per input partner, measured at the SIZ; non-spiking neurons with extended arbors (APL) need pathway-level weights. Counts are adequate for most cell types for slow signals.

SIZ correction, full APL coverage and scale-up (2026-10-07)

SIZ rule corrected. The first rule placed the SIZ at the end of the maximum-flow cable nearest the outputs. In projection neurons that cable is the whole ~180 µm axon tract, so the SIZ landed next to the outputs, which is physiologically wrong. Insect SIZs sit at the start of the axon, near where the soma's neurite joins. The rule now takes the maximum-flow node closest to the soma along the cable. Checks:

With the corrected SIZ, DA1 projection neurons move 0.07 of input weight at 100 Hz (0.34 under the old rule, 0.61 measured at outputs).

Transmission modes come from config/transmission_modes.tsv: literature-based labels with confidence levels. Types not confirmed from recordings stay "unknown". The citations there were written from memory and need checking.

APL with every output partner. All 44,678 output partners (100% of its output synapses), not just the strongest 50:

APL, all partners Slow signals 100 Hz
Non-separability (local routing) 0.40 0.58
Top 50 partners only (4% of outputs), for comparison 0.29 0.41

Local routing is stronger with full coverage, so the earlier result was not an artifact of sampling.

Scale-up (scripts/make_scaleup.py, scripts/run_scaleup.sh, scripts/summarize_scaleup.py; default cable parameters):

Cell types, each reported with the measure that fits its transmission mode (median [IQR]):

Cell type (n) Mode Measure Slow signals 100 Hz
DA1 projection neuron (15) spiking TV, SIZ target 0.025 [0.024–0.034] 0.075 [0.066–0.097]
DNp01, DNa02 (2 each) spiking TV, SIZ target 0.004, 0.011 0.009, 0.057
MBON01 (2) spiking TV, SIZ target 0.014 0.077
HS/VS cells (2 each) graded non-separability ≤ 0.008 ≤ 0.042
Mi1 (1,584) graded non-separability 0.006 [0.004–0.007] 0.027 [0.019–0.036]
APL (2) graded non-separability (top 50 partners) 0.31 0.39
LPLC2 (210) unknown TV outputs / TV SIZ / non-sep. 0.027 / 0.021 / 0.007 0.206 / 0.141 / 0.049
LC4 (104) unknown TV outputs / TV SIZ / non-sep. 0.005 / 0.003 / 0.002 0.035 / 0.011 / 0.013
T4a (1,462) unknown TV outputs / TV SIZ / non-sep. 0.006 / 0.005 / 0.003 0.027 / 0.020 / 0.011

Brain-wide sample by super class (median TV, output target / SIZ target; non-separability), and share of neurons above 0.1 at 100 Hz:

Super class Slow: TV out / SIZ / non-sep. 100 Hz: TV out / SIZ / non-sep. Share > 0.1 at 100 Hz (SIZ / non-sep.)
visual centrifugal 0.074 / 0.041 / 0.020 0.333 / 0.130 / 0.130 63% / 60%
central 0.040 / 0.028 / 0.020 0.222 / 0.124 / 0.097 62% / 50%
visual projection 0.028 / 0.015 / 0.011 0.195 / 0.070 / 0.081 38% / 43%
descending 0.008 / 0.007 / 0.004 0.056 / 0.034 / 0.034 22% / 29%
endocrine 0.019 / 0.013 / 0.006 0.061 / 0.056 / 0.026 23% / 0%
motor 0.007 / 0.009 / 0.005 0.041 / 0.047 / 0.027 25% / 25%
optic 0.009 / 0.008 / 0.005 0.049 / 0.040 / 0.022 13% / 19%
ascending 0.003 / 0.008 / 0.005 0.016 / 0.033 / 0.019 18% / 20%
sensory, sensory ascending ≤ 0.001 ≤ 0.005 ≤ 15%

The pathway analysis needs in-brain output partners with at least 5 synapses and at least one input, so it skips 169 of the 600 sampled neurons, mostly endocrine (56), motor (44) and sensory (50) neurons that project outside the brain or lack inputs; 16 T4a cells are skipped for the same reason. Non-separability for those classes rests on few neurons.

What the scale-up shows:

  1. For slow signals, synapse counts are an adequate proxy almost everywhere. No super class has a median above 0.074 by any measure, and the spiking-appropriate (SIZ) measure stays at or below 0.041.
  2. H2's domain is fast signaling in central-brain and visual feedback neurons. At 100 Hz, about 60% of central and visual centrifugal neurons move more than 10% of input weight even with the spike-appropriate measure, and about half show local routing above 0.1. Optic-lobe intrinsic, sensory, ascending and most descending neurons stay compact.
  3. Local routing is not limited to APL. It is common in central and visual centrifugal neurons at 100 Hz, but rare for slow signals, where APL remains exceptional.
  4. Large, consistent populations behave alike. All 210 LPLC2 cells show substantial input reweighting at 100 Hz (IQR 0.08–0.22 with the SIZ target) but little local routing; T4a, Mi1 and LC4 populations are uniformly compact.

These results use default cable parameters only. The sensitivity sweep (panel) showed axial resistivity and membrane resistance shift values by up to ~4×, so the class ranking is more reliable than the absolute numbers.

Earlier proxy (superseded)

Before synapse data were available, arbor-spread measured transfer impedance to the root (soma) on 12 random neurons. It suggested the same frequency and Rm dependence, but measuring at the soma made HS/VS cells look compact for the wrong reason (their somata hang off long thin neurites). Kept only for the record in results/arbor_spread_*.

Next steps

  1. Sensitivity at scale: repeat the brain-wide sample over the Rm × Ra grid, to see whether the class ranking holds.
  2. Transmission modes: check the citations in config/transmission_modes.tsv and extend labels to more types (central and visual centrifugal neurons first, where headroom is largest).
  3. SIZ validation beyond projection neurons: compare SIZ estimates with recorded spike initiation sites where published (e.g. descending neurons).
  4. B1b: compare count-based and effective-weight-based predictions of measured fast responses in high-headroom types (LPLC2, MBONs).
  5. Radius models: radius floor barely matters; test alternative diameter models (e.g. taper by branch order) before relying on skeleton radii.