bluepysnap.edges

Edge population access.

Classes

EdgePopulation(edge_storage, population_name)

Edge population access.

EdgeStorage(config, circuit)

Edge storage access.

Edges(circuit)

The top level Edges accessor.

class bluepysnap.edges.EdgePopulation(edge_storage, population_name, population_config=None)

Edge population access.

Initializes a EdgePopulation object from a EdgeStorage and a population name.

Parameters
  • edge_storage (EdgeStorage) – the edge storage containing the edge population

  • population_name (str) – the name of the edge population

  • population_config (dict) – the config for the population

Returns

An EdgePopulation object.

Return type

EdgePopulation

afferent_edges(node_id, properties=None)

Get afferent edges for given node_id.

Parameters
  • node_id (CircuitNodeIds/int/sequence/str/mapping/None) – Target node ID.

  • properties – An edge property name, a list of edge property names, or None.

Returns

A pandas Series indexed by edge ID if properties is a string. A pandas DataFrame indexed by edge ID if properties is a list. A list of edge IDs, if properties is None.

Return type

pandas.Series/pandas.DataFrame/list

afferent_nodes(target, unique=True)

Get afferent node IDs for given target node_id.

Notes

Afferent nodes are nodes projecting an outgoing edge to one of the target node.

Parameters
  • target (CircuitNodeIds/int/sequence/str/mapping/None) – the target you want to resolve

  • nodes. (and use as target) –

  • unique (bool) – If True, return only unique afferent node IDs.

Returns

Afferent node IDs for all the targets.

Return type

numpy.ndarray

config

Population config dictionary combined with the components dictionary.

container_property_names(container)

Lists the ConstContainer properties shared with the EdgePopulation.

Parameters

container (ConstContainer) – a container class for edge properties.

Returns

A list of strings corresponding to the properties that you can use from the

container class

Return type

list

Examples

>>> from bluepysnap.sonata_constants import Edge
>>> print(my_edge_population.container_property_names(Edge))
>>> ["AXONAL_DELAY", "SYN_WEIGHT"] # values you can use with my_edge_population
efferent_edges(node_id, properties=None)

Get efferent edges for given node_id.

Parameters
  • node_id (CircuitNodeIds/int/sequence/str/mapping/None) – source node ID

  • properties – None / edge property name / list of edge property names

Returns

List of edge IDs, if properties is None; Pandas Series indexed by edge IDs if properties is string; Pandas DataFrame indexed by edge IDs if properties is list.

efferent_nodes(source, unique=True)

Get efferent node IDs for given source node_id.

Notes

Efferent nodes are nodes receiving an incoming edge from one of the source node.

Parameters
  • source (CircuitNodeIds/int/sequence/str/mapping/None) – the source you want to resolve and use as source nodes.

  • unique (bool) – If True, return only unique afferent node IDs.

Returns

Efferent node IDs for all the sources.

Return type

numpy.ndarray

get(edge_ids, properties)

Edge properties as pandas DataFrame.

Parameters
  • edge_ids (array-like) – array-like of edge IDs

  • properties (str/list) – an edge property name or a list of edge property names

Returns

A pandas Series indexed by edge IDs if properties is scalar. A pandas DataFrame indexed by edge IDs if properties is list.

Return type

pandas.Series/pandas.DataFrame

Notes

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

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

Edge IDs corresponding to edges edge_ids.

Parameters
  • group (None/int/CircuitEdgeId/CircuitEdgeIds/sequence) – Which IDs will be returned depends on the type of the group argument: - None: return all IDs. - int, CircuitEdgeId: return a single edge ID. - CircuitEdgeIds return IDs of edges the edge population in an array. - sequence: return IDs of edges in an array.

  • 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 the EdgePopulation 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 the population all node IDs are returned.

  • raise_missing_property (bool) – if True, raises if a property is not listed in this population. Otherwise the ids are just not selected if a property is missing.

Returns

A numpy array of IDs.

Return type

numpy.array

iter_connections(source=None, target=None, unique_node_ids=False, shuffle=False, return_edge_ids=False, return_edge_count=False)

Iterate through source -> target connections.

Parameters
  • source (CircuitNodeIds/int/sequence/str/mapping/None) – source node group

  • target (CircuitNodeIds/int/sequence/str/mapping/None) – target node group

  • unique_node_ids – if True, no node ID will be used more than once as source or target for edges. Careful, this flag does not provide unique (source, target) pairs but unique node IDs.

  • shuffle – if True, result order would be (somewhat) randomized

  • return_edge_count – if True, edge count is added to yield result

  • return_edge_ids – if True, edge ID list is added to yield result

return_edge_count and return_edge_ids are mutually exclusive.

Yields

(source_node_id, target_node_id, edge_ids) if return_edge_ids == True; (source_node_id, target_node_id, edge_count) if return_edge_count == True; (source_node_id, target_node_id) otherwise.

pair_edges(source_node_id, target_node_id, properties=None)

Get edges corresponding to source_node_id -> target_node_id connection.

Parameters
  • source_node_id (CircuitNodeIds/int/sequence/str/mapping/None) – source node ID

  • target_node_id (CircuitNodeIds/int/sequence/str/mapping/None) – target node ID

  • properties – None / edge property name / list of edge property names

Returns

List of edge IDs, if properties is None; Pandas Series indexed by edge IDs if properties is string; Pandas DataFrame indexed by edge IDs if properties is list.

pathway_edges(source=None, target=None, properties=None)

Get edges corresponding to source -> target connections.

Parameters
  • source (CircuitNodeIds/int/sequence/str/mapping/None) – source node group

  • target (CircuitNodeIds/int/sequence/str/mapping/None) – target node group

  • properties – None / edge property name / list of edge property names

Returns

List of edge IDs, if properties is None; Pandas Series indexed by edge IDs if properties is string; Pandas DataFrame indexed by edge IDs if properties is list.

positions(edge_ids, side, kind)

Edge positions as a pandas DataFrame.

Parameters
  • edge_ids (array-like) – array-like of edge IDs

  • side (str) – afferent or efferent

  • kind (str) – center or surface

Returns

Pandas Dataframe with (‘x’, ‘y’, ‘z’) columns indexed by edge IDs.

properties(edge_ids, properties)

Edge properties as pandas DataFrame.

Parameters
  • edge_ids (array-like) – array-like of edge IDs

  • properties (str/list) – an edge property name or a list of edge property names

Returns

A pandas Series indexed by edge IDs if properties is scalar. A pandas DataFrame indexed by edge IDs if properties is list.

Return type

pandas.Series/pandas.DataFrame

Notes

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

property_dtypes

Returns the dtypes of all the properties.

Returns

series indexed by field name with the corresponding dtype as value.

Return type

pandas.Series

property property_names

Set of available edge properties.

Notes

Properties are a combination of the group attributes, the dynamics_params and the topology properties.

property size

Population size.

source

Source NodePopulation.

target

Target NodePopulation.

property type

Population type.

class bluepysnap.edges.EdgeStorage(config, circuit)

Edge storage access.

Initializes a EdgeStorage object from a edge config and a Circuit.

Parameters
  • config (dict) – a edge config from the global circuit config

  • circuit (bluepysnap.Circuit) – the circuit object that contains the EdgePopulations

  • storage. (from this) –

Returns

A EdgeStorage object.

Return type

EdgeStorage

property circuit

Returns the circuit object containing this storage.

property csv_filepath

Returns the csv filepath of the Storage.

property h5_filepath

Returns the filepath of the Storage.

population(population_name)

Access the different populations from the storage.

population_names

Returns all population names inside this file.

property storage

Access to the libsonata edge storage.

class bluepysnap.edges.Edges(circuit)

The top level Edges accessor.

Initialize the top level Edges accessor.

afferent_edges(node_id, properties=None)

Get afferent edges for given node_id.

Parameters
  • node_id (int) – Target node ID.

  • properties – An edge property name, a list of edge property names, or None.

Returns

A pandas Series indexed by edge ID if properties is a string. A pandas DataFrame indexed by edge ID if properties is a list. A list of edge IDs, if properties is None.

Return type

pandas.Series/pandas.DataFrame/list

afferent_nodes(target, unique=True)

Get afferent CircuitNodeIDs for given target node_id.

Notes

Afferent nodes are nodes projecting an outgoing edge to one of the target node.

Parameters
  • target (CircuitNodeIds/int/sequence/str/mapping/None) – the target you want to resolve

  • nodes. (and use as target) –

  • unique (bool) – If True, return only unique afferent node IDs.

Returns

Afferent CircuitNodeIDs for all the targets from all edge population.

Return type

CircuitNodeIDs

efferent_edges(node_id, properties=None)

Get efferent edges for given node_id.

Parameters
  • node_id – source node ID

  • properties – None / edge property name / list of edge property names

Returns

List of edge IDs, if properties is None; Pandas Series indexed by edge IDs if properties is string; Pandas DataFrame indexed by edge IDs if properties is list.

efferent_nodes(source, unique=True)

Get efferent node IDs for given source node_id.

Notes

Efferent nodes are nodes receiving an incoming edge from one of the source node.

Parameters
  • source (CircuitNodeIds/int/sequence/str/mapping/None) – the source you want to resolve and use as source nodes.

  • unique (bool) – If True, return only unique afferent node IDs.

Returns

Efferent node IDs for all the sources.

Return type

numpy.ndarray

get(edge_ids=None, properties=None)

Edge properties as pandas DataFrame.

Parameters
  • edge_ids (int/CircuitEdgeId/CircuitEdgeIds/sequence) – same as Edges.ids().

  • properties (None/str/list) – an edge property name or a list of edge property names. If set to None ids are returned.

Returns

A pandas Series indexed by edge IDs if properties is scalar. A pandas DataFrame indexed by edge IDs if properties is list.

Return type

pandas.Series/pandas.DataFrame

Notes

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

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

Edge CircuitEdgeIds corresponding to edges edge_ids.

Parameters
  • group (None/int/CircuitEdgeId/CircuitEdgeIds/sequence) – Which IDs will be

  • argument (returned depends on the type of the group) –

    • None: return all CircuitEdgeIds.

    • CircuitEdgeId: return the ID in a CircuitEdgeIds object.

    • CircuitEdgeIds: return the IDs in a CircuitNodeIds object.

    • int: returns a CircuitEdgeIds object containing the corresponding edge ID

      for all populations.

    • sequence: returns a CircuitEdgeIds object containing the corresponding edge

      IDs for all populations.

  • 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 EdgePopulations 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 CircuitEdgeIds containing all the edge IDs and the

corresponding populations. For performance reasons we do not test if the edge ids are present or not in the circuit.

Return type

CircuitEdgeIds

Notes

This envision also the maybe future selection of edges on queries.

items()

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

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

iter_connections(source=None, target=None, return_edge_ids=False, return_edge_count=False)

Iterate through source -> target connections.

Parameters
  • source (CircuitNodeIds/int/sequence/str/mapping/None) – source node group

  • target (CircuitNodeIds/int/sequence/str/mapping/None) – target node group

  • return_edge_count – if True, edge count is added to yield result

  • return_edge_ids – if True, edge ID list is added to yield result

return_edge_count and return_edge_ids are mutually exclusive.

Yields

(source_node_id, target_node_id, edge_ids) if return_edge_ids == True; (source_node_id, target_node_id, edge_count) if return_edge_count == True; (source_node_id, target_node_id) otherwise.

keys()

Returns iterator on the EdgePopulation names.

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

pair_edges(source_node_id, target_node_id, properties=None)

Get edges corresponding to source_node_id -> target_node_id connection.

Parameters
  • source_node_id – source node ID

  • target_node_id – target node ID

  • properties – None / edge property name / list of edge property names

Returns

List of edge IDs, if properties is None; Pandas Series indexed by edge IDs if properties is string; Pandas DataFrame indexed by edge IDs if properties is list.

pathway_edges(source=None, target=None, properties=None)

Get edges corresponding to source -> target connections.

Parameters
  • source – source node group

  • target – target node group

  • properties – None / edge property name / list of edge property names

Returns

CircuitEdgeIDs, if properties is None; Pandas Series indexed by CircuitEdgeIDs if properties is string; Pandas DataFrame indexed by CircuitEdgeIDs if properties is list.

properties(edge_ids, properties)

Edge properties as pandas DataFrame.

Parameters
  • edge_ids (int/CircuitEdgeId/CircuitEdgeIds/sequence) – same as Edges.ids().

  • properties (None/str/list) – an edge property name or a list of edge property names. If set to None ids are returned.

Returns

A pandas Series indexed by edge IDs if properties is scalar. A pandas DataFrame indexed by edge IDs if properties is list.

Return type

pandas.Series/pandas.DataFrame

Notes

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

values()

Returns iterator on the EdgePopulations.

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