add way to test other parameters
This commit is contained in:
parent
29fdee009e
commit
61605cbb9e
@ -10,15 +10,22 @@ import functions as fu
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
values = np.arange(2, 18, 1)
|
||||||
|
parameter = "threshold"
|
||||||
|
for value in values:
|
||||||
lifac_model = LIFACModel({"delta_a": 0})
|
lifac_model = LIFACModel({"delta_a": 0})
|
||||||
stimulus_strengths = np.arange(20, 32, 1)
|
lifac_model.set_variable(parameter, value)
|
||||||
|
stimulus_strengths = np.arange(50, 60, 1)
|
||||||
|
|
||||||
line_vars, boltzmann_vars = find_fitting_boltzmann(lifac_model, stimulus_strengths)
|
line_vars, boltzmann_vars = find_fitting_boltzmann(lifac_model, stimulus_strengths)
|
||||||
find_relation(line_vars, boltzmann_vars)
|
relation = find_relation(lifac_model, line_vars, boltzmann_vars, stimulus_strengths)
|
||||||
|
|
||||||
|
print("threshold:", value)
|
||||||
|
print(relation)
|
||||||
|
|
||||||
|
|
||||||
def find_fitting_boltzmann(lifac_model, stimulus_strengths):
|
def find_fitting_boltzmann(lifac_model, stimulus_strengths):
|
||||||
# Requieres a lifac model with adaption delta_a = 0, so just the base is fit
|
# Requires a lifac model with adaption delta_a = 0, so just the base is fit
|
||||||
frequencies = []
|
frequencies = []
|
||||||
|
|
||||||
duration = 0.2
|
duration = 0.2
|
||||||
@ -44,26 +51,23 @@ def find_fitting_boltzmann(lifac_model, stimulus_strengths):
|
|||||||
return popt, popt2
|
return popt, popt2
|
||||||
|
|
||||||
|
|
||||||
def find_relation(line_vars, boltzmann_vars, stimulus_strengths):
|
def find_relation(lifac, line_vars, boltzmann_vars, stimulus_strengths, use_line=True):
|
||||||
# boltzmann_vars = [2.00728705e+02, 1.09905953e-12, 1.03639686e-01, 2.55002788e+01]
|
# boltzmann_vars = [2.00728705e+02, 1.09905953e-12, 1.03639686e-01, 2.55002788e+01]
|
||||||
# line_vars = [5.10369405, -29.79774806]
|
# line_vars = [5.10369405, -29.79774806]
|
||||||
# example values for base lifac (15.1.20) and stimulus 20-32
|
# example values for base lifac (15.1.20) and stimulus 20-32
|
||||||
|
|
||||||
stimulus_step_size = 2
|
duration = 0.1
|
||||||
stimulus_range = np.arange(20, 32, stimulus_step_size)
|
|
||||||
|
|
||||||
|
|
||||||
duration = 0.2
|
lifac_adaption_strength_range = np.arange(0, 3.1, 0.5)
|
||||||
|
|
||||||
lifac_adaption_strength_range = np.arange(0, 3, 0.5)
|
|
||||||
firerate_adaption_variables = []
|
firerate_adaption_variables = []
|
||||||
for lifac_adaption_strength in lifac_adaption_strength_range:
|
for lifac_adaption_strength in lifac_adaption_strength_range:
|
||||||
print(lifac_adaption_strength)
|
print(lifac_adaption_strength)
|
||||||
lifac = LIFACModel({"delta_a": lifac_adaption_strength, "tau_a": 20})
|
lifac.set_variable("delta_a", lifac_adaption_strength)
|
||||||
|
lifac.set_variable("tau_a", 10)
|
||||||
|
|
||||||
adapted_frequencies = []
|
adapted_frequencies = []
|
||||||
for stim in stimulus_range:
|
for stim in stimulus_strengths:
|
||||||
print("stim:", stim)
|
#print("stim:", stim)
|
||||||
stimulus = StepStimulus(0, duration, stim)
|
stimulus = StepStimulus(0, duration, stim)
|
||||||
lifac.simulate(stimulus, duration)
|
lifac.simulate(stimulus, duration)
|
||||||
spiketimes = lifac.get_spiketimes()
|
spiketimes = lifac.get_spiketimes()
|
||||||
@ -75,16 +79,18 @@ def find_relation(line_vars, boltzmann_vars, stimulus_strengths):
|
|||||||
for i in range(len(adapted_frequencies)):
|
for i in range(len(adapted_frequencies)):
|
||||||
goal_adapted_freq = adapted_frequencies[i]
|
goal_adapted_freq = adapted_frequencies[i]
|
||||||
|
|
||||||
# stimulus_strength_after_adaption = fu.inverse_full_boltzmann(goal_adapted_freq,
|
if use_line:
|
||||||
# boltzmann_vars[0],
|
# assume fitted linear firing rate as basis of the fire-rate model:
|
||||||
# boltzmann_vars[1],
|
|
||||||
# boltzmann_vars[2],
|
|
||||||
# boltzmann_vars[3],)
|
|
||||||
|
|
||||||
# assume fitted line as basis of the fire-rate model:
|
|
||||||
stimulus_strength_after_adaption = fu.inverse_line(goal_adapted_freq, line_vars[0], line_vars[1])
|
stimulus_strength_after_adaption = fu.inverse_line(goal_adapted_freq, line_vars[0], line_vars[1])
|
||||||
|
else:
|
||||||
|
# assume fitted boltzmann firing rate as basis of the fire-rate model:
|
||||||
|
stimulus_strength_after_adaption = fu.inverse_full_boltzmann(goal_adapted_freq,
|
||||||
|
boltzmann_vars[0],
|
||||||
|
boltzmann_vars[1],
|
||||||
|
boltzmann_vars[2],
|
||||||
|
boltzmann_vars[3],)
|
||||||
|
|
||||||
adaption_strength = stimulus_range[i] - stimulus_strength_after_adaption
|
adaption_strength = stimulus_strengths[i] - stimulus_strength_after_adaption
|
||||||
|
|
||||||
firerate_adaption = adaption_strength / goal_adapted_freq
|
firerate_adaption = adaption_strength / goal_adapted_freq
|
||||||
firerate_adaption_strengths.append(firerate_adaption)
|
firerate_adaption_strengths.append(firerate_adaption)
|
||||||
@ -95,7 +101,7 @@ def find_relation(line_vars, boltzmann_vars, stimulus_strengths):
|
|||||||
# plt.show()
|
# plt.show()
|
||||||
|
|
||||||
for i in range(len(lifac_adaption_strength_range)):
|
for i in range(len(lifac_adaption_strength_range)):
|
||||||
plt.plot([lifac_adaption_strength_range[i]+p*0.01 for p in range(len(stimulus_range))], firerate_adaption_variables[i])
|
plt.plot([lifac_adaption_strength_range[i]+p*0.01 for p in range(len(stimulus_strengths))], firerate_adaption_variables[i])
|
||||||
|
|
||||||
mean_firerate_adaption_value = [np.mean(strengths) for strengths in firerate_adaption_variables]
|
mean_firerate_adaption_value = [np.mean(strengths) for strengths in firerate_adaption_variables]
|
||||||
|
|
||||||
@ -103,11 +109,12 @@ def find_relation(line_vars, boltzmann_vars, stimulus_strengths):
|
|||||||
plt.title("Relation of adaption strength variables:\n Small 'subplots' value for different stimulus strength")
|
plt.title("Relation of adaption strength variables:\n Small 'subplots' value for different stimulus strength")
|
||||||
plt.xlabel("lifac adaption strength: delta_a")
|
plt.xlabel("lifac adaption strength: delta_a")
|
||||||
plt.ylabel("firerate adaption strength: alpha")
|
plt.ylabel("firerate adaption strength: alpha")
|
||||||
plt.savefig("figures/adaption_relation_stimulus_strength_stepsize_0-0001.png")
|
plt.savefig("figures/adaption_relation_threshold_" + str(lifac.get_parameters()["threshold"]) + ".png")
|
||||||
plt.close()
|
plt.close()
|
||||||
popt, pcov = curve_fit(fu.line, lifac_adaption_strength_range, mean_firerate_adaption_value)
|
popt, pcov = curve_fit(fu.line, lifac_adaption_strength_range, mean_firerate_adaption_value)
|
||||||
|
|
||||||
print(popt)
|
# print(popt)
|
||||||
|
return popt
|
||||||
|
|
||||||
|
|
||||||
def test_firerate_model( boltzmann_vars):
|
def test_firerate_model( boltzmann_vars):
|
||||||
|
Loading…
Reference in New Issue
Block a user