Python API

Python reader for SONATA circuit files

class libsonata.CircuitConfigStatus

Members:

invalid

complete

partial

property name
class libsonata.EdgePopulation

Collection of edges with attributes and connectivity index

afferent_edges(*args, **kwargs)

Overloaded function.

  1. afferent_edges(target: List[int]) → libsonata.Selection

    Return inbound edges for given node IDs.

  2. afferent_edges(target: int) → libsonata.Selection

    Return inbound edges for given node IDs.

property attribute_names

All attribute names (CSV columns + required attributes + union of attributes in groups)

connecting_edges(*args, **kwargs)

Overloaded function.

  1. connecting_edges(source: List[int], target: List[int]) → libsonata.Selection

    Return edges connecting two given nodes.

  2. connecting_edges(source: int, target: int) → libsonata.Selection

    Return edges connecting two given nodes.

property dynamics_attribute_names

All dynamics attribute names (JSON keys + union of attributes in groups)

efferent_edges(*args, **kwargs)

Overloaded function.

  1. efferent_edges(source: List[int]) → libsonata.Selection

    Return outbound edges for given node IDs.

  2. efferent_edges(source: int) → libsonata.Selection

    Return outbound edges for given node IDs.

property enumeration_names

All attribute names that are explicit enumerations

See also: https://github.com/AllenInstitute/sonata/blob/master/docs/SO NATA_DEVELOPER_GUIDE.md#nodes—enum-datatypes

enumeration_values(name: str) List[str]

Get all allowed attribute enumeration values

Parameter name:

is a string to allow attributes not defined in spec

Raises:

if there is no such attribute for the population

get_attribute(*args, **kwargs)

Overloaded function.

  1. get_attribute(name: str, edge_id: int) → object

    Get attribute value for a given edge. See below for details.

  2. get_attribute(name: str, selection: libsonata.Selection) → object

    Get attribute values for given edge Selection

    If string values are requested and the attribute is a explicit enumeration, values will be resolved to strings.

    See also: https://github.com/AllenInstitute/sonata/blob/master/docs/SO NATA_DEVELOPER_GUIDE.md#nodes—enum-datatypes

    Parameter name:

    is a string to allow attributes not defined in spec

    Parameter selection:

    is a selection to retrieve the attribute values from

    Raises:

    if there is no such attribute for the population

    Raises:

    if the attribute is not defined for _any_ element from the selection

  3. get_attribute(name: str, selection: libsonata.Selection, default_value: object) → object

    Get attribute values for given edge Selection

    If string values are requested and the attribute is a explicit enumeration, values will be resolved to strings.

    See also: https://github.com/AllenInstitute/sonata/blob/master/docs/SO NATA_DEVELOPER_GUIDE.md#nodes—enum-datatypes

    Parameter name:

    is a string to allow attributes not defined in spec

    Parameter selection:

    is a selection to retrieve the attribute values from

    Raises:

    if there is no such attribute for the population

    Raises:

    if the attribute is not defined for _any_ element from the selection

get_dynamics_attribute(*args, **kwargs)

Overloaded function.

  1. get_dynamics_attribute(name: str, edge_id: int) → object

    Get dynamics attribute value for a given edge. See below for details.

  2. get_dynamics_attribute(name: str, selection: libsonata.Selection) → object

    Get dynamics attribute values for given edge Selection

    Parameter name:

    is a string to allow attributes not defined in spec

    Parameter selection:

    is a selection to retrieve the dynamics attribute values from

    Raises:

    if there is no such attribute for the population

    Raises:

    if the attribute is not defined for _any_ edge from the edge selection

  3. get_dynamics_attribute(name: str, selection: libsonata.Selection, default_value: object) → object

    Get dynamics attribute values for given edge Selection

    Parameter name:

    is a string to allow attributes not defined in spec

    Parameter selection:

    is a selection to retrieve the dynamics attribute values from

    Raises:

    if there is no such attribute for the population

    Raises:

    if the attribute is not defined for _any_ edge from the edge selection

get_enumeration(*args, **kwargs)

Overloaded function.

  1. get_enumeration(name: str, edge_id: int) → object

    Get enumeration values for a given edge. See below for details.

  2. get_enumeration(name: str, selection: libsonata.Selection) → object

    Get all allowed attribute enumeration values

    Parameter name:

    is a string to allow attributes not defined in spec

    Raises:

    if there is no such attribute for the population

property name

Name of the population used for identifying it in circuit composition

select_all() libsonata.Selection

Selection covering all elements

property size

Total number of elements

property source

Name of source population extracted from ‘source_node_id’ dataset

source_node(edge_id: int) int

Source node ID for a given edge

source_nodes(selection: libsonata.Selection) numpy.ndarray

Return source node IDs for a given edge selection

property target

Name of target population extracted from ‘target_node_id’ dataset

target_node(edge_id: int) int

Target node ID for given edge

target_nodes(selection: libsonata.Selection) numpy.ndarray

Return target node IDs for a given edge selection

static write_indices(h5_filepath: str, population: str, source_node_count: int, target_node_count: int, overwrite: bool = False) None

Write bidirectional node->edge indices to EdgePopulation HDF5.

class libsonata.EdgeStorage

Collection of EdgePopulations stored in a H5 file and optional CSV.

open_population(name: str) libsonata.EdgePopulation

Open a specific EdgePopulation by name

Parameter name:

the name of the population to open

Raises:

if no population with such a name exists

property population_names

Set of all EdgePopulation names

class libsonata.ElementDataFrame

A container of raw reporting data, compatible with Pandas

class libsonata.ElementReportPopulation

A population inside a ReportReader

property data_units

Return the unit of data.

get(node_ids: libsonata.Selection | None = None, tstart: float | None = None, tstop: float | None = None, tstride: int | None = None, block_gap_limit: int | None = None) libsonata.ElementDataFrame

Return reports with all those node_ids between ‘tstart’ and ‘tstop’ with a stride tstride

get_node_id_element_id_mapping(selection: libsonata.Selection | None = None, block_gap_limit: int | None = None) numpy.ndarray

Return the ElementIds for the passed Node. The return type will depend on the report reader: - For Soma report reader, the return value will be the Node ID to which the report value belongs to. - For Element/full compartment readers, the return value will be an array with 2 elements, the first element is the Node ID and the second element is the compartment ID of the given Node.

Parameter node_ids:

limit the report to the given selection. If nullptr, all nodes in the report are used

Parameter block_gap_limit:

gap limit between each IO block while fetching data from storage

get_node_ids() List[int]

Return the list of nodes ids for this population

property sorted

Return true if the data is sorted.

property time_units

Return the unit of time

property times

Return (tstart, tstop, tstep) of the population

class libsonata.ElementReportReader

Used to read somas files

get_population_names() List[str]

Get list of all populations

class libsonata.NodePopulation

Collection of nodes with attributes

property attribute_names

All attribute names (CSV columns + required attributes + union of attributes in groups)

property dynamics_attribute_names

All dynamics attribute names (JSON keys + union of attributes in groups)

property enumeration_names

All attribute names that are explicit enumerations

See also: https://github.com/AllenInstitute/sonata/blob/master/docs/SO NATA_DEVELOPER_GUIDE.md#nodes—enum-datatypes

enumeration_values(name: str) List[str]

Get all allowed attribute enumeration values

Parameter name:

is a string to allow attributes not defined in spec

Raises:

if there is no such attribute for the population

get_attribute(*args, **kwargs)

Overloaded function.

  1. get_attribute(name: str, node_id: int) → object

    Get attribute value for a given node. See below for details.

  2. get_attribute(name: str, selection: libsonata.Selection) → object

    Get attribute values for given node Selection

    If string values are requested and the attribute is a explicit enumeration, values will be resolved to strings.

    See also: https://github.com/AllenInstitute/sonata/blob/master/docs/SO NATA_DEVELOPER_GUIDE.md#nodes—enum-datatypes

    Parameter name:

    is a string to allow attributes not defined in spec

    Parameter selection:

    is a selection to retrieve the attribute values from

    Raises:

    if there is no such attribute for the population

    Raises:

    if the attribute is not defined for _any_ element from the selection

  3. get_attribute(name: str, selection: libsonata.Selection, default_value: object) → object

    Get attribute values for given node Selection

    If string values are requested and the attribute is a explicit enumeration, values will be resolved to strings.

    See also: https://github.com/AllenInstitute/sonata/blob/master/docs/SO NATA_DEVELOPER_GUIDE.md#nodes—enum-datatypes

    Parameter name:

    is a string to allow attributes not defined in spec

    Parameter selection:

    is a selection to retrieve the attribute values from

    Raises:

    if there is no such attribute for the population

    Raises:

    if the attribute is not defined for _any_ element from the selection

get_dynamics_attribute(*args, **kwargs)

Overloaded function.

  1. get_dynamics_attribute(name: str, node_id: int) → object

    Get dynamics attribute value for a given node. See below for details.

  2. get_dynamics_attribute(name: str, selection: libsonata.Selection) → object

    Get dynamics attribute values for given node Selection

    Parameter name:

    is a string to allow attributes not defined in spec

    Parameter selection:

    is a selection to retrieve the dynamics attribute values from

    Raises:

    if there is no such attribute for the population

    Raises:

    if the attribute is not defined for _any_ edge from the edge selection

  3. get_dynamics_attribute(name: str, selection: libsonata.Selection, default_value: object) → object

    Get dynamics attribute values for given node Selection

    Parameter name:

    is a string to allow attributes not defined in spec

    Parameter selection:

    is a selection to retrieve the dynamics attribute values from

    Raises:

    if there is no such attribute for the population

    Raises:

    if the attribute is not defined for _any_ edge from the edge selection

get_enumeration(*args, **kwargs)

Overloaded function.

  1. get_enumeration(name: str, node_id: int) → object

    Get enumeration values for a given node. See below for details.

  2. get_enumeration(name: str, selection: libsonata.Selection) → object

    Get all allowed attribute enumeration values

    Parameter name:

    is a string to allow attributes not defined in spec

    Raises:

    if there is no such attribute for the population

match_values(*args, **kwargs)

Overloaded function.

  1. match_values(name: str, value: List[int]) → libsonata.Selection

    Return selection of where attribute values match value

    As per node_set predicates, value must be one of type:

    • number H5T_IEEE_*LE, H5T_STD_*LE

    • string H5T_C_S1

    • bool H5T_STD_I8LE

    • null invalid

    Raises:

    if the attribute dtype is not comparable

    Note: This does not match dynamics_params datasets

  2. match_values(name: str, value: List[str]) → libsonata.Selection

    Return selection of where attribute values match value

    As per node_set predicates, value must be one of type:

    • number H5T_IEEE_*LE, H5T_STD_*LE

    • string H5T_C_S1

    • bool H5T_STD_I8LE

    • null invalid

    Raises:

    if the attribute dtype is not comparable

    Note: This does not match dynamics_params datasets

  3. match_values(name: str, value: int) → libsonata.Selection

    Return selection of where attribute values match value

    As per node_set predicates, value must be one of type:

    • number H5T_IEEE_*LE, H5T_STD_*LE

    • string H5T_C_S1

    • bool H5T_STD_I8LE

    • null invalid

    Raises:

    if the attribute dtype is not comparable

    Note: This does not match dynamics_params datasets

  4. match_values(name: str, value: str) → libsonata.Selection

    Return selection of where attribute values match value

    As per node_set predicates, value must be one of type:

    • number H5T_IEEE_*LE, H5T_STD_*LE

    • string H5T_C_S1

    • bool H5T_STD_I8LE

    • null invalid

    Raises:

    if the attribute dtype is not comparable

    Note: This does not match dynamics_params datasets

property name

Name of the population used for identifying it in circuit composition

select_all() libsonata.Selection

Selection covering all elements

property size

Total number of elements

class libsonata.NodeStorage

Collection of NodePopulations stored in a H5 file and optional CSV.

open_population(name: str) libsonata.NodePopulation

Open a specific NodePopulation by name

Parameter name:

the name of the population to open

Raises:

if no population with such a name exists

property population_names

Set of all NodePopulation names

class libsonata.Selection

ID sequence in the form convenient for querying attributes

property flat_size

Total number of elements constituting Selection

flatten() numpy.ndarray

Array of IDs constituting Selection

property ranges

Get a list of ranges constituting Selection

class libsonata.SomaDataFrame

A container of raw reporting data, compatible with Pandas

class libsonata.SomaReportPopulation

A population inside a ReportReader

property data_units

Return the unit of data.

get(node_ids: libsonata.Selection | None = None, tstart: float | None = None, tstop: float | None = None, tstride: int | None = None, block_gap_limit: int | None = None) libsonata.SomaDataFrame

Return reports with all those node_ids between ‘tstart’ and ‘tstop’ with a stride tstride

get_node_id_element_id_mapping(selection: libsonata.Selection | None = None, block_gap_limit: int | None = None) numpy.ndarray

Return the ElementIds for the passed Node. The return type will depend on the report reader: - For Soma report reader, the return value will be the Node ID to which the report value belongs to. - For Element/full compartment readers, the return value will be an array with 2 elements, the first element is the Node ID and the second element is the compartment ID of the given Node.

Parameter node_ids:

limit the report to the given selection. If nullptr, all nodes in the report are used

Parameter block_gap_limit:

gap limit between each IO block while fetching data from storage

get_node_ids() List[int]

Return the list of nodes ids for this population

property sorted

Return true if the data is sorted.

property time_units

Return the unit of time

property times

Return (tstart, tstop, tstep) of the population

class libsonata.SomaReportReader

Used to read somas files

get_population_names() List[str]

Get list of all populations

exception libsonata.SonataError
class libsonata.SpikePopulation

A population inside a SpikeReader

get(node_ids: libsonata.Selection | None = None, tstart: float | None = None, tstop: float | None = None) List[Tuple[int, float]]

Return spikes with all those node_ids between ‘tstart’ and ‘tstop’

get_dict(node_ids: object = None, tstart: object = None, tstop: object = None) dict
property sorting

Return the way data are sorted (‘none’, ‘by_id’, ‘by_time’)

property times

Return (tstart, tstop) of the population

class libsonata.SpikeReader

Used to read spike files

get_population_names() List[str]

Return a list of all population names.