Пример #1
0
def get_component():
# Leaky iaf
    regimes = [
        al.Regime(
            "dV/dt = (-gL*(V-vL) + Isyn)/C",
            transitions=al.On(
                "V>Vth", do=["tspike = t", "V = V_reset", al.OutputEvent('spikeoutput')], to="refractory-regime"),
            name="sub-threshold-regime"
        ),
        al.Regime(
            transitions=al.On("t >= tspike + trefractory", to="sub-threshold-regime"),
            name="refractory-regime"
        )]

    analog_ports = [al.SendPort("V"),
                    al.ReducePort("Isyn", reduce_op="+")]

    leaky_iaf = al.ComponentClass("LeakyIAF", regimes=regimes, analog_ports=analog_ports)

# ampa

    regimes = [
        al.Regime(
            "dg/dt = -g/tau",
            transitions=al.On(al.SpikeInputEvent, do="g+=q")
        )]

    analog_ports = [al.RecvPort("V"),
                    al.SendPort("Isyn = g(E-V)")]

    coba_syn = al.ComponentClass("CoBaSynapse", regimes=regimes, analog_ports=analog_ports)
Пример #2
0
 def _generate_cell_type_and_parameters(self, nineml_population):
     """
     Determine cell class from standardcell--catalog mapping and cellparams
     from nineml_population.prototype.parameters and standardcell.translations
     """
     neuron_model = nineml_population.prototype.definition.component
     neuron_namespace = _generate_variable_name(nineml_population.prototype.name)
     synapse_models = {}
     cell_params = {} # to be implemented
     if nineml_population.name in self.psr_map:
         for psr_component in self.psr_map[nineml_population.name]:
             synapse_models[_generate_variable_name(psr_component.name)] = psr_component.definition.component
     subnodes = {neuron_namespace: neuron_model}
     subnodes.update(synapse_models)
     combined_model = al.ComponentClass(name=_generate_variable_name(nineml_population.name),
                                        subnodes=subnodes)
     # now connect ports
     connections = []
     for source in [port for port in neuron_model.analog_ports if port.mode == 'send']:
         for synapse_name, syn_model in synapse_models.items():
             for target in [port for port in syn_model.analog_ports if port.mode == 'recv']:
                 connections.append(("%s.%s" % (neuron_namespace, source.name), "%s.%s" % (synapse_name, target.name)))
     for synapse_name, syn_model in synapse_models.items():
         for source in [port for port in syn_model.analog_ports if port.mode == 'send']:
             for target in [port for port in neuron_model.analog_ports if port.mode in ('recv, reduce')]:
                 connections.append(("%s.%s" % (synapse_name, source.name), "%s.%s" % (neuron_namespace, target.name)))
     #import pdb; pdb.set_trace()
     for connection in connections:
         combined_model.connect_ports(*connection)
     synapse_components = [self._nineml_module.CoBaSyn(namespace=name,  weight_connector='q') for name in synapse_models.keys()]
     celltype_cls = self._nineml_module.nineml_cell_type(
         combined_model.name, combined_model, synapse_components)
     cell_params, random_params = resolve_parameters(cell_params, self.random_distributions)
     return celltype_cls, cell_params, random_params
Пример #3
0
def get_component():
    subthreshold_regime = al.Regime(
        name="subthreshold_regime",
        time_derivatives=[
            "dV/dt = (g_L*(E_L-V) + g_sfa*(E_sfa-V) + g_rr*(E_rr-V) + Isyn)/C",
            "dg_sfa/dt = -g_sfa/tau_sfa",
            "dg_rr/dt = -g_rr/tau_rr",
        ],
        transitions=al.On("V> theta",
                          do=["g_sfa =g_sfa +  q_sfa", "g_rr =g_rr + q_rr", "t_spike = t",
                              al.OutputEvent('spikeoutput')],
                          to="refractory_regime"),
    )

    refractory_regime = al.Regime(
        name="refractory_regime",
        transitions=al.On("t >= t_spike + t_ref",
                          to='subthreshold_regime'),
    )

    analog_ports = [al.SendPort("V"),
                    al.ReducePort("Isyn", reduce_op="+")]

    c1 = al.ComponentClass("iaf_sfa_relref",
                           regimes=[subthreshold_regime, refractory_regime],
                           analog_ports=analog_ports,
                           )

    return c1
Пример #4
0
def get_component():

    parameters = [
        'C_m', 'g_L', 'E_L', 'Delta', 'V_T', 'S', 'tau_ref', 'tau_w', 'a', 'b'
    ]

    aeIF = al.ComponentClass(
        "aeIF",
        regimes=[
            al.Regime(
                name="subthresholdregime",
                time_derivatives=[
                    "dV/dt = -g_L*(V-E_L)/C_m + g_L*Delta*exp((V-V_T)/Delta-w/S)/C_m+ Isyn/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.ReducePort("Isyn", reduce_op="+")])

    return aeIF
Пример #5
0
def get_hh_na():
    hh_na = al.ComponentClass(
        name="Hodgkin-Huxley-Na",
        dynamicsblock=DynamicsBlock(
            regimes=[
                al.Regime(name="hh_regime_na",
                          time_derivatives=[
                              "dm/dt = (minf(V)-m)/mtau(V)",
                              "dh/dt = (hinf(V)-h)/htau(V)"
                          ])
            ],
            aliases=[
                "q10 := 3.0**((celsius - 6.3)/10.0)",
                "alpha_m := -0.1*(V+40.0)/(exp(-(V+40.0)/10.0) - 1.0)",
                "beta_m := 4.0*exp(-(V+65.0)/18.0)",
                "mtau := 1/(q10*(alpha_m(V) + beta_m(V)))",
                "minf := alpha_m(V)/(alpha_m(V) + beta_m(V))",
                "alpha_h := 0.07*exp(-(V+65.0)/20.0)",
                "beta_h := 1.0/(exp(-(V+35)/10.0) + 1.0)",
                "htau := 1.0/(q10*(alpha_h(V) + beta_h(V)))",
                "hinf := alpha_h(V)/(alpha_h(V) + beta_h(V))",
                "gna := gnabar*m*m*m*h",
                "i := gna * (ena-V)",
            ],
            state_variables=[StateVariable('m'),
                             StateVariable('h')],
        ),
        analog_ports=[SendPort("i"), RecvPort("V")],
    )
Пример #6
0
def get_component():
    subthreshold_regime = al.Regime(
        name="subthreshold_regime",
        time_derivatives=[
            "dV/dt = (-gL*(V-vL) + Isyn)/C",
        ],
        transitions=[
            al.On("V> theta",
                  do=[
                      "t_spike = t", "V = V_reset",
                      al.OutputEvent('spikeoutput')
                  ],
                  to="refractory_regime")
        ],
    )

    refractory_regime = al.Regime(
        transitions=[al.On("t >= t_spike + t_ref", to='subthreshold_regime')],
        name="refractory_regime")

    analog_ports = [al.SendPort("V"), al.ReducePort("Isyn", reduce_op="+")]

    c1 = al.ComponentClass("LeakyIAF",
                           regimes=[subthreshold_regime, refractory_regime],
                           analog_ports=analog_ports)

    return c1
Пример #7
0
def get_component():
    inter_event_regime = al.Regime(
        name="intereventregime",
        time_derivatives=["dA/dt = -A/taur", "dB/dt = -B/taud"],
        transitions=[
            al.On('spikeinput',
                  do=["A = A + weight*factor", "B = B + weight*factor"])
        ])

    dynamicsblock = al.DynamicsBlock(
        aliases=[
            "taupeak := taur*taud/(taud - taur)*log(taud/taur)",
            "factor := 1/(exp(-taupeak/taud) - exp(-taupeak/taur))",
            "gB := 1/(1 + mgconc*exp(-1*gamma*V)/beta)",
            "g := gB*gmax*(B-A)",
            "I := g * df",
            "df := (E-V)",
        ],
        state_variables=[al.StateVariable(o) for o in ('A', 'B')],
        regimes=[inter_event_regime],
    )

    nmda = al.ComponentClass(name="NMDAPSR",
                             dynamicsblock=dynamicsblock,
                             analog_ports=[
                                 al.RecvPort("V"),
                                 al.SendPort("I"),
                             ],
                             event_ports=[al.RecvEventPort('spikeinput')],
                             parameters=[
                                 'taur', 'taud', 'gmax', 'mgconc', 'gamma',
                                 'beta', 'E', 'weight'
                             ])

    return nmda
Пример #8
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.ComponentClass(
        "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.ReducePort("Isyn", reduce_op="+")])

    return aeIF
Пример #9
0
def get_component():
    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.SendPort("V"), al.ReducePort("Isyn", reduce_op="+")]

    c1 = al.ComponentClass("HodgkinHuxley",
                           parameters=parameters,
                           regimes=(hh_regime, ),
                           aliases=aliases,
                           analog_ports=analog_ports)
    return c1
Пример #10
0
def get_component():
    regimes = [
        al.Regime(
            name="sub_threshold_regime",
            time_derivatives=[
                "dV/dt = (v_rest - V)/tau_m + (gE*(e_rev_E - V) + gI*(e_rev_I - V) + i_offset)/cm",
                "dgE/dt = -gE/tau_syn_E",
                "dgI/dt = -gI/tau_syn_I",
            ],
            transitions=(
                al.On("V > v_thresh",
                      do=[
                          "t_spike = t", "V = v_reset",
                          al.OutputEvent('spikeoutput')
                      ],
                      to="refractory_regime"),
                al.On('excitatory', do="gE=gE+q"),
                al.On('inhibitory', do="gI=gI+q"),
            ),
        ),
        al.Regime(
            name="refractory_regime",
            time_derivatives=[
                "dgE/dt = -gE/tau_syn_E",
                "dgI/dt = -gI/tau_syn_I",
            ],
            transitions=(
                al.On("t >= t_spike + tau_refrac", to="sub_threshold_regime"),
                al.On('excitatoryspike', do="gE=gE+q"),
                al.On('inhibitoryspike', do="gI=gI+q"),
            ),
        )
    ]

    analog_ports = [
        al.SendPort("V"),
        al.SendPort("gE"),
        al.SendPort("gI"),
        al.RecvPort("q")
    ]

    c1 = al.ComponentClass("IF_cond_exp",
                           regimes=regimes,
                           analog_ports=analog_ports)
    return c1
Пример #11
0
def get_component():
    regimes = [
        al.Regime(
            name='defaultregime',
            time_derivatives=[
                "dR/dt = (1-R)/tau_r",  # tau_r is the recovery time constant for depression
                "du/dt = -(u-U)/tau_f",  # tau_f is the time constant of facilitation
            ],
            transition=al.On(
                'spikeoutput',
                do=[
                    "Wout = u*R*Win", "R = R -  u*R", "u = u + U*(1-u)",
                    al.PreEventRelay
                ])  # Should I put a OutputEvent('spikeoutput') here?
        )
    ]

    analog_ports = [al.SendPort("Wout")]

    c1 = al.ComponentClass("MarkramSynapseDynamics",
                           regimes=regimes,
                           analog_ports=analog_ports)
Пример #12
0
def get_component():
    regimes = [
        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('spikeoutput')])
            ],
        )
    ]

    analog_ports = [al.SendPort("V"), al.ReducePort("Isyn", reduce_op="+")]

    c1 = al.ComponentClass("Izhikevich",
                           regimes=regimes,
                           analog_ports=analog_ports)
    return c1
Пример #13
0
import nineml.abstraction_layer as al

cond_decay = al.Regime(name='default',
                       time_derivatives=["dg/dt = -g/tau"],
                       transitions=[al.On(al.InputEvent('spikeinput'), do="g = g + q")]
                       )


coba_syn = al.ComponentClass(
    name="CoBaSynapse",
    dynamics=al.DynamicsBlock(
        regimes=[cond_decay],
        aliases=["I := g*(E-V)"],
    ),
    analog_ports=[al.RecvPort("V"), al.SendPort("I")]
)
Пример #14
0
import nineml.abstraction_layer as al

# Define a single regime, and specify the differential equations,
# and a transition when we reach spiking threshold:
regime = al.Regime(
    name='defaultregime',
    time_derivatives=[
        'dV/dt = 0.04*V*V + 5*V + 140 -U + I', 'dU/dt = a*(b*V - U)'
    ],
    transitions=[
        al.On('V > a',
              do=['V = c', 'U = U + d ',
                  al.OutputEvent('spikeoutput')])
    ])

# Create the ComponentClass, including the dynamics.
iz = al.ComponentClass(name="IzikevichNeuron",
                       parameters=['a', 'b', 'c', 'd'],
                       analog_ports=[
                           al.AnalogPort('I', mode='recv'),
                           al.AnalogPort('V', mode='send')
                       ],
                       event_ports=[al.EventPort('spikeoutput', mode='send')],
                       dynamicsblock=al.DynamicsBlock(
                           regimes=[regime], state_variables=['V', 'U']))
Пример #15
0
import nineml.abstraction_layer as al

iz = al.ComponentClass(
    name="IzikevichNeuron",
    parameters=['a', 'b', 'c', 'd'],
    analog_ports=[
        al.AnalogPort('I', mode='recv'),
        al.AnalogPort('V', mode='send')
    ],
    event_ports=[al.EventPort('spikeoutput', mode='send')],
)
import nineml.abstraction_layer as al
r1 = al.Regime(
    name="sub-threshold-regime",
    time_derivatives=["dV/dt = (-gL*(V-vL) + I)/C", ],
    transitions=[al.On("V>Vth",
                       do=["tspike = t",
                           "V = V_reset",
                           al.OutputEvent('spike')],
                 to="refractory-regime"), ],
)

r2 = al.Regime(name="refractory-regime",
               transitions=[al.On("t >= tspike + trefractory",
                                  to="sub-threshold-regime"), ],
               )

leaky_iaf = al.ComponentClass("LeakyIAF",
                              dynamicsblock=al.DynamicsBlock(
                              regimes=[r1, r2],
                              state_variables=['V', 'tspike'],

                              ),
                              analog_ports=[al.AnalogPort("I", mode='recv')],
                              parameters=['C', 'V_reset', 'Vth', 'gL', 't', 'trefractory', 'vL'],
                              )


leaky_iaf.write("leaky_iaf.xml")