def init(): # import pdb;pdb.set_trace() values = request.get_json() values['neuron']['params'] = dict(zip(values['neuron']['params'].keys(), map(float, values['neuron']['params'].values()))) values['input']['params'] = dict(zip(values['input']['params'].keys(), map(float, values['input']['params'].values()))) nest.ResetKernel() nest.SetKernelStatus({'rng_seeds': (int(values['kernel']['params']['rng_seeds']),)}) global neuron neuron = nest.Create(values['neuron']['model'], values['neuron']['count'], params=values['neuron']['params']) global input input = nest.Create(values['input']['model'], params=values['input']['params']) nest.Connect(input,neuron, 'all_to_all') global mm mm = nest.Create('multimeter', params={"record_from": recordables}) nest.Connect(mm,neuron, 'all_to_all') nest.Simulate(values.get('simtime', 500.)) events = nest.GetStatus(mm,'events')[0] nest.SetStatus(mm, {'n_events': 0}) return jsonify(data=dict([(x, hh.prep_multi(events, x)) for x in recordables]), values=values)
def simulate(): values = request.get_json() values['input']['params'] = dict(zip(values['input']['params'].keys(), map(float, values['input']['params'].values()))) values['neuron']['params'] = dict(zip(values['neuron']['params'].keys(), map(float, values['neuron']['params'].values()))) nest.SetStatus(input, values['input']['params']) nest.SetStatus(neuron, values['neuron']['params']) nest.Simulate(1.) events = nest.GetStatus(mm,'events')[0] nest.SetStatus(mm, {'n_events': 0}) return jsonify(data=dict([(x, hh.prep_multi(events, x)) for x in recordables]), values=values)