Interoperability · NeuroML / LEMS
Model: Short-Term Plasticity Synapses
A passive cell receives spikes via three synapse types: 1. expTwoSynapse — no plasticity (control) 2. blockingPlasticSynapse with tsodyksMarkramDepMechanism — depression only 3. blockingPlasticSynapse with tsodyksMarkramDepFacMechanism — depression + facilitation
Reference: NeuroML2 LEMS_NML2_Ex7_STP.xml
1. Define Network in TVBO
from tvbo import SimulationExperiment
exp = SimulationExperiment.from_string("""
label: "NeuroML Ex7: STP Synapses"
network:
dynamics:
passiveCell:
name: passiveCell
iri: neuroml:cell
parameters:
diameter: {value: 17.841242}
specificCapacitance: {value: 1.0, unit: uF_per_cm2}
initMembPotential: {value: -65, unit: mV}
spikeThresh: {value: -20, unit: mV}
resistivity: {value: 0.03, unit: kohm_cm}
components:
passiveChan:
name: passiveChan
iri: neuroml:ionChannelHH
parameters:
conductance: {value: 10, unit: pS}
condDensity: {value: 0.0003, unit: S_per_cm2}
erev: {value: -54.3, unit: mV}
ion: {description: non_specific}
spikeGen30ms:
name: spikeGen30ms
iri: neuroml:spikeGenerator
parameters:
period: {value: 30, unit: ms}
noStpSyn:
name: noStpSyn
iri: neuroml:expTwoSynapse
parameters:
gbase: {value: 1, unit: nS}
erev: {value: 0, unit: mV}
tauRise: {value: 0.1, unit: ms}
tauDecay: {value: 40, unit: ms}
stpSynDep:
name: stpSynDep
iri: neuroml:blockingPlasticSynapse
parameters:
gbase: {value: 1, unit: nS}
erev: {value: 0, unit: mV}
tauRise: {value: 0.1, unit: ms}
tauDecay: {value: 40, unit: ms}
modes:
plasticityMechanism:
name: plasticityMechanism
iri: neuroml:tsodyksMarkramDepMechanism
parameters:
initReleaseProb: {value: 0.5}
tauRec: {value: 300, unit: ms}
stpSynDepFac:
name: stpSynDepFac
iri: neuroml:blockingPlasticSynapse
parameters:
gbase: {value: 1, unit: nS}
erev: {value: 0, unit: mV}
tauRise: {value: 0.1, unit: ms}
tauDecay: {value: 40, unit: ms}
modes:
plasticityMechanism:
name: plasticityMechanism
iri: neuroml:tsodyksMarkramDepFacMechanism
parameters:
initReleaseProb: {value: 0.5}
tauFac: {value: 200, unit: ms}
tauRec: {value: 300, unit: ms}
nodes:
- {id: 0, dynamics: passiveCell}
- {id: 1, dynamics: passiveCell}
- {id: 2, dynamics: passiveCell}
- {id: 10, dynamics: spikeGen30ms}
edges:
- {source: 10, target: 0, coupling: noStpSyn}
- {source: 10, target: 1, coupling: stpSynDep}
- {source: 10, target: 2, coupling: stpSynDepFac}
integration:
method: euler
step_size: 0.01
duration: 300.0
time_scale: ms
""" )
dyn_name = next (iter (exp.network.dynamics)) if exp.network and exp.network.dynamics else 'network'
print (f"TVBO model: { dyn_name} (source var: exp)" )
TVBO model: noStpSyn (source var: exp)
* 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[:3000 ])
<Lems>
<!-- Tell jLEMS/jNeuroML which component is the simulation entry point. -->
<Target component="sim_NeuroML_Ex7__STP_Synapses"/>
<!-- ════════════════════════════════════════════════════════════════
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: passiveCell ── -->
<ComponentType name="passiveCell" extends="baseCellMembPot">
<Parameter name="diameter" dimension="none"/>
<Parameter name="initMembPotential" dimension="voltage"/>
<Parameter name="resistivity" dimension="none"/>
<Parameter name="specificCapacitance" dimension="none"/>
<Parameter name="spikeThresh" 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="passiveCell_inst" type="passiveCell" diameter="17.841242" initMembPotential="-65 mV" resistivity="0.03" specificCapacitance="1.0" spikeThresh="-20 mV"/>
<!-- ════════════════════════════════════════════════════════════════
Built-in/named synapse definitions (no custom ODE dynamics)
════════════════════════════════════════════════════════════════ -->
<!-- Synapse: noStpSyn (noStpSyn) -->
<noStpSyn id="noStpSyn"/>
<!-- Synapse: stpSynDep (stpSynDep) -->
<stpSynDep id="stpSynDep"/>
<!-- Synapse: stpSynDepFac (stpSynDepFac) -->
<stpSynDepFac id="stpSynDepFac"/>
<!-- ════════════════════════════════════════════════════════════════
Input Sources (pulseGenerator, spikeGenerator, spikeArray, etc.)
════════════════════════════════════════════════════════════════ -->
<spikeGenerator id="spikeGen30ms" period="30 ms"/>
<!-- ════════════════════════════════════════════════════════════════
Network
════════════════════════════════════════════════════════════════ -->
<network id="net1">
<population id="passiveCell_pop" component="passiveCell_inst" size="3"/>
<population id="spikeGen30ms_pop" component="spikeGen30ms" size="1"/>
<synapticConnection from="spikeGen30ms_pop[0]" to="passiveCell_pop[0]" synapse="noStpSyn" destination="synapses"/>
<synapticConnection from="spikeGen30ms_pop[0]" to="passiveCell_pop[1]" synapse="stpSynDep" destination="synapses"/>
<synapticConnection from="spikeGen30ms_pop[0]" to="passiveC
3. Run Reference
from tvbo.adapters.neuroml import run_lems_example
ref_outputs = run_lems_example("LEMS_NML2_Ex7_STP.xml" )
for name, arr in ref_outputs.items():
print (f" { name} : shape= { arr. shape} " )
ex7_v.dat: shape=(30001, 4)
4. Run TVBO
result = exp.run("neuroml" )
da = result.integration.data
print (f"TVBO: { da. dims} , shape= { da. shape} " )
pyNeuroML >>> 13:07:33 - INFO - Loading LEMS file: tvbo_lems_sim.xml and running with jNeuroML
pyNeuroML >>> 13:07:33 - 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/tmpmaw1rh9u
pyNeuroML >>> 13:07:35 - INFO - Command completed successfully!
TVBO: ('time', 'quantity'), shape=(30001, 3)
5. Compare & Plot
from tvbo.adapters.neuroml import plot_lems_comparison
plot_lems_comparison("LEMS_NML2_Ex7_STP.xml" , ref_outputs, result.integration.data, title_prefix= "Ex7" )