bsb.placement package

Submodules

bsb.placement.arrays module

class bsb.placement.arrays.ParallelArrayPlacement(*args, _parent=None, _key=None, **kwargs)[source]

Implementation of the placement of cells in parallel arrays Cells are placed in rows on the plane defined by 2 selected axes.

angle: float

Angle between the second axis and the axis of the rows of cells.

boot()[source]
get_node_name()
place(chunk, indicators)[source]

Cell placement: Create a lattice of parallel arrays/lines in the (x, y) surface.

queue(pool: JobPool, chunk_size)

Specifies how to queue this placement strategy into a job pool.

Can be overridden, the default implementation asks each partition to chunk itself and creates 1 placement job per chunk.

Parameters:

pool (JobPool)

spacing_x: float

Space in between two cells along the main axis.

bsb.placement.distributor module

class bsb.placement.distributor.DistributionContext(indicator: bsb.placement.indicator.PlacementIndications, partitions: list[bsb.topology.partition.Partition])[source]
Parameters:
indicator: PlacementIndications
partitions: list[Partition]
class bsb.placement.distributor.Distributor(*args, _parent=None, _key=None, **kwargs)[source]
abstractmethod distribute(positions, context)[source]

Is called to distribute cell properties.

Parameters:

partitions – The partitions the cells were placed in.

Returns:

An array with the property data

Return type:

numpy.ndarray

get_node_name()
strategy

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

class bsb.placement.distributor.DistributorsNode(*args, _parent=None, _key=None, **kwargs)[source]
get_node_name()
morphologies: MorphologyDistributor

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

properties: dict[Distributor]
rotations: RotationDistributor

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

class bsb.placement.distributor.ExplicitNoRotations(*args, _parent=None, _key=None, **kwargs)[source]
distribute(positions, context)[source]

Is called to distribute cell properties.

Parameters:

partitions – The partitions the cells were placed in.

Returns:

An array with the property data

Return type:

numpy.ndarray

get_node_name()
class bsb.placement.distributor.Implicit[source]
class bsb.placement.distributor.ImplicitNoRotations(*args, _parent=None, _key=None, **kwargs)[source]
distribute(positions, context)

Is called to distribute cell properties.

Parameters:

partitions – The partitions the cells were placed in.

Returns:

An array with the property data

Return type:

numpy.ndarray

get_node_name()
class bsb.placement.distributor.MorphologyDistributor(*args, _parent=None, _key=None, **kwargs)[source]
abstractmethod distribute(positions, morphologies, context)[source]

Is called to distribute cell morphologies and optionally rotations.

Parameters:
  • positions (numpy.ndarray) – Placed positions under consideration

  • morphologies – The template morphology loaders. You can decide to use them and/or generate new ones in the MorphologySet that you produce. If you produce any new morphologies, don’t forget to encapsulate them in a StoredMorphology loader, or better yet, use the MorphologyGenerator.

  • context (DistributionContext) – The placement indicator and partitions.

Returns:

A MorphologySet with assigned morphologies, and optionally a RotationSet

Return type:

MorphologySet | tuple[ MorphologySet, RotationSet]

get_node_name()
may_be_empty

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.placement.distributor.MorphologyGenerator(*args, _parent=None, _key=None, **kwargs)[source]

Special case of the morphology distributor that provides extra convenience when generating new morphologies.

distribute(positions, morphologies, context)[source]

Is called to distribute cell morphologies and optionally rotations.

Parameters:
  • positions (numpy.ndarray) – Placed positions under consideration

  • morphologies – The template morphology loaders. You can decide to use them and/or generate new ones in the MorphologySet that you produce. If you produce any new morphologies, don’t forget to encapsulate them in a StoredMorphology loader, or better yet, use the MorphologyGenerator.

  • context (DistributionContext) – The placement indicator and partitions.

Returns:

A MorphologySet with assigned morphologies, and optionally a RotationSet

Return type:

MorphologySet | tuple[ MorphologySet, RotationSet]

abstractmethod generate(positions, morphologies, context)[source]
get_node_name()
may_be_empty

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

class bsb.placement.distributor.RandomMorphologies(*args, _parent=None, _key=None, **kwargs)[source]

Distributes selected morphologies randomly without rotating them.

{ "placement": { "place_XY": {
  "distribute": {
      "morphologies": {"strategy": "random"}
  }
}}}
distribute(positions, morphologies, context)[source]

Uses the morphology selection indicators to select morphologies and returns a MorphologySet of randomly assigned morphologies.

get_node_name()
may_be_empty
class bsb.placement.distributor.RandomRotations(*args, _parent=None, _key=None, **kwargs)[source]
distribute(positions, context)[source]

Is called to distribute cell properties.

Parameters:

partitions – The partitions the cells were placed in.

Returns:

An array with the property data

Return type:

numpy.ndarray

get_node_name()
class bsb.placement.distributor.RotationDistributor(*args, _parent=None, _key=None, **kwargs)[source]

Rotates everything by nothing!

abstractmethod distribute(positions, context)[source]

Is called to distribute cell properties.

Parameters:

partitions – The partitions the cells were placed in.

Returns:

An array with the property data

Return type:

numpy.ndarray

get_node_name()
strategy

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

class bsb.placement.distributor.RoundRobinMorphologies(*args, _parent=None, _key=None, **kwargs)[source]

Distributes selected morphologies round robin, values are looped and assigned one by one in order.

{ "placement": { "place_XY": {
  "distribute": {
      "morphologies": {"strategy": "roundrobin"}
  }
}}}
distribute(positions, morphologies, context)[source]

Is called to distribute cell morphologies and optionally rotations.

Parameters:
  • positions (numpy.ndarray) – Placed positions under consideration

  • morphologies – The template morphology loaders. You can decide to use them and/or generate new ones in the MorphologySet that you produce. If you produce any new morphologies, don’t forget to encapsulate them in a StoredMorphology loader, or better yet, use the MorphologyGenerator.

  • context (DistributionContext) – The placement indicator and partitions.

Returns:

A MorphologySet with assigned morphologies, and optionally a RotationSet

Return type:

MorphologySet | tuple[ MorphologySet, RotationSet]

get_node_name()
may_be_empty
class bsb.placement.distributor.VolumetricRotations(*args, _parent=None, _key=None, **kwargs)[source]
default_vector

Default orientation vector of each position.

distribute(positions, context)[source]

Rotates according to a volumetric orientation field of specific resolution. For each position, find the equivalent voxel in the volumetric orientation field and apply the rotation from the default_vector to the corresponding orientation vector. Positions outside the orientation field will not be rotated.

Parameters:
  • positions – Placed positions under consideration. Its shape is (N, 3) where N is the number of positions.

  • context (DistributionContext) – The placement indicator and partitions.

Returns:

A RotationSet object containing the 3D Euler angles in degrees for the rotation of each position.

Return type:

RotationSet

get_node_name()
orientation_path

Path to the nrrd file containing the volumetric orientation field.

It provides a rotation for each voxel considered. Its shape should be (3, L, W, D) where L, W and D are the sizes of the field.

orientation_resolution

Voxel size resolution of the orientation field.

space_origin

Origin point for the orientation field.

bsb.placement.indicator module

class bsb.placement.indicator.PlacementIndicator(strat, cell_type)[source]
assert_indication(attr)[source]
property cell_type
get_radius()[source]
guess(chunk=None, voxels=None)[source]

Estimate the count of cell to place based on the cell_type’s PlacementIndications. Float estimates are converted to int using an acceptance- rejection method.

Parameters:
  • chunk (bsb.storage._chunks.Chunk) – if provided, will estimate the number of cell within the Chunk.

  • voxels (bsb.voxels.VoxelSet) – if provided, will estimate the number of cell within the VoxelSet. Only for cells with the indication “density_key” set or with the indication “relative_to” set and the target cell has the indication “density_key” set.

Returns:

Cell counts for each chunk or voxel.

Return type:

numpy.ndarray[int]

indication(attr)[source]
property partitions
use_morphologies()[source]

bsb.placement.random module

class bsb.placement.random.RandomPlacement(*args, _parent=None, _key=None, **kwargs)[source]

Place cells in random positions.

get_node_name()
place(chunk, indicators)[source]

Central method of each placement strategy. Given a chunk, should fill that chunk with cells by calling the scaffold’s (available as self.scaffold) place_cells() method.

Parameters:

bsb.placement.strategy module

class bsb.placement.strategy.Entities(*args, _parent=None, _key=None, **kwargs)[source]

Implementation of the placement of entities that do not have a 3D position, but that need to be connected with other cells of the network.

get_node_name()
place(chunk, indicators)[source]

Central method of each placement strategy. Given a chunk, should fill that chunk with cells by calling the scaffold’s (available as self.scaffold) place_cells() method.

Parameters:
queue(pool, chunk_size)[source]

Specifies how to queue this placement strategy into a job pool.

Can be overridden, the default implementation asks each partition to chunk itself and creates 1 placement job per chunk.

class bsb.placement.strategy.FixedPositions(*args, _parent=None, _key=None, **kwargs)[source]
get_node_name()
guess_cell_count()[source]
place(chunk, indicators)[source]

Central method of each placement strategy. Given a chunk, should fill that chunk with cells by calling the scaffold’s (available as self.scaffold) place_cells() method.

Parameters:
positions: ndarray

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

queue(pool, chunk_size)[source]

Specifies how to queue this placement strategy into a job pool.

Can be overridden, the default implementation asks each partition to chunk itself and creates 1 placement job per chunk.

class bsb.placement.strategy.PlacementStrategy(*args, _parent=None, _key=None, **kwargs)[source]

Quintessential interface of the placement module.

Each placement strategy defines an approach to placing neurons into a volume.

cell_types: list[CellType]
depends_on: list[PlacementStrategy]
distribute: DistributorsNode

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

get_deps()[source]
get_indicators()[source]

Return indicators per cell type.

Indicators collect all configuration information into objects that can produce guesses as to how many cells of a type should be placed in a volume.

get_node_name()
guess_cell_count()[source]
indicator_class

alias of PlacementIndicator

is_entities()[source]
name: str

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

overrides: cfgdict[PlacementIndications]
partitions: list[Partition]
abstractmethod place(chunk, indicators)[source]

Central method of each placement strategy. Given a chunk, should fill that chunk with cells by calling the scaffold’s (available as self.scaffold) place_cells() method.

Parameters:
place_cells(indicator, positions, chunk, additional=None)[source]
queue(pool, chunk_size)[source]

Specifies how to queue this placement strategy into a job pool.

Can be overridden, the default implementation asks each partition to chunk itself and creates 1 placement job per chunk.

scaffold: Scaffold
strategy

Base implementation of all the different configuration attributes.

Call the factory function attr() instead.

Module contents