SONATA files reader
Project description
libsonata
C++ / Python reader for SONATA circuit files: SONATA guide
Installation
Installing from PyPI
pip install libsonata
Installing as a Python package, directly from GitHub
pip install git+https://github.com/BlueBrain/libsonata
Building the C++ library
git clone git@github.com:BlueBrain/libsonata.git --recursive
cd libsonata
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DEXTLIB_FROM_SUBMODULES=ON ..
make -j
Usage (Python)
Nodes
NodeStorage
>>> import libsonata
>>> nodes = libsonata.NodeStorage('path/to/H5/file')
# list populations
>>> nodes.population_names
# open population
>>> population = nodes.open_population(<name>)
NodePopulation
# total number of nodes in the population
>>> population.size
# attribute names
>>> population.attribute_names
# get attribute value for single node, say 42
>>> population.get_attribute('mtype', 42)
# ...or Selection of nodes (see below) => returns NumPy array with corresponding values
>>> selection = libsonata.Selection(values=[1, 5, 9, 42]) # nodes 1, 5, 9, 42
>>> mtypes = population.get_attribute('mtype', selection)
>>> list(zip(selection.flatten(), mtypes))
[(1, u'mtype_of_1'), (5, u'mtype_of_5'), (9, u'mtype_of_9'), (42, u'mtype_of_42')]
Selection
List of element IDs (either node_id, or edge_id) where adjacent IDs are grouped for the sake of efficient HDF5 file access. For instance, {1, 2, 3, 5} sequence becomes {[1, 4), [5, 6)}.
- Selection can be instantiated from:
a sequence of scalar values (works for NumPy arrays as well)
a sequence of pairs (interpreted as ranges above, works for N x 2 NumPy arrays as well)
EdgePopulation connectivity queries (see below) return Selections as well.
>>> selection = libsonata.Selection([1, 2, 3, 5])
>>> selection.ranges
[(1, 4), (5, 6)]
>>> selection = libsonata.Selection([(1, 4), (5, 6)])
>>> selection.flatten()
[1, 2, 3, 5]
>>> selection.flat_size
4
>>> bool(selection)
True
Edges
EdgeStorage
Population handling for EdgeStorage is analogous to NodeStorage:
>>> edges = libsonata.EdgeStorage('path/to/H5/file')
# list populations
>>> edges.population_names
# open population
>>> population = edges.open_population(<name>)
EdgePopulation
# total number of edges in the population
>>> population.size
# attribute names
>>> population.attribute_names
# get attribute value for single edge, say 123
>>> population.get_attribute('delay', 123)
# ...or Selection of edges => returns NumPy array with corresponding values
>>> selection = libsonata.Selection([1, 5, 9])
>>> population.get_attribute('delay', selection) # returns delays for edges 1, 5, 9
…with additional methods for querying connectivity, where the results are selections that can be applied like above
# get source / target node ID for the 42nd edge:
>>> population.source_node(42)
>>> population.target_node(42)
# query connectivity (result is Selection object)
>>> selection_to_1 = population.afferent_edges(1) # all edges with target node_id 1
>>> population.target_nodes(selection_to_1) # since selection only contains edges
# targeting node_id 1 the result will be a
# numpy array of all 1's
>>> selection_from_2 = population.efferent_edges(2) # all edges sourced from node_id 2
>>> selection = population.connecting_edges(2, 1) # this selection is all edges from
# node_id 2 to node_id 1
# ...or their vectorized analogues
>>> selection = population.afferent_edges([1, 2, 3])
>>> selection = population.efferent_edges([1, 2, 3])
>>> selection = population.connecting_edges([1, 2, 3], [4, 5, 6])
Acknowledgements
This project/research has received funding from the European Union’s Horizon 2020 Framework Programme for Research and Innovation under the Specific Grant Agreement No. 785907 (Human Brain Project SGA2).
License
libsonata is distributed under the terms of the GNU Lesser General Public License version 3, unless noted otherwise, for example, for external dependencies. Refer to COPYING.LESSER and COPYING files for details.
Copyright (C) 2018-2020, Blue Brain Project/EPFL and contributors.
libsonata is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 as published by the Free Software Foundation.
libsonata is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with libsonata. If not, see <https://www.gnu.org/licenses/>.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file libsonata-0.1.4.dev7.tar.gz
.
File metadata
- Download URL: libsonata-0.1.4.dev7.tar.gz
- Upload date:
- Size: 647.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/38.2.4 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28577b5dead7dfd8408187046cfac9313adecd835dcd73fb83bb743aba0e56d8 |
|
MD5 | 870c5614ea84026e4c28748a55691e99 |
|
BLAKE2b-256 | ceb1602e9b8a8e774cf835409e85a5370c99f23f7ef9a8830ada2b735572c60c |