fit5.load() #Default population size is 8 fit5.do_fit(100) for i in range(len(fit5)): print(i, fit5.fitness_func(fit5[i], fit5.measurement, full=1), '→', fit5.fitness_func(fit5[i], fit5.measurement, full=0)) #to print param values for all simulations print(fit5[i].params) #print best estimate of parameters for i in len(fit5.param_names()): print(fit5.param_names()[i], ':', fit5.params.unscale(fit5.optimizer.result()[0])[i]) drawing.plot_history(fit5, fit5.measurement) ##################################################################################### # example using combined_fitness() - which uses both hyperpolarizing and depolarizing currents ##################################################################################### exp_to_fit = ms1.D1waves042811[[0, 6, 9]] P = aju.optimize.AjuParam params6 = aju.optimize.ParamSet( P('junction_potential', 0, min=-0.015, max=+0.015), P('RA', 12.004, min=0, max=100), P('RM', 9.427, min=0, max=10), P('CM', 0.03604, min=0, max=0.10), P('Cond_Kir', 14.502, min=0, max=100), P('Kir_offset', -.004, min=-0.005, max=+0.005), P('morph_file', 'MScell-tertDendlongRE.p', fixed=1), P('neuron_type', 'D1', fixed=1), P('Cond_NaF_0', 150e3, min=0, max=600e3), P('Cond_KaS_0', 372, min=0, max=600), P('Cond_KaF_0', 641, min=0, max=1000),
######## set up parameters and fitness to be used for all opts ############ params1, fitness = pfc.params_fitness(morph_file, ntype, modeltype) # set-up and do the optimization fit1 = fit_commands.fit_commands(dirname, exp_to_fit, modeltype, ntype, fitness, params1, generations, popsiz, seed, test_size) if test_size > 0: mean_dict, std_dict, CV = converge.iterate_fit(fit1, test_size, popsiz, std_crit=0.02, max_evals=12000) ###########look at results drawing.plot_history(fit1, fit1.measurement) #Save parameters of good results toward the end, and all fitness values startgood = 0 #set to 0 to print/save all threshold = 10 #set to high value to print/save all save_params.save_params(fit1, startgood, threshold) #save_params.persist(fit1,'.') ''' #to create moose_nerp parameter file: from ajustador.helpers.copy_param import create_npz_param npzfile=fit1.name+'.npz' create_npz_param.create_npz_param(npzfile,modeltype,ntype) #to print params of centroid for nm,val,stdev in zip(fit1.param_names(),
modeltype, ntype, fitness, params4, _make_simulation=aju.optimize.MooseSimulation.make, _result_constructor=aju.optimize.MooseSimulationResult) fit4.load() fit4.do_fit(generations, popsize=popsiz, seed=seed) if test_size > 0: mean_dict4, std_dict4, CV4 = converge.iterate_fit(fit4, test_size, popsiz, max_evals=8000) # drawing.plot_history(fit4, fit4.measurement) startgood = 0 #set to 0 to print all threshold = 10 #set to large number to print all save_params.save_params(fit4, startgood, threshold) '''Sag and spike times match great, but AHPs way to big. Perhaps need another channel? Is a second KA current needed? Could KA replace KDr? Check the "optimal" conductance Would additional calcium currents help? What is known about them? observation: strong Kv3 associated with nice looking AHPs, and as it decreases AHPs look worse ------>>>> evaluate Kv3 inactivation - too strong? spike height decreases and NaS decreases along with AHP decrease. Symptom or cause? Z gate of NaS decreases slowly across simulation - this could be causal, BUT eliminating NaS Zgate doesn't change this.
exp_to_fit = ms1.D1waves051811[[8,20,22,23]] #0, 6 are hyperpolarizing dirname=dataname+'_pas2_'+str(seed) if not dirname in os.listdir(rootdir): os.mkdir(rootdir+dirname) os.chdir(rootdir+dirname) tmpdir='/tmp/fit'+modeltype+'-'+ntype+'-'+dirname fit2 = aju.optimize.Fit(tmpdir, exp_to_fit, modeltype, ntype, fitness, params1, _make_simulation=aju.optimize.MooseSimulation.make, _result_constructor=aju.optimize.MooseSimulationResult) fit2.load() fit2.do_fit(generations, popsize=popsiz,seed=seed) mean_dict,std_dict,CV=iterate_fit(fit2,test_size,popsiz) #look at results drawing.plot_history(fit2, fit2.measurement) #Save parameters of good results toward the end, and all fitness values startgood=1000 #set to 0 to print all threshold=0.8 #set to large number to print all save_params.save_params(fit2, startgood, threshold)
test_size = 25 ################## neuron /data specific specifications ############# ntype = 'D2' dataname = 'D2_051311' exp_to_fit = ms1.D2waves051311[[8, 17, 19, 22]] #0, 6 are hyperpol dirname = dataname + '_pas2_' + str(seed) if not dirname in os.listdir(rootdir): os.mkdir(rootdir + dirname) os.chdir(rootdir + dirname) ######## set up parameters and fitness params1, fitness = params_fitness.params_fitness(morph_file, ntype, modeltype) # set-up and do optimization fit3, mean_dict3, std_dict3, CV3 = fit_commands.fit_commands( dirname, exp_to_fit, modeltype, ntype, fitness, params1, generations, popsiz, seed, test_size) #########look at results drawing.plot_history(fit3, fit3.measurement) #Save parameters of good results from end of optimization, and all fitness values startgood = 1000 #set to 0 to print all threshold = 0.8 #set to large number to print all save_params.save_params(fit3, startgood, threshold) #to save the fit object #save_params.persist(fit3,'.')