Side classes

class nngt.GroupProperty(size, constraints={}, neuron_model=None, neuron_param={}, syn_model=None, syn_param={})[source]

Class defining the properties needed to create groups of neurons from an existing GraphClass or one of its subclasses.

Variables:
  • sizeint Size of the group.
  • constraintsdict, optional (default: {}) Constraints to respect when building the NeuralGroup .
  • neuron_modelstring, optional (default: None) name of the model to use when simulating the activity of this group.
  • neuron_paramdict, optional (default: {}) the parameters to use (if they differ from the model’s defaults)

Create a new instance of GroupProperties.

Notes

The constraints can be chosen among:
  • “avg_deg”, “min_deg”, “max_deg” (int) to constrain the total degree of the nodes
  • “avg/min/max_in_deg”, “avg/min/max_out_deg”, to work with the in/out-degrees
  • “avg/min/max_betw” (double) to constrain the betweenness centrality
  • “in_shape” (nngt.geometry.Shape) to chose neurons inside a given spatial region

Examples

>>> di_constrain = { "avg_deg": 10, "min_betw": 0.001 }
>>> group_prop = GroupProperties(200, constraints=di_constrain)
class nngt.NeuralGroup(nodes=None, ntype=1, model=None, neuron_param=None, syn_model=None, syn_param=None)[source]

Class defining groups of neurons.

Variables:
  • idslist of int the ids of the neurons in this group.
  • neuron_typeint the default is 1 for excitatory neurons; -1 is for interneurons
  • modelstring, optional (default: None) the name of the model to use when simulating the activity of this group
  • neuron_paramdict, optional (default: {}) the parameters to use (if they differ from the model’s defaults)

Note

By default, synapses are registered as "static_synapse" in NEST; because of this, only the neuron_model attribute is checked by the has_model function.

Warning

Equality between NeuralGroup`s only compares the neuronal and synaptic ``model` and param attributes, i.e. groups differing only by their ids will register as equal.

Create a group of neurons (empty group is default, but it is not a valid object for most use cases).

Parameters:
  • nodes (int or array-like, optional (default: None)) – Desired size of the group or, a posteriori, NNGT indices of the neurons in an existing graph.
  • ntype (int, optional (default: 1)) – Type of the neurons (1 for excitatory, -1 for inhibitory).
  • model (str, optional (default: None)) – NEST model for the neuron.
  • neuron_param (dict, optional (default: model defaults)) – Dictionary containing the parameters associated to the NEST model.
  • syn_model (str, optional (default: “static_synapse”)) – NEST model for the incoming synapses.
  • syn_param (dict, optional (default: model defaults)) – Dictionary containing the parameters associated to the NEST model.
Returns:

A new NeuralGroup instance.

has_model
ids
nest_gids
neuron_model
properties
size
class nngt.NeuralPop(size, parent=None, with_models=True, **kwargs)[source]

The basic class that contains groups of neurons and their properties.

Variables:has_modelsbool, True if every group has a model attribute.

Initialize NeuralPop instance

Parameters:
  • size (int) – Number of neurons that the population will contain.
  • parent (Network, optional (default: None)) – Network associated to this population.
  • with_models (bool) – whether the population’s groups contain models to use in NEST
  • **kwargs (dict)
Returns:

pop (NeuralPop object.)

add_to_group(group_name, ids)[source]
classmethod copy(pop)[source]

Copy an existing NeuralPop

create_group(name, neurons, ntype=1, neuron_model=None, neuron_param=None, syn_model='static_synapse', syn_param=None)[source]

Create a new groupe from given properties.

Parameters:
  • name (str) – Name of the group.
  • neurons (array-like) – List of the neurons indices.
  • ntype (int, optional (default: 1)) – Type of the neurons : 1 for excitatory, -1 for inhibitory.
  • neuron_model (str, optional (default: None)) – Name of a neuron model in NEST.
  • neuron_param (dict, optional (default: None)) – Parameters for neuron_model in the NEST simulator. If None, default parameters will be used.
  • syn_model (str, optional (default: “static_synapse”)) – Name of a synapse model in NEST.
  • syn_param (dict, optional (default: None)) – Parameters for syn_model in the NEST simulator. If None, default parameters will be used.
classmethod exc_and_inhib(size, iratio=0.2, en_model='aeif_cond_alpha', en_param=None, es_model='static_synapse', es_param=None, in_model='aeif_cond_alpha', in_param=None, is_model='static_synapse', is_param=None, parent=None)[source]

Make a NeuralPop with a given ratio of inhibitory and excitatory neurons.

classmethod from_groups(groups, names=None, parent=None, with_models=True)[source]

Make a NeuralPop object from a (list of) NeuralGroup object(s).

Parameters:
  • groups (list of NeuralGroup objects) – Groups that will be used to form the population.
  • names (list of str, optional (default: None)) – Names that can be used as keys to retreive a specific group. If not provided, keys will be the position of the group in groups, stored as a string. In this case, the first group in a population named pop will be retreived by either pop[0] or pop[‘0’].
  • parent (Graph, optional (default: None)) – Parent if the population is created from an exiting graph.

Note

If the population is not generated from an existing Graph and the groups do not contain explicit ids, then the ids will be generated upon population creation: the first group, of size N0, will be associated the indices 0 to N0 - 1, the second group (size N1), will get N0 to N0 + N1 - 1, etc.

classmethod from_network(graph, *args)[source]

Make a NeuralPop object from a network. The groups of neurons are determined using instructions from an arbitrary number of GroupProperties.

get_group(neurons, numbers=False)[source]

Return the group of the neurons.

Parameters:
  • neurons (int or array-like) – IDs of the neurons for which the group should be returned.
  • numbers (bool, optional (default: False)) – Whether the group identifier should be returned as a number; if False, the group names are returned.
get_param(groups=None, neurons=None, element='neuron')[source]

Return the element (neuron or synapse) parameters for neurons or groups of neurons in the population.

Parameters:
  • groups (str, int or array-like, optional (default: None)) – Names or numbers of the groups for which the neural properties should be returned.
  • neurons (int or array-like, optional (default: None)) – IDs of the neurons for which parameters should be returned.
  • element (list of str, optional (default: "neuron")) – Element for which the parameters should be returned (either "neuron" or "synapse").
Returns:

param (list) – List of all dictionaries with the elements’ parameters.

has_models
is_valid
set_model(model, group=None)[source]

Set the groups’ models.

Parameters:
  • model (dict) – Dictionary containing the model type as key (“neuron” or “synapse”) and the model name as value (e.g. {“neuron”: “iaf_neuron”}).
  • group (list of strings, optional (default: None)) – List of strings containing the names of the groups which models should be updated.

Note

By default, synapses are registered as “static_synapse”s in NEST; because of this, only the neuron_model attribute is checked by the has_models function: it will answer True if all groups have a ‘non-None’ neuron_model attribute.

Warning

No check is performed on the validity of the models, which means that errors will only be detected when building the graph in NEST.

set_param(param, group=None)[source]

Set the groups’ parameters.

Parameters:
  • param (dict) – Dictionary containing the model type as key (“neuron” or “synapse”) and the model parameter as value (e.g. {“neuron”: {“C_m”: 125.}}).
  • group (list of strings, optional (default: None)) – List of strings containing the names of the groups which models should be updated.
  • .. warning:: – No check is performed on the validity of the parameters, which means that errors will only be detected when building the graph in NEST.
size
classmethod uniform(size, neuron_model='aeif_cond_alpha', neuron_param=None, syn_model='static_synapse', syn_param=None, parent=None)[source]

Make a NeuralPop of identical neurons