Spaces:
Running
Running
File size: 1,416 Bytes
dd8b826 b9c182b dd8b826 cdb94e2 dd8b826 b9c182b dd8b826 cdb94e2 b9c182b cdb94e2 b9c182b db52738 cdb94e2 b9c182b dd8b826 cdb94e2 db52738 | 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 | # Based on: https://github.com/allenai/s2-folks/tree/main/examples/python
#
#
import os
import re
from neuromllite.utils import load_simulation_json
from neuromllite.utils import load_network_json
from neuromllite.NetworkGenerator import generate_and_run
MODELS = {
"Muscle model": [
"models/Sim_IClamp_GenericMuscleCell.json",
"models/IClamp_GenericMuscleCell.json",
],
"Neuron model": [
"models/Sim_IClamp_GenericNeuronCell.json",
"models/IClamp_GenericNeuronCell.json",
],
}
def run_model(text, model, verbose=False):
info = """Running [%s] with parameter: [%s]...
""" % (
model,
text,
)
print(info)
sim_file = MODELS[model][0]
net_file = MODELS[model][1]
sim = load_simulation_json(sim_file)
net = load_network_json(net_file)
net.parameters["stim_amp"] = text.strip()
if verbose:
info += (
"""```%s```
"""
% sim.to_json()
)
info += (
"""```%s```
"""
% net.to_json()
)
traces, events = generate_and_run(
sim,
network=net,
simulator="jNeuroML",
base_dir="./models",
target_dir="./models",
return_results=True,
)
# info+="""Results returned: %s"""%(list(traces.keys()))
info += """Finished simulation!"""
print(info)
return info, traces, events
|