bsb package

Subpackages

Submodules

bsb.core module

class bsb.core.ReportListener(scaffold, file)[source]

Bases: object

class bsb.core.Scaffold(config=None, storage=None, clear=False, comm=None)[source]

Bases: object

This is the main object of the bsb package, it represents a network and puts together all the pieces that make up the model description such as the Configuration with the technical side like the Storage.

Bootstraps a network object.

Parameters:
  • config (Configuration) – The configuration to use for this network. If it is omitted the default configuration is used.

  • storage (Storage) – The storage to use to read and write data for this network. If it is omitted the configuration’s Storage node is used to construct one.

  • clear (bool) – Start with a new network, clearing any previously stored information

  • comm (mpi4py.MPI.Comm) – MPI communicator that shares control over the Storage.

Returns:

A network object

Return type:

Scaffold

property after_connectivity
property after_placement
attr = 'simulations'
property cell_types
clear()[source]

Clears the storage. This deletes any existing network data!

clear_connectivity()[source]

Clears the connectivity storage.

clear_placement()[source]

Clears the placement storage.

compile(skip_placement=False, skip_connectivity=False, skip_after_placement=False, skip_after_connectivity=False, only=None, skip=None, clear=False, append=False, redo=False, force=False, fail_fast=True)[source]

Run reconstruction steps in the scaffold sequence to obtain a full network.

property configuration: Configuration
connect_cells(pre_set, post_set, src_locs, dest_locs, name)[source]

Connect cells from a presynaptic placement set to cells of a postsynaptic placement set, and into a connectivity set. The description of the hemitype (source or target cell population) connection location is stored as a list of 3 ids: the cell index (in the placement set), morphology branch index, and the morphology branch section index. If no morphology is attached to the hemitype, then the morphology indexes can be set to -1.

Parameters:
property connectivity
create_entities(cell_type, count)[source]

Create entities in the simulation space.

Entities are different from cells because they have no positional data and don’t influence the placement step. They do have a representation in the connection and simulation step.

Parameters:
  • cell_type (CellType) – The cell type of the entities

  • count (int) – Number of entities to place

Todo:

Allow additional data for entities

create_job_pool(fail_fast=None, quiet=False)[source]
property files: FileStore
get_cell_types() List[CellType][source]

Return a list of all cell types in the network.

Return type:

List[CellType]

get_config_diagram()[source]
get_connectivity(anywhere=None, presynaptic=None, postsynaptic=None, skip=None, only=None) List[ConnectivitySet][source]
Return type:

List[ConnectivitySet]

get_connectivity_set(tag=None, pre=None, post=None) ConnectivitySet[source]

Return a connectivity set from its name according to the output formatter. The name can be specified directly with tag or with deduced from pre and post if there is only one connectivity set matching this pair.

Parameters:
  • tag (str) – Unique identifier of the connectivity set in the output formatter

  • pre (CellType) – Presynaptic cell type

  • post (CellType) – Postsynaptic cell type

Returns:

A connectivity set

Return type:

ConnectivitySet

get_connectivity_sets() List[ConnectivitySet][source]

Return all connectivity sets from the output formatter.

Returns:

All connectivity sets

Return type:

List[ConnectivitySet]

get_dependency_pipelines()[source]
get_placement(cell_types=None, skip=None, only=None) List[PlacementStrategy][source]
Return type:

List[PlacementStrategy]

get_placement_of(*cell_types)[source]

Find all the placement strategies that involve the given cell types.

Parameters:

cell_types (Union[CellType, str]) – Cell types (or their names) of interest.

get_placement_set(type, chunks=None, labels=None, morphology_labels=None) PlacementSet[source]

Return a cell type’s placement set from the output formatter.

Parameters:
  • type (Union[CellType, str]) – Cell type name

  • chunks (list[tuple[float, float, float]]) – Optionally load a specific list of chunks.

  • labels (list[str]) – Labels to filter the placement set by.

  • morphology_labels (list[str]) – Subcellular labels to apply to the morphologies.

Returns:

A placement set

Return type:

PlacementSet

get_placement_sets() List[PlacementSet][source]

Return all the placement sets present in the network.

Return type:

List[PlacementSet]

get_simulation(sim_name: str) Simulation[source]

Retrieve the default single-instance adapter for a simulation.

Parameters:

sim_name (str)

Return type:

Simulation

get_storage_diagram()[source]
is_main_process() bool[source]
Return type:

bool

is_worker_process() bool[source]
Return type:

bool

merge(other, label=None)[source]
property morphologies: MorphologyRepository
property network
property partitions
place_cells(cell_type, positions, morphologies=None, rotations=None, additional=None, chunk=None)[source]

Place cells inside the scaffold

# Add one granule cell at position 0, 0, 0
cell_type = scaffold.get_cell_type("granule_cell")
scaffold.place_cells(cell_type, cell_type.layer_instance, [[0., 0., 0.]])
Parameters:
  • cell_type (CellType) – The type of the cells to place.

  • positions (Any np.concatenate type of shape (N, 3).) – A collection of xyz positions to place the cells on.

property placement
property regions
register_listener(listener, max_wait=None)[source]
register_pool_cached_item(id, cleanup)[source]

Registers a cleanup function for items cached during a parallel workflow. Internal use only.

Parameters:
  • id – Id of the cached item. Should be unique but identical across MPI nodes

  • cleanup – A callable that cleans up the cached item.

remove_listener(listener)[source]
require_connectivity_set(pre, post, tag=None) ConnectivitySet[source]
Return type:

ConnectivitySet

resize(x=None, y=None, z=None)[source]

Updates the topology boundary indicators. Use before placement, updates only the abstract topology tree, does not rescale, prune or otherwise alter already existing placement data.

run_after_connectivity(hooks=None, fail_fast=None, pipelines=True)[source]

Run after placement hooks.

run_after_placement(hooks=None, fail_fast=None, pipelines=True)[source]

Run after placement hooks.

run_connectivity(strategies=None, fail_fast=True, pipelines=True)[source]

Run connection strategies.

run_pipelines(fail_fast=True, pipelines=None)[source]
run_placement(strategies=None, fail_fast=True, pipelines=True)[source]

Run placement strategies.

run_placement_strategy(strategy)[source]

Run a single placement strategy.

run_simulation(simulation_name: str)[source]

Run a simulation starting from the default single-instance adapter.

Parameters:

simulation_name (str) – Name of the simulation in the configuration.

property simulations
property storage: Storage
property storage_cfg
bsb.core.from_storage(root, comm=None)[source]

Load core.Scaffold from a storage object.

Parameters:
  • root – Root (usually path) pointing to the storage object.

  • comm (mpi4py.MPI.Comm) – MPI communicator that shares control over the Storage.

Returns:

A network scaffold

Return type:

Scaffold

bsb.cell_types module

Module for the CellType configuration node and its dependencies.

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

Bases: object

Information on a population of cells.

clear()[source]

Clear all the placement and connectivity data associated with this cell type.

clear_connections()[source]

Clear all the connectivity data associated with this cell type. Any connectivity set that this cell type is a part of will be entirely removed.

clear_placement()[source]

Clear all the placement data associated with this cell type. Connectivity data will remain, but be invalid.

entity

Whether this cell type is an entity type. Entity types don’t have representations in space, but can still be connected and simulated.

get_morphologies()[source]

Return the list of morphologies of this cell type.

Return type:

List[StoredMorphology]

get_node_name()
get_placement()[source]

Get the placement components this cell type is a part of.

get_placement_set(*args, **kwargs)[source]

Retrieve this cell type’s placement data

Parameters:

chunks (List[bsb.storage._chunks.Chunk]) – When given, restricts the placement data to these chunks.

property morphologies
name

Name of the cell type, equivalent to the key it occurs under in the configuration.

plotting

Plotting information about the cell type, such as color and labels.

scaffold: Scaffold
spatial

Spatial information about the cell type such as radius and density, and geometric or morphological information.

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

Bases: object

count: int

Base implementation of all the different configuration attributes. Call the factory function attr() instead.

count_ratio: float

Base implementation of all the different configuration attributes. Call the factory function attr() instead.

density: float

Base implementation of all the different configuration attributes. Call the factory function attr() instead.

density_key: str

Base implementation of all the different configuration attributes. Call the factory function attr() instead.

density_ratio: float

Base implementation of all the different configuration attributes. Call the factory function attr() instead.

geometry: dict
get_node_name()
local_count_ratio: float

Base implementation of all the different configuration attributes. Call the factory function attr() instead.

morphologies: cfglist[MorphologySelector]
planar_density: 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.

relative_to: CellType
scaffold: Scaffold
class bsb.cell_types.Plotting(*args, _parent=None, _key=None, **kwargs)[source]

Bases: object

color

Color used to display this cell type in plots.

display_name

Label used to display this cell type in plots.

get_node_name()
opacity

Opacity used to display this cell type in plots.

scaffold: Scaffold

bsb.exceptions module

exception bsb.exceptions.AdapterError(*args, **kwargs)

Bases: ScaffoldError

AdapterError exception

exception bsb.exceptions.AllenApiError(*args, **kwargs)

Bases: GatewayError

AllenApiError exception

exception bsb.exceptions.AttributeMissingError(*args, **kwargs)

Bases: StorageError

AttributeMissingError exception

exception bsb.exceptions.BootError(*args, **kwargs)

Bases: ConfigurationError

BootError exception

exception bsb.exceptions.CLIError(*args, **kwargs)

Bases: ScaffoldError

CLIError exception

exception bsb.exceptions.CastConfigurationError(*args, **kwargs)

Bases: ConfigurationError

CastConfigurationError exception

exception bsb.exceptions.CastError(*args, **kwargs)

Bases: ConfigurationError

CastError exception

exception bsb.exceptions.CfgReferenceError(*args, **kwargs)

Bases: ConfigurationError

CfgReferenceError exception

exception bsb.exceptions.ChunkError(*args, **kwargs)

Bases: PlacementError

ChunkError exception

exception bsb.exceptions.CircularMorphologyError(*args, **kwargs)

Bases: MorphologyError

CircularMorphologyError exception

exception bsb.exceptions.ClassError(*args, **kwargs)

Bases: ScaffoldError

ClassError exception

exception bsb.exceptions.ClassMapMissingError(*args, **kwargs)

Bases: DynamicClassError

ClassMapMissingError exception

exception bsb.exceptions.CodeImportError(*args, **kwargs)

Bases: ScaffoldError

CodeImportError exception

exception bsb.exceptions.CommandError(*args, **kwargs)

Bases: CLIError

CommandError exception

exception bsb.exceptions.CompartmentError(*args, **kwargs)

Bases: MorphologyError

CompartmentError exception

exception bsb.exceptions.CompilationError(*args, **kwargs)

Bases: ScaffoldError

CompilationError exception

exception bsb.exceptions.ConfigTemplateNotFoundError(*args, **kwargs)

Bases: CLIError

ConfigTemplateNotFoundError exception

exception bsb.exceptions.ConfigurationError(*args, **kwargs)

Bases: ScaffoldError

ConfigurationError exception

exception bsb.exceptions.ConfigurationFormatError(*args, **kwargs)

Bases: ConfigurationError

ConfigurationFormatError exception

exception bsb.exceptions.ConfigurationWarning[source]

Bases: ScaffoldWarning

exception bsb.exceptions.ConnectivityError(*args, **kwargs)

Bases: ScaffoldError

ConnectivityError exception

exception bsb.exceptions.ConnectivityWarning[source]

Bases: ScaffoldWarning

exception bsb.exceptions.ContinuityError(*args, **kwargs)

Bases: PlacementError

ContinuityError exception

exception bsb.exceptions.DataNotFoundError(*args, **kwargs)

Bases: StorageError

DataNotFoundError exception

exception bsb.exceptions.DataNotProvidedError(*args, **kwargs)

Bases: ScaffoldError

DataNotProvidedError exception

exception bsb.exceptions.DatasetExistsError(*args, **kwargs)

Bases: StorageError

DatasetExistsError exception

exception bsb.exceptions.DatasetNotFoundError(*args, **kwargs)

Bases: StorageError

DatasetNotFoundError exception

exception bsb.exceptions.DependencyError(*args, **kwargs)

Bases: ScaffoldError

DependencyError exception

exception bsb.exceptions.DistributionCastError(*args, **kwargs)

Bases: CastError

DistributionCastError exception

exception bsb.exceptions.DistributorError(*args, **kwargs)

Bases: CompilationError

DistributorError exception

exception bsb.exceptions.DryrunError(*args, **kwargs)

Bases: CLIError

DryrunError exception

exception bsb.exceptions.DynamicClassError(*args, **kwargs)

Bases: ConfigurationError

DynamicClassError exception

exception bsb.exceptions.DynamicClassInheritanceError(*args, **kwargs)

Bases: DynamicClassError

DynamicClassInheritanceError exception

exception bsb.exceptions.DynamicObjectNotFoundError(*args, **kwargs)

Bases: DynamicClassError

DynamicObjectNotFoundError exception

exception bsb.exceptions.EmptyBranchError(*args, **kwargs)

Bases: MorphologyError

EmptyBranchError exception

exception bsb.exceptions.EmptySelectionError(*args, **kwargs)

Bases: MorphologyError

EmptySelectionError exception

exception bsb.exceptions.EmptyVoxelSetError(*args, **kwargs)

Bases: VoxelSetError

EmptyVoxelSetError exception

exception bsb.exceptions.ExternalSourceError(*args, **kwargs)

Bases: ConnectivityError

ExternalSourceError exception

exception bsb.exceptions.FileImportError(*args, **kwargs)

Bases: ParserError

FileImportError exception

exception bsb.exceptions.FileReferenceError(*args, **kwargs)

Bases: ParserError

FileReferenceError exception

exception bsb.exceptions.GatewayError(*args, **kwargs)

Bases: ScaffoldError

GatewayError exception

exception bsb.exceptions.IncompleteExternalMapError(*args, **kwargs)

Bases: ExternalSourceError

IncompleteExternalMapError exception

exception bsb.exceptions.IncompleteMorphologyError(*args, **kwargs)

Bases: MorphologyError

IncompleteMorphologyError exception

exception bsb.exceptions.IndicatorError(*args, **kwargs)

Bases: ConfigurationError

IndicatorError exception

exception bsb.exceptions.InputError(*args, **kwargs)

Bases: CLIError

InputError exception

exception bsb.exceptions.IntersectionDataNotFoundError(*args, **kwargs)

Bases: DatasetNotFoundError

IntersectionDataNotFoundError exception

exception bsb.exceptions.InvalidReferenceError(*args, **kwargs)

Bases: TypeHandlingError

InvalidReferenceError exception

exception bsb.exceptions.JobCancelledError(*args, **kwargs)

Bases: JobPoolError

JobCancelledError exception

exception bsb.exceptions.JobPoolContextError(*args, **kwargs)

Bases: JobPoolError

JobPoolContextError exception

exception bsb.exceptions.JobPoolError(*args, **kwargs)

Bases: ScaffoldError

JobPoolError exception

exception bsb.exceptions.JobSchedulingError(*args, **kwargs)

Bases: JobPoolError

JobSchedulingError exception

exception bsb.exceptions.LayoutError(*args, **kwargs)

Bases: TopologyError

LayoutError exception

exception bsb.exceptions.MissingActiveConfigError(*args, **kwargs)

Bases: StorageError

MissingActiveConfigError exception

exception bsb.exceptions.MissingMorphologyError(*args, **kwargs)

Bases: MorphologyError

MissingMorphologyError exception

exception bsb.exceptions.MissingSourceError(*args, **kwargs)

Bases: ExternalSourceError

MissingSourceError exception

exception bsb.exceptions.MorphologyDataError(*args, **kwargs)

Bases: MorphologyError

MorphologyDataError exception

exception bsb.exceptions.MorphologyError(*args, **kwargs)

Bases: ScaffoldError

MorphologyError exception

exception bsb.exceptions.MorphologyRepositoryError(*args, **kwargs)

Bases: MorphologyError

MorphologyRepositoryError exception

exception bsb.exceptions.MorphologyWarning[source]

Bases: ScaffoldWarning

exception bsb.exceptions.NoReferenceAttributeSignal(*args, **kwargs)

Bases: CfgReferenceError

NoReferenceAttributeSignal exception

exception bsb.exceptions.NodeNotFoundError(*args, **kwargs)

Bases: ScaffoldError

NodeNotFoundError exception

exception bsb.exceptions.NoneReferenceError(*args, **kwargs)

Bases: TypeHandlingError

NoneReferenceError exception

exception bsb.exceptions.OptionError(*args, **kwargs)

Bases: ScaffoldError

OptionError exception

exception bsb.exceptions.PackageRequirementWarning[source]

Bases: ScaffoldWarning

exception bsb.exceptions.PackingError(*args, **kwargs)

Bases: PlacementError

PackingError exception

exception bsb.exceptions.PackingWarning[source]

Bases: PlacementWarning

exception bsb.exceptions.ParameterError(*args, **kwargs)

Bases: SimulationError

ParameterError exception

exception bsb.exceptions.ParserError(*args, **kwargs)

Bases: ScaffoldError

ParserError exception

exception bsb.exceptions.PlacementError(*args, **kwargs)

Bases: ScaffoldError

PlacementError exception

exception bsb.exceptions.PlacementRelationError(*args, **kwargs)

Bases: PlacementError

PlacementRelationError exception

exception bsb.exceptions.PlacementWarning[source]

Bases: ScaffoldWarning

exception bsb.exceptions.PluginError(*args, **kwargs)

Bases: ScaffoldError

PluginError exception

exception bsb.exceptions.ReadOnlyOptionError(*args, **kwargs)

Bases: OptionError

ReadOnlyOptionError exception

exception bsb.exceptions.RedoError(*args, **kwargs)

Bases: CompilationError

RedoError exception

exception bsb.exceptions.ReificationError(*args, **kwargs)

Bases: ParameterError

ReificationError exception

exception bsb.exceptions.RequirementError(*args, **kwargs)

Bases: ConfigurationError

RequirementError exception

exception bsb.exceptions.ScaffoldError(*args, **kwargs)

Bases: DetailedException

ScaffoldError exception

exception bsb.exceptions.ScaffoldWarning[source]

Bases: UserWarning

exception bsb.exceptions.SelectorError(*args, **kwargs)

Bases: ScaffoldError

SelectorError exception

exception bsb.exceptions.SimulationError(*args, **kwargs)

Bases: ScaffoldError

SimulationError exception

exception bsb.exceptions.SourceQualityError(*args, **kwargs)

Bases: ExternalSourceError

SourceQualityError exception

exception bsb.exceptions.StorageError(*args, **kwargs)

Bases: ScaffoldError

StorageError exception

exception bsb.exceptions.TopologyError(*args, **kwargs)

Bases: ScaffoldError

TopologyError exception

exception bsb.exceptions.TreeError(*args, **kwargs)

Bases: ScaffoldError

TreeError exception

exception bsb.exceptions.TypeHandlingError(*args, **kwargs)

Bases: ScaffoldError

TypeHandlingError exception

exception bsb.exceptions.UnfitClassCastError(*args, **kwargs)

Bases: CastError

UnfitClassCastError exception

exception bsb.exceptions.UnknownConfigAttrError(*args, **kwargs)

Bases: ConfigurationError

UnknownConfigAttrError exception

exception bsb.exceptions.UnknownGIDError(*args, **kwargs)

Bases: ConnectivityError

UnknownGIDError exception

exception bsb.exceptions.UnknownStorageEngineError(*args, **kwargs)

Bases: StorageError

UnknownStorageEngineError exception

exception bsb.exceptions.UnmanagedPartitionError(*args, **kwargs)

Bases: TopologyError

UnmanagedPartitionError exception

exception bsb.exceptions.UnresolvedClassCastError(*args, **kwargs)

Bases: CastError

UnresolvedClassCastError exception

exception bsb.exceptions.VoxelSetError(*args, **kwargs)

Bases: ScaffoldError

VoxelSetError exception

bsb.exceptions module

class bsb.mixins.HasDependencies[source]

Mixin class to mark that this node may depend on other nodes.

abstract get_deps()[source]
classmethod sort_deps(objects)[source]

Orders a given dictionary of objects by the class’s default mechanism and then apply the after attribute for further restrictions.

class bsb.mixins.InvertedRoI[source]

This mixin inverts the perspective of the get_region_of_interest interface and lets you find presynaptic regions of interest for a postsynaptic chunk.

Usage:

..code-block:: python

class MyConnStrat(InvertedRoI, ConnectionStrategy):
def get_region_of_interest(post_chunk):

return [pre_chunk1, pre_chunk2]

queue(pool)[source]
class bsb.mixins.NotParallel[source]

bsb.option module

This module contains the classes required to construct options.

class bsb.option.BsbOption(positional=False)[source]

Bases: object

Base option class. Can be subclassed to create new options.

add_to_parser(parser, level)[source]

Register this option into an argparse parser.

get(prio=None)[source]

Get the option’s value. Cascades the script, cli, env & default descriptors together.

Returns:

option value

get_cli_tags()[source]

Return the argparse positional arguments from the tags.

Returns:

-x or --xxx for each CLI tag.

Return type:

list

get_default()[source]

Override to specify the default value of the option.

is_set(slug)[source]
classmethod register()[source]

Register this option class into the bsb.options module.

unregister()[source]

Remove this option class from the bsb.options module, not part of the public API as removing options is undefined behavior but useful for testing.

class bsb.option.CLIOptionDescriptor(*tags)[source]

Bases: OptionDescriptor

Descriptor that retrieves its value from the given CLI command arguments.

slug = 'cli'
class bsb.option.EnvOptionDescriptor(*args, flag=False)[source]

Bases: OptionDescriptor

Descriptor that retrieves its value from the environment variables.

is_set(instance)[source]
slug = 'env'
class bsb.option.OptionDescriptor(*tags)[source]

Bases: object

Base option property descriptor. Can be inherited from to create a cascading property such as the default CLI, env & script descriptors.

is_set(instance)[source]
class bsb.option.ProjectOptionDescriptor(*tags)[source]

Bases: OptionDescriptor

Descriptor that retrieves and stores values in the pyproject.toml file. Traverses up the filesystem tree until one is found.

is_set(instance)[source]
slug = 'project'
class bsb.option.ScriptOptionDescriptor(*tags)[source]

Bases: OptionDescriptor

Descriptor that retrieves and sets its value from/to the bsb.options module.

is_set(instance)[source]
slug = 'script'

bsb.options module

This module contains the global options.

You can set options at the script level (which superceeds all other levels such as environment variables or project settings).

import bsb.options
from bsb import BsbOption

class MyOption(BsbOption, cli=("my_setting",), env=("MY_SETTING",), script=("my_setting", "my_alias")):
    def get_default(self):
        return 4

# Register the option into the `bsb.options` module
MyOption.register()

assert bsb.options.my_setting == 4
bsb.options.my_alias = 6
assert bsb.options.my_setting == 6

Your MyOption will also be available on all CLI commands as --my_setting and will be read from the MY_SETTING environment variable.

class bsb.options.ProfilingOption(positional=False)[source]

Bases: BsbOption

Enables profiling.

cli

Descriptor that retrieves its value from the given CLI command arguments.

description = None
env

Descriptor that retrieves its value from the environment variables.

get_default()[source]

Override to specify the default value of the option.

getter(value)[source]
inverted_flag = False
is_flag = True
name = 'profiling'
positional = False
project

Descriptor that retrieves and stores values in the pyproject.toml file. Traverses up the filesystem tree until one is found.

readonly = False
script

Descriptor that retrieves and sets its value from/to the bsb.options module.

setter(value)[source]
use_action = False
use_extend = False
class bsb.options.VerbosityOption(positional=False)[source]

Bases: BsbOption

Set the verbosity of the package. Verbosity 0 is completely silent, 1 is default, 2 is verbose, 3 is progress and 4 is debug.

cli

Descriptor that retrieves its value from the given CLI command arguments.

description = None
env

Descriptor that retrieves its value from the environment variables.

get_default()[source]

Override to specify the default value of the option.

getter(value)[source]
inverted_flag = False
is_flag = False
name = 'verbosity'
positional = False
project

Descriptor that retrieves and stores values in the pyproject.toml file. Traverses up the filesystem tree until one is found.

readonly = False
script

Descriptor that retrieves and sets its value from/to the bsb.options module.

setter(value)[source]
use_action = False
use_extend = False
bsb.options.discover_options()[source]
bsb.options.get_module_option(tag)[source]

Get the value of a module option. Does the same thing as getattr(options, tag)

Parameters:

tag (str) – Name the option is registered with in the module.

bsb.options.get_option(tag, prio=None)[source]

Retrieve the cascaded value for an option.

Parameters:
  • tag (str) – Name the option is registered with.

  • prio (str) – Give priority to a type of value. Can be any of ‘script’, ‘cli’, ‘project’, ‘env’.

Returns:

(Possibly prioritized) value of the option.

Return type:

Any

bsb.options.get_option_classes()[source]

Return all of the classes that are used to create singleton options from. Useful to access the option descriptors rather than the option values.

Returns:

The classes of all the installed options by name.

Return type:

dict[str, bsb.option.BsbOption]

bsb.options.get_option_descriptor(name)[source]

Return an option

Parameters:

name (str) – Name of the option to look for.

Returns:

The option singleton of that name.

Return type:

dict[str, bsb.option.BsbOption]

bsb.options.get_option_descriptors()[source]

Get all the registered option singletons.

bsb.options.get_project_option(tag)[source]

Find a project option

Parameters:

tag (str) – dot-separated path of the option. e.g. networks.config_link.

Returns:

Project option instance

Return type:

option.BsbOption

bsb.options.is_module_option_set(tag)[source]

Check if a module option was set.

Parameters:

tag (str) – Name the option is registered with in the module.

Returns:

Whether the option was ever set from the module

Return type:

bool

bsb.options.read_option(tag=None)[source]

Read an option value from the project settings. Returns all project settings if tag is omitted.

Parameters:

tag (str) – Dot-separated path of the project option

Returns:

Value for the project option

Return type:

Any

bsb.options.register_option(name, option)[source]

Register an option as a global BSB option. Options that are installed by the plugin system are automatically registered on import of the BSB.

Parameters:
  • name (str) – Name for the option, used to store and retrieve its singleton.

  • option (option.BsbOption) – Option instance, to be used as a singleton.

bsb.options.reset_module_option(tag)[source]
bsb.options.set_module_option(tag, value)[source]

Set the value of a module option. Does the same thing as setattr(options, tag, value).

Parameters:
  • tag (str) – Name the option is registered with in the module.

  • value (Any) – New module value for the option

bsb.options.store_option(tag, value)[source]

Store an option value permanently in the project settings.

Parameters:
  • tag (str) – Dot-separated path of the project option

  • value (Any) – New value for the project option

bsb.options.unregister_option(option)[source]

Unregister a globally registered option. Also removes its script and project parts.

Parameters:

option (option.BsbOption) – Option singleton, to be removed.

bsb.plugins module

Plugins module. Uses pkg_resources to detect installed plugins and loads them as categories.

bsb.plugins.discover(category)[source]

Discover all plugins for a given category.

Parameters:

category (str) – Plugin category (e.g. adapters to load all bsb.adapters)

Returns:

Loaded plugins by name.

Return type:

dict

bsb.postprocessing module

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

Bases: ABC

get_node_name()
name: str

Base implementation of all the different configuration attributes. Call the factory function attr() instead.

abstract postprocess()[source]
queue(pool)[source]
strategy

Base implementation of all the different configuration attributes. Call the factory function attr() instead.

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

Bases: ABC

get_node_name()
name: str

Base implementation of all the different configuration attributes. Call the factory function attr() instead.

abstract postprocess()[source]
queue(pool)[source]
strategy

Base implementation of all the different configuration attributes. Call the factory function attr() instead.

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

Bases: AfterConnectivityHook

postprocess()[source]
class bsb.postprocessing.Relay(*args, _parent=None, _key=None, **kwargs)[source]

Bases: AfterConnectivityHook

Replaces connections on a cell with the relayed connections to the connection targets of that cell. Not implemented yet.

cell_types
get_node_name()
postprocess()[source]
class bsb.postprocessing.SpoofDetails(*args, _parent=None, _key=None, **kwargs)[source]

Bases: AfterConnectivityHook

Create fake morphological intersections between already connected non-detailed connection types.

casts = {'postsynaptic': <class 'str'>, 'presynaptic': <class 'str'>}
postprocess()[source]
spoof_connections(connection_type, connectivity_matrix)[source]

bsb.reporting module

bsb.reporting.report(*message, level=2, ongoing=False, nodes=None, all_nodes=False)[source]

Send a message to the appropriate output channel.

Parameters:
  • message (str) – Text message to send.

  • level (int) – Verbosity level of the message.

  • ongoing (bool) – The message is part of an ongoing progress report.

bsb.reporting.warn(message, category=None, stacklevel=2, log_exc=None)[source]

Send a warning.

Parameters:
  • message (str) – Warning message

  • category – The class of the warning.

bsb.trees module

Module for binary space partitioning, to facilitate optimal runtime complexity for n-point problems.

class bsb.trees.BoxTree(boxes)[source]

Tree for fast lookup of repeat queries of axis aligned rhomboids.

class bsb.trees.BoxTreeInterface[source]

Tree for fast lookup of queries of axis aligned rhomboids.

abstract query(boxes, unique=False)[source]

Should return a generator that yields lists of intersecting IDs per query box if unique=False. If unique=True, yield a flat list of unique intersecting box IDs for all queried boxes.

class bsb.trees._BoxRTree(boxes)[source]

Tree for fast lookup of queries of axis aligned rhomboids using the Rtree package.

bsb.voxels module

class bsb.voxels.VoxelData(data, keys=None)[source]

Bases: ndarray

Chunk identifier, consisting of chunk coordinates and size.

copy()[source]

Return a new copy of the voxel data

property keys

Returns the keys, or column labels, associated to each data column.

class bsb.voxels.VoxelSet(voxels, size, data=None, data_keys=None, irregular=False)[source]

Bases: object

Constructs a voxel set from the given voxel indices or coordinates.

Parameters:
  • voxels (numpy.ndarray) – The spatial coordinates, or grid indices of each voxel. Nx3 matrix

  • size (numpy.ndarray) – The global or individual size of the voxels. If it has 2 dimensions it needs to have the same length as voxels, and will be used as individual voxels.

  • data

Warning

If numpy.ndarray are passed, they will not be copied in order to save memory and time. You may accidentally change a voxelset if you later change the same array.

as_boxes(cache=False)[source]
as_boxtree(cache=False)[source]
as_spatial_coords(copy=True)[source]
property bounds

The minimum and maximum coordinates of this set.

Return type:

tuple[numpy.ndarray, numpy.ndarray]

classmethod concatenate(*sets)[source]
coordinates_of(positions)[source]
copy()[source]
crop(ldc, mdc)[source]
crop_chunk(chunk)[source]
property data

The size of the voxels. When it is 0D or 1D it counts as the size for all voxels, if it is 2D it is 1 an individual size per voxel.

Return type:

Union[numpy.ndarray, None]

property data_keys
classmethod empty(size=None)[source]
property equilateral

Whether all sides of all voxels have the same lengths.

Return type:

bool

classmethod fill(positions, voxel_size, unique=True)[source]
classmethod from_morphology(morphology, estimate_n, with_data=True)[source]
get_data(index=None, /, copy=True)[source]
get_raw(copy=True)[source]
get_size(copy=True)[source]
get_size_matrix(copy=True)[source]
property has_data

Whether the set has any data associated to the voxels

Return type:

bool

index_of(positions)[source]
inside(positions)[source]
property is_empty

Whether the set contain any voxels

Return type:

bool

property of_equal_size
classmethod one(ldc, mdc, data=None)[source]
property raw
property regular

Whether the voxels are placed on a regular grid.

Return type:

bool

resize(size)[source]
property size

The size of the voxels. When it is 0D or 1D it counts as the size for all voxels, if it is 2D it is 1 an individual size per voxel.

Return type:

numpy.ndarray

snap_to_grid(voxel_size, unique=False)[source]
unique()[source]
property volume

Module contents

bsb-core is the backbone package contain the essential code of the BSB: A component framework for multiscale bottom-up neural modelling.

bsb-core needs to be installed alongside a bundle of desired bsb plugins, some of which are essential for bsb-core to function. First time users are recommended to install the bsb package instead.