Side classes

class nngt.geometry.Shape(unit='um', parent=None)[source]

Class containing the shape of the area where neurons will be distributed to form a network.

..warning :
With this backup shape, only a rectangle or a disk can be created.
area

double – Area of the shape in mm^2.

centroid

tuple of doubles – Position of the center of mass of the current shape.

add_subshape(subshape, position, unit='um')[source]

Add a Shape to the current one.

Parameters:
  • subshape (Shape) – Subshape to add.
  • position (tuple of doubles) – Position of the subshape’s center of gravity in space.
  • unit (string (default ‘um’)) – Unit in the metric system among ‘um’, ‘mm’, ‘cm’, ‘dm’, ‘m’
area

Area of the shape.

centroid

Centroid of the shape.

coords
classmethod disk(radius, centroid=(0.0, 0.0), unit='um', parent=None)[source]

Generate a disk of given radius and center (centroid).

Parameters:
  • height (float) – Height of the rectangle.
  • width (float) – Width of the rectangle.
  • centroid (tuple of floats, optional (default: (0., 0.))) – Position of the rectangle’s center of mass.
  • unit (string (default: ‘um’)) – Unit in the metric system among ‘um’ (\(\mu m\)), ‘mm’, ‘cm’, ‘dm’, ‘m’.
  • parent (nngt.Graph or subclass) – The graph which is associated to this Shape.
Returns:

shape (Shape) – Rectangle shape.

geom_type
parent

Return the parent of the Shape.

classmethod rectangle(height, width, centroid=(0.0, 0.0), unit='um', parent=None)[source]

Generate a rectangle of given height, width and center of mass.

Parameters:
  • height (float) – Height of the rectangle.
  • width (float) – Width of the rectangle.
  • centroid (tuple of floats, optional (default: (0., 0.))) – Position of the rectangle’s center of mass.
  • unit (string (default: ‘um’)) – Unit in the metric system among ‘um’ (\(\mu m\)), ‘mm’, ‘cm’, ‘dm’, ‘m’.
  • parent (nngt.Graph or subclass) – The graph which is associated to this Shape.
Returns:

shape (Shape) – Rectangle shape.

seed_neurons(nodes=None)[source]

Return the positions of the neurons inside the Shape.

Parameters:
  • unit (string (default: None)) – Unit in which the positions of the neurons will be returned, among ‘um’, ‘mm’, ‘cm’, ‘dm’, ‘m’.
  • neurons (int, optional (default: None)) – Number of neurons to seed. This argument is considered only if the Shape has no parent, otherwise, a position is generated for each neuron in parent.
Returns:

positions (array of double with shape (N, 2))

set_parent(parent)[source]
unit

Return the unit for the Shape coordinates.

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, id_list)[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, parent=None, en_model='aeif_cond_alpha', en_param={}, es_model='static_synapse', es_param={}, in_model='aeif_cond_alpha', in_param={}, is_model='static_synapse', is_param={})[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).

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, parent=None, neuron_model='aeif_cond_alpha', neuron_param=None, syn_model='static_synapse', syn_param=None)[source]

Make a NeuralPop of identical neurons