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: - size –
int
Size of the group. - constraints –
dict
, optional (default: {}) Constraints to respect when building theNeuralGroup
. - neuron_model –
string
, optional (default: None) name of the model to use when simulating the activity of this group. - neuron_param –
dict
, 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
- “avg_deg”, “min_deg”, “max_deg” (
Examples
>>> di_constrain = { "avg_deg": 10, "min_betw": 0.001 } >>> group_prop = GroupProperties(200, constraints=di_constrain)
- size –
-
class
nngt.
NeuralGroup
(nodes=None, ntype=1, neuron_model=None, neuron_param=None, name=None)[source]# Class defining groups of neurons.
Variables: - ids –
list
ofint
the ids of the neurons in this group. - neuron_type –
int
the default is1
for excitatory neurons;-1
is for interneurons - model –
string
, optional (default: None) the name of the model to use when simulating the activity of this group - neuron_param –
dict
, 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 theneuron_model
attribute is checked by thehas_model
function.Warning
Equality between
NeuralGroup`s only compares the size and neuronal ``model`
andparam
attributes. This means that groups differing only by theirids
will register as equal.Create a group of neurons (empty group is default, but it is not a valid object for most use cases).
Changed in version 0.8: Removed syn_model and syn_param.
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).
- neuron_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.
Returns: A new
NeuralGroup
instance.-
has_model
#
-
ids
#
-
is_valid
()[source]# Whether the group can be used in a population: i.e. if it has either a size or some ids associated to it.
New in version 1.0.
-
name
#
-
nest_gids
#
-
neuron_model
#
-
neuron_param
#
-
properties
#
-
size
#
- ids –
-
class
nngt.
NeuralPop
(size=None, parent=None, with_models=True, *args, **kwargs)[source]# The basic class that contains groups of neurons and their properties.
Variables: - has_models –
bool
,True
if every group has amodel
attribute. - size –
int
, Returns the number of neurons in the population. - syn_spec –
dict
, Dictionary containing informations about the synapses between the different groups in the population. - is_valid –
bool
, Whether this population can be used to create a network in NEST.
Initialize NeuralPop instance
Parameters: - size (int, optional (default: 0)) – 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 - *args (items for OrderedDict parent)
- **kwargs (
dict
)
Returns: pop (
NeuralPop
object.)-
add_to_group
(group_name, ids)[source]# Add neurons to a specific group.
Parameters: - group_name (str or int) – Name or index of the group.
- ids (list or 1D-array) – Neuron ids.
-
create_group
(name, neurons, ntype=1, neuron_model=None, neuron_param=None)[source]# Create a new groupe from given properties.
Changed in version 0.8: Removed syn_model and syn_param.
Changed in version 1.0: neurons can be an int to signify a desired size for the group without actually setting the indices.
Parameters: - name (str) – Name of the group.
- neurons (int or array-like) – Desired number of neurons or 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.
-
classmethod
exc_and_inhib
(size, iratio=0.2, en_model='aeif_cond_alpha', en_param=None, in_model='aeif_cond_alpha', in_param=None, syn_spec=None, parent=None)[source]# Make a NeuralPop with a given ratio of inhibitory and excitatory neurons.
Changed in version 0.8: Added syn_spec parameter.
Parameters: size (int) – Number of neurons contained by the population.
iratio (float, optional (default: 0.2)) – Fraction of the neurons that will be inhibitory.
en_model (str, optional (default: default_neuron)) – Name of the NEST model that will be used to describe excitatory neurons.
en_param (dict, optional (default: default NEST parameters)) – Parameters of the excitatory neuron model.
in_model (str, optional (default: default_neuron)) – Name of the NEST model that will be used to describe inhibitory neurons.
in_param (dict, optional (default: default NEST parameters)) – Parameters of the inhibitory neuron model.
syn_spec (dict, optional (default: static synapse)) – Dictionary containg a directed edge between groups as key and the associated synaptic parameters for the post-synaptic neurons (i.e. those of the second group) as value. If provided, all connections between groups will be set according to the values contained in syn_spec. Valid keys are:
- (‘excitatory’, ‘excitatory’)
- (‘excitatory’, ‘inhibitory’)
- (‘inhibitory’, ‘excitatory’)
- (‘inhibitory’, ‘inhibitory’)
parent (
Network
, optional (default: None)) – Network associated to this population.
See also
nest.Connect()
,as()
-
classmethod
from_groups
(groups, names=None, syn_spec=None, parent=None, with_models=True)[source]# Make a NeuralPop object from a (list of)
NeuralGroup
object(s).Changed in version 0.8: Added syn_spec parameter.
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. - syn_spec (dict, optional (default: static synapse)) – Dictionary containg a directed edge between groups as key and the associated synaptic parameters for the post-synaptic neurons (i.e. those of the second group) as value. If a ‘default’ entry is provided, all unspecified connections will be set to its value.
- with_model (bool, optional (default: True)) – Whether the groups require models (set to False to use populations for graph theoretical purposes, without NEST interaction)
Example
For synaptic properties, if provided in syn_spec, all connections between groups will be set according to the values. Keys can be either group names or types (1 for excitatory, -1 for inhibitory). Because of this, several combination can be available for the connections between two groups. Because of this, priority is given to source (presynaptic properties), i.e. NNGT will look for the entry matching the first group name as source before looking for entries matching the second group name as target.
# we created groups `g1`, `g2`, and `g3` prop = { ('g1', 'g2'): {'model': 'tsodyks2_synapse', 'tau_fac': 50.}, ('g1', g3'): {'weight': 100.}, ... } pop = NeuronalPop.from_groups( [g1, g2, g3], names=['g1', 'g2', 'g3'], syn_spec=prop)
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.- groups (list of
-
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
ofstr
, 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.- groups (
-
has_models
#
-
is_valid
# Whether the population can be used to create a NEST network.
-
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 thehas_models
function: it will answerTrue
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_neuron_param
(params, neurons=None, group=None)[source]# Set the parameters of specific neurons or of a whole group.
New in version 1.0.
Parameters: - params (dict) – Dictionary containing parameters for the neurons. Entries can be either a single number (same for all neurons) or a list (one entry per neuron).
- neurons (list of ints, optional (default: None)) – Ids of the neurons whose parameters should be modified.
- group (list of strings, optional (default: None)) – List of strings containing the names of the groups whose parameters should be updated. When modifying neurons from a single group, it is still usefull to specify the group name to speed up the pace.
Note
If both neurons and group are None, all neurons will be modified.
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
# Number of neurons in this population.
-
syn_spec
# The properties of the synaptic connections between groups. Returns a
dict
containing tuples as keys and dicts of parameters as values.The keys are tuples containing the names of the groups in the population, with the projecting group first (presynaptic neurons) and the receiving group last (post-synaptic neurons).
Example
For a population of excitatory (“exc”) and inhibitory (“inh”) neurons.
syn_spec = { ("exc", "exc"): {'model': 'stdp_synapse', 'weight': 2.5}, ("exc", "inh"): {'model': 'static_synapse'}, ("exc", "inh"): {'model': 'stdp_synapse', 'delay': 5.}, ("inh", "inh"): { 'model': 'stdp_synapse', 'weight': 5., 'delay': ('normal', 5., 2.)} } }
New in version 0.8.
- has_models –