Placement sets

PlacementSets are constructed from the bsb.storage.Storage and can be used to retrieve the positions, morphologies, rotations and additional datasets.

Note

Loading datasets from storage is an expensive operation. Store a local reference to the data you retrieve instead of making multiple calls.

Retrieving a PlacementSet

Multiple get_placement_set methods exist in several places as shortcuts to create the same bsb.storage.interfaces.PlacementSet. If the placement set does not exist, a DatesetNotFoundError is thrown.

from bsb import from_storage

scaffold = from_storage("my_network.hdf5")
ps = scaffold.get_placement_set("my_cell")
# Alternatives to obtain the same placement set:
ps = scaffold.get_placement_set(network.cell_types.my_cell)
ps = scaffold.cell_types.my_cell.get_placement_set()

print(ps.tag)  # Name of the placement set

Identifiers

Cells have no global identifiers, instead you use the indices of their data, i.e. the n-th position belongs to cell n, and so will the n-th rotation. To easily retrieve the cells’ IDs make use of the method bsb.storage.interfaces.PlacementSet.load_ids().

list_of_ids = ps.load_ids()

Positions

The positions of the cells can be retrieved using the bsb.storage.interfaces.PlacementSet.load_positions() method.

for n, position in enumerate(ps.load_positions()):
  print(f"Cell {n}, position: {pos}")

Morphologies

The morphology of the cells can be retrieved using the bsb.storage.interfaces.PlacementSet.load_morphologies() method.

for n, (pos, morpho) in enumerate(zip(ps.load_positions(), ps.load_morphologies())):
  print(f"Cell {n}, position: {pos}, morpho: {morpho}")

Warning

Loading morphologies is especially expensive.
There are better ways to iterate over it using either soft caching or hard caching.

Rotations

The positions of the cells can be retrieved using the bsb.storage.interfaces.PlacementSet.load_rotations() method.

for n, rotation in enumerate(ps.load_rotations()):
  print(f"Cell {n}, rotation: ", rotation)

Labeling

You can label cells and/or their attached morphologies using the bsb.storage.interfaces.PlacementSet.load_rotations()

Additional datasets

Not implemented yet.