3.6. Population¶
A Population
object represents a group of identical neurons. It is associated with a geometry (defining the number of neurons and optionally its spatial structure), a neuron type and optionally a name.

class
ANNarchy.
Population
(geometry, neuron, name=None, stop_condition=None, storage_order='post_to_pre', copied=False)[source]¶ Container for a population of homogeneous neurons.
Parameters:  geometry – population geometry as tuple. If an integer is given, it is the size of the population.
 neuron – instance of
ANNarchy.Neuron
. It can be userdefined or a builtin model.  name – unique name of the population (optional, it defaults to
pop0
,pop1
, etc).  stop_condition – a single condition on a neural variable which can stop the simulation whenever it is true.
Example:
pop = Population(100, neuron=Izhikevich, name="Excitatory population")

clear
()[source]¶ Clears all spiking events previously emitted (history of spikes, delayed spikes).
Can be useful if you do not want to totally reset a population (i.e. all variables), only to clear the spiking history between two trials.
Note: does nothing for ratecoded networks.

compute_firing_rate
(window)[source]¶ Tells spiking neurons in the population to compute their mean firing rate over the given window and store the values in the variable r.
This method has an effect on spiking neurons only.
If this method is not called, r will always be 0.0. r can of course be accessed and recorded as any other variable.
Parameters: window – window in ms over which the spikes will be counted.

coordinates_from_rank
(rank)[source]¶ Returns the coordinates of a neuron based on its rank.
Parameters: rank – rank of the neuron.

disable
()[source]¶ Temporarily disables computations in this population (including the projections leading to it).
You can reenable it with the
enable()
method.

enable
()[source]¶ (Re)enables computations in this population, after they were disabled by the
disable()
method.The status of the population is accessible through the
enabled
flag.

get
(name)[source]¶ Returns the value of neural variables and parameters.
Parameters: name – attribute name as a string.

load
(filename)[source]¶ Load the saved state of the population by Population.save().
Warning: Matlab data can not be loaded.
Parameters: filename – the filename with relative or absolute path. Example:
pop.load('pop1.npz') pop.load('pop1.txt') pop.load('pop1.txt.gz')

neuron
(*coord)[source]¶ Returns an
IndividualNeuron
object wrapping the neuron with the provided rank or coordinates.

normalized_coordinates_from_rank
(rank, norm=1.0)[source]¶ Returns normalized coordinates of a neuron based on its rank. The geometry of the population is mapped to the hypercube [0, 1]^d.
Parameters:  rank – rank of the neuron
 norm – norm of the cube (default = 1.0)

rank_from_coordinates
(coord)[source]¶ Returns the rank of a neuron based on coordinates.
Parameters: coord – coordinate tuple, can be multidimensional.

reset
(attributes=1)[source]¶ Resets all parameters and variables of the population 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.

save
(filename)[source]¶ Saves all information about the population (structure, current value of parameters and variables) into a file.
 If the file name is ‘.npz’, the data will be saved and compressed using np.savez_compressed (recommended).
 If the file name ends with ‘.gz’, the data will be pickled into a binary file and compressed using gzip.
 If the file name is ‘.mat’, the data will be saved as a Matlab 7.2 file. Scipy must be installed.
 Otherwise, the data will be pickled into a simple binary text file using pickle.
Parameters: 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:
pop.save('pop1.npz') pop.save('pop1.txt') pop.save('pop1.txt.gz') pop.save('pop1.mat')

set
(values)[source]¶ Sets the value of neural variables and parameters.
Parameters: values – dictionary of attributes to be updated. Example:
set({ ‘tau’ : 20.0, ‘r’= np.random.rand((8,8)) } )

size_in_bytes
()[source]¶ Returns the size of allocated memory on the C++ side. Please note that this does not contain monitored data and works only if compile() was invoked.

sum
(target)[source]¶ Returns the array of weighted sums corresponding to the target:
excitatory = pop.sum('exc')
For spiking networks, this is equivalent to accessing the conductances directly:
excitatory = pop.g_exc
If no incoming projection has the given target, the method returns zeros.
Parameters: target – the desired projection target. Note: it is not possible to distinguish the original population when the same target is used.

neurons
¶ Returns iteratively each neuron in the population.
For instance, if you want to iterate over all neurons of a population:
for neuron in pop.neurons: neuron.r = 0.0
Alternatively, one could also benefit from the
__iter__
special command. The following code is equivalent:for neuron in pop: neuron.r = 0.0