bsb.simulation package

Submodules

bsb.simulation.simulation module

class bsb.simulation.simulation.ProgressEvent(progression, duration, time)[source]

Bases: object

class bsb.simulation.simulation.Simulation(*args, _parent=None, _key=None, **kwargs)[source]

Bases: object

cell_models: cfgdict[CellModel]

Dictionary linking the cell population name to its model.

connection_models: cfgdict[ConnectionModel]

Dictionary linking the connection sets name to its model.

devices: cfgdict[DeviceModel]

Dictionary linking the device name to its model.

duration: float

Duration of the simulation in milliseconds.

get_components()[source]
get_connectivity_sets() Mapping[ConnectionModel, ConnectivitySet][source]
Return type:

Mapping[ConnectionModel, ConnectivitySet]

get_model_of(type: CellType | ConnectionStrategy) CellModel | ConnectionModel[source]
Parameters:

type (CellType | ConnectionStrategy)

Return type:

CellModel | ConnectionModel

get_node_name()
name: str

Name of the simulation.

post_prepare: cfglist[Callable[[Simulation, Any], None]]

List of hook functions to call after the simulation has been prepared.

resolution

Simulation time step size in milliseconds.

scaffold: Scaffold
simulator: str

Simulator name.

bsb.simulation.adapter module

class bsb.simulation.adapter.FixedStepProgressController(simulations, adapter, step=1)[source]

Bases: object

get_next_checkpoint()[source]
run_checkpoint()[source]
use_bar()[source]
class bsb.simulation.adapter.SimulationData(simulation: Simulation, result=None, filename=None)[source]

Bases: object

Parameters:

simulation (Simulation)

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:

list[SimulationResult]

execute_checkpoints(controllers)[source]
get_next_checkpoint()[source]
implement_components(simulation)[source]
load_controllers(simulation)[source]
abstractmethod prepare(simulation, filename=None)[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:

SimulationData

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:

list[SimulationResult]

simulate(*simulations, post_prepare=None, filename=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:

list[SimulationResult]

bsb.simulation.cell module

class bsb.simulation.cell.CellModel(*args, _parent=None, _key=None, **kwargs)[source]

Bases: SimulationComponent

Cell models are simulator specific representations of a cell type.

cell_type: CellType

The cell type that this model represents.

get_node_name()
get_placement_set(chunks=None)[source]
parameters: cfglist[Parameter]

The parameters of the model.

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

class bsb.simulation.connection.ConnectionModel(*args, _parent=None, _key=None, **kwargs)[source]

Bases: SimulationComponent

get_connectivity_set()[source]
get_node_name()
tag: str

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

bsb.simulation.device module

class bsb.simulation.device.DeviceModel(*args, _parent=None, _key=None, **kwargs)[source]

Bases: SimulationComponent

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.

bsb.simulation.parameter module

class bsb.simulation.parameter.CellParameter(*args, _parent=None, _key=None, **kwargs)[source]

Bases: ABC

Class for cell parameters to be computed during simulation loading.

abstractmethod compute(sim, ps: PlacementSet, id: int)[source]
Parameters:
get_node_name()
name: str

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

strategy

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

class bsb.simulation.parameter.ConnectionParameter(*args, _parent=None, _key=None, **kwargs)[source]

Bases: ABC

Class for connection parameters to be computed during simulation loading.

abstractmethod compute(sim, cs: ConnectivitySet, pre_locs, post_locs)[source]
Parameters:

cs (ConnectivitySet)

get_node_name()
name: str

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

strategy

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

class bsb.simulation.parameter.DistanceDelayParameter(*args, _parent=None, _key=None, **kwargs)[source]

Bases: ConnectionParameter

axon_speed

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

compute(sim, cs, pre_locs, post_locs)[source]
get_node_name()
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.

class bsb.simulation.parameter.ParameterValue(*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.

bsb.simulation.results module

class bsb.simulation.results.SimulationRecorder[source]

Bases: object

flush(segment: neo.core.Segment)[source]
Parameters:

segment (neo.core.Segment)

class bsb.simulation.results.SimulationResult(simulation, filename=None)[source]

Bases: object

add(recorder)[source]
property block
create_recorder(flush: Callable[[neo.core.Segment], None])[source]
Parameters:

flush (Callable[[neo.core.Segment], None])

flush()[source]
write(filename, mode='ow')[source]

bsb.simulation.targetting module

class bsb.simulation.targetting.BranchLocTargetting(*args, _parent=None, _key=None, **kwargs)[source]

Bases: LabelTargetting

get_locations(cell)[source]
get_node_name()
x

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

class bsb.simulation.targetting.ByIdTargetting(*args, _parent=None, _key=None, **kwargs)[source]

Bases: FractionFilter, CellTargetting

Targets all given identifiers.

get_node_name()
get_targets(adapter, simulation, simdata)[source]
ids: dict[str, list[int]]

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

class bsb.simulation.targetting.ByLabelTargetting(*args, _parent=None, _key=None, **kwargs)[source]

Bases: CellModelFilter, FractionFilter, CellTargetting

Targets all given labels.

get_node_name()
get_targets(adapter, simulation, simdata)[source]
labels: list[str]

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

class bsb.simulation.targetting.CellModelFilter[source]

Bases: object

cell_models: list[CellModel]
get_targets(adapter, simulation, simdata)[source]
class bsb.simulation.targetting.CellModelTargetting(*args, _parent=None, _key=None, **kwargs)[source]

Bases: CellModelFilter, FractionFilter, CellTargetting

Targets all cells of certain cell models.

cell_models: list[CellModel]
get_node_name()
get_targets(adapter, simulation, simdata)[source]
class bsb.simulation.targetting.CellTargetting(*args, _parent=None, _key=None, **kwargs)[source]

Bases: Targetting

get_node_name()
get_targets(adapter, simulation, simdata)[source]
type: Literal['cell', 'connection']
class bsb.simulation.targetting.ConnectionTargetting(*args, _parent=None, _key=None, **kwargs)[source]

Bases: Targetting

get_node_name()
get_targets(adapter, simulation, simdata)[source]
type: Literal['cell', 'connection']
class bsb.simulation.targetting.CylindricalTargetting(*args, _parent=None, _key=None, **kwargs)[source]

Bases: CellModelFilter, FractionFilter, CellTargetting

Targets all cells in a cylinder along specified axis.

axis: Literal['x', 'y', 'z']

Main axis of the cylinder.

get_node_name()
get_targets(adapter, simulation, simdata)[source]

Target all or certain cells within a cylinder of specified radius.

origin: ndarray[float]

Coordinates of the base of the cylinder for each non main axis.

radius: float

Radius of the cylinder.

class bsb.simulation.targetting.FractionFilter[source]

Bases: object

count

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

static filter(f)[source]
fraction

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

satisfy_fractions(targets)[source]
class bsb.simulation.targetting.LabelTargetting(*args, _parent=None, _key=None, **kwargs)[source]

Bases: LocationTargetting

get_locations(cell)[source]
get_node_name()
labels
class bsb.simulation.targetting.LocationTargetting(*args, _parent=None, _key=None, **kwargs)[source]

Bases: object

get_locations(cell)[source]
get_node_name()
strategy

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

class bsb.simulation.targetting.RepresentativesTargetting(*args, _parent=None, _key=None, **kwargs)[source]

Bases: CellModelFilter, FractionFilter, CellTargetting

Targets all identifiers of certain cell types.

get_node_name()
get_targets(adapter, simulation, simdata)[source]
n: int

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

class bsb.simulation.targetting.SomaTargetting(*args, _parent=None, _key=None, **kwargs)[source]

Bases: LocationTargetting

get_locations(cell)[source]
get_node_name()
class bsb.simulation.targetting.SphericalTargetting(*args, _parent=None, _key=None, **kwargs)[source]

Bases: CellModelFilter, FractionFilter, CellTargetting

Targets 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.

origin: list[float]

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

radius: float

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

class bsb.simulation.targetting.Targetting(*args, _parent=None, _key=None, **kwargs)[source]

Bases: object

get_node_name()
get_targets(adapter, simulation, simdata)[source]
strategy

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

type: Literal['cell', 'connection']

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

Module contents

class bsb.simulation.SimulationBackendPlugin(Adapter: bsb.simulation.adapter.SimulatorAdapter, Simulation: bsb.simulation.simulation.Simulation)[source]

Bases: object

Parameters:
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.