Interoperability · NeuroML / LEMS
Model: Q10 Temperature Dependence
Demonstrates how ion channel rate constants scale with temperature using the Q10 coefficient: \(k(T) = k(T_{\text{ref}}) \cdot Q_{10}^{(T - T_{\text{ref}})/10}\) .
At network temperature \(T = 22°C\) with \(T_{\text{ref}} = 32°C\) and \(Q_{10} = 3\) :
\[\text{factor} = 3^{(22 - 32)/10} = 3^{-1} \approx 0.333\]
All gating rates are slowed by a factor of 3 compared to reference temperature. The cell is otherwise standard HH with the same conductances as Ex1/Ex5.
1. Define in TVBO
from tvbo import SimulationExperiment
# Q10 factor = 3^((22-32)/10) = 1/3
# All standard HH rates multiplied by Q10_factor = 0.3333
# Same conductances as Ex1/Ex5: g_Na=1200nS, g_K=360nS, g_L=3nS, C=10pF
exp = SimulationExperiment.from_string("""
label: "NeuroML Ex10: Q10 Temperature Dependence"
dynamics:
name: HodgkinHuxley_Q10
iri: neuroml:pointCellCondBased
description: >
HH cell with Q10 temperature scaling on all gates.
Network at 22°C, experimental temp 32°C → Q10 = 3^(-1) ≈ 0.333.
parameters:
C: { value: 10, unit: pF }
v0: { value: -65, unit: mV }
thresh: { value: 20, unit: mV }
pulse_delay: { value: 100, unit: ms }
pulse_duration: { value: 100, unit: ms }
I_amp: { value: 0.08, unit: nA }
network_temperature: { value: 22, unit: degC }
components:
passive:
name: passive
iri: neuroml:ionChannelPassive
parameters:
conductance: { value: 10, unit: pS }
number: { value: 300 }
erev: { value: -54.3, unit: mV }
na:
name: na
iri: neuroml:ionChannelHH
parameters:
conductance: { value: 10, unit: pS }
number: { value: 120000 }
erev: { value: 50, unit: mV }
components:
m:
name: m
iri: neuroml:gateHHrates
parameters:
instances: { value: 3 }
components:
q10Settings:
name: q10Settings
iri: neuroml:q10ExpTemp
parameters:
q10Factor: { value: 3 }
experimentalTemp: { value: 32, unit: degC }
forwardRate:
name: forwardRate
iri: neuroml:HHExpLinearRate
parameters:
rate: { value: 1, unit: per_ms }
midpoint: { value: -40, unit: mV }
scale: { value: 10, unit: mV }
reverseRate:
name: reverseRate
iri: neuroml:HHExpRate
parameters:
rate: { value: 4, unit: per_ms }
midpoint: { value: -65, unit: mV }
scale: { value: -18, unit: mV }
h:
name: h
iri: neuroml:gateHHrates
parameters:
instances: { value: 1 }
components:
q10Settings:
name: q10Settings
iri: neuroml:q10ExpTemp
parameters:
q10Factor: { value: 3 }
experimentalTemp: { value: 32, unit: degC }
forwardRate:
name: forwardRate
iri: neuroml:HHExpRate
parameters:
rate: { value: 0.07, unit: per_ms }
midpoint: { value: -65, unit: mV }
scale: { value: -20, unit: mV }
reverseRate:
name: reverseRate
iri: neuroml:HHSigmoidRate
parameters:
rate: { value: 1, unit: per_ms }
midpoint: { value: -35, unit: mV }
scale: { value: 10, unit: mV }
k:
name: k
iri: neuroml:ionChannelHH
parameters:
conductance: { value: 10, unit: pS }
number: { value: 36000 }
erev: { value: -77, unit: mV }
components:
n:
name: n
iri: neuroml:gateHHrates
parameters:
instances: { value: 4 }
components:
q10Settings:
name: q10Settings
iri: neuroml:q10ExpTemp
parameters:
q10Factor: { value: 3 }
experimentalTemp: { value: 32, unit: degC }
forwardRate:
name: forwardRate
iri: neuroml:HHExpLinearRate
parameters:
rate: { value: 0.1, unit: per_ms }
midpoint: { value: -55, unit: mV }
scale: { value: 10, unit: mV }
reverseRate:
name: reverseRate
iri: neuroml:HHExpRate
parameters:
rate: { value: 0.125, unit: per_ms }
midpoint: { value: -65, unit: mV }
scale: { value: -80, unit: mV }
integration:
step_size: 0.01
duration: 300.0
time_scale: ms
""" )
print (f"Model: { exp. dynamics. name if exp. dynamics else 'network' } " )
print (f"Q10 scaling: rates × { 1 / 3 :.4f} " )
Model: HodgkinHuxley_Q10
Q10 scaling: rates × 0.3333
2. Render LEMS XML
xml = exp.render("lems" )
print (xml[:1500 ])
<Lems>
<!-- Tell jLEMS/jNeuroML which component is the simulation entry point. -->
<Target component="sim_NeuroML_Ex10__Q10_Temperature_Dependence"/>
<Include file="Cells.xml"/>
<Include file="Networks.xml"/>
<Include file="Simulation.xml"/>
<!-- ════════════════════════════════════════════════════════════════
Dynamics ComponentType & Component instances
════════════════════════════════════════════════════════════════ -->
<!-- ════════════════════════════════════════════════════════════════
ComponentType: HodgkinHuxley_Q10
Generated from TVBO Dynamics: HodgkinHuxley_Q10
════════════════════════════════════════════════════════════════ -->
<ComponentType name="HodgkinHuxley_Q10">
<!-- Parameters -->
<Parameter name="C" dimension="capacitance"/>
<Parameter name="I_amp" dimension="current"/>
<Parameter name="network_temperature" dimension="none"/>
<Parameter name="pulse_delay" dimension="time"/>
<Parameter name="pulse_duration" dimension="time"/>
<Parameter name="thresh" dimension="voltage"/>
<Parameter name="v0" dimension="voltage"/>
<!-- Coupling inputs -->
<!-- Initial condition parameters -->
<!-- Time conversion for derivatives.
When all parameters and state variables carry proper LEMS dimensions,
LEMS handles unit conversion natively (e.g. tau="30 ms" → 0.03 s).
No SEC constant is needed and TimeDerivatives use the RHS directly.
When dimen
3. Run Reference
from tvbo.adapters.neuroml import run_lems_example
ref_outputs = run_lems_example("LEMS_NML2_Ex10_Q10.xml" )
for name, arr in ref_outputs.items():
print (f" { name} : shape= { arr. shape} " )
hhq10_v.dat: shape=(30001, 2)
4. Run TVBO Version
result = exp.run("neuroml" )
da = result.integration.data
print (f"TVBO: { da. dims} , shape= { da. shape} " )
pyNeuroML >>> 16:40:21 - INFO - Loading LEMS file: tvbo_lems_sim.xml and running with jNeuroML
pyNeuroML >>> 16:40:21 - 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/tmp7gjbkly5
pyNeuroML >>> 16:40:22 - INFO - Command completed successfully!
TVBO: ('time', 'variable'), shape=(30001, 1)
5. Compare & Plot
from tvbo.adapters.neuroml import plot_lems_comparison
plot_lems_comparison("LEMS_NML2_Ex10_Q10.xml" , ref_outputs, result.integration.data, title_prefix= "Ex10" )