#pl.plot(t_newdt, v_newdt) #pl.show() # compute parameter dvdt_newdt = np.concatenate((np.array([(v_newdt[1]-v_newdt[0])/dt]), np.diff(v_newdt)/dt)) i_newdt = data_newdt.i.values celsius = problem.simulation_params['celsius'] # get currents candidate = np.ones(len(problem.path_variables)) # gbars should be 1 problem.update_cell(candidate) currents_newdt = currents_given_v(v_newdt, t_newdt, problem.cell.soma, channel_list, ion_list, celsius) # convert units dvdt_sc, i_inj_sc, currents_sc, Cm, _ = convert_units(problem.cell.soma.L, problem.cell.soma.diam, problem.cell.soma.cm, dvdt_newdt, i_newdt, currents_newdt) # linear regression weights, residual, y, X = linear_regression(dvdt_sc, i_inj_sc, currents_sc, i_pas=0, Cm=Cm) # plots #plot_fit(y, X, weights, t_newdt, channel_list) # compute error error_traces[i, j] = rms(y, np.sum(np.array(currents), 0)) error_tmp = [rms(weights_model[k], weights[k]) for k in range(len(weights_model))] error_weights[i, j] = np.mean(error_tmp)
v_exp = problem.data.v.values t_exp = problem.data.t.values i_exp = problem.data.i.values dt = t_exp[1] - t_exp[0] dvdt = np.concatenate((np.array([(v_exp[1]-v_exp[0])/dt]), np.diff(v_exp) / dt)) candidate = np.ones(len(problem.path_variables)) problem.update_cell(candidate) channel_list = get_channel_list(problem.cell, 'soma') ion_list = get_ionlist(channel_list) celsius = problem.simulation_params['celsius'] currents = currents_given_v(v_exp, t_exp, problem.cell.soma, channel_list, ion_list, celsius) # convert units dvdt_sc, i_inj_sc, currents_sc, Cm, cell_area = convert_units(problem.cell.soma.L, problem.cell.soma.diam, problem.cell.soma.cm, dvdt, i_exp, currents) # linear regression weights, residual, y, X = linear_regression(dvdt_sc, i_inj_sc, currents_sc, i_pas=0, Cm=Cm) #weights, residual, y, X = linear_regression(dvdt_sc, i_inj_sc, currents_sc, i_pas=0, Cm=None, cell_area=cell_area) # output print 'channels: ' + str(channel_list) print 'weights: ' + str(weights) # plot fit # plot in three parts merge_points = [0, 22999, 26240, 550528] for i in range(len(merge_points)-1): y_plot = y[merge_points[i]:merge_points[i+1]]