bluepysnap.nodes.nodes

Nodes access.

Classes

Nodes(circuit)

The top level Nodes accessor.

class bluepysnap.nodes.nodes.Nodes(circuit)

The top level Nodes accessor.

Initialize the top level Nodes accessor.

get(group=None, properties=None)

Node properties by iterating populations.

Parameters:
  • group (CircuitNodeIds/int/sequence/str/mapping/None) – Which nodes will have their properties returned depends on the type of the group argument: See ids.

  • properties (str/list) – If specified, return only the properties in the list. Otherwise return all properties.

Returns:

yields tuples of (<population_name>, pandas.DataFrame):
  • DataFrame indexed by CircuitNodeIds containing the properties from properties.

Return type:

generator

Notes

The NodePopulation.property_names function will give you all the usable properties for the properties argument.

ids(group=None, sample=None, limit=None)

Returns the CircuitNodeIds corresponding to the nodes from group.

Parameters:
  • group (CircuitNodeId/CircuitNodeIds/int/sequence/str/mapping/None) –

    Which IDs will be returned depends on the type of the group argument:

    • CircuitNodeId: return the ID in a CircuitNodeIds object if it belongs to the circuit.

    • CircuitNodeIds: return the IDs in a CircuitNodeIds object if they belong to the circuit.

    • int: if the node ID is present in all populations, returns a CircuitNodeIds object containing the corresponding node ID for all populations.

    • sequence: if all the values contained in the sequence are present in all populations, returns a CircuitNodeIds object containing the corresponding node IDs for all populations.

    • str: use a node set name as input. Returns a CircuitNodeIds object containing nodes selected by the node set.

    • mapping: Returns a CircuitNodeIds object containing nodes matching a properties filter.

    • None: return all node IDs of the circuit in a CircuitNodeIds object.

  • sample (int) – If specified, randomly choose sample number of IDs from the match result. If the size of the sample is greater than the size of all the NodePopulations then all ids are taken and shuffled.

  • limit (int) – If specified, return the first limit number of IDs from the match result. If limit is greater than the size of all the populations, all node IDs are returned.

Returns:

returns a CircuitNodeIds containing all the node IDs and the corresponding populations. All the explicitly requested IDs must be present inside the circuit.

Return type:

CircuitNodeIds

Raises:
  • BluepySnapError – when a population from a CircuitNodeIds is not present in the circuit.

  • BluepySnapError – when an id query via a int, sequence, or CircuitNodeIds is not present in the circuit.

Examples

The available group parameter values (example with 2 node populations pop1 and pop2):

>>> nodes = circuit.nodes
>>> nodes.ids(group=None)  #  returns all CircuitNodeIds from the circuit
>>> node_ids = CircuitNodeIds.from_arrays(["pop1", "pop2"], [1, 3])
>>> nodes.ids(group=node_ids)  #  returns ID 1 from pop1 and ID 3 from pop2
>>> nodes.ids(group=0)  #  returns CircuitNodeIds 0 from pop1 and pop2
>>> nodes.ids(group=[0, 1])  #  returns CircuitNodeIds 0 and 1 from pop1 and pop2
>>> nodes.ids(group="node_set_name")  # returns CircuitNodeIds matching node set
>>> nodes.ids(group={Node.LAYER: 2})  # returns CircuitNodeIds matching layer==2
>>> nodes.ids(group={Node.LAYER: [2, 3]})  # returns CircuitNodeIds with layer in [2,3]
>>> nodes.ids(group={Node.X: (0, 1)})  # returns CircuitNodeIds with 0 < x < 1
>>> # returns CircuitNodeIds matching one of the queries inside the 'or' list
>>> nodes.ids(group={'$or': [{ Node.LAYER: [2, 3]},
>>>                          { Node.X: (0, 1), Node.MTYPE: 'L1_SLAC' }]})
>>> # returns CircuitNodeIds matching all the queries inside the 'and' list
>>> nodes.ids(group={'$and': [{ Node.LAYER: [2, 3]},
>>>                           { Node.X: (0, 1), Node.MTYPE: 'L1_SLAC' }]})
items()

Returns iterator on the tuples (population name, NodePopulations).

Made to simulate the behavior of a dict.items().

keys()

Returns iterator on the NodePopulation names.

Made to simulate the behavior of a dict.keys().

property population_names

Defines all sorted node population names from the Circuit.

property_values(prop)

Returns all the values for a given Nodes property.

values()

Returns iterator on the NodePopulations.

Made to simulate the behavior of a dict.values().