I wrote a network configuration file, used bsb compile <that-file>.json
and it generated an HDF5
output file, but it's hard to extract the cell positions from it. How can I read the cell positions from such a file?
How can I read the cell positions of a network I generated with `bsb compile`?
21 Views Asked by Robin De Schepper At
1
The output HDF5 file is a network storage file, in a library-specific format. It's not recommended to try to write your own code to read it, because the format may change arbitrarily. The library instead offers the
from_storage
function to load networks from such storage files. You can then read the cell positions using thePlacementSet.load_positions
method, which will return an(Nx3)
(x, y, z) numpy array with the cell positions for that cell type:If you don't know which cell type you want, you can iterate over all the placement sets like this:
Note: Calling
load_positions
reads all the data from file into memory which is an expensive operation. Don't call it multiple times if you don't have to, and make sure you have enough memory. You can useset_chunk_filter
to load only parts of the data if memory is a problem.