# Neuron laboratory: model and validation

The redesigned `neuron.html` separates a single membrane patch from a spatial cable experiment. The shared `neuron-model.js` is unchanged. The original anatomy page is retained as `neuron-classic.html`, including its illustrative axon animation. The homepage and cardiac comparison still use the same shared Hodgkin-Huxley implementation.

## Reproduce

Serve the repository over HTTP, for example `python3 -m http.server 8766 --bind 127.0.0.1`, and open `neuron.html`. The experiment runs in `neuron-lab-worker.js`. No package installation or build is required.

Run `node neuron-lab.test.js` for the added numerical checks. Existing regression checks remain available through `home.test.js`, `cardiac.test.js`, `cardiac-ui.test.js`, `electrophysiology.test.js`, `orbitals.test.js`, `tdse.test.js`, and `wave2d.test.js`.

## Single cell

Original Hodgkin-Huxley squid-axon kinetics at 6.3 °C, with no temperature scaling. All parameters and current equations come from `neuron-model.js`. Initial voltage is −65 mV, with equilibrium gates at that voltage. The current pulse begins at 5 ms. Current is a density in µA/cm², not total electrode current.

The threshold preset compares 10 and 2 µA/cm² for 5 ms. It demonstrates responses to those stimuli, rather than calculating a universal firing threshold. A spike is operationally recorded at the first upward crossing of 0 mV.

## Educational cable

The extension is a deliberately simplified spatial model. It is not a published or experimentally fitted model of a human myelinated axon.

- 61 membrane compartments, 0.1 mm between neighboring centers, 6 mm between endpoint centers.
- Diameter: 5 to 20 µm; default 10 µm. Axial resistivity: 100 Ω·cm.
- Sealed ends, with no axial current beyond the endpoints. Endpoint control volumes use the same capacitance and membrane area convention as other compartments.
- Active membrane uses the original HH equations with capacitance 1 µF/cm².
- The bare configuration is active everywhere.
- The insulated configuration is active every fifth compartment, including both endpoints. Other compartments have capacitance 0.05 µF/cm² and passive conductance 0.015 mS/cm² with reversal −65 mV. There are no active channels in these internodes.
- Current is injected only into the first compartment. Equal current density across different diameters does not imply equal total injected current.
- The default pulse is 80 µA/cm² for 2 ms, beginning at 5 ms. The larger stimulus relative to the isolated-cell preset compensates for the axial load; it is not intended as a threshold calibration.

For compartment i, the axial voltage derivative is:

`dV_i/dt = d / (4 Ri dx² Ci) × (V_(i−1) − 2 V_i + V_(i+1))`

with the conductance converted to mS/cm². Only existing neighbors contribute at sealed endpoints. The default axial conductance coefficient is 25 mS/cm².

The comparison changes capacitance, leak, and active-channel distribution together. It does not isolate myelin as the only independent physical variable. There is no nodal geometry model, extracellular field, synapse, stochastic channel noise, or tissue temperature correction. Insulation spacing and channel densities are illustrative. Spatial resolution is fixed; this release does not establish spatial convergence or physiological accuracy of the predicted speeds.

## Integration and recordings

Fixed timestep 0.002 ms, independent of display refresh rate and replay speed. Axial coupling uses a Crank-Nicolson half step on either side of a full ionic step (Strang splitting). Active ionic kinetics use the existing RK4 implementation; passive leak is integrated analytically. The supported pulse durations and onset align with the timestep.

Recordings cover 0 through 50 ms, sampled every 0.1 ms. The complete voltage field is retained so moving probes requires no rerun. The scene, graph cursor, and voltage readouts use the same recorded sample, rounded to the nearest 0.1 ms. The graph always shows the full completed run; playback moves a cursor over that result. At 1×, one wall-clock second represents 5 ms. Reduced-motion preference disables automatic playback after runs, while explicit playback remains available.

Probe positions are constrained to distinct active-node locations, with A to the left of B. First upward 0 mV crossings are interpolated between output samples. Speed is distance in mm divided by transit time in ms, numerically equal to m/s. No speed is reported without both arrivals and positive transit time. CSV exports contain the completed run's settings, timestep, probe locations, times, and voltages, including comparison runs. Unsaved control edits do not relabel results or exports.

## Numerical evidence

At 10 µm with the default pulse and probes at 1.5 and 4.5 mm:

| Configuration | Measured speed |
| --- | ---: |
| Insulated | 2.035575 m/s |
| Bare | 1.057450 m/s |

These numbers describe this educational parameterization, not a biological measurement.

`neuron-lab.test.js` verifies:

- Single-cell recordings agree with direct calls to the unchanged HH integrator.
- The weak preset does not cross 0 mV; the strong preset does.
- Propagation reaches the downstream probe after the upstream probe.
- Repeated runs produce identical recordings; zero-stimulus cables remain near rest.
- Halving the timestep to 0.001 ms changes measured speed by less than 0.1% in both default configurations.
- All combinations of endpoint diameter, pulse duration, current, and insulation settings remain finite and within the tested voltage bounds.
- An independently implemented, unsplit RK4 integration of the full coupled ODE system at 0.001 ms agrees over the first 15 ms at all 61 sites. Maximum sampled voltage difference is approximately 0.06513 mV for insulated and 0.01402 mV for bare cable, below the 0.1 mV test tolerance. This independently checks the coupling and split integrator, while sharing the existing ionic equations.

This is numerical validation of the implementation. Experimental validation would require a chosen species, temperature, morphology, measured membrane properties, and comparison against data.

## Sources and scope

- [Hodgkin and Huxley (1952)](https://doi.org/10.1113/jphysiol.1952.sp004764), underlying single-cell current model.
- [NEURON documentation](https://www.neuronsimulator.org/en/latest/guide/what_is_neuron.html), background on cable models, spatial discretization, and separation of biological models from numerical solvers. The application does not embed NEURON or claim numerical equivalence to it.

## Interface verification

Checked in the in-app WebKit browser at desktop width and in a 390 px iframe layout: initial run, both comparison presets, timeline scrubbing, movement of probe A, settings edits retaining completed results, and cancellation retaining previous traces. The compact layout exposes settings through an expandable control. CSV serialization is checked for comparison runs, completed settings, timestep, selected probe positions, sample counts, and recorded voltage values. These checks do not constitute physical-device or cross-browser certification.
