Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update x nmllite model to have bias/gain params #98

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ arm64
/examples/parametersweep/IClamp_GenericNeuronCellX__lems.xml
/examples/parametersweep/LEMS_SimCanonical_X.png
/examples/parametersweep/Canonical_X__lems.xml
/examples/parametersweep/average_last_1percent_GenericNeuronCellX.png
56 changes: 34 additions & 22 deletions examples/parametersweep/CanonicalCircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,18 @@ def generate(duration=1000, paramset="C"):

net = Network(id=reference)
net.parameters = {}

cell_params = {"bias": 0, "gain": 1, "tau": "100ms"}

if paramset == "X":
neuron_id = "GenericNeuronCellX"

neuron_nmllite = Cell(id=neuron_id, lems_source_file='cell_X.xml')
neuron_nmllite = Cell(id=neuron_id, lems_source_file="cell_X.xml")
neuron_nmllite.parameters = {}

for p in cell_params:
neuron_nmllite.parameters[p] = p
net.parameters[p] = cell_params[p]

exc_syn = Synapse(
id="neuron_to_neuron_exc_syn_x", neuroml2_source_file="test_syns.xml"
Expand Down Expand Up @@ -126,11 +134,11 @@ def generate(duration=1000, paramset="C"):
net.parameters["scaleDinout"] = 0.5

if paramset == "X":
net.parameters["stim_duration"] = "250ms"
net.parameters["stim_amp"] = "1pA"
net.parameters["stim_duration"] = "2000ms"
net.parameters["stim_amp"] = "0.2pA"
net.parameters["weight_IN_MN"] = 1
net.parameters["weight_MN_MN_Exc"] = 1
net.parameters["weight_MN_MN_Inh"] = -1
net.parameters["weight_MN_MN_Inh"] = -5
net.parameters["scaleDinout"] = 0.5

mode = "circ"
Expand All @@ -150,20 +158,22 @@ def generate(duration=1000, paramset="C"):
add_connection(net, "DD", "DB", inh_syn, "weight_MN_MN_Inh")

if mode == "iclamp":

add_connection(net, "AVB", "VD", exc_syn, "weight_IN_MN")
add_connection(net, "VD", "VB", exc_syn, "weight_MN_MN_Inh")
add_connection(net, "AVB", "VB", exc_syn, "weight_IN_MN")
add_connection(net, "VB", "VD", exc_syn, "weight_MN_MN_Exc")
# add_connection(net, "VB", "DD", exc_syn, "weight_MN_MN_Exc")

add_connection(net, "VD", "VB", inh_syn, "weight_MN_MN_Inh")

if paramset == "X":
input_source = InputSource(
id="iclamp_0",
neuroml2_input="PulseGenerator",
parameters={
"amplitude": "stim_amp",
"delay": "500ms",
"duration": "stim_duration",
},
)
input_source = InputSource(
id="iclamp_0",
neuroml2_input="PulseGenerator",
parameters={
"amplitude": "stim_amp",
"delay": "500ms",
"duration": "stim_duration",
},
)

else:
input_source = InputSource(
Expand Down Expand Up @@ -202,13 +212,15 @@ def generate(duration=1000, paramset="C"):
},
)

if paramset=="X":

sim.record_traces={}
sim.record_variables={"state": {"all": "*"}, "output": {"all": "*"}} # "V": {"all": "*"},
sim.plots2D={
if paramset == "X":
sim.record_traces = {}
sim.record_variables = {
"state": {"all": "*"},
"output": {"all": "*"},
} # "V": {"all": "*"},
sim.plots2D = {
"DB-VB": {
"x_axis": "DB/0/%s/output" % neuron_id,
"x_axis": "VD/0/%s/output" % neuron_id,
"y_axis": "VB/0/%s/output" % neuron_id,
}
}
Expand Down
31 changes: 25 additions & 6 deletions examples/parametersweep/Canonical_X.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@
"Canonical_X": {
"version": "NeuroMLlite v0.6.1",
"parameters": {
"stim_duration": "250ms",
"stim_amp": "1pA",
"bias": 0,
"gain": 1,
"tau": "100ms",
"stim_duration": "2000ms",
"stim_amp": "0.2pA",
"weight_IN_MN": 1,
"weight_MN_MN_Exc": 1,
"weight_MN_MN_Inh": -1,
"weight_MN_MN_Inh": -5,
"scaleDinout": 0.5
},
"cells": {
"GenericNeuronCellX": {
"parameters": {
"bias": "bias",
"gain": "gain",
"tau": "tau"
},
"lems_source_file": "cell_X.xml"
}
},
Expand Down Expand Up @@ -119,9 +127,9 @@
}
},
"projections": {
"proj_AVB_VD": {
"proj_AVB_VB": {
"presynaptic": "AVB",
"postsynaptic": "VD",
"postsynaptic": "VB",
"synapse": "neuron_to_neuron_exc_syn_x",
"type": "continuousProjection",
"delay": 0,
Expand All @@ -130,10 +138,21 @@
"probability": 1
}
},
"proj_VB_VD": {
"presynaptic": "VB",
"postsynaptic": "VD",
"synapse": "neuron_to_neuron_exc_syn_x",
"type": "continuousProjection",
"delay": 0,
"weight": "weight_MN_MN_Exc",
"random_connectivity": {
"probability": 1
}
},
"proj_VD_VB": {
"presynaptic": "VD",
"postsynaptic": "VB",
"synapse": "neuron_to_neuron_exc_syn_x",
"synapse": "neuron_to_neuron_inh_syn_x",
"type": "continuousProjection",
"delay": 0,
"weight": "weight_MN_MN_Inh",
Expand Down
23 changes: 15 additions & 8 deletions examples/parametersweep/Canonical_X.net.nml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
Generated network: Canonical_X
Generation seed: 1234
NeuroMLlite parameters:
bias = 0
gain = 1
scaleDinout = 0.5
stim_amp = 1pA
stim_duration = 250ms
stim_amp = 0.2pA
stim_duration = 2000ms
tau = 100ms
weight_IN_MN = 1
weight_MN_MN_Exc = 1
weight_MN_MN_Inh = -1</notes>
weight_MN_MN_Inh = -5</notes>
<include href="Canonical_X__lems.xml"/>
<include href="test_syns.xml"/>
<silentSynapse id="silentSyn_proj_AVB_VD"/>
<silentSynapse id="silentSyn_proj_AVB_VB"/>
<silentSynapse id="silentSyn_proj_VB_VD"/>
<silentSynapse id="silentSyn_proj_VD_VB"/>
<pulseGenerator id="iclamp_0" delay="500ms" duration="250ms" amplitude="1pA"/>
<pulseGenerator id="iclamp_0" delay="500ms" duration="2000ms" amplitude="0.2pA"/>
<network id="Canonical_X">
<property tag="recommended_dt_ms" value="0.1"/>
<property tag="recommended_duration_ms" value="3000.0"/>
Expand Down Expand Up @@ -52,11 +56,14 @@
<location x="234.608896559712321" y="62.328147503916853" z="61.581569510361525"/>
</instance>
</population>
<continuousProjection id="proj_AVB_VD" presynapticPopulation="AVB" postsynapticPopulation="VD">
<continuousConnectionInstance id="0" preCell="../AVB/0/GenericNeuronCellX" postCell="../VD/0/GenericNeuronCellX" preComponent="silentSyn_proj_AVB_VD" postComponent="neuron_to_neuron_exc_syn_x"/>
<continuousProjection id="proj_AVB_VB" presynapticPopulation="AVB" postsynapticPopulation="VB">
<continuousConnectionInstance id="0" preCell="../AVB/0/GenericNeuronCellX" postCell="../VB/0/GenericNeuronCellX" preComponent="silentSyn_proj_AVB_VB" postComponent="neuron_to_neuron_exc_syn_x"/>
</continuousProjection>
<continuousProjection id="proj_VB_VD" presynapticPopulation="VB" postsynapticPopulation="VD">
<continuousConnectionInstance id="0" preCell="../VB/0/GenericNeuronCellX" postCell="../VD/0/GenericNeuronCellX" preComponent="silentSyn_proj_VB_VD" postComponent="neuron_to_neuron_exc_syn_x"/>
</continuousProjection>
<continuousProjection id="proj_VD_VB" presynapticPopulation="VD" postsynapticPopulation="VB">
<continuousConnectionInstanceW id="0" preCell="../VD/0/GenericNeuronCellX" postCell="../VB/0/GenericNeuronCellX" preComponent="silentSyn_proj_VD_VB" postComponent="neuron_to_neuron_exc_syn_x" weight="-1.0"/>
<continuousConnectionInstanceW id="0" preCell="../VD/0/GenericNeuronCellX" postCell="../VB/0/GenericNeuronCellX" preComponent="silentSyn_proj_VD_VB" postComponent="neuron_to_neuron_inh_syn_x" weight="-5.0"/>
</continuousProjection>
<inputList id="stim" population="AVB" component="iclamp_0">
<input id="0" target="../AVB/0/GenericNeuronCellX" destination="synapses"/>
Expand Down
39 changes: 24 additions & 15 deletions examples/parametersweep/GenerateExamples.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def generate(cell, duration=3000, config="IClamp", parameters=None):
reference = "%s_%s" % (config, cell)

cell_id = "%s" % cell
if cell_id=='GenericNeuronCellX':
cell_nmll = Cell(id=cell_id, lems_source_file='cell_X.xml')

if cell_id == "GenericNeuronCellX":
cell_nmll = Cell(id=cell_id, lems_source_file="cell_X.xml")
else:
cell_nmll = Cell(id=cell_id, neuroml2_source_file="%s.cell.nml" % (cell))

Expand All @@ -30,15 +30,21 @@ def generate(cell, duration=3000, config="IClamp", parameters=None):
if not parameters:
parameters = {}
parameters["stim_amp"] = "350pA"

parameters["stim_delay"] = "2000ms"
parameters["stim_duration"] = "6000ms"

if cell_id is not "GenericNeuronCellX":

if cell_id is not 'GenericNeuronCellX':
parameters["stim_delay"] = "500ms"
parameters["stim_duration"] = "2000ms"
input_source = InputSource(
id="iclamp_0",
neuroml2_input="PulseGenerator",
parameters={
"amplitude": "stim_amp",
"delay": "500ms",
"duration": "2000ms",
"delay": "stim_delay",
"duration": "stim_duration",
},
)
else:
Expand All @@ -47,8 +53,8 @@ def generate(cell, duration=3000, config="IClamp", parameters=None):
neuroml2_input="PulseGenerator",
parameters={
"amplitude": "stim_amp",
"delay": "2000ms",
"duration": "6000ms",
"delay": "stim_delay",
"duration": "stim_duration",
},
)

Expand Down Expand Up @@ -80,25 +86,28 @@ def generate(cell, duration=3000, config="IClamp", parameters=None):
input_for_default_population=input_source,
)

if cell_id=='GenericNeuronCellX':
sim.record_traces={}
sim.record_variables={"v": {"all": "*"}, "state": {"all": "*"}, "output": {"all": "*"}}
if cell_id == "GenericNeuronCellX":
sim.record_traces={"all": "*"}
sim.record_variables = {
"state": {"all": "*"},
"output": {"all": "*"},
}

#qprint(dir(sim))
# qprint(dir(sim))
sim.to_json_file()

return sim, net


if __name__ == "__main__":

if "-all" in sys.argv:
for cell in colors:
generate(cell, 3000, config="IClamp", parameters={"stim_amp": "4pA"})

elif "-x" in sys.argv:

sim, net = generate("GenericNeuronCellX", 10000, config="IClamp", parameters={"stim_amp": "1pA"})
sim, net = generate(
"GenericNeuronCellX", 10000, config="IClamp", parameters={"stim_amp": "1pA"}
)
check_to_generate_or_run(sys.argv, sim)

else:
Expand Down
8 changes: 5 additions & 3 deletions examples/parametersweep/IClamp_GenericMuscleCell.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "NeuroMLlite v0.6.1",
"notes": "A network model: IClamp_GenericMuscleCell",
"parameters": {
"stim_amp": "4pA"
"stim_amp": "4pA",
"stim_delay": "500ms",
"stim_duration": "2000ms"
},
"cells": {
"GenericMuscleCell": {
Expand All @@ -14,8 +16,8 @@
"iclamp_0": {
"parameters": {
"amplitude": "stim_amp",
"delay": "500ms",
"duration": "2000ms"
"delay": "stim_delay",
"duration": "stim_duration"
},
"neuroml2_input": "PulseGenerator"
}
Expand Down
4 changes: 3 additions & 1 deletion examples/parametersweep/IClamp_GenericMuscleCell.net.nml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Generated network: IClamp_GenericMuscleCell
Generation seed: 1234
NeuroMLlite parameters:
stim_amp = 4pA</notes>
stim_amp = 4pA
stim_delay = 500ms
stim_duration = 2000ms</notes>
<include href="GenericMuscleCell.cell.nml"/>
<pulseGenerator id="iclamp_0" delay="500ms" duration="2000ms" amplitude="4pA"/>
<network id="IClamp_GenericMuscleCell" type="networkWithTemperature" temperature="34.0degC">
Expand Down
8 changes: 5 additions & 3 deletions examples/parametersweep/IClamp_GenericNeuronCell.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "NeuroMLlite v0.6.1",
"notes": "A network model: IClamp_GenericNeuronCell",
"parameters": {
"stim_amp": "4pA"
"stim_amp": "4pA",
"stim_delay": "500ms",
"stim_duration": "2000ms"
},
"cells": {
"GenericNeuronCell": {
Expand All @@ -14,8 +16,8 @@
"iclamp_0": {
"parameters": {
"amplitude": "stim_amp",
"delay": "500ms",
"duration": "2000ms"
"delay": "stim_delay",
"duration": "stim_duration"
},
"neuroml2_input": "PulseGenerator"
}
Expand Down
4 changes: 3 additions & 1 deletion examples/parametersweep/IClamp_GenericNeuronCell.net.nml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Generated network: IClamp_GenericNeuronCell
Generation seed: 1234
NeuroMLlite parameters:
stim_amp = 4pA</notes>
stim_amp = 4pA
stim_delay = 500ms
stim_duration = 2000ms</notes>
<include href="GenericNeuronCell.cell.nml"/>
<pulseGenerator id="iclamp_0" delay="500ms" duration="2000ms" amplitude="4pA"/>
<network id="IClamp_GenericNeuronCell" type="networkWithTemperature" temperature="34.0degC">
Expand Down
2 changes: 1 addition & 1 deletion examples/parametersweep/SimCanonical_X.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"plots2D": {
"DB-VB": {
"x_axis": "DB/0/GenericNeuronCellX/output",
"x_axis": "VD/0/GenericNeuronCellX/output",
"y_axis": "VB/0/GenericNeuronCellX/output"
}
}
Expand Down
Loading
Loading