Accessing network data#

Configuration#

The configuration of a network is available as network.configuration, the root nodes such as cell_types, placement and others are available on network as well.

from bsb import from_storage

network = from_storage("network.hdf5")
print("My network was configured with", network.configuration)
print("My network has", len(network.configuration.cell_types), "cell types")
(
    # But to avoid some needless typing and repetition,
    network.cell_types is network.configuration.cell_types
    and network.placement is network.configuration.placement
    and "so on"
)

Placement data#

The placement data is available through the storage.interfaces.PlacementSet interface. This example shows how to access the cell positions of each population:

import numpy as np

from bsb import from_storage

network = from_storage("network.hdf5")
for cell_type in network.cell_types:
    ps = cell_type.get_placement_set()
    pos = ps.load_positions()
    print(len(pos), cell_type.name, "placed")
    # The positions are an (Nx3) numpy array
    print("The median cell is located at", np.median(pos, axis=0))

Todo

Document best practices for the morphology data

Todo

Document best practices for the connectivity data