bsb_nest package

Subpackages

Submodules

bsb_nest.adapter module

class bsb_nest.adapter.NestAdapter(comm=None)

Bases: SimulatorAdapter

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.

check_comm()
connect_neurons(simulation)

Connect the cells in NEST according to the connection model configurations

create_neurons(simulation)

Create a population of nodes in the NEST simulator based on the cell model configurations.

load_modules(simulation)
prepare(simulation)

Prepare the simulation environment in NEST.

This method initializes internal data structures and performs all setup steps required before running the simulation:

  • Loads and installs required NEST modules.

  • Applies simulation-level settings (e.g., resolution, verbosity, seed).

  • Creates neuron populations based on cell models.

  • Establishes connectivity between neurons using connection models.

  • Instantiates devices (e.g., recorders, stimuli) used in the simulation.

If any error occurs during preparation, the corresponding internal state is cleaned up to avoid partial setups.

Parameters:

simulation (NestSimulation) – The simulation configuration to prepare.

Returns:

The prepared simulation data associated with the given simulation.

Return type:

bsb.simulation.adapter.SimulationData

reset_kernel()
run(*simulations)

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]

set_settings(simulation: NestSimulation)
Parameters:

simulation (NestSimulation)

simulate(*simulations, post_prepare=None)

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]

class bsb_nest.adapter.NestResult(simulation)

Bases: SimulationResult

record(nc, **annotations)

bsb_nest.cell module

class bsb_nest.cell.NestCell(*args, _parent=None, _key=None, **kwargs)

Bases: CellModel

constants

Dictionary of the constants values to assign to the cell model.

create_population(simdata)
get_node_name()
model

Importable reference to the NEST model describing the cell type.

set_constants(population)
set_parameters(population, simdata)

bsb_nest.connection module

class bsb_nest.connection.LazySynapseCollection(pre, post)

Bases: object

property collection
class bsb_nest.connection.NestConnectionSettings(*args, _parent=None, _key=None, **kwargs)

Bases: object

Class interfacing a NEST connection rule.

constants

Dictionary of parameters to assign to the connection rule.

get_node_name()
rule

Importable reference to the NEST connection rule used to connect the cells.

class bsb_nest.connection.NestSynapseSettings(*args, _parent=None, _key=None, **kwargs)

Bases: object

Class interfacing a NEST synapse model.

constants

Dictionary of the constants values to assign to the synapse model.

delay

Delay of the transmission between the presynaptic and the postsynaptic cells.

get_node_name()
model

Importable reference to the NEST model describing the synapse type.

receptor_type

Index of the postsynaptic receptor to target.

weight

Weight of the connection between the presynaptic and the postsynaptic cells.

class bsb_nest.connection.NestConnection(*args, _parent=None, _key=None, **kwargs)

Class interfacing a NEST connection, including its connection rule and synaptic parameters.

block_iterator(cs, comm)
create_connections(simdata, pre_nodes, post_nodes, cs, comm)
get_conn_spec()
get_connectivity_set()
get_node_name()
get_syn_specs()
local_iterator(cs, comm)
model_strategy: str

Specifies the strategy used by the connection model for synapse creation and management.

predict_mem_iterator(pre_nodes, post_nodes, cs, comm)
synapses

List of synapse models to use for a connection.

bsb_nest.device module

class bsb_nest.device.ExtNestDevice(*args, _parent=None, _key=None, **kwargs)

Bases: NestDevice

Class interfacing Nest devices.

constants

Dictionary of the constants values to assign to the device model.

get_node_name()
implement(adapter, simulation, simdata)

Create, connect and register the Nest device.

Parameters:
nest_model

Importable reference to the NEST model describing the device type.

class bsb_nest.device.NestDevice(*args, _parent=None, _key=None, **kwargs)

Bases: DeviceModel

connect_to_nodes(device, nodes)
delay

delay of the transmission between the device and its target

device: str

Name of the NEST device model (e.g., “spike_generator”, “poisson_generator”).

get_dict_targets(adapter, simulation, simdata) dict

Get a dictionary from a target group to its NEST Collection for each target group of the device.

Parameters:
Returns:

dictionary of device target group to NEST Collection

Return type:

dict

get_node_name()
get_target_nodes(adapter, simulation, simdata)

Get the NEST Collection of the targets of the device.

Parameters:
Returns:

Flattened NEST collection with all the targets of the device

abstractmethod implement(adapter, simulation, simdata)

Create, connect and register the Nest device.

Parameters:
receptor_type

Integer ID of the postsynaptic target receptor

register_device(simdata, device)
targetting

Targets of the device, which should be either a population or a nest rule

weight

weight of the connection between the device and its target

class bsb_nest.device.NestRule(*args, _parent=None, _key=None, **kwargs)

Bases: object

Interface to connect a device directly through the NEST interface.

cell_models

Reference to the Nest cell model to target with the Device

constants

Dictionary of parameters for the targetting rule.

get_node_name()
rule

Connection rule to connect

bsb_nest.distributions module

class bsb_nest.distributions.NestRandomDistribution(*args, _parent=None, _key=None, **kwargs)

Bases: object

Class to handle NEST random distributions.

distribution: str

Distribution name. Should correspond to a function of nest.random.hl_api_random

get_node_name()
parameters: dict[str, Any]

Dictionary of parameters to assign to the distribution. Should correspond to NEST’s

scaffold: Scaffold
class bsb_nest.distributions.nest_parameter

Bases: TypeHandler

Type validator. Type casts the value or node to a Nest parameter, that can be either a value or a NestRandomDistribution.

bsb_nest.exceptions module

exception bsb_nest.exceptions.KernelWarning

Bases: Warning

exception bsb_nest.exceptions.NestConnectError

Bases: NestError

exception bsb_nest.exceptions.NestError

Bases: Exception

exception bsb_nest.exceptions.NestKernelError

Bases: NestError

exception bsb_nest.exceptions.NestModelError

Bases: NestError

exception bsb_nest.exceptions.NestModuleError

Bases: NestKernelError

bsb_nest.simulation module

class bsb_nest.simulation.NestSimulation(*args, _parent=None, _key=None, **kwargs)

Bases: Simulation

Interface between the scaffold model and the NEST simulator.

cell_models: cfgdict[NestCell]

Dictionary of cell models in the simulation.

connection_models: cfgdict[NestConnection]

Dictionary of connection models in the simulation.

devices: cfgdict[NestDevice]

Dictionary of devices in the simulation.

get_node_name()
modules

List of NEST modules to load at the beginning of the simulation

resolution

Simulation time step size in milliseconds

seed

Random seed for the simulations

threads

Number of threads to use during simulation

verbosity

NEST verbosity level

Module contents

NEST simulation adapter for the BSB framework.