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)
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
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
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")] )
] ports = [nineml.ReducePort("Isyn", op="+")] leaky_iaf = nineml.Component("deltaLIFid5", regimes=regimes, ports=ports) # delta jump synapses regimes = [ nineml.Regime( "dv/dt = -g*v", transitions=nineml.On(nineml.SpikeInputEvent, do="g+=W"), ) ] ports = [nineml.RecvPort("W"), nineml.SendPort("Isyn = dv/dt")] # can i even send dv/dt as a variable? delta_syn = nineml.Component("delta_jump_id5", regimes=regimes, ports=ports) # User layer connects # leaky_iaf.ports['V'] -> delta_syn.ports['V'] # delta_syn.ports['Isyn'] -> leaky_iaf.ports['Isyn'] for multiple synapses (reduce port) # Simulator attaches to SpikeInput and SpikeOutput ports for input and output. # write to file object f if defined c1 = leaky_iaf try: # This case is used in the test suite for examples. c1.write(f)
"do/dt = -o/tau_minus", "deps_r/dt = (1-eps_r)/tau_er", "deps_o/dt = (1-eps_o)/tau_eo", transitions=[nineml.On(nineml.PreEvent, do=["W -= R * A_minus * eps_r * o * (W - Wmin) / (Wmax - Wmin), "W = max(W,W_min)", "r += eps_r", "eps_r = 0.0", nineml.PreEventRelay]), nineml.On(nineml.PostEvent, do=["W += R*A_plus*eps_o*r*(Wmax-W)/(Wmax-Wmin)", "W = max(W,W_max)", "o += eps_o", "eps_o = 0.0"])] )] ports = [nineml.RecvPort("R"), nineml.SendPort("W")] c1 = nineml.Component("RmulSTDPid7", regimes=regimes, ports=ports) # write to file object f if defined try: # This case is used in the test suite for examples. c1.write(f) except NameError: import os base = "RmulSTDPid7" c1.write(base + ".xml") c2 = nineml.parse(base + ".xml") assert c1 == c2
ports = [nineml.SendPort("V"), nineml.ReducePort("Isyn", op="+")] leaky_iaf = nineml.Component("gLIFid8", regimes=regimes, ports=ports) # alpha conductances regimes = [ nineml.Regime( "dg_a/dt = -g_a/tau_a", "dg/dt = g_a - g/tau_a", transitions=nineml.On(nineml.SpikeInputEvent, do="g+=W"), ) ] ports = [ nineml.RecvPort("V"), nineml.RecvPort("W"), nineml.SendPort("Isyn = g(E-V)") ] coba_syn = nineml.Component("alpha_cond_id8", regimes=regimes, ports=ports) # User layer connects # leaky_iaf.ports['V'] -> coba_syn.ports['V'] # coba_syn.ports['Isyn'] -> leaky_iaf.ports['Isyn'] for multiple synapses (reduce port) # Simulator attaches to SpikeInput and SpikeOutput ports for input and output. # write to file object f if defined c1 = leaky_iaf try:
inter_event_regime = nineml.Regime(transitions=nineml.On( nineml.SpikeInputEvent, do=["pfire = W/N", "p = rand()"], to="probabilistic_regime"), name="inter_event_regime") probabilistic_regime = nineml.Regime(transitions=[ nineml.On("pfire >= p", do=nineml.SpikeInputEventRelay, to=inter_event_regime), nineml.On("pfire < p", to=inter_event_regime) ], name="probabilistic_regime") ports = [nineml.RecvPort("W")] # problems: assumes the presence of a decent rand function prob_input = nineml.Component( "prob_id8", regimes=[inter_event_regime, probabilistic_regime]) c1 = linear_poiss # write to file object f if defined try: # This case is used in the test suite for examples. c1.write(f) except NameError: import os base = "LPNid8" c1.write(base + ".xml")