Managing Scaffold files¶
Note
This guide is a continuation of the Getting Started guide.
In this tutorial, we assume that you have successfully reconstructed a network with BSB. In this guide, you will learn how to access the data stored in your produced network
Loading a scaffold from file¶
To retrieve the information from your network file, you need to open it with Python.
To follow this tutorial, either create a new python file "load_data.py" in your project
folder. You can load a stored network from file using the method
from_storage:
from bsb import from_storage
scaffold = from_storage("network.hdf5")
Once you have loaded the Scaffold object, you have access to its Configuration and Storage.
Tip
Remember that the storage is filled with the data produced during the reconstruction while the configuration describes the process to obtain the data (read again this section if it is not clear to you).
Accessing Scaffold data¶
Configuration¶
The Configuration of a Scaffold is available as scaffold.configuration.
Its root components such as cell_types, placement and others are
also directly available in the Scaffold object, so you can avoid some
needless typing and repetition.
config = scaffold.configuration
print(f"My network was configured with {config}")
# scaffold.cell_types corresponds to scaffold.configuration.cell_types
print(f"My network has {len(scaffold.cell_types)} cell types")
Placement data¶
The placement data is available through the PlacementSet
interface. You can access stored placement sets through their name or their cell type.
This example shows how to access the cell positions of each population:
for type_name, cell_type in scaffold.cell_types.items():
ps = cell_type.get_placement_set()
pos = ps.load_positions()
print(f"{len(pos)} {type_name} placed")
# The positions are a (Nx3) numpy array
print("The median cell is located at", np.median(pos, axis=0))
Take some time to familiarize yourself with PlacementSet methods here.
Connectivity data¶
The connectivity data is available through the
ConnectivitySet interface.
Remember that connection sets are labelled by default according to the connection strategy
used to obtain them (and the pre and postsynaptic cell types in case their are more than one).
Here we are going to retrieve one connection set using its name ("A_to_B") and print the neuron
id of each connected pair.
cs = scaffold.get_connectivity_set("A_to_B")
for src_locs, dest_locs in cs.load_connections():
print(f"Cell id: {src_locs[0]} connects to cell {dest_locs[0]}")
See more info on how to manipulate ConnectivitySet here.
What is next?¶
At this stage, you can either learn about modeling multi-compartment networks or point-neuron networks .