The key engineering step is turning anatomical tables into an executable, directed network while preserving what the data actually measures.

## Start with three source tables

The importer uses the public MaleCNS v1.0 flat files: neuron annotations, neurotransmitter predictions, and segment-to-segment synapse counts. It reads these tables directly, so preparing this model does not require downloading the electron-microscopy image volume. Official MaleCNS download documentation.

Table used | Role in this project
--- | ---
Body annotations | Identify named, Traced neurons and their type, side, superclass, and nerve-cord segment.
Body neurotransmitters | Attach a predicted transmitter label, later converted into an assumed fast synaptic sign.
Connectome weights | Supply directed source-to-target synapse counts, including original input totals.

The preparation code retains exact source URLs and SHA-256 hashes in the exported graphs. A hash records the bytes used, which makes an experiment traceable even if a source file is later updated. Downloading current files again should include a comparison against those recorded hashes.

## Turn neurons into population units

The full connection table is much larger than the browser needs for an interactive experiment. The model first retains named, Traced neurons, then groups them by cell type × side × nerve-cord soma segment. One scalar activity variable represents each group.

    population key = type + "|" + side + "|" + segment

    Example population key:
    TTMn|R|T2

Original neuron body IDs remain attached to each population. Counts on all directed neuron connections between two groups are summed into a population edge. A within-population connection becomes a self-edge, so recurrent effects are not automatically discarded.

This is a deliberate reduction. It removes individual-neuron variability and within-type receptive-field positions. It also means that a population-level path can combine edges belonging to different individual neurons. Such a path is not proof of a continuous single-neuron route.

## Keep the model scales distinct

Model | Units | Represented neurons | Directed links
--- | --- | --- | ---
Circuit experiment | {{CIRCUIT_NODES}} | {{CIRCUIT_NEURONS}} | {{CIRCUIT_EDGES}}
Embodied arena | {{ARENA_NODES}} | {{ARENA_NEURONS}} | {{ARENA_EDGES}}
Full typed CNS, Python | {{FULL_NODES}} | {{FULL_NEURONS}} | {{FULL_EDGES}}

These counts are read from the prepared project data when the articles are generated. The full typed model still pools neurons, and excludes untyped or non-Traced units. The browser runs the two smaller graphs; full-CNS results on the site are recorded Python experiments.

The original subnetwork ranks populations using six unsigned propagation rounds, anatomical group quotas, strong input paths, and existing bilateral counterparts. The arena preserves that graph and adds DLM/DVM wing motor and b2 steering units, each added motor unit’s strongest presynaptic populations, input paths, and bilateral counterparts. All measured edges between the chosen populations are retained.

## Convert counts into signed weights

Wij = sj Cji / total_inputi

Cji is the measured count from source j to target i. sj is the assumed effect of the source’s transmitter. The denominator contains the target’s original incoming counts from all source segments, including inputs outside the selected subnetwork.

That last choice matters. If we cropped the network and renormalized only the remaining edges, the surviving connections would become artificially stronger. Keeping the original denominator avoids that particular artifact. It does not recover the activity of omitted inputs; those inputs remain silent.

Illustrative arithmetic. An excitatory source with 12 synapses onto a target receiving 120 original input synapses has weight 0.1. At source activity 0.4 and gain 3, it contributes 0.12 to the target’s recurrent drive before the nonlinear update. These example counts are invented only to explain the calculation.

Signed mode assigns positive output to acetylcholine, negative output to GABA and histamine, and negative output to glutamate by default. Unknown and modulatory fast effects are omitted. The transmitter predictions do not establish receptor-specific physiology; the circuit view therefore exposes alternative glutamate assumptions.

## Update all activity simultaneously

ri(t + Δt) = ri(t) + α [max(0, tanh(Ii(t) + g Σj Wijrj(t))) − ri(t)]
α = 1 − exp(−Δt / τ)

Term | Meaning
--- | ---
r | Normalized population activity, bounded between 0 and 1.
I | External visual-feature drive.
g | Connection gain, 3 at the defaults.
Δt | Neural step, 2 model ms.
τ | Leak time constant, 20 model ms.
α | Fraction of the gap closed in one update, approximately 0.0952 at the defaults.

The hyperbolic tangent limits the target response, rectification prevents negative rates, and the leak makes activity approach that target gradually. Every population reads the previous state before any new state is used. This prevents the ordering of nodes in an array from deciding which neurons respond first.

Silenced populations are clamped to zero. Their removal does not rescale the remaining weights. The time constants and gain are chosen model parameters, not fitted biological measurements.

## Implement the same rule at different scales

The browser’s batch solver computes the circuit experiment in a Web Worker. Its stateful solver reuses typed-array buffers and accepts a new input vector at each step; the arena calls that interface for feedback. The full Python solver uses a sparse matrix so it can propagate through millions of edges without building a dense matrix.

The stateful and batch JavaScript implementations are checked for trajectory agreement. The project also includes scalar and sparse Python comparisons. Agreement establishes that implementations calculate the intended equation consistently. It does not establish that the equation reproduces real neural responses.

You can inspect the graph directly: each node includes its type, side, original body IDs, transmitter, original input total, and retained input fraction. Edges use compact `[source_index, target_index, count]` records.

### Inspect the actual inputs to the model

The prepared graphs and source code are included with the lab.

Download the arena graph Download the circuit graph Download the project