Skip to content

Neuron#

ANNarchy.core.Neuron.Neuron #

Base class to define a neuron.

Source code in ANNarchy/core/Neuron.py
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
class Neuron :
    """
    Base class to define a neuron.
    """
    # Default name and description for reporting
    _default_names = {'rate': "Rate-coded neuron", 'spike': "Spiking neuron"}

    def __init__(self, parameters="", equations="", spike=None, axon_spike=None, reset=None, axon_reset=None, refractory = None, functions=None, name="", description="", extra_values={} ):
        """
        :param parameters: parameters of the neuron and their initial value.
        :param equations: equations defining the temporal evolution of variables.
        :param functions: additional functions used in the variables' equations.
        :param spike: condition to emit a spike (only for spiking neurons).
        :param axon_spike: condition to emit an axonal spike (only for spiking neurons and optional). The axonal spike can appear additional to the spike and is independent from refractoriness of a neuron.
        :param reset: changes to the variables after a spike (only for spiking neurons).
        :param axon_reset: changes to the variables after an axonal spike (only for spiking neurons).
        :param refractory: refractory period of a neuron after a spike (only for spiking neurons).
        :param name: name of the neuron type (used for reporting only).
        :param description: short description of the neuron type (used for reporting).

        """

        # Store the parameters and equations
        self.parameters = parameters
        self.equations = equations
        self.functions = functions
        self.spike = spike
        self.axon_spike = axon_spike
        self.reset = reset
        self.axon_reset = axon_reset
        self.refractory = refractory
        self.extra_values = extra_values

        # Find the type of the neuron
        self.type = 'spike' if self.spike else 'rate'

        # Not available by now ...
        if axon_spike and config['paradigm'] != "openmp":
            _error("Axonal spike conditions are only available for openMP by now.")

        # Reporting
        if not hasattr(self, '_instantiated') : # User-defined
            _objects['neurons'].append(self)
        elif len(self._instantiated) == 0: # First instantiated of the class
            _objects['neurons'].append(self)
        self._rk_neurons_type = len(_objects['neurons'])

        if name:
            self.name = name
        else:
            self.name = self._default_names[self.type]

        if description:
            self.short_description = description
        else:
            self.short_description = "User-defined model of a spiking neuron." if self.type == 'spike' else "User-defined model of a rate-coded neuron."

        # Analyse the neuron type
        self.description = None

    def _analyse(self):
        # Analyse the neuron type
        if not self.description:
            self.description = analyse_neuron(self)

    def __repr__(self):
        if self.type == 'rate':
            text= """Rate-coded neuron.

Parameters:
""" + str(self.parameters) + """
Equations of the variables:
""" + str(self.equations) + """

"""
        else:
            text= """Spiking neuron.

Parameters:
""" + str(self.parameters) + """
Equations of the variables:
""" + str(self.equations) + """
Spiking condition:
""" + str(self.spike) + """
Axonal spiking condition:
""" + str(self.axon_spike) + """
Reset after a spike:
""" + str(self.reset)

        return text

__init__(parameters='', equations='', spike=None, axon_spike=None, reset=None, axon_reset=None, refractory=None, functions=None, name='', description='', extra_values={}) #

Parameters:

  • parameters

    parameters of the neuron and their initial value.

  • equations

    equations defining the temporal evolution of variables.

  • functions

    additional functions used in the variables' equations.

  • spike

    condition to emit a spike (only for spiking neurons).

  • axon_spike

    condition to emit an axonal spike (only for spiking neurons and optional). The axonal spike can appear additional to the spike and is independent from refractoriness of a neuron.

  • reset

    changes to the variables after a spike (only for spiking neurons).

  • axon_reset

    changes to the variables after an axonal spike (only for spiking neurons).

  • refractory

    refractory period of a neuron after a spike (only for spiking neurons).

  • name

    name of the neuron type (used for reporting only).

  • description

    short description of the neuron type (used for reporting).

Source code in ANNarchy/core/Neuron.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
def __init__(self, parameters="", equations="", spike=None, axon_spike=None, reset=None, axon_reset=None, refractory = None, functions=None, name="", description="", extra_values={} ):
    """
    :param parameters: parameters of the neuron and their initial value.
    :param equations: equations defining the temporal evolution of variables.
    :param functions: additional functions used in the variables' equations.
    :param spike: condition to emit a spike (only for spiking neurons).
    :param axon_spike: condition to emit an axonal spike (only for spiking neurons and optional). The axonal spike can appear additional to the spike and is independent from refractoriness of a neuron.
    :param reset: changes to the variables after a spike (only for spiking neurons).
    :param axon_reset: changes to the variables after an axonal spike (only for spiking neurons).
    :param refractory: refractory period of a neuron after a spike (only for spiking neurons).
    :param name: name of the neuron type (used for reporting only).
    :param description: short description of the neuron type (used for reporting).

    """

    # Store the parameters and equations
    self.parameters = parameters
    self.equations = equations
    self.functions = functions
    self.spike = spike
    self.axon_spike = axon_spike
    self.reset = reset
    self.axon_reset = axon_reset
    self.refractory = refractory
    self.extra_values = extra_values

    # Find the type of the neuron
    self.type = 'spike' if self.spike else 'rate'

    # Not available by now ...
    if axon_spike and config['paradigm'] != "openmp":
        _error("Axonal spike conditions are only available for openMP by now.")

    # Reporting
    if not hasattr(self, '_instantiated') : # User-defined
        _objects['neurons'].append(self)
    elif len(self._instantiated) == 0: # First instantiated of the class
        _objects['neurons'].append(self)
    self._rk_neurons_type = len(_objects['neurons'])

    if name:
        self.name = name
    else:
        self.name = self._default_names[self.type]

    if description:
        self.short_description = description
    else:
        self.short_description = "User-defined model of a spiking neuron." if self.type == 'spike' else "User-defined model of a rate-coded neuron."

    # Analyse the neuron type
    self.description = None