SimulationRunner#
- class SimulationRunner(
- network: Network,
- models: dict[str, Any],
- step_callback: Callable[[Any], Any],
- model_outputs: dict[str, list[str] | None] | None = None,
- temperature__celsius: float = 36.0,
Bases:
objectManages NEURON simulation execution with automated setup, initialization, and result collection for neuromuscular simulations.
Provides a clean interface for running complex neuromuscular simulations while maintaining full user control over populations, connections, and step-by-step simulation logic. Automatically handles NEURON environment setup, voltage initialization, and structured result collection.
Separates simulation control from plotting and analysis concerns.
Initialize SimulationRunner with network, models, and step callback.
- Parameters:
network (Network) – Configured Network instance with populations and connections.
models (Dict[str, Any]) – Physiological models (e.g., {“hill”: hill_model, “spin”: spindle_model}).
step_callback (Callable) – User-defined function called at each simulation timestep.
model_outputs (Optional[Dict[str, Union[List[str], None]]], optional) – Explicit model output attributes to collect. None uses smart defaults. Format: {“model_name”: [“attr1”, “attr2”]} or {“model_name”: None} for defaults, by default None.
temperature__celsius (float, optional) – NEURON simulation temperature, by default 36.0.
Methods
Initialize SimulationRunner with network, models, and step callback.
Get the list of output attributes that will be collected for a model.
Execute NEURON simulation with automated setup and result collection.
Override the output attributes for a specific model.
- run(
- duration__ms: Quantity__ms,
- timestep__ms: Quantity__ms,
- membrane_recording: dict[str, list[int]] | None = None,
Execute NEURON simulation with automated setup and result collection.
- Parameters:
duration__ms (Quantity__ms) – Total simulation duration in milliseconds.
timestep__ms (Quantity__ms) – Integration timestep in milliseconds.
membrane_recording (Optional[Dict[str, List[int]]], optional) – Populations and cell indices for membrane potential recording. Format: {“population_name”: [cell_id1, cell_id2, …]}, by default None.
- Returns:
Structured simulation results containing: - spikes: Spike timing and ID data for all populations - membrane: Membrane potential traces (if requested) - models: Output data from all physiological models - simulation: Time vector and simulation metadata
- Return type:
Block
- Raises:
ValueError – If model output attributes don’t exist on model instances.
RuntimeError – If NEURON simulation fails to complete.
- get_model_outputs(model_name: str) list[str][source]#
Get the list of output attributes that will be collected for a model.