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.

angle#

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

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

Cell placement: Create a lattice of parallel arrays/lines in the layer’s surface.

queue(pool, 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.

spacing_x#

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

bsb.placement.distributor module#

class bsb.placement.distributor.DistributionContext(indicator: bsb.placement.indicator.PlacementIndications, partitions: List[bsb.topology.partition.Partition])[source]#
indicator: PlacementIndications#
partitions: List[Partition]#
class bsb.placement.distributor.Distributor(*args, _parent=None, _key=None, **kwargs)[source]#
abstract 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#

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

properties#
rotations#

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]#
abstract 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:

Union[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:

Union[MorphologySet, Tuple[ MorphologySet, RotationSet]]

abstract 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!

abstract 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:

Union[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.PlacementIndications(*args, _parent=None, _key=None, **kwargs)[source]#
count#

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

count_ratio#

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

density#

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

density_key#

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

density_ratio#

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

geometry#
get_node_name()#
morphologies#
planar_density#

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

radius#

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

relative_to#
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.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]#
use_morphologies()[source]#

bsb.placement.particle module#

class bsb.placement.particle.AdaptiveNeighbourhood(track_displaced=False, scaffold=None, strat=None)[source]#
find_neighbourhood(particle)[source]#
class bsb.placement.particle.LargeParticleSystem[source]#
fill()[source]#
placing()[source]#
solve_collisions()[source]#
class bsb.placement.particle.Neighbourhood(epicenter, neighbours, neighbour_radius, partners, partner_radius)[source]#
colliding()[source]#
get_overlap()[source]#
class bsb.placement.particle.Particle(radius, position)[source]#
displace()[source]#
displace_by(other)[source]#
static get_displacement_force(radius, distance)[source]#
reset_displacement()[source]#
class bsb.placement.particle.ParticlePlacement(*args, _parent=None, _key=None, **kwargs)[source]#

Place cells in random positions, then have them repel each other until there is no overlap.

bounded#

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

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:
prune#

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

restrict#

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

class bsb.placement.particle.ParticleSystem(track_displaced=False, scaffold=None, strat=None)[source]#
add_particle(radius, position, type=None)[source]#
add_particles(radius, positions, type=None)[source]#
deintersect(nearest_neighbours=None)[source]#
fill(voxels, particles, check_pack=True)[source]#
find_colliding_particles(freeze=False)[source]#
find_neighbourhood(particle)[source]#
freeze()[source]#
get_packing_factor(particles=None, volume=None)[source]#
property positions#
prune(at_risk_particles=None, voxels=None)[source]#

Remove particles that have been moved outside of the bounds of the voxels.

Parameters:
  • at_risk_particles (numpy.ndarray) – Subset of particles that might’ve been moved and might need to be moved, if omitted check all particles.

  • voxels – A subset of the voxels that the particles have to be in bounds of, if omitted all voxels are used.

remove_particles(particles_id)[source]#
resolve_neighbourhood(neighbourhood)[source]#
solve_collisions()[source]#
class bsb.placement.particle.ParticleVoxel(origin, dimensions)[source]#
class bsb.placement.particle.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:
class bsb.placement.particle.SmallestNeighbourhood(track_displaced=False, scaffold=None, strat=None)[source]#
find_neighbourhood(particle)[source]#
bsb.placement.particle.distance(a, b)[source]#
bsb.placement.particle.get_particle_trace(particle)[source]#
bsb.placement.particle.get_particles_trace(particles, dimensions=3, axes={'x': 0, 'y': 1, 'z': 2}, **kwargs)[source]#
bsb.placement.particle.plot_detailed_system(system)[source]#
bsb.placement.particle.plot_particle_system(system)[source]#
bsb.placement.particle.sphere_volume(radius)[source]#

bsb.placement.satellite module#

class bsb.placement.satellite.Satellite(*args, _parent=None, _key=None, **kwargs)[source]#

Implementation of the placement of cells in layers as satellites of existing cells

Places cells as a satellite cell to each associated cell at a random distance depending on the radius of both cells.

boot()[source]#
get_after()[source]#
get_node_name()#
indicator_class#

alias of SatelliteIndicator

partitions#
per_planet#

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

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_type(chunk, indicator)[source]#
planet_types#
class bsb.placement.satellite.SatelliteIndicator(strat, cell_type)[source]#
guess(chunk=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.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]

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.

entities = True#
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#

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.

after#
cell_types#
create_after()[source]#
distribute#

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

get_after()[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()#
classmethod get_ordered(objects)[source]#
guess_cell_count()[source]#
has_after()[source]#
indicator_class#

alias of PlacementIndicator

is_entities()[source]#
name#

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

overrides#
partitions#
abstract 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.

strategy#

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

Module contents#