Ex8: Adaptive Exponential IF

AdEx integrate-and-fire neuron with adaptation current — four variants

Model: AdEx (adExIaFCell)

Four variants: burst2, burst4, burstChaos (excitatory input), and rebound (inhibitory input).

Reference: NeuroML2 LEMS_NML2_Ex8_AdEx.xml


1. Define Network in TVBO

from tvbo import SimulationExperiment

exp = SimulationExperiment.from_string("""
label: "NeuroML Ex8: AdEx"
dynamics:
  name: adExBurst2
  iri: neuroml:adExIaFCell
network:
  dynamics:
    adExBurst2:
      name: adExBurst2
      iri: neuroml:adExIaFCell
      parameters:
        C: {value: 281, unit: pF}
        gL: {value: 30, unit: nS}
        EL: {value: -70.6, unit: mV}
        reset: {value: -48.5, unit: mV}
        VT: {value: -50.4, unit: mV}
        thresh: {value: -40.4, unit: mV}
        delT: {value: 2, unit: mV}
        tauw: {value: 40, unit: ms}
        a: {value: 4, unit: nS}
        b: {value: 0.08, unit: nA}
        refract: {value: 0, unit: ms}
    adExBurst4:
      name: adExBurst4
      iri: neuroml:adExIaFCell
      parameters:
        C: {value: 281, unit: pF}
        gL: {value: 30, unit: nS}
        EL: {value: -70.6, unit: mV}
        reset: {value: -47.2, unit: mV}
        VT: {value: -50.4, unit: mV}
        thresh: {value: -40.4, unit: mV}
        delT: {value: 2, unit: mV}
        tauw: {value: 40, unit: ms}
        a: {value: 4, unit: nS}
        b: {value: 0.08, unit: nA}
        refract: {value: 0, unit: ms}
    adExBurstChaos:
      name: adExBurstChaos
      iri: neuroml:adExIaFCell
      parameters:
        C: {value: 281, unit: pF}
        gL: {value: 30, unit: nS}
        EL: {value: -70.6, unit: mV}
        reset: {value: -48, unit: mV}
        VT: {value: -50.4, unit: mV}
        thresh: {value: -40.4, unit: mV}
        delT: {value: 2, unit: mV}
        tauw: {value: 40, unit: ms}
        a: {value: 4, unit: nS}
        b: {value: 0.08, unit: nA}
        refract: {value: 0, unit: ms}
    adExRebound:
      name: adExRebound
      iri: neuroml:adExIaFCell
      parameters:
        C: {value: 281, unit: pF}
        gL: {value: 30, unit: nS}
        EL: {value: -60, unit: mV}
        reset: {value: -51, unit: mV}
        VT: {value: -54, unit: mV}
        thresh: {value: -30, unit: mV}
        delT: {value: 2, unit: mV}
        tauw: {value: 150, unit: ms}
        a: {value: 200, unit: nS}
        b: {value: 0.1, unit: nA}
        refract: {value: 0, unit: ms}
    pulseGen1:
      name: pulseGen1
      iri: neuroml:pulseGenerator
      parameters:
        delay: {value: 0, unit: ms}
        duration: {value: 2000, unit: ms}
        amplitude: {value: 0.8, unit: nA}
    pulseGen2:
      name: pulseGen2
      iri: neuroml:pulseGenerator
      parameters:
        delay: {value: 150, unit: ms}
        duration: {value: 50, unit: ms}
        amplitude: {value: -0.5, unit: nA}
  nodes:
    - {id: 0, dynamics: adExBurst2}
    - {id: 1, dynamics: adExBurst4}
    - {id: 2, dynamics: adExBurstChaos}
    - {id: 3, dynamics: adExRebound}
    - {id: 10, dynamics: pulseGen1, record: false}
    - {id: 11, dynamics: pulseGen2, record: false}
  edges:
    - {source: 10, target: 0}
    - {source: 10, target: 1}
    - {source: 10, target: 2}
    - {source: 11, target: 3}
integration:
  method: euler
  step_size: 0.025
  duration: 300.0
  time_scale: ms
""")
print(f"Network dynamics: {list(exp.network.dynamics.keys())}")
Network dynamics: ['adExBurst2', 'adExBurst4', 'adExBurstChaos', 'adExRebound', 'pulseGen1', 'pulseGen2']
* Owlready2 * Warning: ignoring cyclic subclass of/subproperty of, involving:
  http://uri.interlex.org/tgbugs/uris/readable/atlas/Space

2. Render LEMS XML

xml = exp.render("lems")
print(xml[:2000])
<Lems>

  <!-- Tell jLEMS/jNeuroML which component is the simulation entry point. -->
  <Target component="sim_NeuroML_Ex8__AdEx"/>

  <!-- ════════════════════════════════════════════════════════════════
       Standard NeuroML2 type includes for network mode.
       Provides all standard dimensions, units, synapse types, input
       types, network infrastructure, and simulation types.
       ════════════════════════════════════════════════════════════════ -->
  <Include file="Cells.xml"/>
  <Include file="Networks.xml"/>
  <Include file="Simulation.xml"/>

  <!-- ════════════════════════════════════════════════════════════════
       Dynamics ComponentType & Component instances
       ════════════════════════════════════════════════════════════════ -->


  <!-- ── ComponentType: adExBurst2 ── -->
  <ComponentType name="adExBurst2" extends="baseCellMembPot">
    <Parameter name="C" dimension="capacitance"/>
    <Parameter name="EL" dimension="voltage"/>
    <Parameter name="VT" dimension="voltage"/>
    <Parameter name="a" dimension="conductance"/>
    <Parameter name="b" dimension="current"/>
    <Parameter name="delT" dimension="voltage"/>
    <Parameter name="gL" dimension="conductance"/>
    <Parameter name="refract" dimension="time"/>
    <Parameter name="reset" dimension="voltage"/>
    <Parameter name="tauw" dimension="time"/>
    <Parameter name="thresh" dimension="voltage"/>
    <Constant name="SEC" dimension="time" value="1ms"/>
    <!-- Dynamically attached synapses/inputs from network connections -->
    <Attachments name="synapses" type="basePointCurrent"/>

    <Dynamics>
      <!-- ── Flat dynamics ── -->
      <OnStart>
      </OnStart>
    </Dynamics>
  </ComponentType>

  <Component id="adExBurst2_inst" type="adExBurst2" C="281 pF" EL="-70.6 mV" VT="-50.4 mV" a="4 nS" b="0.08 nA" delT="2 mV" gL="30 nS" refract="0 ms" reset="-48.5 mV" tauw="40 ms" thresh="-40.4 mV"/>

  <!-- ── ComponentType: adExBurst4 ── -->
  <ComponentType name="adExBurst4" ex

3. Run Reference

from tvbo.adapters.neuroml import run_lems_example

ref_outputs = run_lems_example("LEMS_NML2_Ex8_AdEx.xml")
for name, arr in ref_outputs.items():
    print(f"  {name}: shape={arr.shape}")
  adEx_2burst.dat: shape=(12001, 3)
  adEx_4burst.dat: shape=(12001, 3)
  adEx_chaos.dat: shape=(12001, 3)
  adEx_rebound.dat: shape=(12001, 3)

4. Run TVBO

result = exp.run("neuroml")
da = result.integration.data
print(f"TVBO: {da.dims}, shape={da.shape}")
pyNeuroML >>> 13:07:42 - INFO - Loading LEMS file: tvbo_lems_sim.xml and running with jNeuroML
pyNeuroML >>> 13:07:42 - INFO - Executing: (java -Xmx400M  -Djava.awt.headless=true -jar  "/Users/leonmartin_bih/tools/tvbo/.venv/lib/python3.12/site-packages/pyneuroml/utils/./../lib/jNeuroML-0.14.0-jar-with-dependencies.jar"  tvbo_lems_sim.xml  -nogui -I '') in directory: /var/folders/ym/9kw1g21j1nd7kwfn8c0z3st40000gn/T/tmpefisiqi7
pyNeuroML >>> 13:07:43 - INFO - Command completed successfully!
TVBO: ('time', 'quantity'), shape=(12001, 4)

5. Compare & Plot

from tvbo.adapters.neuroml import plot_lems_comparison
plot_lems_comparison("LEMS_NML2_Ex8_AdEx.xml", ref_outputs, result.integration.data, title_prefix="Ex8")