3.8. Projection

The module ANNarchy.Projection defines projections at the population level. A projection is an ensemble of connections (or synapses) between a subset of a population (called the pre-synaptic population) and a subset of another population (the post-synaptic population), with a specific connection type. The pre- and post-synaptic populations may be the same.

3.8.1. Class Projection

class ANNarchy.Projection(pre, post, target, synapse=None, name=None, copied=False)[source]

Represents all synapses of the same type between two populations.

Parameters:

  • pre: pre-synaptic population (either its name or a Population object).
  • post: post-synaptic population (either its name or a Population object).
  • target: type of the connection.
  • synapse: a Synapse instance.
  • name: unique name of the projection (optional).

By default, the synapse only ensures linear synaptic transmission:

  • For rate-coded populations: psp = w * pre.r
  • For spiking populations: g_target += w
connect_all_to_all(weights, delays=0.0, allow_self_connections=False, force_multiple_weights=False, storage_format='lil', storage_order='post_to_pre')

Builds an all-to-all connection pattern between the two populations.

Parameters:

  • weights: synaptic values, either a single value or a random distribution object.
  • delays: synaptic delays, either a single value or a random distribution object (default=dt).
  • allow_self_connections: if True, self-connections between a neuron and itself are allowed (default = False if the pre- and post-populations are identical, True otherwise).
  • force_multiple_weights: if a single value is provided for weights and there is no learning, a single weight value will be used for the whole projection instead of one per synapse. Setting force_multiple_weights to True ensures that a value per synapse will be used.

Additional Parameter:

  • storage_format: for some of the default connection patterns ANNarchy provide different storage formats. For all-to-all we support list-of-list (“lil”) or compressed sparse row (“csr”), by default lil is chosen.
  • storage_order: for some of the available storage formats ANNarchy provides different storage orderings. For all-to-all we support pre_to_post and post_to_pre, by default post_to_pre is chosen.

Please note, these arguments should be changed carefully, as they can have large impact on the computational performance of ANNarchy.

connect_dog(amp_pos, sigma_pos, amp_neg, sigma_neg, delays=0.0, limit=0.01, allow_self_connections=False)

Builds a Difference-Of-Gaussians connection pattern between the two populations.

Each neuron in the postsynaptic population is connected to a region of the presynaptic population centered around the neuron with the same normalized coordinates using a Difference-Of-Gaussians profile.

Parameters:

  • amp_pos: amplitude of the positive Gaussian function
  • sigma_pos: width of the positive Gaussian function
  • amp_neg: amplitude of the negative Gaussian function
  • sigma_neg: width of the negative Gaussian function
  • delays: synaptic delay, either a single value or a random distribution object (default=dt).
  • limit: proportion of amp below which synapses are not created (default: 0.01)
  • allow_self_connections: allows connections between a neuron and itself.
connect_fixed_number_post(number, weights=1.0, delays=0.0, allow_self_connections=False, force_multiple_weights=False)

Builds a connection pattern between the two populations with a fixed number of post-synaptic neurons.

Each neuron in the pre-synaptic population sends connections to a fixed number of neurons of the post-synaptic population chosen randomly.

Parameters:

  • number: number of synapses per pre-synaptic neuron.
  • weights: either a single value for all synapses or a RandomDistribution object.
  • delays: either a single value for all synapses or a RandomDistribution object (default = dt)
  • allow_self_connections : defines if self-connections are allowed (default=False)
  • force_multiple_weights: if a single value is provided for weights and there is no learning, a single weight value will be used for the whole projection instead of one per synapse. Setting force_multiple_weights to True ensures that a value per synapse will be used.
connect_fixed_number_pre(number, weights, delays=0.0, allow_self_connections=False, force_multiple_weights=False, storage_format='lil', storage_order='post_to_pre')

Builds a connection pattern between the two populations with a fixed number of pre-synaptic neurons.

Each neuron in the postsynaptic population receives connections from a fixed number of neurons of the presynaptic population chosen randomly.

Parameters:

  • number: number of synapses per postsynaptic neuron.
  • weights: either a single value for all synapses or a RandomDistribution object.
  • delays: either a single value for all synapses or a RandomDistribution object (default = dt)
  • allow_self_connections : defines if self-connections are allowed (default=False).
  • force_multiple_weights: if a single value is provided for weights and there is no learning, a single weight value will be used for the whole projection instead of one per synapse. Setting force_multiple_weights to True ensures that a value per synapse will be used.
connect_fixed_probability(probability, weights, delays=0.0, allow_self_connections=False, force_multiple_weights=False, storage_format='lil', storage_order='post_to_pre')

Builds a probabilistic connection pattern between the two populations.

Each neuron in the postsynaptic population is connected to neurons of the presynaptic population with the given probability. Self-connections are avoided by default.

Parameters:

  • probability: probability that a synapse is created.
  • weights: either a single value for all synapses or a RandomDistribution object.
  • delays: either a single value for all synapses or a RandomDistribution object (default = dt)
  • allow_self_connections : defines if self-connections are allowed (default=False).
  • force_multiple_weights: if a single value is provided for weights and there is no learning, a single weight value will be used for the whole projection instead of one per synapse. Setting force_multiple_weights to True ensures that a value per synapse will be used.
  • storage_format: for some of the default connection patterns ANNarchy provide different storage formats. For all-to-all we support list-of-list (“lil”) or compressed sparse row (“csr”), by default lil is chosen.
connect_from_file(filename)

Builds a connection pattern using data saved using the Projection.save_connectivity() method (not save()!).

Parameters:

  • filename: file where the data was saved.

Note

Only the ranks, weights and delays are loaded, not the other variables.

connect_from_matrix(weights, delays=0.0, pre_post=False)

Builds a connection pattern according to a dense connectivity matrix.

The matrix must be N*M, where N is the number of neurons in the post-synaptic population and M in the pre-synaptic one. Lists of lists must have the same size.

If a synapse should not be created, the weight value should be None.

Parameters:

  • weights: a matrix or list of lists representing the weights. If a value is None, the synapse will not be created.
  • delays: a matrix or list of lists representing the delays. Must represent the same synapses as weights. If the argument is omitted, delays are 0.
  • pre_post: states which index is first. By default, the first dimension is related to the post-synaptic population. If pre_post is True, the first dimension is the pre-synaptic population.
connect_from_sparse(weights, delays=0.0)

Builds a connectivity pattern using a Scipy sparse matrix for the weights and (optionally) delays.

Warning: a sparse matrix has pre-synaptic ranks as first dimension.

Parameters:

  • weights: a sparse lil_matrix object created from scipy.
  • delays: the value of the constant delay (default: dt).
connect_gaussian(amp, sigma, delays=0.0, limit=0.01, allow_self_connections=False)

Builds a Gaussian connection pattern between the two populations.

Each neuron in the postsynaptic population is connected to a region of the presynaptic population centered around the neuron with the same normalized coordinates using a Gaussian profile.

Parameters:

  • amp: amplitude of the Gaussian function
  • sigma: width of the Gaussian function
  • delays: synaptic delay, either a single value or a random distribution object (default=dt).
  • limit: proportion of amp below which synapses are not created (default: 0.01)
  • allow_self_connections: allows connections between a neuron and itself.
connect_one_to_one(weights=1.0, delays=0.0, shift=None, force_multiple_weights=False)

Builds a one-to-one connection pattern between the two populations.

Parameters:

  • weights: initial synaptic values, either a single value (float) or a random distribution object.
  • delays: synaptic delays, either a single value or a random distribution object (default=dt).
  • shift: obsolete, do not use.
  • force_multiple_weights: if a single value is provided for weights and there is no learning, a single weight value will be used for the whole projection instead of one per synapse. Setting force_multiple_weights to True ensures that a value per synapse will be used.
connect_with_func(method, **args)

Builds a connection pattern based on a user-defined method.

Parameters:

  • method: method to call. The method must return a CSR object.
  • args: list of arguments needed by the function
connectivity_matrix(fill=0.0)[source]

Returns a dense connectivity matrix (2D Numpy array) representing the connections between the pre- and post-populations.

The first index of the matrix represents post-synaptic neurons, the second the pre-synaptic ones.

If PopulationViews were used for creating the projection, the matrix is expanded to the whole populations by default.

Parameters:

  • fill: value to put in the matrix when there is no connection (default: 0.0).
dendrite(post)[source]

Returns the dendrite of a postsynaptic neuron according to its rank.

Parameters:

  • post: can be either the rank or the coordinates of the postsynaptic neuron
disable_learning(update=None)[source]

Disables learning for all synapses of this projection.

The effect depends on the rate-coded or spiking nature of the projection:

  • Rate-coded: the updating of all synaptic variables is disabled (including the weights w). This is equivalent to proj.update = False.
  • Spiking: the updating of the weights w is disabled, but all other variables are updated. This is equivalent to proj.plasticity = False.

This method is useful when performing some tests on a trained network without messing with the learned weights.

enable_learning(period=None, offset=None)[source]

Enables learning for all the synapses of this projection.

Parameters:

  • period determines how often the synaptic variables will be updated.
  • offset determines the offset at which the synaptic variables will be updated relative to the current time.

For example, providing the following parameters at time 10 ms:

enable_learning(period=10., offset=5.)

would call the updating methods at times 15, 25, 35, etc...

The default behaviour is that the synaptic variables are updated at each time step. The parameters must be multiple of dt

get(name)[source]

Returns a list of parameters/variables values for each dendrite in the projection.

The list will have the same length as the number of actual dendrites (self.size), so it can be smaller than the size of the postsynaptic population. Use self.post_ranks to indice it.

Parameters:

  • name: the name of the parameter or variable
load(filename)[source]

Loads the saved state of the projection.

Warning: Matlab data can not be loaded.

Parameters:

  • filename: the filename with relative or absolute path.

Example:

proj.load('proj1.txt')
receptive_fields(variable='w', in_post_geometry=True)[source]

Gathers all receptive fields within this projection.

Parameters:

  • variable: name of variable
  • in_post_geometry: if set to false, the data will be plotted as square grid. (default = True)
reset(attributes=-1, synapses=False)[source]

Resets all parameters and variables of the projection to the value they had before the call to compile.

Parameters:

  • attributes: list of attributes (parameter or variable) which should be reinitialized. Default: all attributes.

Note

Only parameters and variables are reinitialized, not the connectivity structure (including the weights and delays).

The parameter synapses will be used in a future release to also reinitialize the connectivity structure.

save(filename)[source]

Saves all information about the projection (connectivity, current value of parameters and variables) into a file.

  • If the extension is ‘.mat’, the data will be saved as a Matlab 7.2 file. Scipy must be installed.
  • If the extension ends with ‘.gz’, the data will be pickled into a binary file and compressed using gzip.
  • Otherwise, the data will be pickled into a simple binary text file using pickle.

Parameter:

  • filename: filename, may contain relative or absolute path.

Warning

The ‘.mat’ data will not be loadable by ANNarchy, it is only for external analysis purpose.

Example:

proj.save('proj1.txt')
save_connectivity(filename)[source]

Saves the projection pattern in a file.

Only the connectivity matrix, the weights and delays are saved, not the other synaptic variables.

The generated data should be used to create a projection in another network:

proj.connect_from_file(filename)

Parameters:

  • filename: file where the data will be saved.
set(value)[source]

Sets the parameters/variables values for each dendrite in the projection.

For parameters, you can provide:

  • a single value, which will be the same for all dendrites.
  • a list or 1D numpy array of the same length as the number of actual dendrites (self.size).

For variables, you can provide:

  • a single value, which will be the same for all synapses of all dendrites.
  • a list or 1D numpy array of the same length as the number of actual dendrites (self.size). The synapses of each postsynaptic neuron will take the same value.

Warning

It not possible to set different values to each synapse using this method. One should iterate over the dendrites:

for dendrite in proj.dendrites:
    dendrite.w = np.ones(dendrite.size)

Parameter:

  • value: a dictionary with the name of the parameter/variable as key.
start_creating(period=None)[source]

Starts creating the synapses in the projection if the synapse defines a ‘creating’ argument.

‘structural_plasticity’ must be set to True in setup().

Parameters:

  • period: how often creating should be evaluated (default: dt, i.e. each step)
start_pruning(period=None)[source]

Starts pruning the synapses in the projection if the synapse defines a ‘pruning’ argument.

‘structural_plasticity’ must be set to True in setup().

Parameters:

  • period: how often pruning should be evaluated (default: dt, i.e. each step)
stop_creating()[source]

Stops creating the synapses in the projection if the synapse defines a ‘creating’ argument.

‘structural_plasticity’ must be set to True in setup().

stop_pruning()[source]

Stops pruning the synapses in the projection if the synapse defines a ‘pruning’ argument.

‘structural_plasticity’ must be set to True in setup().

synapse(pre, post)[source]

Returns the synapse between a pre- and a post-synaptic neuron if it exists, None otherwise.

Parameters:

  • pre: rank of the pre-synaptic neuron.
  • post: rank of the post-synaptic neuron.
dendrites

Iteratively returns the dendrites corresponding to this projection.

nb_synapses

Total number of synapses in the projection.

size

Number of post-synaptic neurons receiving synapses.