This release introduces a major new simulation — SimMyelinatedAxon — with a full biophysics + RxD radial-diffusion engine for myelinated axons, along with a redesigned animation and data-capture pipeline, an interactive GUI for drawing myelinated regions, and two complementary AI-agent tools for codebase assistance.
| Area | What changed |
|---|---|
| Simulation | New SimMyelinatedAxon with Schwann-cell RxD, radial K+ diffusion (Config B), and IClamp / SEClamp support |
| RxD engine | Extended-shell (Config B) radial grid; piecewise diffusion; Dirichlet / zero-flux boundary conditions per-zone; ProcAdvanceHelper |
| Geometry helpers | BaseAxonHelper, AxonTransformationHelper, CellBuildHelper — build, transform, and validate axon sections |
| Myelin region | MyelRegionHelper — entire-axon / zebra / draw-by-hand modes with PlotShape marker integration |
| Biophysics helpers | AxonBiophysCompsHelper — manages MechManager rescan; dirty-state tracking via DirtyStatesHelper |
| Animation & export | Dual-mode recording: in-process PyplotAndSaveHelper and subprocess-isolated PyplotHelper; TXT export; frame-slider playback |
| AI tooling | Terminal agent (braincell_agent.py + braincell_mapper.py) and GUI panel (braincell_panel.py); BrainCell AI Agent manuals |
| Multi-cell export | Export packages now include all extra cells from ExtraCellsManagerWidget; re-import and one-cycle re-export supported; extra-cell detection by comp.name regex |
| Import without nano | Plain geometry HOC files (astrocyte and neuron, no nano arrays) now load cleanly; SWC / ASC / ZIP import paths normalised; Geometry Zoo library added |
| User simulations | Open plugin framework for user-defined simulation scenarios via SimManager ABCs; nine built-in reference implementations; GUI embedding rules documented |
A complete NEURON simulation for studying K+ dynamics in myelinated peripheral axons.
Implemented in SimMyelinatedAxon.py (main GUI class) and
SimCore.py (SimMyelinatedAxonCore), with supporting
HOC parameters in ParamsHelper.hoc.
The simulation inherits RequiresAltRunControl, UsesCustomProcAdvance,
and Simulation from the SimManager ABCs, so it integrates cleanly with
BrainCell's standard init / run / continue workflow.
Three modes are selectable via radio buttons at runtime
(EnumAxonGeometry in BasicEnums.py):
nseg
Three states selectable via radio buttons (EnumMyelSheath):
ik = ik0 + A·sin(2π(x/X − t/T))
via the iksine mechanism, for validation and debugging
DirtyStatesHelper (in DirtyStatesHelper.py) maintains a
dirtyParamCat value that records the deepest change made since the
last successful run. EnumParamCats defines six levels in ascending depth:
| Level | Meaning |
|---|---|
none | No pending changes |
anim | Animation / presentation params changed |
rxd | RxD shell or diffusion params changed |
biophys | Biophysics or initial conditions changed |
modifGeom | Sheath / myelination geometry changed |
baseGeom | Base axon geometry (length, diameter, nseg) changed |
On each Init & Run, SimMyelinatedAxon.preRun() reads
dirtyParamCat and rebuilds only what has changed, avoiding redundant
re-initialization of expensive structures such as RxD.
SimMyelinatedAxonCore.initRxDStaff() constructs a two-zone radial shell
model around each axon trunk section:
The transition between zones uses a harmonic mean of the two diffusion
coefficients to avoid numerical discontinuities at the sheath boundary.
All shell-to-shell transport is implemented as NEURON
rxd.MultiCompartmentReaction with appropriate unit scaling
(mM → molecules·μm−3).
ProcAdvanceHelpersegm._ref_kflux_i2fc
into the innermost shell
A new ProcAdvanceHelper class (ProcAdvanceHelper.py) is called
on every NEURON timestep via the UsesCustomProcAdvance mechanism. It performs
three operations in order:
veryMinOuterConc
(prevents NaN propagation)schwann.ko
for each Schwann-cell segment, so MOD files in Schwann sections can read
the correct extracellular [K+]The segment-to-node mapping for step 3 is pre-computed in the constructor (not per-timestep) for performance.
BaseAxonHelper.py encapsulates all logic for creating the base axon
section before any myelination transformation. It handles:
AxonTransformationHelper.py transforms the base axon into a
biologically realistic myelinated structure. It creates:
axonUnderSchwann)diam_sheath
Key data structures: AxonArcInterval (normalized 0–1 arc position)
and Axon3DPointWithArc for 3D coordinate reconstruction.
CellBuildHelper.py provides a dockable panel for drawing axon sections
by hand in Draw-by-hand mode. It validates the drawn topology and provides
a warning footer when the geometry is invalid (e.g., the user clicks
Init & Run before completing the drawing).
MyelRegionHelper.py implements the myelinated-region selection logic
for the three modes defined in EnumMyelRegion:
All sections are myelinated from trunk start to trunk end. No user input needed.
Schwann cells and nodes are placed periodically from four parameters:
schwann1_start, schwann1_end, schwann2_start
(the first three anchor points), and maxNumSchwannCells.
All subsequent boundaries are computed by linear extrapolation.
The user selects segments interactively on the PlotShape canvas using the
Draw Myelinated Region menu tool. Mouse press and drag events are
handled by onMousePressOrDragging(), which maintains a
SortedSet of selected segment indices and groups them into
contiguous Interval objects.
Coloured markers (blue by default) are placed at the start and end of
each myelinated region. A Clean up drawing button removes all markers.
The simulation can record and display K+ concentration data in two modes,
controlled by the isShowPyplotFigsInSubProcess flag:
PyplotAndSaveHelper)
Implemented in PyplotAndSaveHelper_Separated.py.
Frames are stored directly in memory as OneFrame objects
and rendered with matplotlib in the same process.
A frame slider and start/stop button are provided for playback.
Cumulative min/max tracking ensures consistent colour-scale across all frames.
PyplotSubProcHelper)
Implemented in PyplotSubProcHelper.py.
Frames are serialised to .pickle files in a temporary folder
(named frame0000.pickle, frame0001.pickle, …).
A separate Python process reads and animates them via a polling timer,
keeping the NEURON GUI responsive during long simulations.
Marker files (running, save_to, saved)
coordinate the lifecycle between producer and consumer.
pcolormesh
AnimSavePrintHelper.py is called from the simulation's custom
procAdvance hook at intervals of Dt ms.
On each frame it:
rxd.Species.nodes()OneFrame to the recordingDt ms
When the Save K+ conc(t, dist, radius) to TXT file checkbox is enabled,
all recorded frames are written to a structured text file after the run completes.
In subprocess mode, the save request is communicated via a marker file to avoid
thread-safety issues; in in-process mode, PyplotAndSaveHelper.saveToTxtFile()
is called directly.
PresentationParams.py consolidates all recording and display checkboxes
into a single object used by both SimMyelinatedAxon and
AnimSavePrintHelper:
isAnim[0] — animate K+ radial colour map vs segment indexisAnim[1] — animate K+ radial concentration vs distance per shellisSave — save to TXT (requires isAnim[1])isDraw[0..6] — seven individual NEURON graph enable/disable flagsisPrint — console print of ik and ko at each Dt interval
Checking/unchecking isAnim automatically resets
altRunControlWidget.isInited to prevent Continue from using
stale RxD state.
AxonBiophysCompsHelper.py manages the MechManager interaction for the
myelinated axon simulation. After the base axon geometry is established, it
schedules a MechManager rescan (scheduleRescan(2)) and optionally
shows the MechManager widget if the user has previously opened it.
It also detects all un-insertable biophysics mechanism names from
BrainCell's global list and skips them safely during biophysics application.
ProtoGeomStructs.py provides lightweight data classes used
across the geometry pipeline to pass section properties (length, diameter,
3D point list, parent connectivity) between helpers without coupling them
to specific NEURON section objects.
Scans all .mod, .hoc, and .py files in the
BrainCell repository and produces braincell_map.json — a structured
index of every file with its procedures, functions, classes, imports, and size.
The map is used by the agent for fast keyword-based file search without reading
every file on each query.
Output statistics: 131 MOD files, 346 HOC files, 74 Python files (typical repository). Run once at setup, then again whenever new files are added.
A terminal-based AI assistant powered by the Anthropic Claude API
(claude-opus-4-6). Supports four commands:
| Command | Description |
|---|---|
ask <question> | General question about any file or concept |
search <query> | Find the 8 most relevant files by keyword |
explain <file> | Full biophysical explanation of a MOD / HOC / PY file |
modify <file> <task> | Propose a code modification; requires explicit user approval before saving |
The agent's system prompt includes the full repository structure, key MOD file list, and instructions to always cite parameter names and line-level details when discussing biophysics.
A tkinter-based desktop application providing the same AI-agent
functionality without a terminal. Features a dark-blue colour scheme matching
BrainCell's visual identity, a scrollable output area with monospace code
rendering, a file browser for selecting targets, and background threading so
the GUI stays responsive during API calls.
The panel reads and writes ANTHROPIC_API_KEY from the environment
and can be launched by double-clicking braincell_panel.py in
File Explorer — no Anaconda Prompt required.
| Area | Limitation |
|---|---|
| RxD | Only K+ is supported for radial diffusion; Na+, Ca2+, and other ions are not yet included |
| RxD | No longitudinal diffusion; its contribution at nodes of Ranvier may be significant |
| RxD | Diffusion coefficient in the outer zone is uniform (D/α); section-dependent values would require separate rxd.Region objects per zone |
| RxD | Homogeneous radial shell spacing assumed; inhomogeneous axon diameter and per-section shell counts are not supported |
| Simulation | Outside-in diffusion extracellular mechanisms are not inserted into newly created axon and Schwann sections on re-use |
| Simulation | Switching real biophysics → test sines → real biophysics resets biophysics to defaults (mini bug) |
| Visualisation | Colour map columns have equal visual width regardless of the segment length they represent |
| Performance | ProcAdvanceHelper.onAdvance() iterates over all RxD nodes; candidate for @njit parallelisation |
| MOD units | NEURON's modlunit checker reports a units problem in _i2fc.mod |
BrainCell now supports exporting simulation packages that contain not only the
primary cell but also all additional cells registered through the
Extra Cells Manager (ExtraCellsManagerWidget.hoc).
The export generator (GeneratorsForMainHocFile.py) iterates over
extraCellsManagerWidget.listOfExtraCellListItems and emits
instantiation code for each extra cell, preserving:
The exported HOC package is self-contained and re-runnable without the BrainCell GUI, making it suitable for cluster submission (e.g., NSG / HPC workflows).
Exported multi-cell packages can be re-imported into BrainCell via
_Testing/init_ImportExtraCells.hoc and the
ExtraCellsManagerWidget. After re-import, the user can modify
biophysics or connection parameters and perform a second export.
extraCellsManagerWidget.listOfExtraCellListItems is empty at that
point — the re-imported cells are instantiated directly from HOC rather than
being registered through the widget's normal creation path.registerExistingExtraCell procedure in
ExtraCellsManagerWidget that registers already-instantiated cells
without re-running ExtraCell.__init__. Until that fix is in place,
one reliable multi-cell export/re-import cycle is supported.
When scanning sections after re-import, extra-cell sections are identified by
matching comp.name against the regular expression
^Extra Cell #(\d+)$.
This is more robust than the previous approach of inspecting
comp.list_ref[0].sec.name(), which was fragile after re-import
because section names can change.
Previously, BrainCell required nano-geometry (Nanogeometry/ HOC files
with embedded spine/process data) for astrocytes and neurons to be fully functional
in the GUI. This release extends the import pipeline to accept plain
geometry-only files — HOC files from Geometry/Astrocyte/
and Geometry/Neuron/ that contain only section topology and 3D coordinates,
with no nano-structure arrays.
The import layer (_Code/Import/ImportBaseGeometry/) now:
CheckUtils.checkIfThisHocFileIsOfAstroOldStyle()
and related inspection functionsGeometry/Astrocyte/New Style/ and
Geometry/Astrocyte/Old Style/
A new Geometry/Zoo/ folder provides reference morphologies for both
cell types in plain format, independent of any nano-structure. These files are
suitable for rapid prototyping, teaching, and validation workflows where
nano-scale geometry is not required. Currently includes
neuron_NEURON_HOC.hoc (48 kB) as a starting reference.
The import pipeline supports morphology files in three formats beyond plain HOC:
NLMorphologyConverter and cached in
_Code/Import/temp_folder/last_converted.hocAll three paths normalise to a temporary HOC file before loading, ensuring a single downstream import code path regardless of source format. The temporary file is regenerated only when the source changes, avoiding redundant conversion on repeated loads.
BrainCell now provides a formal extension point that allows any user to add a
completely new simulation scenario without modifying BrainCell's core files.
The mechanism is based on the SimManager plugin architecture:
each simulation is a Python class that inherits one or more abstract base classes
(ABCs) from SimABCs and is registered with SimManager via a
sourcePythonCode call in the SimManager loader.
_Code/Simulations/Sims/Common/ or
_Code/Simulations/Sims/Neuron/ (or Astrocyte)
containing a Python file with your simulation classSimulation alone for a basic simulation,
RequiresAltRunControl for a custom run-control widget,
or UsesCustomProcAdvance to hook into every NEURON timestepshow(), preRun(isInitOnly), and optionally
procAdvance() and postRun()sourcePythonCode("\\Sims\\Common\\MySimFolder", "from MySimFile import MySimClass", "context")
| ABC | What it provides |
|---|---|
Simulation |
Base class; requires show() and preRun(isInitOnly) |
RequiresAltRunControl |
Replaces NEURON's default RunControl with a custom Init & Run panel; required when default tstop / dt controls are insufficient |
UsesCustomProcAdvance |
Registers a Python procAdvance() method that is called on every NEURON timestep via CVode.extra_scatter_gather() |
The following built-in simulations serve as reference implementations and templates for user-defined scenarios:
| Simulation | Cell type | Demonstrates |
|---|---|---|
SimMyelinatedAxon |
Neuron | Full ABC combination, RxD, dirty-state tracking, custom procAdvance, matplotlib animation |
SimVoltageCA1Neuron |
Neuron | Voltage-clamp / current-clamp with graph recording |
SimCalciumWave |
Common | RxD calcium wave propagation |
SimFrapSphere / Cylinder / Plane |
Common | FRAP (fluorescence recovery) diffusion modelling in three geometries |
SimGlutamate / SimPotassium |
Common | Iterative neurotransmitter / ion concentration dynamics |
SimOutsideInDiffusion |
Common | Integration with the OutsideInDiffusion extracellular engine |
SimConstantElectricalSimulations |
Common | Constant-current injection protocols |
SimFrequencyElectricalSimulation |
Common | Frequency-sweep stimulation |
SimSpatialVoltageDistributions |
Common | Spatial voltage along dendrites |
Each simulation's show() method must build its GUI using
h.xpanel("") / h.xpanel() blocks as top-level containers.
This ensures the simulation's controls appear inside SimManager's panel
rather than as a detached pop-up window — a requirement enforced by SimManager's
panel-embedding architecture. Using bc.VBox as the outermost container
is explicitly disallowed for this reason.
BrainCell • What's New • Savtchenko / Rusakov Lab, UCL • March 2026