arborize package¶
Subpackages¶
Submodules¶
arborize.constraints module¶
- class arborize.constraints.CablePropertyConstraints(Ra: arborize.constraints.Constraint = None, cm: arborize.constraints.Constraint = None)[source]¶
Bases:
CableProperties- Parameters:
Ra (Constraint)
cm (Constraint)
- class arborize.constraints.CableTypeConstraints(cable_property_class=<class 'arborize.definitions.CableProperties'>)[source]¶
Bases:
CableType- cable: CablePropertyConstraints¶
- ions: dict[str, IonConstraints]¶
- synapses: dict[str, SynapseConstraints]¶
- class arborize.constraints.CableTypeConstraintsDict[source]¶
Bases:
TypedDict- ions: dict[str, IonConstraintsDict]¶
- class arborize.constraints.Constraint[source]¶
Bases:
object- classmethod from_value(value: Constraint | float | tuple[float, float] | list[float]) Constraint[source]¶
- property lower¶
- property tolerance¶
- property upper¶
- arborize.constraints.ConstraintValue = arborize.constraints.Constraint | float | tuple[float, float] | list[float]¶
Type alias for values used to specify constraints.
Can be: - A single
Constraintinstance, - A single float value, - A tuple of two floats representing a range (lower, upper), - A list of floats representing a range (lower, upper).This flexible type allows defining constraints either as explicit Constraint objects or as simple numeric bounds.
- class arborize.constraints.ConstraintsDefinition(use_defaults=False)[source]¶
Bases:
Definition[CableTypeConstraints,CablePropertyConstraints,IonConstraints,MechanismConstraints,SynapseConstraints]A specialized Definition that supports parameter constraints for cable types, ions, mechanisms, and synapses.
This class wraps all components with Constraint instances, allowing ranges or tolerances to be applied to physiological parameters. Use define_constraints to create an instance from a dictionary and apply a global tolerance.
Example:
constraints = define_constraints( { "cable_types": { "dend": { "cable": {"Ra": (100, 200), "cm": 1.0}, "ions": { "na": { "rev_pot": -65.0, "int_con": (10.0, 15.0), "ext_con": 150.0, }, }, "mechanisms": {"hh": {"gnabar": (0.1, 0.3), "gl": 0.0003}}, } } }, tolerance=0.1, )
- Variables:
cable_type_class (type[CableTypeConstraints]) – The class used for representing constrained cable types.
cable_properties_class (type[CablePropertyConstraints]) – The class used for constrained cable properties (e.g., Ra, cm).
ion_class (type[IonConstraints]) – The class used for constrained ion properties.
mechanism_class (type[MechanismConstraints]) – The class used for constrained mechanism parameters.
synapse_class (type[SynapseConstraints]) – The class used for constrained synapse parameters.
- Parameters:
tolerance (float or None) – Optional tolerance to apply to all parameter constraints (e.g., 0.1 = ±10%).
- Returns:
A fully structured ConstraintsDefinition with all values wrapped in Constraint objects.
- Return type:
- cable_properties_class[source]¶
alias of
CablePropertyConstraints
- cable_type_class[source]¶
alias of
CableTypeConstraints
- ion_class[source]¶
alias of
IonConstraints
- mechanism_class[source]¶
alias of
MechanismConstraints
- synapse_class[source]¶
alias of
SynapseConstraints
- class arborize.constraints.ConstraintsDefinitionDict[source]¶
Bases:
TypedDict- cable_types: dict[str, CableTypeConstraintsDict]¶
- class arborize.constraints.IonConstraints(rev_pot: arborize.constraints.Constraint = None, int_con: arborize.constraints.Constraint = None, ext_con: arborize.constraints.Constraint = None)[source]¶
Bases:
Ion- Parameters:
rev_pot (Constraint)
int_con (Constraint)
ext_con (Constraint)
- class arborize.constraints.MechanismConstraints(parameters: dict[str, Constraint | float | tuple[float, float] | list[float]])[source]¶
Bases:
Mechanism- Parameters:
parameters (dict[str, Constraint])
- parameters: dict[str, Constraint]¶
- class arborize.constraints.SynapseConstraints(parameters, mech_id: str | tuple[str] | tuple[str, str] | tuple[str, str, str])[source]¶
Bases:
Synapse,MechanismConstraints
- arborize.constraints.SynapseConstraintsDict = dict[str, arborize.constraints.Constraint | float | tuple[float, float] | list[float]] | arborize.constraints.SynapseConstraintsDict¶
Type definition for synapse constraints.
This can be either:
A dictionary mapping parameter names to
ConstraintValues, orA TypedDict with optional keys:
mechanism: Identifier for the synapse mechanism (typeMechId).
parameters: Dictionary of parameter names to
This flexible type supports simple parameter dicts or more structured dicts including the synapse mechanism identifier.
- arborize.constraints.define_constraints(constraints: ConstraintsDefinitionDict, tolerance=None, use_defaults=False) ConstraintsDefinition[source]¶
Create a ConstraintsDefinition instance from a dictionary of constraints, applying an optional global tolerance and default values.
- Parameters:
constraints (ConstraintsDefinitionDict) – Dictionary specifying constraint values structured as ConstraintsDefinitionDict.
tolerance (float or None) – Optional tolerance to apply to all parameter constraints (e.g., 0.1 means ±10%), defaults to None.
use_defaults (bool) – Whether to fill in missing constraint values with defaults, defaults to False.
- Returns:
A fully constructed ConstraintsDefinition instance with all values wrapped in Constraint objects and tolerance applied.
- Return type:
arborize.definitions module¶
- class arborize.definitions.CP¶
Type variable for cable properties.
alias of TypeVar(‘CP’, bound=
CableProperties)
- class arborize.definitions.CT¶
Type variable for cable types.
alias of TypeVar(‘CT’, bound=
CableType)
- class arborize.definitions.CableType(cable_property_class=<class 'arborize.definitions.CableProperties'>)[source]¶
Bases:
object- add_mech(mech_id: str | tuple[str] | tuple[str, str] | tuple[str, str, str], mech: Mechanism)[source]¶
- add_synapse(label: str | tuple[str] | tuple[str, str] | tuple[str, str, str], synapse: Synapse)[source]¶
- classmethod anchor(defs: ~typing.Iterable[~arborize.definitions.CableType], synapses: dict[str | tuple[str] | tuple[str, str] | tuple[str, str, str], ~arborize.definitions.Synapse] = None, use_defaults: bool = False, ion_class=<class 'arborize.definitions.Ion'>) CableType[source]¶
- cable: CableProperties¶
- class arborize.definitions.CableTypeDict[source]¶
Bases:
TypedDict- cable: CablePropertiesDict¶
- class arborize.definitions.Definition(use_defaults=False)[source]¶
- class arborize.definitions.Ion(rev_pot: float = None, int_con: float = None, ext_con: float = None)[source]¶
- class arborize.definitions.ModelDefinition(use_defaults=False)[source]¶
Bases:
Definition[CableType,CableProperties,Ion,Mechanism,Synapse]- cable_properties_class[source]¶
alias of
CableProperties
- class arborize.definitions.ModelDefinitionDict[source]¶
Bases:
TypedDict- cable_types: dict[str, CableTypeDict]¶
- class arborize.definitions.Synapse(parameters, mech_id: str | tuple[str] | tuple[str, str] | tuple[str, str, str])[source]¶
Bases:
Mechanism
- arborize.definitions.define_model(template: ModelDefinition, definition: ModelDefinitionDict, /, use_defaults: bool = False) ModelDefinition[source]¶
- arborize.definitions.define_model(definition: ModelDefinitionDict, /, use_defaults: bool = False) ModelDefinition
arborize.exceptions module¶
- exception arborize.exceptions.ArborizeError(*args, **kwargs)¶
Bases:
DetailedExceptionArborizeError exception
- exception arborize.exceptions.ConstructionError(*args, **kwargs)¶
Bases:
SchematicErrorConstructionError exception
- exception arborize.exceptions.FrozenError(*args, **kwargs)¶
Bases:
SchematicErrorFrozenError exception
- exception arborize.exceptions.ModelDefinitionError(*args, **kwargs)¶
Bases:
ArborizeErrorModelDefinitionError exception
- exception arborize.exceptions.ModelError(*args, **kwargs)¶
Bases:
ArborizeErrorModelError exception
- exception arborize.exceptions.SchematicError(*args, **kwargs)¶
Bases:
ArborizeErrorSchematicError exception
- exception arborize.exceptions.TransmitterError(*args, **kwargs)¶
Bases:
ModelErrorTransmitterError exception
- exception arborize.exceptions.UnconnectedPointInSpaceWarning[source]¶
Bases:
ArborizeWarning
- exception arborize.exceptions.UnknownLocationError(*args, **kwargs)¶
Bases:
ModelErrorUnknownLocationError exception
- exception arborize.exceptions.UnknownSynapseError(*args, **kwargs)¶
Bases:
ModelErrorUnknownSynapseError exception
arborize.parameter module¶
arborize.schematic module¶
- class arborize.schematic.CableBranch[source]¶
Bases:
Branch- children: list[CableBranch]¶
- parent: CableBranch | None¶
- class arborize.schematic.Point(loc, branch: UnitBranch, coords, radius)[source]¶
Bases:
object- Parameters:
branch (UnitBranch)
- class arborize.schematic.Schematic(name=None)[source]¶
Bases:
objectA schematic is an intermediate object that associates parameter definitions to points in space. You can define locations (3d coords + radius) and tag them with labels, or set parameters directly on the locations. You can pass a schematic to a Builder, which will freeze the schematic (no changes can be made anymore) and create a simulator specific instance of the model.
Schematics create a user-facing layer of “virtual branches”, which is the network graph of the created locations. However, NEURON does not support the resolution that arbor does, so an underlying layer of “true branches” is created. In NEURON, a map is kept on the model between the locations on the virtual branches and the locations on the true branches, so that we can arbitrarily split up true branches into smaller pieces to achieve the resolution we need.
- create_location(location: tuple[int, int], coords: tuple[float, float, float], radius: float, labels: list[str], endpoint: tuple[int, int] | None = None)[source]¶
Add a new location to the schematic. A location is a tuple of the branch id and point-on-branch id. Locations must be appended in ascending order.
- Parameters:
location (tuple[int, int]) – The location tuple with branch id and point id.
coords (tuple[float, float, float]) – The 3 coordinates of the point.
radius (float) – The radius of the branch at the point.
endpoint (tuple[int, int] | None) – Optional endpoint of the previous branch to connect the location to.
- Returns:
- property definition¶
Definition of the model, contains the definition of the parameters for the cables, mechanisms, and synapses of this model.
- property name¶
Base name for all the instances of this model.
Suffixed unique names for each instance can be obtained by calling
create_name.
- class arborize.schematic.UnitBranch[source]¶
Bases:
Branch- children: list[UnitBranch]¶
- parent: UnitBranch | None¶
arborize.synapse module¶
arborize._util module¶
- arborize._util.MechId = str | tuple[str] | tuple[str, str] | tuple[str, str, str]¶
Type alias for mechanism identifiers.
Can be either: - A simple string identifier, e.g., “hh” - A
MechIdTuplewith 1 to 3 strings for hierarchical naming.This type supports flexible representation of mechanism IDs.
- arborize._util.MechIdTuple = tuple[str] | tuple[str, str] | tuple[str, str, str]¶
Type alias for mechanism identifiers represented as tuples.
Can be a tuple with 1 to 3 strings, e.g.: - (“hh”,) - (“mod”, “hh”) - (“region”, “mod”, “hh”)
This allows hierarchical or detailed identification of mechanisms.
- arborize._util.get_arclengths(pts: Iterable[Point]) ndarray[Any, dtype[float64]][source]¶
Compute normalized cumulative arclengths from a sequence of points.
Module contents¶
Write descriptions for NEURON cell models in an Arbor-like manner for both the Arbor and NEURON brain simulation engines.
- class arborize.CableType(cable_property_class=<class 'arborize.definitions.CableProperties'>)[source]¶
Bases:
object- add_mech(mech_id: str | tuple[str] | tuple[str, str] | tuple[str, str, str], mech: Mechanism)[source]¶
- add_synapse(label: str | tuple[str] | tuple[str, str] | tuple[str, str, str], synapse: Synapse)[source]¶
- classmethod anchor(defs: ~typing.Iterable[~arborize.definitions.CableType], synapses: dict[str | tuple[str] | tuple[str, str] | tuple[str, str, str], ~arborize.definitions.Synapse] = None, use_defaults: bool = False, ion_class=<class 'arborize.definitions.Ion'>) CableType[source]¶
- cable: CableProperties¶
- class arborize.ModelDefinition(use_defaults=False)[source]¶
Bases:
Definition[CableType,CableProperties,Ion,Mechanism,Synapse]- cable_properties_class[source]¶
alias of
CableProperties
- arborize.bsb_schematic(morphology: bsb.morphologies.Morphology, definitions: Definition | None = None) Schematic[source]¶
Generate a schematic from a bsb.Morphology object.
- Parameters:
morphology (bsb.morphologies.Morphology) – A bsb.Morphology instance.
definitions (arborize.definitions.Definition) – Optional Definition instance.
- Returns:
A schematic representation.
- Return type:
- arborize.define_constraints(constraints: ConstraintsDefinitionDict, tolerance=None, use_defaults=False) ConstraintsDefinition[source]¶
Create a ConstraintsDefinition instance from a dictionary of constraints, applying an optional global tolerance and default values.
- Parameters:
constraints (ConstraintsDefinitionDict) – Dictionary specifying constraint values structured as ConstraintsDefinitionDict.
tolerance (float or None) – Optional tolerance to apply to all parameter constraints (e.g., 0.1 means ±10%), defaults to None.
use_defaults (bool) – Whether to fill in missing constraint values with defaults, defaults to False.
- Returns:
A fully constructed ConstraintsDefinition instance with all values wrapped in Constraint objects and tolerance applied.
- Return type:
- arborize.define_model(templ_or_def, def_dict=None, /, use_defaults=False) ModelDefinition[source]¶
- Return type:
- arborize.file_schematic(file_like: str | os.PathLike | ~typing.TextIO, definitions: Definition | None = None, fname: str = None, *, name=None, morphio_options: ~morphio._morphio.Option = <Option.no_modifier: 0>) Schematic[source]¶
- Parameters:
file_like (str | os.PathLike | TextIO)
definitions (Definition | None)
fname (str)
morphio_options (Option)
- Return type: