bsb.simulation package¶
Submodules¶
bsb.simulation.simulation module¶
- class bsb.simulation.simulation.Simulation(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
object- connection_models: cfgdict[ConnectionModel]¶
Dictionary linking the connection sets name to its model.
- devices: cfgdict[DeviceModel]¶
Dictionary linking the device name to its model.
- get_connectivity_sets() Mapping[ConnectionModel, ConnectivitySet][source]¶
- Return type:
- get_model_of(type: CellType | ConnectionStrategy) CellModel | ConnectionModel[source]¶
- Parameters:
type (CellType | ConnectionStrategy)
- Return type:
- get_node_name()¶
bsb.simulation.adapter module¶
- class bsb.simulation.adapter.FixedStepProgressController(simulations, adapter, step=1)[source]¶
Bases:
object
- class bsb.simulation.adapter.SimulationData(simulation: Simulation, result=None)[source]¶
Bases:
object- Parameters:
simulation (Simulation)
result (SimulationResult)
- result: SimulationResult¶
- class bsb.simulation.adapter.SimulatorAdapter(comm=None)[source]¶
Bases:
ABC- Parameters:
comm – The mpi4py MPI communicator to use. Only nodes in the communicator will participate in the simulation. The first node will idle as the main node.
- collect(results)[source]¶
Collect the output the simulations that completed.
- Returns:
Collected simulation results.
- Return type:
- abstractmethod prepare(simulation)[source]¶
Reset the simulation backend and prepare for the given simulation.
- Parameters:
simulation (Simulation) – The simulation configuration to prepare.
- Returns:
Prepared simulation data.
- Return type:
- abstractmethod run(*simulations)[source]¶
Fire up the prepared adapter.
- Parameters:
simulations (Simulation) – One or a list of simulation configurations to simulate.
- Returns:
List of simulation results.
- Return type:
- simulate(*simulations, post_prepare=None)[source]¶
Simulate the given simulations.
- Parameters:
simulations (Simulation) – One or a list of simulation configurations to simulate.
post_prepare – Optional callable to run after the simulations’ preparation.
- Returns:
List of simulation results for each simulation run.
- Return type:
bsb.simulation.cell module¶
- class bsb.simulation.cell.CellModel(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
SimulationComponentCell models are simulator specific representations of a cell type.
- get_node_name()¶
bsb.simulation.component module¶
- class bsb.simulation.component.SimulationComponent(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
object- get_node_name()¶
- implement(adapter, simulation, simdata)[source]¶
Method called when simulation is being set up. Can be used for components to set themselves up and store the context they need to operate.
- name: str¶
Base implementation of all the different configuration attributes.
Call the factory function
attr()instead.
- property simulation¶
bsb.simulation.connection module¶
bsb.simulation.device module¶
- class bsb.simulation.device.DeviceModel(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
SimulationComponent- get_node_name()¶
bsb.simulation.parameter module¶
- class bsb.simulation.parameter.Parameter(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
object- get_node_name()¶
- type¶
Base implementation of all the different configuration attributes.
Call the factory function
attr()instead.
- value: ParameterValue¶
Base implementation of all the different configuration attributes.
Call the factory function
attr()instead.
bsb.simulation.results module¶
- class bsb.simulation.results.Recording(ps_name: str, cell_id: int, device: str, name: str, units: str, kind: type, data: object, annotations: dict)[source]¶
Bases:
objectFlat view of a single recorded Neo object inside a
.nioblock.- Parameters:
- class bsb.simulation.results.SimulationRecorder(device=None, meta: dict | None = None)[source]¶
Bases:
objectA recorder appends Neo objects to a segment on each
flush. It is also inspectable at runtime, before anything is written to file:device_namelinks it back to the device that created it, andmetaexposes recorder-level metadata. This lets a controller (e.g. an LFP probe) find the recorders of the devices it manages during a flush and query their metadata, such asrecorder.meta("lfp_source_geometry").- Parameters:
meta (dict | None)
- flush(segment: neo.core.Segment)[source]¶
- Parameters:
segment (neo.core.Segment)
- class bsb.simulation.results.SimulationResult(simulation)[source]¶
Bases:
object- analog_signal(*, data, units, sampling_period, name: str, ps_name: str, cell_id: int, cell_model, device, recording_kind: str = 'cell', **fields)[source]¶
Build a
AnalogSignalcarrying the layeredbsb_*annotations.The annotations come in two layers, all as flat sibling keys. The baseline identifies what is doing the recording and ties the object back to its run:
bsb_device_name,bsb_device_kind,bsb_recording_kind,bsb_simulation_id,bsb_segment_id. The recording-kind layer, selected byrecording_kind, declares what is being recorded; this helper fills the"cell"anchor (bsb_ps_name,bsb_cell_id,bsb_cell_model) shared by the cell, compartment and synapse kinds.Neo’s native fields carry the recorded quantity:
nameis the label (e.g."V_m","I_syn") andunitsthe dimension.Any extra
fieldsare namespaced as first-classbsb_<key>annotations alongside the baseline, so a kind that records a compartment passessection=..., arc=...and getsbsb_section/bsb_arc.
- property analogsignals¶
- create_recorder(flush: Callable[[neo.core.Segment], None], *, device=None, meta: dict | None = None)[source]¶
Register
flushas a recorder. Passdeviceto link the recorder back to it (setsrecorder.device_name) andmetato expose recorder-level metadata queryable at runtime viarecorder.meta(...).- Parameters:
flush (Callable[[neo.core.Segment], None])
meta (dict | None)
- mark_started(started_at: str | None = None) None[source]¶
- Parameters:
started_at (str | None)
- Return type:
None
- set_simulator(name: str, version: str | None = None, **extra) None[source]¶
Adapters call this in
prepareso simulator metadata lands on the Block.
- spike_train(*, times, ps_name: str, cell_id: int, cell_model, device, t_stop, units: str = 'ms', recording_kind: str = 'cell', **fields)[source]¶
Build a
SpikeTraincarrying the baselinebsb_*annotations plus the"cell"-target fields. Seeanalog_signal()for the annotation layering and howfieldsextends it.Convenience only: BSB does not validate or require recorders to use it. Recorders are free to emit any Neo objects they want, in any quantity.
- property spiketrains¶
- stimulus_train(*, times, device, target_count: int, t_stop, units: str = 'ms')[source]¶
Build a stimulator
SpikeTrain: the device’s own emitted spikes, not a recording of a cell. It carries the baselinebsb_*annotations withbsb_recording_kind="stimulus"andbsb_target_count, but no cell anchor (nobsb_ps_name/bsb_cell_id), soiter_recordings()skips it.
- bsb.simulation.results.iter_recordings(block) Iterator[Recording][source]¶
Yield one
Recordingper Neo object across all segments.Skips Neo objects that lack a
bsb_ps_nameannotation (e.g. third-party plugin output that does not follow the convention).
bsb.simulation.targetting module¶
- class bsb.simulation.targetting.BranchLocTargetting(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
LabelTargetting- get_node_name()¶
- class bsb.simulation.targetting.ByIdTargetting(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
FractionFilter,CellTargettingTargets all given identifiers.
- get_node_name()¶
- class bsb.simulation.targetting.ByLabelTargetting(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
CellModelFilter,FractionFilter,CellTargettingTargets all given labels.
- get_node_name()¶
- class bsb.simulation.targetting.CellModelTargetting(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
CellModelFilter,FractionFilter,CellTargettingTargets all cells of certain cell models.
- get_node_name()¶
- class bsb.simulation.targetting.CellTargetting(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
Targetting- get_node_name()¶
- class bsb.simulation.targetting.ConnectionTargetting(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
Targetting- get_node_name()¶
- class bsb.simulation.targetting.CylindricalTargetting(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
CellModelFilter,FractionFilter,CellTargettingTargets all cells in a cylinder along specified axis.
- get_node_name()¶
- class bsb.simulation.targetting.FractionFilter[source]¶
Bases:
object- count¶
Base implementation of all the different configuration attributes.
Call the factory function
attr()instead.
- class bsb.simulation.targetting.LabelTargetting(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
LocationTargetting- get_node_name()¶
- labels¶
- class bsb.simulation.targetting.LocationTargetting(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
object- get_node_name()¶
- class bsb.simulation.targetting.RepresentativesTargetting(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
CellModelFilter,FractionFilter,CellTargettingTargets all identifiers of certain cell types.
- get_node_name()¶
- class bsb.simulation.targetting.SomaTargetting(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
LocationTargetting- get_node_name()¶
- class bsb.simulation.targetting.SphericalTargetting(*args, _parent=None, _key=None, **kwargs)[source]¶
Bases:
CellModelFilter,FractionFilter,CellTargettingTargets all cells in a sphere.
- get_node_name()¶
- get_targets(adapter, simulation, simdata)[source]¶
Target all or certain cells within a sphere of specified radius.
Module contents¶
- class bsb.simulation.SimulationBackendPlugin(Adapter: bsb.simulation.adapter.SimulatorAdapter, Simulation: bsb.simulation.simulation.Simulation)[source]¶
Bases:
object- Parameters:
Adapter (SimulatorAdapter)
Simulation (Simulation)
- Adapter: SimulatorAdapter¶
- Simulation: Simulation¶
- bsb.simulation.get_simulation_adapter(name: str, comm=None)[source]¶
Return the adapter corresponding to the given simulator name.
- Parameters:
name (str) – Name of the simulator.
comm – The mpi4py MPI communicator to use. Only nodes in the communicator will participate in the simulation. The first node will idle as the main node.