def spiking_component_type_to_nineml(cls):
     """Return a 9ML ComponentClass describing the spike source model."""
     source = al.ComponentClass(
         name="poisson_spike_source",
         regimes=[
             al.Regime(
                 name="before",
                 transitions=[al.On("t > start",
                                    do=["t_spike = -1"],
                                    to="on")]),
             al.Regime(
                 name="on",
                 transitions=[al.On("t >= t_spike",
                                    do=["t_spike = t_spike + random.exponential(rate)",
                                        al.OutputEvent('spike_output')]),
                              al.On("t >= start + duration",
                                    to="after")],
             ),
             al.Regime(name="after")
         ],
         state_variables=[
             al.StateVariable('t_spike'), #, dimension='[T]'
         ],
         event_ports=[al.EventSendPort('spike_output'), ],
         parameters=['start', 'rate', 'duration'],  # add dimensions, or infer them from dimensions of variables
     )
     return source
 def spiking_component_type_to_nineml(cls):
     """Return a 9ML ComponentClass describing the neuron model."""
     iaf = al.ComponentClass(
         name="iaf_tau",
         regimes=[
             al.Regime(
                 name="subthreshold_regime",
                 time_derivatives=["dv/dt = (v_rest - v)/tau_m + (i_offset + i_syn)/cm"],
                 transitions=al.On("v > v_thresh",
                                   do=["t_spike = t",
                                       "v = v_reset",
                                       al.OutputEvent('spike_output')],
                                   to="refractory_regime"),
             ),  
             al.Regime(
                 name="refractory_regime",
                 time_derivatives=["dv/dt = 0"],
                 transitions=[al.On("t >= t_spike + tau_refrac",
                                    to="subthreshold_regime")],
             )
         ],
         state_variables=[
             al.StateVariable('v'), #, dimension='[V]' # '[V]' should be an alias for [M][L]^2[T]^-3[I]^-1
             al.StateVariable('t_spike'), #, dimension='[T]'
         ],
         analog_ports=[al.AnalogSendPort("v"),
                       al.AnalogReducePort("i_syn", reduce_op="+"), ],
         event_ports=[al.EventSendPort('spike_output'), ],
         parameters=['cm', 'tau_refrac', 'tau_m', 'v_reset', 'v_rest', 'v_thresh', 'i_offset']  # add dimensions, or infer them from dimensions of variables
                                                                                                # in fact, we should be able to infer what are the parameters, without listing them
     )
     return iaf
Ejemplo n.º 3
0
def get_Izh_FS_component():
    """
    Load Fast spiking Izhikevich XML definition from file and parse into
    Abstraction Layer of Python API.
    """
    izhi_fs = al.Dynamics(
        name='IzhikevichFS',
        parameters=[
            al.Parameter('a', un.per_time),
            al.Parameter('b', un.conductance / (un.voltage**2)),
            al.Parameter('c', un.voltage),
            al.Parameter('k', un.conductance / un.voltage),
            al.Parameter('Vr', un.voltage),
            al.Parameter('Vt', un.voltage),
            al.Parameter('Vb', un.voltage),
            al.Parameter('Vpeak', un.voltage),
            al.Parameter('Cm', un.capacitance)
        ],
        analog_ports=[
            al.AnalogReducePort('iSyn', un.current, operator="+"),
            al.AnalogReducePort('iExt', un.current, operator="+"),
            al.AnalogSendPort('U', un.current),
            al.AnalogSendPort('V', un.voltage)
        ],
        event_ports=[al.EventSendPort("spikeOutput")],
        state_variables=[
            al.StateVariable('V', un.voltage),
            al.StateVariable('U', un.current)
        ],
        regimes=[
            al.Regime('dU/dt = a * (b * pow(V - Vb, 3) - U)',
                      'dV/dt = V_deriv',
                      transitions=[
                          al.On('V > Vpeak',
                                do=['V = c',
                                    al.OutputEvent('spikeOutput')],
                                to='subthreshold')
                      ],
                      name="subthreshold"),
            al.Regime('dU/dt = - U * a',
                      'dV/dt = V_deriv',
                      transitions=[al.On('V > Vb', to="subthreshold")],
                      name="subVb")
        ],
        aliases=[
            "V_deriv := (k * (V - Vr) * (V - Vt) - U + iExt + iSyn) / Cm"
        ])  # @IgnorePep8
    return izhi_fs
 def spiking_component_type_to_nineml(cls):
     """Return a 9ML ComponentClass describing the spike source model."""
     source = al.ComponentClass(
         name="spike_source_array",
         regimes=[
             al.Regime(
                 name="on",
                 transitions=[al.On("t >= spike_times[i]",  # this is currently illegal
                                    do=["i = i + 1",
                                        al.OutputEvent('spike_output')])],
             ),
         ],
         state_variables=[
             al.StateVariable('t_spike'), #, dimension='[T]'
             al.StateVariable('i'), #, dimension='[T]'
         ],
         event_ports=[al.EventSendPort('spike_output'), ],
         parameters=['start', 'rate', 'duration'],  # add dimensions, or infer them from dimensions of variables
     )
     return source
Ejemplo n.º 5
0
        ),
        al.Regime(
            name="refractory",
            transitions=[al.On("t > refractory_end", to="subthreshold")],
        )
    ],
    state_variables=[
        al.StateVariable('v', dimension=voltage),
        al.StateVariable('refractory_end', dimension=time)
    ],
    analog_ports=[
        al.AnalogSendPort("v", dimension=voltage),
        al.AnalogSendPort("refractory_end", dimension=time),
        al.AnalogReducePort("i_synaptic", operator="+", dimension=current)
    ],
    event_ports=[
        al.EventSendPort('spike_output'),
    ],
    parameters=[
        al.Parameter('tau', time),
        al.Parameter('v_threshold', voltage),
        al.Parameter('refractory_period', time),
        al.Parameter('v_reset', voltage),
        al.Parameter('R', resistance)
    ])

if __name__ == "__main__":
    import nineml
    filename = __file__[0].upper() + __file__[1:].replace(".py", ".xml")
    nineml.write(model, filename)
Ejemplo n.º 6
0
"""

"""

import nineml.abstraction as al
from nineml.units import time

model = al.Dynamics(
    name="Tonic",
    regimes=[
        al.Regime(name="default",
                  transitions=al.On("t > t_next",
                                    do=[
                                        "t_next = t + interval",
                                        al.OutputEvent('spikeOutput')
                                    ]))
    ],
    event_ports=[al.EventSendPort('spikeOutput')],
    state_variables=[al.StateVariable('t_next', dimension=time)],
    parameters=[al.Parameter('interval', dimension=time)],
)

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