File size: 1,967 Bytes
0558c72 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | from neuromllite import Network, Cell, InputSource, Population, Synapse
from neuromllite import Projection, RandomConnectivity, Input, Simulation
import sys
################################################################################
### Build new network
net = Network(id="HHTest")
net.notes = "Example HH cell"
net.parameters = {"N": 1}
cell = Cell(id="hhcell", neuroml2_source_file="../hhcell.cell.nml")
cell.parameters = {}
params = {
}
for p in params:
cell.parameters[p] = p
net.parameters[p] = params[p]
net.cells.append(cell)
pop = Population(
id="hhPop", size="1", component=cell.id, properties={"color": ".7 0 0"}
)
net.populations.append(pop)
net.parameters["delay"] = "5ms"
net.parameters["stim_amp"] = "0.05nA"
net.parameters["duration"] = "25ms"
input_source = InputSource(
id="iclamp_0",
neuroml2_input="pulseGenerator",
parameters={"amplitude": "stim_amp", "delay": "delay", "duration": "duration"},
)
net.input_sources.append(input_source)
net.inputs.append(
Input(
id="stim",
input_source=input_source.id,
population=pop.id,
percentage=100,
weight=1,
)
)
print(net)
print(net.to_json())
net_yaml_file = net.to_yaml_file("%s.nmllite.yaml" % net.id)
net_json_file = net.to_json_file("%s.nmllite.json" % net.id)
################################################################################
### Build Simulation object & save as JSON
record_variables = {"v": {"all": "*"}}
sim = Simulation(
id="Sim%s" % net.id,
network=net_yaml_file,
duration="50",
dt="0.025",
record_variables=record_variables,
)
sim.to_yaml_file("%s.yaml" % sim.id)
sim.network = net_json_file
sim.to_json_file("%s.json" % sim.id)
################################################################################
### Run in some simulators
from neuromllite.NetworkGenerator import check_to_generate_or_run
import sys
check_to_generate_or_run(sys.argv, sim)
|