add routine for fitting with const refractory period
This commit is contained in:
parent
859faae812
commit
5a58483edb
38
Fitter.py
38
Fitter.py
@ -96,6 +96,24 @@ class Fitter:
|
|||||||
|
|
||||||
return fmin, self.base_model.get_parameters()
|
return fmin, self.base_model.get_parameters()
|
||||||
|
|
||||||
|
def fit_routine_const_ref_period(self, start_parameters):
|
||||||
|
self.counter = 0
|
||||||
|
# fit only v_offset, mem_tau, input_scaling, dend_tau
|
||||||
|
|
||||||
|
x0 = np.array([start_parameters["mem_tau"], start_parameters["noise_strength"],
|
||||||
|
start_parameters["input_scaling"], self.tau_a, start_parameters["delta_a"],
|
||||||
|
start_parameters["dend_tau"], start_parameters["refractory_period"]])
|
||||||
|
initial_simplex = create_init_simples(x0, search_scale=2)
|
||||||
|
self.base_model.set_variable("refractory_period", start_parameters["refractory_period"])
|
||||||
|
# error_list = [error_bf, error_vs, error_sc, error_cv,
|
||||||
|
# error_f_inf, error_f_inf_slope, error_f_zero, error_f_zero_slope]
|
||||||
|
error_weights = (0, 1, 1, 1, 1, 1, 1, 1, 1)
|
||||||
|
fmin = minimize(fun=self.cost_function_without_ref_period,
|
||||||
|
args=(error_weights,), x0=x0, method="Nelder-Mead",
|
||||||
|
options={"initial_simplex": initial_simplex, "xatol": 0.001, "maxfev": 200, "maxiter": 400})
|
||||||
|
|
||||||
|
return fmin, self.base_model.get_parameters()
|
||||||
|
|
||||||
# similar results to fit routine 1
|
# similar results to fit routine 1
|
||||||
def fit_routine_2(self, start_parameters):
|
def fit_routine_2(self, start_parameters):
|
||||||
self.counter = 0
|
self.counter = 0
|
||||||
@ -143,6 +161,26 @@ class Fitter:
|
|||||||
|
|
||||||
return sum(error_list)
|
return sum(error_list)
|
||||||
|
|
||||||
|
def cost_function_without_ref_period(self, X, error_weights=None):
|
||||||
|
self.base_model.set_variable("mem_tau", X[0])
|
||||||
|
self.base_model.set_variable("noise_strength", X[1])
|
||||||
|
self.base_model.set_variable("input_scaling", X[2])
|
||||||
|
self.base_model.set_variable("tau_a", X[3])
|
||||||
|
self.base_model.set_variable("delta_a", X[4])
|
||||||
|
self.base_model.set_variable("dend_tau", X[5])
|
||||||
|
|
||||||
|
base_stimulus = SinusoidalStepStimulus(self.eod_freq, 0)
|
||||||
|
# find right v-offset
|
||||||
|
test_model = self.base_model.get_model_copy()
|
||||||
|
test_model.set_variable("noise_strength", 0)
|
||||||
|
v_offset = test_model.find_v_offset(self.baseline_freq, base_stimulus)
|
||||||
|
self.base_model.set_variable("v_offset", v_offset)
|
||||||
|
|
||||||
|
# [error_bf, error_vs, error_sc, error_f_inf, error_f_inf_slope, error_f_zero, error_f_zero_slope]
|
||||||
|
error_list = self.calculate_errors(error_weights)
|
||||||
|
|
||||||
|
return sum(error_list)
|
||||||
|
|
||||||
def cost_function_all_without_noise(self, X, error_weights=None):
|
def cost_function_all_without_noise(self, X, error_weights=None):
|
||||||
self.base_model.set_variable("mem_tau", X[0])
|
self.base_model.set_variable("mem_tau", X[0])
|
||||||
self.base_model.set_variable("input_scaling", X[1])
|
self.base_model.set_variable("input_scaling", X[1])
|
||||||
|
Loading…
Reference in New Issue
Block a user