SONATA文件阅读器
项目描述
libsonata
C++ / Python阅读器,用于SONATA电路文件:SONATA指南
安装
从PyPI安装
pip install libsonata
直接从GitHub安装Python包
pip install git+https://github.com/BlueBrain/libsonata
构建C++库
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
由于libsonata使用backports for std::optional和std::variant,这些在可用时会转换为其实际STL实现,因此建议使用与链接到libsonata的项目相同的C++标准编译libsonata。这可以通过向上面的cmake命令传递-DCMAKE_CXX_STANDARD={14,17}来实现。
使用(Python)
节点
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')]
选择
元素ID列表(可以是node_id或edge_id),相邻ID被分组以提高HDF5文件访问效率。例如,{1, 2, 3, 5}序列变为{[1, 4), [5, 6)}
- 选择可以从以下实例化
标量值序列(也适用于NumPy数组)
对序列(解释为上述范围,也适用于N x 2 NumPy数组)
EdgePopulation 连接查询(见下文)也返回 选择。
>>> 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
节点集合
libsonata 可以与节点集合概念协同工作,如以下所述: SONATA指南:节点集合文件 这允许为细胞组定义名称,并提供查询它们的方法。libsonata 还允许使用扩展表达式,例如正则表达式和浮点数测试,如以下所述: SONATA扩展:节点集合
# load a node set JSON file
>>> node_sets = libsonata.NodeSets.from_file('node_sets.json')
# list node sets
>>> node_sets.names
{'L6_UPC', 'Layer1', 'Layer2', 'Layer3', ....}
# get the selection of nodes that match in population
>>> selection = node_sets.materialize('Layer1', population)
# node sets can also be loaded from a JSON string
>>> node_sets_manual = libsonata.NodeSets(json.dumps({"SLM_PPA_and_SP_PC": {"mtype": ["SLM_PPA", "SP_PC"]}}))
>>> node_sets_manual.names
{'SLM_PPA_and_SP_PC'}
边
边存储
EdgeStorage 的节点处理与 NodeStorage 类似
>>> edges = libsonata.EdgeStorage('path/to/H5/file')
# list populations
>>> edges.population_names
# open population
>>> population = edges.open_population(<name>)
边人口
# 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
…提供额外的查询连接的方法,结果为可以像上面一样应用的选择
# 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])
报告
尖峰读取器
>>> import libsonata
>>> spikes = libsonata.SpikeReader('path/to/H5/file')
# list populations
>>> spikes.get_population_names()
# open population
>>> population = spikes['<name>']
尖峰人口
# get all spikes [(node_id, timestep)]
>>> population.get()
[(5, 0.1), (2, 0.2), (3, 0.3), (2, 0.7), (3, 1.3)]
# get all spikes betwen tstart and tstop
>>> population.get(tstart=0.2, tstop=1.0)
[(2, 0.2), (3, 0.3), (2, 0.7)]
# get spikes attribute sorting (by_time, by_id, none)
>>> population.sorting
'by_time'
Pandas can be used to create a dataframe and get a better representation of the data
>>> import pandas
data = population.get()
df = pandas.DataFrame(data=data, columns=['ids', 'times']).set_index('times')
print(df)
ids
times
0.1 5
0.2 2
0.3 3
0.7 2
1.3 3
细胞体报告读取器
>>> somas = libsonata.SomaReportReader('path/to/H5/file')
# list populations
>>> somas.get_population_names()
# open population
>>> population_somas = somas['<name>']
细胞体报告人口
# get times (tstart, tstop, dt)
>>> population_somas.times
(0.0, 1.0, 0.1)
# get unit attributes
>>> population_somas.time_units
'ms'
>>> population_somas.data_units
'mV'
# node_ids sorted?
>>> population_somas.sorted
True
# get a list of all node ids in the selected population
>>> population_somas.get_node_ids()
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
# get the DataFrame of the node_id values for the timesteps between tstart and tstop
>>> data_frame = population_somas.get(node_ids=[13, 14], tstart=0.8, tstop=1.0)
# get the data values
>>> data_frame.data
[[13.8, 14.8], [13.9, 14.9]]
# get the list of timesteps
>>> data_frame.times
[0.8, 0.9]
# get the list of node ids
>>> data_frame.ids
[13, 14]
再次使用pandas,可以创建一个使用数据、id和时间的列表的dataframe
>>> import pandas
df = pandas.DataFrame(data_frame.data, columns=data_frame.ids, index=data_frame.times)
print(df)
13 14
0.8 13.8 14.8
0.9 13.9 14.9
元素报告读取器
>>> elements = libsonata.ElementReportReader('path/to/H5/file')
# list populations
>>> elements.get_population_names()
# open population
>>> population_elements = elements['<name>']
元素报告人口
# get times (tstart, tstop, dt)
>>> population_elements.times
(0.0, 4.0, 0.2)
>>> population_elements.get_node_ids()
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
# get the DataFrame of the node_id values for the timesteps between tstart and tstop
>>> data_frame = population_elements.get(node_ids=[13, 14], tstart=0.8, tstop=1.0)
# get the data values (list of list of floats with data[time_index][element_index])
>>> data_frame.data
[[46.0, 46.1, 46.2, 46.3, 46.4, 46.5, 46.6, 46.7, 46.8, 46.9], [56.0, 56.1, 56.2, 56.3, 56.4, 56.5, 56.6, 56.7, 56.8, 56.9]]
# get the list of timesteps
>>> data_frame.times
[0.8, 1.0]
# get the list of (node id, element_id)
>>> data_frame.ids
[(13, 30), (13, 30), (13, 31), (13, 31), (13, 32), (14, 32), (14, 33), (14, 33), (14, 34), (14, 34)]
与尖峰和细胞体报告一样,可以使用pandas更好地表示数据
>>> import pandas
df = pandas.DataFrame(data_frame.data, columns=pandas.MultiIndex.from_tuples(data_frame.ids), index=data_frame.times)
print(df)
13 14
30 30 31 31 32 32 33 33 34 34
0.8 46.0 46.1 46.2 46.3 46.4 46.5 46.6 46.7 46.8 46.9
1.0 56.0 56.1 56.2 56.3 56.4 56.5 56.6 56.7 56.8 56.9
对于大数据集,使用numpy数组可以大大提高性能
>>> import numpy
np_data = numpy.asarray(data_frame.data)
np_ids = numpy.asarray(data_frame.ids).T
np_times = numpy.asarray(data_frame.times)
df = pandas.DataFrame(np_data, columns=pandas.MultiIndex.from_arrays(np_ids), index=np_times)
致谢
本软件的开发得到了瑞士联邦理工学院洛桑联邦理工学院(EPFL)的Blue Brain Project研究中心的资金支持,该中心得到了瑞士政府ETH委员会的资助。
本研究得到了EBRAINS研究基础设施的支持,该基础设施由欧盟的Horizon 2020研究与创新框架计划资助,具体资助协议编号为945539(人类大脑项目SGA3)。该项目/研究还得到了欧盟的Horizon 2020研究与创新框架计划的资助,具体资助协议编号为785907(人类大脑项目SGA2)。
许可协议
libsonata在以下条件下分发:GNU Lesser General Public License版本3,除非另有说明,例如外部依赖项。有关详细信息,请参阅COPYING.LESSER和COPYING文件。
版权(c)2018-2022 Blue Brain Project/EPFL
libsonata是自由软件:您可以按照自由软件基金会发布的GNU Lesser General Public License版本3的条款重新分发和/或修改它。
libsonata以希望它将是有用的方式分发,但没有任何保证;甚至没有关于其商售性或适用于特定目的的隐含保证。有关详细信息,请参阅GNU Lesser General Public License。
您应该已经收到了GNU Lesser General Public License的副本,与libsonata一起。如果没有,请参阅 <https://gnu.ac.cn/licenses/>。
项目详情
libsonata-0.1.28.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9421366a2b2cd5b3c0d0f62a5aaea852949e60bac3032a3161bf0bbb107dada9 |
|
MD5 | 0e6a030e7874fdf53e45fd7aabf1315f |
|
BLAKE2b-256 | fd0554b698009b0f0220f2dd34bb781134d2c27a329437900b5202a736daa26e |
libsonata-0.1.28-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 47a5fb61807dcc696ad653836a6d7cc71ae70282e5dc760d3b6d1644cfaf5dbb |
|
MD5 | 8f9cf8edaf6e2073c4e912d045e46e5e |
|
BLAKE2b-256 | b6d9c3e66ba6fff2efe09aaef59d3699e6dc5ebd6521d185b045ee5ab021a600 |
哈希值 用于 libsonata-0.1.28-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 62192a55525420883846edc93742d85e8d6b39c90522227ec4d807e7c9239cc8 |
|
MD5 | 02492b39b62d1f55e874f5e245a4d5df |
|
BLAKE2b-256 | 99de01e157fe9f44f16a93155cdc446a63444a6a0b911e70929e567bc2fa59e4 |
哈希值 用于 libsonata-0.1.28-cp313-cp313-macosx_11_0_arm64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 7140030d3c64aa41cff256c2901c1040793c5934b91d3190f74e170f099a6186 |
|
MD5 | 596ad1a39588485b5e8f9db358997d7f |
|
BLAKE2b-256 | 709cafa64ccb1c269550c52e493e95484ebe96211058b3aee49ff4c8b633da1e |
哈希值 用于 libsonata-0.1.28-cp313-cp313-macosx_10_13_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 24c9f6ebc5982b3002cb8cec05a43d60b516c80027c54ee0df68f5050420f21f |
|
MD5 | aacf6a8b68b827189c59419bf9b41a3b |
|
BLAKE2b-256 | 34bb72512c785874f4c9469c2d9d839b5418d0a5b20c360ef7e06a465105cc21 |
哈希值 用于 libsonata-0.1.28-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a97c0c52d595505f1c2ea95fac9cb81b92fc96a175a4c035039b816295141023 |
|
MD5 | 50acc3af27aafaab19dc8e3d0f66bb4f |
|
BLAKE2b-256 | 01f2b9d2b8ae96eea0a89b2740e9e6d77f59a7d9c2fe19a87738e128ea0c6616 |
哈希值 用于 libsonata-0.1.28-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 26c0d260f2ea8fd85b4ed6ef89cb8d67e28e96470c7b882afbb539fbfc665803 |
|
MD5 | 996b6050b2f182149e97af84b52f08f6 |
|
BLAKE2b-256 | bb8ba003c1947f7165d06f699e01b0c4f83912f65bb40da34ba87b0993f55433 |
哈希值 用于 libsonata-0.1.28-cp312-cp312-macosx_11_0_arm64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 99f55c983c746563d6bd0f092f458092f3174b3fd5153ee6eb92a89e27078599 |
|
MD5 | 93dc3a9d7ddda5da27f601ef3d91e0ec |
|
BLAKE2b-256 | 317af22802e612f4a61115f16238e98498291f7bb5ed23701668bb4d1795ebcb |
哈希值 用于 libsonata-0.1.28-cp312-cp312-macosx_10_9_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a6accaddefe9d7517ce3c27ba7b8fb65f94197998c4d782a868c924fe6d3b373 |
|
MD5 | df83e68c33d8eb3161da05a7405d2e7f |
|
BLAKE2b-256 | 98ec8fb18101243fad4a62cfcb4e3e9d61233f6448a0001ac2e3893889ff5cc1 |
哈希值 用于 libsonata-0.1.28-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 0ebebe67174bec4b297c4222bf18127c72420f73b23561cd170d7b0bae12fea3 |
|
MD5 | 2d2285fe3c9b0104acf2cc5a45d6826a |
|
BLAKE2b-256 | 672c3837968a5206a0bdc298578467732e0e07f3c8daeffdcbb9784df90e107c |
哈希值 用于 libsonata-0.1.28-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | b936b65785da2e4b09d911cdb782aa79778ce679215aa32708a1e5f4bd0ed65c |
|
MD5 | 76cc17ee23a382760054207a715ee81a |
|
BLAKE2b-256 | e819d7803958a014ad38c44635349a2f6e9786dbd37ac906d7852f08d0b5191d |
哈希值 用于 libsonata-0.1.28-cp311-cp311-macosx_11_0_arm64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | acb96e51ee7454bbbfc404c02fdc84a6251268dfabc0dc3ad226bd87a104b584 |
|
MD5 | fb3e084f62f9bd57ea23ad909e5c37be |
|
BLAKE2b-256 | b5de625002493a0348919200f017aca7a1750a7cacc992b767e98a16e5779e1a |
哈希值 用于 libsonata-0.1.28-cp311-cp311-macosx_10_9_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 950c7883fa68e2abe7f29735634fa1e0a8cada00e67d3fe0404ca436fe9fe1a0 |
|
MD5 | 5175d4f2ffe58ec79ce4fa04f0fc7b83 |
|
BLAKE2b-256 | 211ce49722fc4f7f7e163771c2e95e2aa1228b95f53c08a0be6f1885db522753 |
哈希值 用于 libsonata-0.1.28-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9b7288cb4323e457b56b1a1e9e64a2f7146bdf84d973ec0a3cbf6d630115d1ff |
|
MD5 | 6d0b5518b26114b822cb4009aef0a76a |
|
BLAKE2b-256 | 4842bb480d2fdc0f78b91e3ca069031fe0c9fa16c9712b2e9b06d500614bfd37 |
哈希值 用于 libsonata-0.1.28-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | f9606cb526894ff1a09d4ec7c6044e46ad50422d5b1e51c2e3d554ab91e593ef |
|
MD5 | de155974fa4966660f67d61a3155ee08 |
|
BLAKE2b-256 | 174dd6ab3918259b06a0015076e7b6a9d2a1519ffff0f4db07a79eba1a56350d |
哈希值 用于 libsonata-0.1.28-cp310-cp310-macosx_11_0_arm64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 3e72bb4aad1ac18095edaec22441702c1c65064b4acf9bd71552841856fcbed7 |
|
MD5 | 13b5059d8f70eed61db37f714de701af |
|
BLAKE2b-256 | 584daa351d23402b30aabda095b1b5efb5070622e5c986f4a2a0c8b6cfea1386 |
哈希值 用于 libsonata-0.1.28-cp310-cp310-macosx_10_9_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 85436421ed288c4e64ed9eb8fb446455601893529863f0a9d093afd7e01aed4b |
|
MD5 | 565c023672a4684cf103a84deed61bcf |
|
BLAKE2b-256 | 4f79fb5eb28f6521e47c271562f8e99d2e74dc6630d70f3d08cdbd4e978ff0e4 |
哈希值 用于 libsonata-0.1.28-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e19e4d2e71460b5891e9215feed8338978eedcb84d89f73845ebd6c0bd747f38 |
|
MD5 | 72fcd4698f0784e94ee65702d5fa8f01 |
|
BLAKE2b-256 | 449da4b3df5a8a3d6a59a59774460fd9d54570f7d0563f7144b6b784dbdd424b |
哈希值 用于 libsonata-0.1.28-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e4880b0ca0d5c37d5a31f1cf5c5918d764c4f62db596fe8b29c03a9b24d00967 |
|
MD5 | a75409ff33c5e2e26c0b0a0fde43c837 |
|
BLAKE2b-256 | 1577adbfb773d0c668b03b05c850972afcad4ebec1b084b073b6fb5c78f70465 |
哈希值 用于 libsonata-0.1.28-cp39-cp39-macosx_11_0_arm64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | dd3fa664192333c697dbcb9552c523aff1b01b4a66143c23b66840d0b196d500 |
|
MD5 | ef013b3bc76cf2b9046d07678c48e9a2 |
|
BLAKE2b-256 | fd8d7ccf6b4c064979f6d9bb819cf6fe6eee2852703817e47d1cb1962a95e1e9 |
哈希值 用于 libsonata-0.1.28-cp39-cp39-macosx_10_9_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 2d186269c17874db4ae08c1794ff2b173163c6300372adb446d0e64a6faa3672 |
|
MD5 | 5b53db0661ab1db5ffa71da1ab74962f |
|
BLAKE2b-256 | 55c348b1c2afe7f92193241da354ccb4c126a64586d1c19f0971b6696c6867df |
哈希值 用于 libsonata-0.1.28-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9fd382bd421650182be434855b433daaf48da6df40ff40bc07f6e8ea3eabf3b8 |
|
MD5 | c04d16bf26039f74e69291e909681387 |
|
BLAKE2b-256 | fc46b130192b3205a52c7473740fe7172dc489fda0f9caa195837d80f8504b8a |
哈希值 用于 libsonata-0.1.28-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | fee272fe2d140be8a20434b912d843503d9583056427f2a5f6a8567d88f358ab |
|
MD5 | 8bf76d2bf5f4749bd23a06f8de34c88d |
|
BLAKE2b-256 | c7dc980b3b6ab22d29fc923da135e6c14eb1a53d2db94b6c784cef0011bd91a7 |
哈希值 用于 libsonata-0.1.28-cp38-cp38-macosx_11_0_arm64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | b868b39026feb65f2886c2848486ec35a4aa96c852af004750d0fc51800064e9 |
|
MD5 | aa47048a141c396b78d4a64cf96d7b7e |
|
BLAKE2b-256 | 7e8e080bd163f92117c2ba88a762eff45f6047fd30e067aaa2dce836f8fe61f3 |
哈希值 用于 libsonata-0.1.28-cp38-cp38-macosx_10_9_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | ad8348a2891b8364ff55e6d49fb1d17fb4198dc12e29541ece71ba69dadac008 |
|
MD5 | b689f2eda4842bdf5ad5027127118559 |
|
BLAKE2b-256 | d17896ee50fab371654dfbe540cbea2d9624b3cc950253bf4d64441b44b88660 |