bmtk.utils.sonata package¶
Subpackages¶
Submodules¶
bmtk.utils.sonata.column_property module¶
bmtk.utils.sonata.edge module¶
bmtk.utils.sonata.file module¶
bmtk.utils.sonata.file_root module¶
-
class
bmtk.utils.sonata.file_root.
EdgesRoot
(edges, edge_types, mode='r')[source]¶ Bases:
bmtk.utils.sonata.file_root.FileRoot
-
edge_types_table
¶
-
get_populations
(name=None, source=None, target=None)[source]¶ Find all populations with matching criteria, either using the population name (which will return a list of size 0 or 1) or based on the source/target population.
To return a list of all populations just use populations() method
Parameters: - name – (str) name of population
- source – (str or NodePopulation) returns edges with nodes coming from matching source-population
- target – (str or NodePopulation) returns edges with nodes coming from matching target-population
Returns: A (potential empty) list of EdgePopulation objects filter by criteria.
-
-
class
bmtk.utils.sonata.file_root.
FileRoot
(root_name, h5_files, h5_mode, csv_files)[source]¶ Bases:
object
Base class for both /nodes and /edges root group in h5 file
-
get_population
(population_name, default=None)[source]¶ Return a population group object based on population’s name
-
population_names
¶
-
populations
¶
-
root_name
¶
-
types_table
¶
-
-
class
bmtk.utils.sonata.file_root.
NodesRoot
(nodes, node_types, mode='r', gid_table=None)[source]¶ Bases:
bmtk.utils.sonata.file_root.FileRoot
-
generate_gids
(file_name, gids=None, force=False)[source]¶ Creates a gid <–> (node_id, population) table based on sonnet specifications.
Generating gids will take some time and so not recommend to call this during the simulation. Instead save the file to the disk and pass in h5 file during the simulation (using gid_table parameter). In fact if you’re worried about efficeny don’t use this method.Parameters: - file_name – Name of h5 file to save gid map to.
- gids – rule/list of gids to use
- force – set to true to overwrite existing gid map (default False).
-
has_gids
¶
-
node_types_table
¶
-
bmtk.utils.sonata.group module¶
-
class
bmtk.utils.sonata.group.
EdgeGroup
(group_id, h5_group, parent)[source]¶ Bases:
bmtk.utils.sonata.group.Group
-
edge_type_ids
¶
-
get_values
(property_name, all_rows=False)[source]¶ Returns all values for a group property.
Note that a row within a group may not have a corresponding node/edge, or they may have a different order or multiple node/edges may share the same group row. Setting all_rows=False will return all the values as you see if you iterated through all the population’s items. Setting all_rows=True just returns the data as a list as they appear in the dataset (will be faster).
Parameters: - property_name – Name of dataset property/column to fetch.
- all_rows – Set false to return order in which they appear in population, false to return entire dataset
Returns: A list of values for the given column name.
-
src_node_ids
¶
-
trg_node_ids
¶
-
-
class
bmtk.utils.sonata.group.
Group
(group_id, h5_group, parent)[source]¶ Bases:
object
A container containig a node/edge population groups.
A node or edge population will have one or more groups, each having a unique identifier. Each group shared the same columns and datatypes, thus each group is essentially a different model.
-
all_columns
¶
-
columns
¶
-
get_values
(property_name, all_rows=False)[source]¶ Returns all values for a group property.
Note that a row within a group may not have a corresponding node/edge, or they may have a different order or multiple node/edges may share the same group row. Setting all_rows=False will return all the values as you see if you iterated through all the population’s items. Setting all_rows=True just returns the data as a list as they appear in the dataset (will be faster).
Parameters: - property_name – Name of dataset property/column to fetch.
- all_rows – Set false to return order in which they appear in population, false to return entire dataset
Returns: A list of values for the given column name.
-
group_columns
¶
-
group_id
¶
-
has_dynamics_params
¶
-
has_gids
¶
-
parent
¶
-
-
class
bmtk.utils.sonata.group.
NodeGroup
(group_id, h5_group, parent)[source]¶ Bases:
bmtk.utils.sonata.group.Group
-
filter
(**filter_props)[source]¶ Filter all nodes in the group by key=value pairs.
The filter specifications may apply to either node_type or group column properties. Currently at the moment it only supports equivlency. An intersection (and operator) is done for every different filter pair. This will produce a generator of all nodes matching the the filters.
- for node in filter(pop_name=’VIp’, depth=10.0):
- assert(node[‘pop_name’] == ‘VIp’ and node[‘depth’] == 10.0)
Parameters: filter_props – keys and their values to filter nodes on. Returns: A generator that produces all valid nodes within the group with matching key==value pairs.
-
get_values
(property_name, filtered_indicies=True)[source]¶ Returns all values for a group property.
Note that a row within a group may not have a corresponding node/edge, or they may have a different order or multiple node/edges may share the same group row. Setting all_rows=False will return all the values as you see if you iterated through all the population’s items. Setting all_rows=True just returns the data as a list as they appear in the dataset (will be faster).
Parameters: - property_name – Name of dataset property/column to fetch.
- all_rows – Set false to return order in which they appear in population, false to return entire dataset
Returns: A list of values for the given column name.
-
gids
¶
-
node_ids
¶
-
node_type_ids
¶
-
bmtk.utils.sonata.node module¶
bmtk.utils.sonata.population module¶
-
class
bmtk.utils.sonata.population.
EdgePopulation
(pop_name, pop_group, edge_types_tables)[source]¶ Bases:
bmtk.utils.sonata.population.Population
-
edge_types_table
¶
-
group_id_column
¶
-
group_index_column
¶
-
group_indicies
(group_id, build_cache=False, as_list=False)[source]¶ Returns a list of all the population row index that maps onto the given group.
Used for iterating or searching within a Group
Parameters: - group_id – id of a given group
- build_cache – Will cache indicies for all groups. Will be faster if making multiple calls but requires more memory (default False)
Returns: A (possibly empty) list of row indicies (non-contiguous, but unique)
-
source_population
¶
-
target_population
¶
-
type_ids_column
¶
-
-
class
bmtk.utils.sonata.population.
NodePopulation
(pop_name, pop_group, node_types_tables)[source]¶ Bases:
bmtk.utils.sonata.population.Population
-
get_rows
(row_indicies)[source]¶ Returns a set of all nodes based on list of row indicies.
Warning: currently due to the use of h5py, the list must be ordered and cannot contain duplicates.
Parameters: row_indicies – A list of row indicies Returns: An iterable NodeSet of nodes in the specified indicies
-
gids
¶
-
group_id_column
¶
-
group_index_column
¶
-
has_gids
¶
-
index_column_name
¶
-
node_ids
¶
-
node_types_table
¶
-
type_ids_column
¶
-
-
class
bmtk.utils.sonata.population.
Population
(pop_name, pop_group, types_table)[source]¶ Bases:
object
-
group_id_column
¶
-
group_id_ds
¶
-
group_ids
¶ List of all group_ids belonging to population
-
group_index_column
¶
-
group_index_ds
¶
-
group_indicies
(group_id, build_cache=False)[source]¶ Returns a list of all the population row index that maps onto the given group.
Used for iterating or searching within a Group
Parameters: - group_id – id of a given group
- build_cache – Will cache indicies for all groups. Will be faster if making multiple calls but requires more memory (default False)
Returns: A (possibly empty) list of row indicies (non-contiguous, but unique)
-
groups
¶ Returns a list of sonata.Group objects
-
name
¶ name of current population
-
type_ids
¶
-
type_ids_column
¶
-
types_table
¶
-
bmtk.utils.sonata.types_table module¶
-
class
bmtk.utils.sonata.types_table.
EdgeTypesTable
(parent=None)[source]¶ Bases:
bmtk.utils.sonata.types_table.TypesTable
-
edge_type_ids
¶
-
index_column_name
¶
-
-
class
bmtk.utils.sonata.types_table.
NodeTypesTable
(parent=None)[source]¶ Bases:
bmtk.utils.sonata.types_table.TypesTable
-
index_column_name
¶
-
node_type_ids
¶
-
-
class
bmtk.utils.sonata.types_table.
TypesTable
(parent=None)[source]¶ Bases:
object
-
columns
¶
-
find
(column_key, column_val, silent=False)[source]¶ Returns a list of type_ids that contain column property column_key==column_val
Parameters: - column_key – Name of column to search
- column_val – Value of column to select for
- silent – Set to true to prevent KeyError if column_key doesn’t exist (default=False)
Returns: A (potentially empty) list of type_ids
-
index_column_name
¶
-
type_ids
¶
-