pest_pars = LMpest(freeParams=['gna', 'gl'], testModel=HH_test_model, context=pest_context, verbose_level=2 ) # In case finite difference stepsize needs adjusting pest_pars.fn.eps=1e-5 pest_context.set_weights({spike_interface: {sp_feat: 10}, geom_interface: {geom_feat: 0.2}}) t0=clock() pestData_par_phase1 = pest_pars.run(parDict={'ftol':1e-5, 'xtol':1e-6 }, verbose=True) HH_test_model.set(pars=pestData_par_phase1['pars_sol']) pest_context.set_weights({spike_interface: {sp_feat: 5}, geom_interface: {geom_feat: 0.7}}) pestData_par = pest_pars.run(parDict={'ftol':1e-5, 'xtol':1e-6 }, verbose=True) print('... finished in %.4f seconds\n'%(clock()-t0)) ## Finish preparing plots
pass pest_data_interface_w = ext_iface(reftraj, pest_condition_w) c = context([ (pest_data_interface_w, int_iface) ]) testModel_par = embed(Generator.Vode_ODEsystem(testDSargs)) pest_pars = LMpest(freeParams=['k'], testModel=testModel_par, context=c ) start_time = time.clock() pestData_par = pest_pars.run(parDict={'ftol': ftol, 'xtol':1e-3}, verbose=True) print('... finished in %.4f seconds\n' % (time.clock()-start_time)) bestFitModel_par = pestData_par['sys_sol'] ## Initial condition estimation print("Estimating initial condition for w (assuming k is correct)") print("Goal value is w(0) = ", xic['w'], " ...") modelArgs_ic = copy(testDSargs) modelArgs_ic['ics'] = {'w': 0.0} modelArgs_ic['pars'] = {'k': pestData_par['pars_sol']['k']} modelArgs_ic['name'] = 'test_model_ic' testModel_ic = embed(Generator.Vode_ODEsystem(modelArgs_ic))
pest_pars = LMpest(freeParams=['gna', 'gl'], testModel=HH_test_model, context=pest_context, verbose_level=2, usePsyco=False ) # In case finite difference stepsize needs adjusting pest_pars.fn.eps=1e-5 pest_context.set_weights({spike_interface: {sp_feat: 10}, geom_interface: {geom_feat: 0.2}}) t0=clock() pestData_par_phase1 = pest_pars.run(parDict={'ftol':1e-5, 'xtol':1e-6 }, verbose=True) HH_test_model.set(pars=pestData_par_phase1['pars_sol']) pest_context.set_weights({spike_interface: {sp_feat: 5}, geom_interface: {geom_feat: 0.7}}) pestData_par = pest_pars.run(parDict={'ftol':1e-5, 'xtol':1e-6 }, verbose=True) print('... finished in %.4f seconds\n'%(clock()-t0)) ## Finish preparing plots
## Parameter estimation print("Estimating pars gna and vl for fit to non-identical HH cell") print("Goal values are gna =", par_args_HH_goal["gna"], ", gl =", par_args_HH_goal["gl"], " ...") pest_pars = LMpest( freeParams=["gna", "gl"], testModel=HH_test_model, context=pest_context, verbose_level=2, usePsyco=False ) # In case finite difference stepsize needs adjusting pest_pars.fn.eps = 1e-5 pest_context.set_weights({spike_interface: {sp_feat: 10}, geom_interface: {geom_feat: 0.2}}) t0 = clock() pestData_par_phase1 = pest_pars.run(parDict={"ftol": 1e-5, "xtol": 1e-6}, verbose=True) HH_test_model.set(pars=pestData_par_phase1["pars_sol"]) pest_context.set_weights({spike_interface: {sp_feat: 5}, geom_interface: {geom_feat: 0.7}}) pestData_par = pest_pars.run(parDict={"ftol": 1e-5, "xtol": 1e-6}, verbose=True) print("... finished in %.4f seconds\n" % (clock() - t0)) ## Finish preparing plots print("\nPreparing plots") figure() disp_dt = 0.05 plotData_orig = HH_test_model.sample("orig", ["v"], disp_dt, precise=True) origleg = "v initial"