Skip to content
master
Go to file
Code

Latest commit

This pull request adds:
- A new class: CircuitNodeId 
  - A CircuitNodeIds is a combination of a population and a node id. --> ("population_name", node_id). 
- This implies to also allow the sequence of circuit node id as queries. So you have a low performance container using list of ids for the queries. We also provide a "high performance" one : CircuitNodeIds.
- A new class : CircuitNodeIds, based on pandas.MultiIndex to store and manipulate of global circuit ids. This is a high performance container for queries. I used composition and not heritage for this class because all the useful classmethods from pandas.MultiIndex return MutiIndex and not cls(). Therefore, implementing the `\_\_call\_\_` allows to use it as an index in the dataframes.

I chose this over a simple offsetting of ids because this is more compatible with the sonata main feature of "adding extra populations" to the circuit. With this design, the direct calls to ids in analysis scripts or the "on-disk stored" node ids (more common than we think ...) are not invalidated with new populations. We can also trustfully compare two sets of ids which is not the case with offsets. And since we allow people to use the sonata node ids or global ids this reduce the possible confusion and more flexibility for the API. I also don t want people to mix the sonata node ids and the global ids.
This also allows to do simple operations more transparently on ids like sorting/append/comparisons/filtering without relying on the circuit itself or mapping. 


Ex of uses for this class:
```
>>> ids_pop12 = CircuitNodeIds.from_arrays(["pop1", "pop1", "pop2"], [0, 1, 0])  # main 
[("pop1", 0), ("pop1", 1), ("pop2", 0)]
>>> ids_pop3 = CircuitNodeIds.from_dict({"pop3": [0, 1]})
[("pop3", 0), ("pop3", 1)]
ids_pop123 = ids_pop12.append(ids_pop3)
ids_pop1 = ids_pop123.filter_population("pop1")
sample_ids_pop123 = ids_pop123.sample(2)
```

- A new class: Nodes. This class aims at : 
  - Accessing the different node populations (like the current `circuit.nodes` does).
  - For compat you can iterate on the population using the dict interface : items(), values(), keys() or the wrapper populations(), names().
  - Allowing queries on the whole circuit for nodes. You can now do `circuit.nodes.ids(query)` and all the nodes from all populations matching the query will be returned. This should be handy for the spacial queries on different type of cells (like glia cells mixed with neurons) or for the combination of multiple regions merged together containing the same type of cells (like neocortex split in multiple sub region). 
  - Allowing queries on the whole circuit for nodes properties. You can now do `circuit.nodes.get(query, properties=[prop1, prop2])`. This will return a dataframe indexed by a MultiIndex (population, id). You will be able to query on this dataframe using : 
tuple ("population", id), CircuitNodeId, a list of tuples or a list of CircuitNodeId or a MultiIndex or CircuitNodeIds : 
```
ids = circuit.nodes.ids(query)  #  CircuitNodeIds corresponding to the query
data = circuit.nodes.get() # all data from all populations 
data.loc[ids]  # identical to circuit.nodes.get(query)
```
if a property is missing for a node id (this is possible due to population mixing) a NaN is attributed to the missing property value.

- The edges and morph class has been updated. You can use the CircuitNodeId/CircuitNodeIds inside the edges functions and the CircuitNodeId inside MorphHelper.
- Tests has been added accordingly.
c211d79

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
doc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.rst

banner

Build Status license codecov.io documentation status

Blue Brain SNAP

Blue Brain Simulation and Neural network Analysis Productivity layer (Blue Brain SNAP).

Blue Brain SNAP is a Python library for accessing BlueBrain circuit models represented in SONATA format.

Installation

Blue Brain SNAP can be installed using pip:

pip install bluepysnap

Usage

There are two main interface classes provided by Blue Brain SNAP:

Circuit corresponds to the static structure of a neural network, that is:

  • node positions and properties,
  • edge positions and properties, and,
  • detailed morphologies.

Simulation corresponds to the dynamic data for a neural network simulation, including:

  • spike reports,
  • soma reports, and,
  • compartment reports.

Most of Blue Brain SNAP methods return pandas Series or DataFrames, indexed in a way to facilitate combining data from different sources (that is, by node or edge IDs).

Among other dependencies, Blue Brain SNAP relies on Blue Brain Project provided libraries:

  • libsonata, for accessing SONATA files
  • NeuroM, for accessing detailed morphologies

Tools

Blue Brain SNAP also provides a SONATA circuit validator for verifying circuits.

The validation includes:

  • integrity of the circuit config file.
  • existence of the different node/edges files and components directories.
  • presence of the "sonata required" field for node/edges files.
  • the correctness of the edge to node population/ids bindings.
  • existence of the morphology files for the nodes.

This functionality is provided by either the cli function:

bluepysnap validate my/circuit/path/circuit_config.json

Or a python free function:

from bluepysnap.circuit_validation import validate
errors = validate("my/circuit/path/circuit_config.json")

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).

The Blue Brain Project would like to thank Dr Eilif Muller, the author of the precursor to Blue Brain SNAP, for his invaluable insights and contributions

License

Blue Brain SNAP is licensed under the terms of the GNU Lesser General Public License version 3, unless noted otherwise, for example, external dependencies. Refer to COPYING.LESSER and COPYING for details.

Copyright (C) 2019-2020, Blue Brain Project/EPFL and contributors.

This program 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.

This program 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 this program. If not, see <https://www.gnu.org/licenses/>.

You can’t perform that action at this time.