Cell#
- class braincell.Cell(morpho, *, pop_size=1, cv_policy=None, V_th=Quantity(0, 'mV'), V_init=None, spk_fun=ReluGrad(alpha=0.3, width=1.0), solver='staggered', subsolver=None, substeps=None, cache_ion_total_current=True, ion_channel_update_order='family', membrane_linearizer='point', name=None)#
Multi-compartment cell with explicit declaration / initialization phases.
- Parameters:
morpho (
Morphology) – Morphology tree.cv_policy (
CVPolicy|None) – Control-volume splitting policy; defaults toCVPerBranch.V_th (
Quantity) – Spike-detection threshold (default0. mV).V_init (
Array|ndarray|bool|number|bool|int|float|complex|Quantity|Callable|None) – Initial voltage.Nonemeans “use per-CV resting potential”.spk_fun (
Callable) – Surrogate-gradient spike function.solver (
str|Callable) – Integrator name (registry lookup) or callable step function.subsolver (
str|Callable|None) – Integrator for Markov channels and kinetic ions. Together withsubsteps=None,Noneselects"backward_euler".substeps (
int|None) – Number of subsolver steps per main cell step. Together withsubsolver=None,Noneselects one step.ion_channel_update_order (
str) – Post-voltage ion/channel scheduling."family"updates all ions before all channels;"integration"preserves the previous IndependentIntegration-grouped scheduling.membrane_linearizer (
str) – Compatibility selector for the membrane-current linearization strategy. Both values currently differentiate the assembled CV-space membrane derivative; painted density mechanisms already live on the CV axis, while sparse point contributions are gathered first.
- add_reduction(name, model)[source]#
Register one interchangeable reduced model under a Cell-local name.
- bind_synapse_input(synapse, source, *, weight=1.0, transform=None)[source]#
Deprecated compatibility adapter for per-boundary event payloads.
- Parameters:
synapse (
str) – Synapse instance name, matchingbraincell.mech.Synapse(name=...)or its default instance name.source (array-like or callable) – Presynaptic drive source. Callables are evaluated every step; this supports bindings such as
lambda: pre_cell.spike.value.weight (array-like, optional) – Multiplicative weight applied to
source.transform (callable, optional) – Optional mapping called as
transform(source_value)before weighting, useful when the source shape does not directly broadcast to the target synapse shape.
- Return type:
- cache_ion_total_currents(V=None)[source]#
Cache ion source currents before voltage advances in staggered mode.
- Return type:
- property clamps: ClampView#
Return a view over all logical current-clamp instances.
- compute_derivative()[source]#
Fill in the derivative of every state this neuron integrates.
- Parameters:
*args – Positional arguments defined by the subclass.
**kwargs – Keyword arguments defined by the subclass.
- Raises:
NotImplementedError – Always, in the base class. Subclasses must override.
- property connections#
Return a unified view over all direct event-routing rows.
- property cv_midpoints: LocsetMask#
Return one resolved continuous midpoint for every control volume.
- discretize()[source]#
Atomically rebuild the declaration preview before initialization.
Creation, policy assignment, initialization and dirty preview reads call this method automatically. Existing selections expire on success. Runtime parameters never trigger rediscretization.
- Returns:
This Cell with a refreshed discrete preview.
- Return type:
- Raises:
RuntimeError – If already initialized. Call
reset()before editing declarations.
- property event_outputs: EventOutputCollection#
Return named live event-output ports for this cell population.
- get_placement_state(placement_id)[source]#
Return runtime state for one independent point placement.
- init_state(batch_size=None)[source]#
Lower the declaration into runtime state and allocate V / spike.
- Raises:
RuntimeError – If the cell is already initialized. Call
reset()first.- Return type:
- mech_table()[source]#
Return the point-domain mechanism table for this cell.
- Returns:
Rows are mechanism identities, columns are point ids.
- Return type:
MechanismObjectTable- Raises:
RuntimeError – If
init_state()has not been called.
- property morphology: Morphology#
Return the declaration morphology (
morphocompatibility alias).
- property n_compartment: int#
Number of compartments per neuron.
- Returns:
How many compartments – soma, dendrite, axon sections – each neuron in the group is divided into.
- Return type:
- Raises:
NotImplementedError – Always, in the base class. Subclasses must override.
- property network_owner#
Return the Network that owns execution of this cell, if any.
- paint(region, *mechanisms)[source]#
Paint mechanisms onto
region. Returnsselffor chaining.- Return type:
- place(locset, *mechanisms)[source]#
Place point mechanisms at shared or per-cell locations.
- Parameters:
locset (
LocsetExpr|LocsetMask|LocsetBatch) – One shared locset, an aligned rectangular batch, or one possibly ragged locset per population member.*mechanisms (Point) – Point-mechanism declarations placed independently at each row.
- Returns:
This Cell for chaining.
- Return type:
- property point_placements#
Return point-mechanism placements in stable declaration order.
- Returns:
Static placement records available before and after initialization.
- Return type:
tuple of PointPlacement
- property pop_size: tuple[int, ...]#
Neuron-population shape, that is
sizewithout the compartment axis.- Returns:
The population size in each dimension:
(100, 50)is a 2-D population of 100 by 50 neurons.- Return type:
- Raises:
NotImplementedError – Always, in the base class. Subclasses must override.
- post_integral()[source]#
Run whatever must happen after each integration step.
Does nothing by default. Subclasses override it to publish spikes, clamp concentrations, or otherwise fix up state the solver wrote.
- Parameters:
*args – Positional arguments defined by the subclass.
**kwargs – Keyword arguments defined by the subclass.
- pre_integral()[source]#
Run whatever must happen before each integration step.
- Parameters:
*args – Positional arguments defined by the subclass.
**kwargs – Keyword arguments defined by the subclass.
- Raises:
NotImplementedError – Always, in the base class. Subclasses must override.
- property recordings: Mapping[str, RecordingSpec]#
Return a read-only snapshot of Cell recording declarations.
- property reductions: ReductionViewCollection#
Return all Cell-local registered reduction models.
- reset()[source]#
Drop runtime and per-step state; return to DECLARING.
- Raises:
RuntimeError – If the cell is not initialized.
- Return type:
Notes
reset()is distinct fromreset_state().reset_statereseedsV/spike/current_timein place and stays in the INITIALIZED phase.reset()fully tears down the runtime and returns to DECLARING sopaint/placecan run again.
- reset_state(batch_size=None)[source]#
Reseed
V/spike/current_timewithout leaving INITIALIZED.Distinct from
reset():reset_stateis the in-phase brainstate lifecycle hook;resettears down the runtime entirely and returns the cell to DECLARING.- Return type:
- run(*, dt, duration)[source]#
Run the cell for
durationatdtand return probe traces.If
init_state()has not been called yet,runcalls it automatically. Once initialized the cell will not be re-initialized on subsequentruninvocations.
- runtime_objects(*args, **kwargs)[source]#
Return runtime graph objects from the inherited container API.
- property subsolver#
Return the effective Markov/kinetic-ion integrator callable.
- property synapses: SynapseView#
Return a view over all logical point-synapse instances.
- update()[source]#
Advance the cell by one simulation step.
This method is the standalone cell-level step wrapper. It applies already-prepared synaptic events, advances continuous membrane and mechanism dynamics by one
dt, computes the spike output, and prepares synaptic input for the next standalone step.- Returns:
Spike value produced by the transition from the previous membrane voltage to the updated membrane voltage.
- Return type:
Notes
The standalone update order is:
Apply prepared runtime synapse events.
Advance voltage and mechanism dynamics through
self.solver.Detect and store the current spike.
Prepare discrete event payloads for the next step.
In network execution, delayed event delivery is scheduled outside the cell.
Network.run(...)writes arrivals into runtime state buffers before calling the corresponding internal cell phases.
- use_model(name='detailed')[source]#
Select the detailed model or one registered reduction for the next initialization.
- Return type:
- property varshape: tuple[int, ...]#
Get the shape of variables in the neuron group.
This property provides access to the geometry (shape) of the neuron population, which determines how variables and states are structured.
- Returns:
A tuple representing the dimensional shape of the neuron group, matching the in_size parameter provided during initialization.
- Return type:
See also
in_sizeThe input geometry specification for the neuron group