Python API

Python reader for SONATA circuit files

class libsonata.CircuitConfig

Circuit Configuration

property config_status

ibid

edge_population(*args, **kwargs)

Overloaded function.

  1. edge_population(arg0: str) → bbp::sonata::EdgePopulation

  2. edge_population(arg0: str, arg1: libsonata.Hdf5Reader) → bbp::sonata::EdgePopulation

edge_population_properties(name: str) libsonata.EdgePopulationProperties
static from_file(arg0: object) libsonata.CircuitConfig
node_population(arg0: str) libsonata.NodePopulation
node_population_properties(name: str) libsonata.NodePopulationProperties
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.NodeSets
static from_file(arg0: object) libsonata.NodeSets
materialize(arg0: str, arg1: libsonata.NodePopulation) libsonata.Selection

Return a selection corresponding to the node_set name

Parameter name:

is the name of the node_set rule to be evaluated

Parameter population:

is the population for which the returned selection will be valid

property names

Names of the node sets available

toJSON() str

Return the nodesets as a JSON string.

update(other: libsonata.NodeSets) Set[str]

Update this to include all nodesets from this and other.

Duplicate names are overridden with the values from other.

The duplicate names are returned.

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

Simulation Configuration

class Conditions

Parameters defining global experimental conditions

class SpikeLocation

Members:

soma

AIS

property name
property celsius

Temperature of experiment. Default is 34.0

property extracellular_calcium

Extracellular calcium concentration, being applied to the synapse uHill parameter in order to scale the U parameter of synapses. Default is None.

property list_modification_names

Returns the names of the modifications

property mechanisms

Properties to assign values to variables in synapse MOD files. The format is a dictionary with keys being the SUFFIX names and values being dictionaries of variables’ names and values.

modification(name: str) Union[bbp::sonata::SimulationConfig::ModificationTTX, bbp::sonata::SimulationConfig::ModificationConfigureAllSections, nonstd::variants::detail::TX<nonstd::variants::detail::S2>, nonstd::variants::detail::TX<nonstd::variants::detail::S3>, nonstd::variants::detail::TX<nonstd::variants::detail::S4>, nonstd::variants::detail::TX<nonstd::variants::detail::S5>, nonstd::variants::detail::TX<nonstd::variants::detail::S6>, nonstd::variants::detail::TX<nonstd::variants::detail::S7>, nonstd::variants::detail::TX<nonstd::variants::detail::S8>, nonstd::variants::detail::TX<nonstd::variants::detail::S9>, nonstd::variants::detail::TX<nonstd::variants::detail::S10>, nonstd::variants::detail::TX<nonstd::variants::detail::S11>, nonstd::variants::detail::TX<nonstd::variants::detail::S12>, nonstd::variants::detail::TX<nonstd::variants::detail::S13>, nonstd::variants::detail::TX<nonstd::variants::detail::S14>, nonstd::variants::detail::TX<nonstd::variants::detail::S15>]

Returns the given modification parameters

Raises:

SonataError if the given modification name does not exist

property randomize_gaba_rise_time

Enable legacy behavior to randomize the GABA_A rise time in the helper functions. Default is false

property spike_location

The spike detection location. Can be either ‘soma’ or ‘AIS’. Default is ‘soma’

property v_init

Initial membrane voltage in mV. Default is -80

class ConnectionOverride

List of parameters of a connection

property delay

Adjustments from weight of this connection_override are applied after the specified delay has elapsed in ms, default = 0.

property modoverride

Synapse helper files to instantiate the synapses in this connection_override, default = None

property name

the name of the connection override

property neuromodulation_dtc

To override the neuromod_dtc values between the selected source and target neurons for the neuromodulatory projection. Given in ms.

property neuromodulation_strength

To override the neuromod_strength values between the selected source and target neurons for the neuromodulatory projection. Given in muM.

property source

node_set specifying presynaptic nodes

property spont_minis

Rate to spontaneously trigger the synapses in this connection_override, default = None

property synapse_configure

Snippet of hoc code to be executed on the synapses in this connection_override, default = None

property synapse_delay_override

Value to override the synaptic delay time originally set in the edge file (ms), default = None.

property target

node_set specifying postsynaptic nodes

property weight

Scalar to adjust synaptic strength, default = 1.

class Output

Parameters of simulation output

class SpikesSortOrder

Members:

none

by_id

by_time

property name
property log_file

Filename where console output is written. Default is STDOUT.

property output_dir

Spike report file output directory. Default is “output”

property spikes_file

Spike report file name. Default is “out.h5”

property spikes_sort_order

The sorting order of the spike report. Default is “by_time”

class Report

Parameters of a report

class Compartments

Members:

center

all

property name
class Scaling

Members:

none

area

property name
class Sections

Members:

soma :

axon :

dend :

apic :

all :

property name
class Type

Members:

compartment

lfp

summation

synapse

property name
property cells

Node sets on which to report

property compartments

For compartment type, select compartments to report. Default value: “center”(for sections: soma), “all”(for other sections)

property dt

Interval between reporting steps in milliseconds

property enabled

Allows for suppressing a report so that is not created. Default is true

property end_time

Time to stop reporting in milliseconds

property file_name

Report filename. Default is “<report name>.h5”

property scaling

For summation type, specify the handling of density values. Default value: “area”

property sections

“soma”

Type:

Sections on which to report. Default value

property start_time

Time to step reporting in milliseconds

property type

Report type.

property unit

Descriptive text of the unit recorded. Not validated for correctness

property variable_name

The simulation variable to access. The variables available are model dependent. For summation type, it supports multiple variables by comma separated strings. E.g. “ina”, “AdEx.V_M, v”, “i_membrane, IClamp”.

class Run

Stores parameters defining global simulation settings

class IntegrationMethod

Members:

euler

nicholson

nicholson_ion

property name
property dt

Integration step duration in milliseconds

property electrodes_file

Filename that contains the weights for the LFP calculation.

property integration_method

Selects the NEURON/CoreNEURON integration method. This parameter sets the NEURON global variable h.secondorder. Default 0 (‘euler’)

property ionchannel_seed

A non-negative integer used for seeding stochastic ion channels, default is 0.

property minis_seed

A non-negative integer used for seeding the Poisson processes that drives the minis, default is 0.

property random_seed

Random seed

property spike_threshold

The spike detection threshold. Default is -30mV

property stimulus_seed

A non-negative integer used for seeding noise stimuli and any other future stochastic stimuli, default is 0.

property synapse_seed

A non-negative integer used for seeding stochastic synapses, default is 0.

property tstop

Biological simulation end time in milliseconds

class SimulatorType

SimulatorType Enum

Members:

NEURON

CORENEURON

property name
property base_path

Returns the base path of the simulation config file

property beta_features

Returns the beta_features section

property conditions

Returns the Conditions section of the simulation configuration.

connection_overrides() List[libsonata.SimulationConfig.ConnectionOverride]

Returns the full list of connection overrides

property expanded_json

Returns the configuration file JSON whose variables have been expanded by the manifest entries.

static from_file(arg0: object) libsonata.SimulationConfig

Loads a SONATA JSON simulation config file from disk and returns a SimulationConfig object which parses it.

Raises:

SonataError on: - Non accesible file (does not exists / does not have read access) - Ill-formed JSON - Missing mandatory entries (in any depth)

input(name: str) Union[libsonata.SimulationConfig.Linear, libsonata.SimulationConfig.RelativeLinear, libsonata.SimulationConfig.Pulse, libsonata.SimulationConfig.Subthreshold, libsonata.SimulationConfig.Hyperpolarizing, libsonata.SimulationConfig.SynapseReplay, libsonata.SimulationConfig.Seclamp, libsonata.SimulationConfig.Noise, libsonata.SimulationConfig.ShotNoise, libsonata.SimulationConfig.RelativeShotNoise, libsonata.SimulationConfig.AbsoluteShotNoise, libsonata.SimulationConfig.OrnsteinUhlenbeck, libsonata.SimulationConfig.RelativeOrnsteinUhlenbeck, nonstd::variants::detail::TX<nonstd::variants::detail::S13>, nonstd::variants::detail::TX<nonstd::variants::detail::S14>, nonstd::variants::detail::TX<nonstd::variants::detail::S15>]

Returns the given input parameters.

Raises:

SonataError if the given input name does not exist

property list_input_names

Returns the names of the inputs

property list_report_names

Returns the names of the reports

property metadata

Returns the metadata section

property network

Returns circuit config file associated with this simulation config

property node_set

Returns the name of node set to be instantiated for the simulation, default = None

property node_sets_file

Returns the path of node sets file overriding node_sets_file provided in _network, default is empty in case of no setting in _network

property output

Returns the Output section of the simulation configuration.

report(name: str) libsonata.SimulationConfig.Report

Returns the given report parameters.

Raises:

SonataError if the given report name does not correspond with any existing report.

property run

Returns the Run section of the simulation configuration.

property target_simulator

Returns the name of simulator, default = NEURON

Raises:

SonataError if the given value is neither NEURON nor CORENEURON

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.