Model: Izhikevich 2003
The Izhikevich (2003) model is a computationally efficient spiking neuron with four firing modes from different parameter sets.
Reference: NeuroML2 LEMS_NML2_Ex2_Izh.xml
1. Define Network in TVBO
from tvbo import SimulationExperiment
exp = SimulationExperiment.from_string("""
label: "NeuroML Ex2: Izhikevich"
dynamics:
name: izBurst
iri: neuroml:izhikevichCell
network:
dynamics:
izBurst:
name: izBurst
iri: neuroml:izhikevichCell
parameters:
v0: {value: -70, unit: mV}
thresh: {value: 30, unit: mV}
a: {value: 0.02}
b: {value: 0.2}
c: {value: -50}
d: {value: 2}
izTonic:
name: izTonic
iri: neuroml:izhikevichCell
parameters:
v0: {value: -70, unit: mV}
thresh: {value: 30, unit: mV}
a: {value: 0.02}
b: {value: 0.2}
c: {value: -65}
d: {value: 6}
izMixed:
name: izMixed
iri: neuroml:izhikevichCell
parameters:
v0: {value: -70, unit: mV}
thresh: {value: 30, unit: mV}
a: {value: 0.02}
b: {value: 0.2}
c: {value: -55}
d: {value: 4}
izClass1:
name: izClass1
iri: neuroml:izhikevichCell
parameters:
v0: {value: -60, unit: mV}
thresh: {value: 30, unit: mV}
a: {value: 0.02}
b: {value: -0.1}
c: {value: -55}
d: {value: 6}
i0:
name: i0
iri: neuroml:pulseGeneratorDL
parameters:
delay: {value: 22, unit: ms}
duration: {value: 2000, unit: ms}
amplitude: {value: 15}
i1:
name: i1
iri: neuroml:pulseGeneratorDL
parameters:
delay: {value: 20, unit: ms}
duration: {value: 2000, unit: ms}
amplitude: {value: 14}
i2:
name: i2
iri: neuroml:pulseGeneratorDL
parameters:
delay: {value: 20, unit: ms}
duration: {value: 2000, unit: ms}
amplitude: {value: 10}
rg0:
name: rg0
iri: neuroml:rampGeneratorDL
parameters:
delay: {value: 30, unit: ms}
duration: {value: 170, unit: ms}
startAmplitude: {value: -32}
finishAmplitude: {value: 50}
baselineAmplitude: {value: -32}
nodes:
- {id: 0, dynamics: izBurst}
- {id: 1, dynamics: izTonic}
- {id: 2, dynamics: izMixed}
- {id: 3, dynamics: izClass1}
- {id: 10, dynamics: i0, record: false}
- {id: 11, dynamics: i1, record: false}
- {id: 12, dynamics: i2, record: false}
- {id: 13, dynamics: rg0, record: false}
edges:
- {source: 10, target: 0}
- {source: 11, target: 1}
- {source: 12, target: 2}
- {source: 13, target: 3}
integration:
method: euler
step_size: 0.005
duration: 200.0
time_scale: ms
""")
print(f"Network dynamics: {list(exp.network.dynamics.keys())}")
Network dynamics: ['i0', 'i1', 'i2', 'izBurst', 'izClass1', 'izMixed', 'izTonic', 'rg0']
2. Render LEMS XML
xml = exp.render("lems")
print(xml[:2000])
<Lems>
<Target component="sim_NeuroML_Ex2__Izhikevich"/>
<Include file="Cells.xml"/>
<Include file="Networks.xml"/>
<Include file="Inputs.xml"/>
<Include file="Simulation.xml"/>
<izhikevichCell id="izBurst" a="0.02" b="0.2" c="-50" d="2" thresh="30 mV" v0="-70 mV"/>
<izhikevichCell id="izTonic" a="0.02" b="0.2" c="-65" d="6" thresh="30 mV" v0="-70 mV"/>
<izhikevichCell id="izMixed" a="0.02" b="0.2" c="-55" d="4" thresh="30 mV" v0="-70 mV"/>
<izhikevichCell id="izClass1" a="0.02" b="-0.1" c="-55" d="6" thresh="30 mV" v0="-60 mV"/>
<pulseGeneratorDL id="i0" amplitude="15.0" delay="22.0 ms" duration="2000.0 ms"/>
<pulseGeneratorDL id="i1" amplitude="14.0" delay="20.0 ms" duration="2000.0 ms"/>
<pulseGeneratorDL id="i2" amplitude="10.0" delay="20.0 ms" duration="2000.0 ms"/>
<rampGeneratorDL id="rg0" baselineAmplitude="-32.0" delay="30.0 ms" duration="170.0 ms" finishAmplitude="50.0" startAmplitude="-32.0"/>
<network id="net1">
<population id="izBurst_pop" component="izBurst" size="1"/>
<population id="izTonic_pop" component="izTonic" size="1"/>
<population id="izMixed_pop" component="izMixed" size="1"/>
<population id="izClass1_pop" component="izClass1" size="1"/>
<explicitInput target="izBurst_pop[0]" input="i0" destination="synapses"/>
<explicitInput target="izTonic_pop[0]" input="i1" destination="synapses"/>
<explicitInput target="izMixed_pop[0]" input="i2" destination="synapses"/>
<explicitInput target="izClass1_pop[0]" input="rg0" destination="synapses"/>
</network>
<Simulation id="sim_NeuroML_Ex2__Izhikevich" length="200.0ms" step="0.005ms" target="net1">
<OutputFile id="of0" fileName="results/izBurst.dat">
<OutputColumn id="izBurst_pop_0_v" quantity="izBurst_pop[0]/v"/>
</OutputFile>
<OutputFile id="of1" fileName="results/izTonic.dat">
<OutputColumn id="izTonic_pop_0_v" quantity="izTonic_
3. Run Reference
from tvbo.adapters.neuroml import run_lems_example
ref_outputs = run_lems_example("LEMS_NML2_Ex2_Izh.xml")
for name, arr in ref_outputs.items():
print(f" {name}: shape={arr.shape}")
auto.dat: shape=(40001, 10)
4. Run TVBO
result = exp.run("neuroml")
da = result.integration.data
print(f"TVBO: {da.dims}, shape={da.shape}")
TVBO: ('time', 'quantity'), shape=(40001, 4)
5. Compare & Plot
from tvbo.adapters.neuroml import plot_lems_comparison
plot_lems_comparison("LEMS_NML2_Ex2_Izh.xml", ref_outputs, result.integration.data, title_prefix="Ex2")