Esempio n. 1
0
def get_Izh_component():
    subthreshold_regime = al.Regime(
        name="subthreshold_regime",
        time_derivatives=[
            "dV/dt = 0.04*V*V + 5*V + 140.0 - U + Isyn",
            "dU/dt = a*(b*V - U)",
        ],
        transitions=[
            al.On("V > theta",
                  do=[
                      "V = c",
                      "U =  U+ d",
                      al.OutputEvent('spike'),
                  ],
                  to='subthreshold_regime')
        ])

    ports = [
        al.AnalogSendPort("V"),
        al.AnalogReducePort("Isyn", reduce_op="+")
    ]

    c1 = al.DynamicsClass(name="Izhikevich",
                          regimes=[subthreshold_regime],
                          analog_ports=ports)
    return c1
Esempio n. 2
0
def get_aeIF_component():
    """
    Adaptive exponential integrate-and-fire neuron as described in
    A. Destexhe, J COmput Neurosci 27: 493--506 (2009)

    Author B. Kriener (Jan 2011)

    ## neuron model: aeIF

    ## variables:
    ## V: membrane potential
    ## w: adaptation variable

    ## parameters:
    ## C_m     # specific membrane capacitance [muF/cm**2]
    ## g_L     # leak conductance [mS/cm**2]
    ## E_L     # resting potential [mV]
    ## Delta   # steepness of exponential approach to threshold [mV]
    ## V_T     # spike threshold [mV]
    ## S       # membrane area [mum**2]
    ## trefractory # refractory time [ms]
    ## tspike  # spike time [ms]
    ## tau_w   # adaptation time constant
    ## a, b    # adaptation parameters [muS, nA]
    """
    parameters = [
        'C_m', 'g_L', 'E_L', 'Delta', 'V_T', 'S', 'trefractory', 'tspike',
        'tau_w', 'a', 'b'
    ]

    aeIF = al.DynamicsClass(
        "aeIF",
        regimes=[
            al.Regime(
                name="subthresholdregime",
                time_derivatives=[
                    "dV/dt = -g_L*(V-E_L)/C_m + Isyn/C_m + g_L*Delta*exp((V-V_T)/Delta-w/S)/C_m",
                    "dw/dt = (a*(V-E_L)-w)/tau_w",
                ],
                transitions=al.On(
                    "V > V_T",
                    do=["V = E_L", "w = w + b",
                        al.OutputEvent('spikeoutput')],
                    to="refractoryregime"),
            ),
            al.Regime(
                name="refractoryregime",
                transitions=al.On("t>=tspike+trefractory",
                                  to="subthresholdregime"),
            )
        ],
        analog_ports=[al.AnalogReducePort("Isyn", reduce_op="+")])

    return aeIF
Esempio n. 3
0
def get_HH_component():
    """A Hodgkin-Huxley single neuron model.
    Written by Andrew Davison.
    See http://phobos.incf.ki.se/src_rst/examples/examples_al_python.html#example-hh
    """
    aliases = [
        "q10 := 3.0**((celsius - 6.3)/10.0)",  # temperature correction factor
        "alpha_m := -0.1*(V+40.0)/(exp(-(V+40.0)/10.0) - 1.0)",  # m
        "beta_m := 4.0*exp(-(V+65.0)/18.0)",
        "mtau := 1/(q10*(alpha_m + beta_m))",
        "minf := alpha_m/(alpha_m + beta_m)",
        "alpha_h := 0.07*exp(-(V+65.0)/20.0)",  # h
        "beta_h := 1.0/(exp(-(V+35)/10.0) + 1.0)",
        "htau := 1.0/(q10*(alpha_h + beta_h))",
        "hinf := alpha_h/(alpha_h + beta_h)",
        "alpha_n := -0.01*(V+55.0)/(exp(-(V+55.0)/10.0) - 1.0)",  # n
        "beta_n := 0.125*exp(-(V+65.0)/80.0)",
        "ntau := 1.0/(q10*(alpha_n + beta_n))",
        "ninf := alpha_n/(alpha_n + beta_n)",
        "gna := gnabar*m*m*m*h",  #
        "gk := gkbar*n*n*n*n",
        "ina := gna*(ena - V)",  # currents
        "ik := gk*(ek - V)",
        "il := gl*(el - V )"
    ]

    hh_regime = al.Regime("dn/dt = (ninf-n)/ntau",
                          "dm/dt = (minf-m)/mtau",
                          "dh/dt = (hinf-h)/htau",
                          "dV/dt = (ina + ik + il + Isyn)/C",
                          transitions=al.On("V > theta",
                                            do=al.SpikeOutputEvent()))

    # the rest are not "parameters" but aliases, assigned vars, state vars,
    # indep vars, analog_analog_ports, etc.
    parameters = [
        'el', 'C', 'ek', 'ena', 'gkbar', 'gnabar', 'theta', 'gl', 'celsius'
    ]

    analog_ports = [
        al.AnalogSendPort("V"),
        al.AnalogReducePort("Isyn", reduce_op="+")
    ]

    c1 = al.DynamicsClass("HodgkinHuxley",
                          parameters=parameters,
                          regimes=(hh_regime, ),
                          aliases=aliases,
                          analog_ports=analog_ports)
    return c1
Esempio n. 4
0
model = al.DynamicsClass(
    name="BrunelIaF",
    regimes=[
        al.Regime(
            name="subthresholdRegime",
            time_derivatives=["dV/dt = (-V + R*Isyn)/tau"],
            transitions=al.On("V > theta",
                              do=[
                                  "t_rpend = t + tau_rp", "V = Vreset",
                                  al.OutputEvent('spikeOutput')
                              ],
                              to="refractoryRegime"),
        ),
        al.Regime(
            name="refractoryRegime",
            time_derivatives=["dV/dt = 0"],
            transitions=[
                al.On(
                    "t > t_rpend",
                    #do=[al.OutputEvent('refractoryEnd')],
                    to="subthresholdRegime")
            ],
        )
    ],
    state_variables=[
        al.StateVariable('V', dimension=voltage),
        al.StateVariable('t_rpend', dimension=time)
    ],
    analog_ports=[
        al.AnalogSendPort("V", dimension=voltage),
        al.AnalogSendPort("t_rpend", dimension=time),
        al.AnalogReducePort("Isyn", reduce_op="+", dimension=current)
    ],
    event_ports=[
        al.EventSendPort('spikeOutput'),
    ],
    parameters=[
        al.Parameter('tau', time),
        al.Parameter('theta', voltage),
        al.Parameter('tau_rp', time),
        al.Parameter('Vreset', voltage),
        al.Parameter('R', resistance)
    ])
Esempio n. 5
0
import nineml.abstraction_layer as al
from nineml.abstraction_layer.units import current

model = al.DynamicsClass(
    name="StaticConnection",
    regimes=[al.Regime(
        name="default",
        time_derivatives=["dweight/dt = 0"],
    )],
    state_variables=[
        al.StateVariable(
            'weight',
            dimension=current),  # would be nice to make this dimensionless
    ],
    analog_ports=[al.AnalogSendPort("weight", dimension=current)],
)

if __name__ == "__main__":
    from nineml.abstraction_layer.dynamics.writers import XMLWriter
    filename = __file__[0].upper() + __file__[1:].replace(".py", ".xml")
    XMLWriter.write(model, filename)
Esempio n. 6
0
"""

"""

import nineml.abstraction_layer as al
from nineml.abstraction_layer.units import time, per_time

model = al.DynamicsClass(
    name="Poisson",
    regimes=[
        al.Regime(name="default",
                  transitions=al.On(
                      "t > t_next",
                      do=[
                          "t_next = t + random.exponential(1000/rate)",
                          al.OutputEvent('spikeOutput')
                      ]))
    ],
    event_ports=[al.EventSendPort('spikeOutput')],
    state_variables=[al.StateVariable('t_next', dimension=time)],
    parameters=[
        al.Parameter('rate', dimension=per_time),
    ])

if __name__ == "__main__":
    from nineml.abstraction_layer.dynamics.writers import XMLWriter
    filename = __file__[0].upper() + __file__[1:].replace(".py", ".xml")
    XMLWriter.write(model, filename)
Esempio n. 7
0
import nineml.abstraction_layer as al
from nineml.abstraction_layer.units import current, time

model = al.DynamicsClass(
    name="AlphaPSR",
    aliases=["Isyn := A"],
    regimes=[
        al.Regime(
            name="default",
            time_derivatives=["dA/dt = B - A/tau_syn", "dB/dt = (-B)/tau_syn"],
            transitions=al.On(
                'spike', do=["B = B + q"]
            ),  # would be nice to allow constant quantities, so we could make q dimensionless
        )
    ],
    state_variables=[
        al.StateVariable('A', dimension=current),
        al.StateVariable('B', dimension=current),
    ],
    analog_ports=[
        al.AnalogSendPort("Isyn", dimension=current),
        al.AnalogSendPort("A", dimension=current),
        al.AnalogSendPort("B", dimension=current),
        al.AnalogReceivePort("q", dimension=current)
    ],
    parameters=[al.Parameter('tau_syn', dimension=time)])

if __name__ == "__main__":
    from nineml.abstraction_layer.dynamics.writers import XMLWriter
    filename = __file__[0].upper() + __file__[1:].replace(".py", ".xml")
    XMLWriter.write(model, filename)