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
def create_leaky_integrate_and_fire(): dyn = al.Dynamics( name='LeakyIntegrateAndFire', regimes=[ al.Regime('dv/dt = (i_synaptic*R - v)/tau', transitions=[al.On('v > v_threshold', do=[al.OutputEvent('spike_output'), al.StateAssignment( 'refractory_end', 't + refractory_period'), al.StateAssignment('v', 'v_reset')], to='refractory')], name='subthreshold'), al.Regime(transitions=[al.On('t > refractory_end', to='subthreshold')], name='refractory')], state_variables=[al.StateVariable('v', dimension=un.voltage), al.StateVariable('refractory_end', dimension=un.time)], parameters=[al.Parameter('R', un.resistance), al.Parameter('refractory_period', un.time), al.Parameter('v_reset', un.voltage), al.Parameter('v_threshold', un.voltage), al.Parameter('tau', un.time)], analog_ports=[al.AnalogReducePort('i_synaptic', un.current, operator='+'), al.AnalogSendPort('refractory_end', un.time), al.AnalogSendPort('v', un.voltage)]) return dyn
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 create_izhikevich(): subthreshold_regime = al.Regime( name="subthreshold_regime", time_derivatives=[ "dV/dt = alpha*V*V + beta*V + zeta - U + Isyn / C_m", "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", un.voltage), al.AnalogReducePort("Isyn", un.current, operator="+") ] parameters = [ al.Parameter('theta', un.voltage), al.Parameter('a', un.per_time), al.Parameter('b', un.per_time), al.Parameter('c', un.voltage), al.Parameter('d', old_div(un.voltage, un.time)), al.Parameter('C_m', un.capacitance), al.Parameter('alpha', old_div(un.dimensionless, (un.voltage * un.time))), al.Parameter('beta', un.per_time), al.Parameter('zeta', old_div(un.voltage, un.time)) ] state_variables = [ al.StateVariable('V', un.voltage), al.StateVariable('U', old_div(un.voltage, un.time)) ] c1 = al.Dynamics(name="Izhikevich", parameters=parameters, state_variables=state_variables, regimes=[subthreshold_regime], analog_ports=ports) return c1
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
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] """ aeIF = al.Dynamics( name="aeIF", parameters=[ al.Parameter('C_m', un.capacitance), al.Parameter('g_L', un.conductance), al.Parameter('E_L', un.voltage), al.Parameter('Delta', un.voltage), al.Parameter('V_T', un.voltage), al.Parameter('S'), al.Parameter('trefractory', un.time), al.Parameter('tspike', un.time), al.Parameter('tau_w', un.time), al.Parameter('a', un.dimensionless / un.voltage), al.Parameter('b') ], state_variables=[ al.StateVariable('V', un.voltage), al.StateVariable('w') ], 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", # @IgnorePep8 "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", un.current, operator="+")]) return aeIF
""" import nineml.abstraction as al from nineml.units import voltage, time, resistance, current model = al.Dynamics( name="BrunelIaF", regimes=[ al.Regime( name="subthreshold", time_derivatives=["dv/dt = (-v + R*i_synaptic)/tau"], transitions=al.On("v > v_threshold", do=[ "refractory_end = t + refractory_period", "v = v_reset", al.OutputEvent('spike_output') ], to="refractory"), ), 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),
""" """ 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)