1. Define Izhikevich 2007 RS Cell in TVBO
from tvbo import SimulationExperiment
exp = SimulationExperiment.from_string("""
label: "NeuroML Ex16: Izhikevich 2007 RS with Pulse Input"
dynamics:
name: Izhikevich2007Cell
parameters:
C: { value: 100.0, description: "Capacitance (pF)" }
k: { value: 0.7, description: "nS/mV" }
vr: { value: -60.0, description: "Resting potential (mV)" }
vt: { value: -40.0, description: "Threshold potential (mV)" }
vpeak: { value: 35.0, description: "Peak voltage (mV)" }
a: { value: 0.03, description: "Recovery rate (1/ms)" }
b: { value: -2.0, description: "Recovery sensitivity (nS)" }
c: { value: -50.0, description: "Reset voltage (mV)" }
d: { value: 100.0, description: "Recovery increment (pA)" }
derived_variables:
I_ext:
equation:
rhs: "Piecewise((1000.0, (t >= 0.05) & (t < 0.25)), (0.0, True))"
description: "pulseGen0: delay=50ms, duration=200ms, amplitude=1nA=1000pA (times in SI seconds)"
state_variables:
v:
equation:
rhs: "(k*(v - vr)*(v - vt) + I_ext - u) / C"
initial_value: -60.0
variable_of_interest: true
u:
equation:
rhs: "a*(b*(v - vr) - u)"
initial_value: 0.0
events:
spike:
condition: { rhs: "v > vpeak" }
affect: { rhs: "v = c; u = u + d" }
network:
number_of_nodes: 1
integration:
method: euler
step_size: 0.001
duration: 300.0
time_scale: ms
""" )
print (f"Model: { exp. dynamics. name} " )
Model: Izhikevich2007Cell
2. Render LEMS XML
xml = exp.render("lems" )
print (xml[:1200 ])
<Lems>
<!-- Tell jLEMS/jNeuroML which component is the simulation entry point. -->
<Target component="sim_NeuroML_Ex16__Izhikevich_2007_RS_with_Pulse_Input"/>
<!-- ════════════════════════════════════════════════════════════════
Dimensions & Units (inline — no external includes needed)
════════════════════════════════════════════════════════════════ -->
<!-- Dimensions -->
<Dimension name="none"/>
<Dimension name="time" t="1"/>
<Dimension name="voltage" m="1" l="2" t="-3" i="-1"/>
<Dimension name="per_time" t="-1"/>
<Dimension name="conductance" m="-1" l="-2" t="3" i="2"/>
<Dimension name="capacitance" m="-1" l="-2" t="4" i="2"/>
<Dimension name="current" i="1"/>
<Dimension name="resistance" m="1" l="2" t="-3" i="-2"/>
<Dimension name="concentration" l="-3" n="1"/>
<Dimension name="substance" n="1"/>
<Dimension name="charge" t="1" i="1"/>
<Dimension name="temperature" k="1"/>
<!-- Units -->
<Unit symbol="s" dimension="time" power="0"/>
<Unit symbol="ms" dimension="time" power="-3"/>
<Unit symbol="us" dimension="time" power="-6"/>
<Unit symbol="V" dimension="voltage" power="0"/>
<Unit symbol="mV" dimension="voltage" powe
3. Run Reference
import sys, os
sys.path.insert(0 , os.path.dirname(os.path.abspath("." )))
from _nml_helpers import run_lems_example
ref_outputs = run_lems_example("LEMS_NML2_Ex16_Inputs.xml" )
for name, arr in ref_outputs.items():
print (f" { name} : shape= { arr. shape} " )
ex16_v.dat: shape=(300001, 11)
4. Run TVBO
import numpy as np
result = exp.run("neuroml" )
da = result.integration.data
tvbo_arr = np.column_stack([da.coords['time' ].values, da.values])
print (f"TVBO: shape= { tvbo_arr. shape} " )