Neurodamus.io Sub-Modules¶
neurodamus.io.cell_readers¶
Collection of Cell Readers from different sources (Pure HDF5, SynTool…)
Functions
|
A reader supporting additional dynamic properties from Sonata files. |
|
Splits a numpy ndarray[uint32] round-robin. |
Exceptions
- neurodamus.io.cell_readers.dry_run_distribution(gid_metype_bundle, stride=1, stride_offset=0)¶
Distribute gid in metype bundles for dry run.
The principle is the following: all gids with the same metype have to be assigned to the same rank. This function receives a list of list of gids, each sublist containing gids of the same metype. The gid_metype_bundle list of lists is generated by the retrieve_unique_metype function. This function performs a round robin distribution of the inner lists, i.e. it returns a list of gids that are sequentially in the same metype. The return is a flattened numpy array of gids that shall be instantiated on the same rank.
Example
gid_metype_bundle = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]
stride = 2 stride_offset = 0 return = [1, 2, 3, 7, 8, 9]
stride = 2 stride_offset = 1 return = [4, 5, 6, 10]
- Parameters:
gid_metype_bundle – list of lists of gids to be distributed
- Returns:
A numpy array of gids that are sequentially in the same metype
- neurodamus.io.cell_readers.load_sonata(circuit_conf, all_gids, stride=1, stride_offset=0, *, node_population, load_dynamic_props=(), has_extra_data=False, dry_run_stats=None, load_mode=None)¶
A reader supporting additional dynamic properties from Sonata files.
- neurodamus.io.cell_readers.split_round_robin(all_gids, stride=1, stride_offset=0, total_cells=None)¶
Splits a numpy ndarray[uint32] round-robin. Assumes gids are 0-based. If the array is None generates new arrays based on the nr of total cells
neurodamus.io.synapse_reader¶
Module implementing interfaces to the several synapse readers (eg.: synapsetool, Hdf5Reader)
Classes
Synapse parameter names and dtypes for numpy recarrays following the SONATA specification. |
|
|
Reader for SONATA edge files. |
Exceptions
- class neurodamus.io.synapse_reader.SonataReader(edge_file, population=None, *_, **kw)¶
Reader for SONATA edge files.
Uses libsonata. It will read each attribute for multiple GIDs at once and cache read data in a columnar fashion.
FIXME Remove the caching at the np.recarray level.
- EMPTY_DATA = {}¶
- LOOKUP_BY_TARGET_IDS = True¶
- Parameters¶
alias of
SynapseParameters
- SYNAPSE_INDEX_NAMES = ('synapse_index',)¶
- configure_override(mod_override)¶
- custom_parameters = {'ipt', 'isec', 'offset'}¶
Custom parameters are skipped from direct loading and trigger _load_params_custom()
- get_conn_counts(tgids)¶
Count synapses per source→target connection for given target gids.
- Parameters:
tgids (array-like of int) – One or more target neuron gids to query.
Returns
-------
dict[int – Mapping target gid -> dict mapping source gid -> number of synapses from that source to the target. If a requested gid has no synapses it will be present with value equal to EMPTY_DATA (typically an empty dict).
dict[int – Mapping target gid -> dict mapping source gid -> number of synapses from that source to the target. If a requested gid has no synapses it will be present with value equal to EMPTY_DATA (typically an empty dict).
int]] – Mapping target gid -> dict mapping source gid -> number of synapses from that source to the target. If a requested gid has no synapses it will be present with value equal to EMPTY_DATA (typically an empty dict).
Notes
-----
using (- The method queries the underlying libsonata population)
self._population.afferent_edges
and (self._population.target_nodes)
self._population.source_nodes
(target (then counts unique)
source)
pairs.
from (- Results are cached in self._counts; only missing tgids are read)
calls. (the file on subsequent)
Example
-------
synapses (>>> # Suppose target 10 has 3 incoming)
none. (>>> # one from source 2; target 20 has)
np.array([10 (>>> tgids =)
20])
reader.get_conn_counts(tgids) (>>> conn_counts =)
Result (>>> #)
{ (>>> #)
10 (>>> #)
20 (>>> #)
} (>>> #)
- get_counts(tgids)¶
Count synapses for the given target neuron ids.
- Parameters:
tgids (array-like of int) – One or more target neuron gids to query.
Returns
-------
dict[int – Mapping target gid -> number of synapse edges targeting that gid. Any requested gid that has no synapses present in the underlying population will be included with a value of 0.
int] – Mapping target gid -> number of synapse edges targeting that gid. Any requested gid that has no synapses present in the underlying population will be included with a value of 0.
Notes
-----
using (The implementation queries the underlying libsonata population)
to (self._population.afferent_edges and self._population.target_nodes)
occurrences. (determine the edge-to-target mapping and then counts)
Example
-------
np.array([10 (>>> tgids =)
20
30])
reader.get_counts(tgids) (>>> counts =)
result (>>> # Possible)
- get_property(gid, field_name)¶
Retrieves a full pre-loaded property given a gid and the property name.
- get_synapse_parameters(gid) numpy.recarray¶
Return the synapse parameters record array for the given gid, loading and caching it if needed.
- has_property(field_name)¶
Checks whether source data has the given additional field.
- parameter_mapping = {'D': 'depression_time', 'DTC': 'decay_time', 'F': 'facilitation_time', 'U': 'u_syn', 'conductance_ratio': 'conductance_scale_factor', 'nrrp': 'n_rrp_vesicles', 'synType': 'syn_type_id', 'weight': 'conductance'}¶
- preload_data(gids, minimal_mode=False)¶
Preload SONATA fields for the specified IDs. Set minimal_mode to True to read a single synapse per connection
- class neurodamus.io.synapse_reader.SynapseParameters¶
Synapse parameter names and dtypes for numpy recarrays following the SONATA specification.
For detailed info on the parameters, see: https://sonata-extension.readthedocs.io/en/latest/sonata_tech.html#edge-file
- classmethod all_fields()¶
Return all defined field names.
- classmethod dtype(extra_fields=None)¶
Return dtype including optional extra fields (all float64).
- classmethod fields(exclude: set = (), with_translation: dict | None = None)¶
Return list of fields with optional exclusion and translation.
Returns list of tuples (field_name, translated_name or is_optional).
- classmethod load_fields()¶
Return all fields except reserved ones.
- classmethod make_synapse_parameters_array(data: dict, extra_fields: list[str], extra_cellular_calcium: float | None, extra_scale_vars: list[str])¶
Create a recarray from data with optional extra fields and apply patches.