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`?
19 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_storagefunction to load networks from such storage files. You can then read the cell positions using thePlacementSet.load_positionsmethod, 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_positionsreads 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_filterto load only parts of the data if memory is a problem.