Spaces:
Running
Running
| # 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 | |