prepare for testing of other variables
This commit is contained in:
parent
3eda710394
commit
29fdee009e
@ -10,68 +10,60 @@ import functions as fu
|
||||
|
||||
|
||||
def main():
|
||||
#boltzmann_vars = find_fitting_boltzmann()
|
||||
#test_firerate_model(boltzmann_vars)
|
||||
find_relation()
|
||||
lifac_model = LIFACModel({"delta_a": 0})
|
||||
stimulus_strengths = np.arange(20, 32, 1)
|
||||
|
||||
def find_fitting_boltzmann():
|
||||
lifac = LIFACModel({"delta_a": 0})
|
||||
line_vars, boltzmann_vars = find_fitting_boltzmann(lifac_model, stimulus_strengths)
|
||||
find_relation(line_vars, boltzmann_vars)
|
||||
|
||||
|
||||
def find_fitting_boltzmann(lifac_model, stimulus_strengths):
|
||||
# Requieres a lifac model with adaption delta_a = 0, so just the base is fit
|
||||
frequencies = []
|
||||
stim_strengths = np.arange(20, 32, 0.5)
|
||||
duration = 0.5
|
||||
for stim_strength in stim_strengths:
|
||||
lifac.simulate(StepStimulus(0, duration, stim_strength), duration)
|
||||
|
||||
spiketimes = lifac.get_spiketimes()
|
||||
duration = 0.2
|
||||
for stim_strength in stimulus_strengths:
|
||||
lifac_model.simulate(StepStimulus(0, duration, stim_strength), duration)
|
||||
|
||||
spiketimes = lifac_model.get_spiketimes()
|
||||
if len(spiketimes) == 0:
|
||||
frequencies.append(0)
|
||||
continue
|
||||
time, freq = hf.calculate_isi_frequency(spiketimes, 0, lifac.get_sampling_interval()/1000)
|
||||
time, freq = hf.calculate_isi_frequency(spiketimes, 0, lifac_model.get_sampling_interval() / 1000)
|
||||
|
||||
frequencies.append(freq[-1])
|
||||
|
||||
popt, pcov = curve_fit(fu.line, stim_strengths, frequencies)
|
||||
popt2, pcov = curve_fit(fu.full_boltzmann, stim_strengths, frequencies, p0=[700, 0, 5, 25], bounds=([0, 0, -np.inf, -np.inf], [3000, 0.001, np.inf, np.inf]))
|
||||
popt, pcov = curve_fit(fu.line, stimulus_strengths, frequencies)
|
||||
popt2, pcov = curve_fit(fu.full_boltzmann, stimulus_strengths, frequencies, p0=[700, 0, 5, 25], bounds=([0, 0, -np.inf, -np.inf], [3000, 0.001, np.inf, np.inf]))
|
||||
print("line:", popt)
|
||||
print("boltzmann:", popt2)
|
||||
# plt.plot(stim_strengths, frequencies)
|
||||
# plt.plot(stim_strengths, [fu.line(x, popt[0], popt[1]) for x in stim_strengths], '.')
|
||||
# plt.plot(stim_strengths, [fu.full_boltzmann(x, popt2[0], popt2[1], popt2[2], popt2[3]) for x in stim_strengths], 'o')
|
||||
# plt.plot(stimulus_strengths, frequencies)
|
||||
# plt.plot(stimulus_strengths, [fu.line(x, popt[0], popt[1]) for x in stimulus_strengths], '.')
|
||||
# plt.plot(stimulus_strengths, [fu.full_boltzmann(x, popt2[0], popt2[1], popt2[2], popt2[3]) for x in stimulus_strengths], 'o')
|
||||
# plt.show()
|
||||
return popt2
|
||||
return popt, popt2
|
||||
|
||||
|
||||
def test_firerate_model(boltzmann_vars):
|
||||
fr_model = FirerateModel(params={"function_params": boltzmann_vars, "adaptation_factor": 0})
|
||||
def find_relation(line_vars, boltzmann_vars, stimulus_strengths):
|
||||
# boltzmann_vars = [2.00728705e+02, 1.09905953e-12, 1.03639686e-01, 2.55002788e+01]
|
||||
# line_vars = [5.10369405, -29.79774806]
|
||||
# example values for base lifac (15.1.20) and stimulus 20-32
|
||||
|
||||
frequencies = []
|
||||
stim_strengths = np.arange(0, 50, 0.5)
|
||||
duration = 0.5
|
||||
for stim_strength in stim_strengths:
|
||||
fr_model.simulate(StepStimulus(0, duration, stim_strength), duration)
|
||||
|
||||
frequencies.append(fr_model.get_frequency()[-1])
|
||||
|
||||
plt.plot(stim_strengths, frequencies)
|
||||
plt.plot(np.arange(20, 32, 1), [fu.line(x, 5.10369, -29.7977481) for x in np.arange(20, 32, 1)], 'o')
|
||||
plt.show()
|
||||
stimulus_step_size = 2
|
||||
stimulus_range = np.arange(20, 32, stimulus_step_size)
|
||||
|
||||
|
||||
def find_relation():
|
||||
stimulus_step_size = 1
|
||||
stimulus_range = np.arange(20, 32, stimulus_step_size)
|
||||
boltzmann_vars = [2.00728705e+02, 1.09905953e-12, 1.03639686e-01, 2.55002788e+01]
|
||||
line_vars = [5.10369405, -29.79774806]
|
||||
duration = 0.5
|
||||
duration = 0.2
|
||||
|
||||
lifac_adaption_strength_range = np.arange(0, 3, 0.2)
|
||||
lifac_adaption_strength_range = np.arange(0, 3, 0.5)
|
||||
firerate_adaption_variables = []
|
||||
for lifac_adaption_strength in lifac_adaption_strength_range:
|
||||
lifac = LIFACModel({"delta_a": lifac_adaption_strength, "tau_a": 20}, "")
|
||||
print(lifac_adaption_strength)
|
||||
lifac = LIFACModel({"delta_a": lifac_adaption_strength, "tau_a": 20})
|
||||
|
||||
adapted_frequencies = []
|
||||
for stim in stimulus_range:
|
||||
print("stim:", stim)
|
||||
stimulus = StepStimulus(0, duration, stim)
|
||||
lifac.simulate(stimulus, duration)
|
||||
spiketimes = lifac.get_spiketimes()
|
||||
@ -111,12 +103,28 @@ def find_relation():
|
||||
plt.title("Relation of adaption strength variables:\n Small 'subplots' value for different stimulus strength")
|
||||
plt.xlabel("lifac adaption strength: delta_a")
|
||||
plt.ylabel("firerate adaption strength: alpha")
|
||||
plt.savefig("figures/adaption_relation_stimulus_strength.png")
|
||||
plt.savefig("figures/adaption_relation_stimulus_strength_stepsize_0-0001.png")
|
||||
plt.close()
|
||||
popt, pcov = curve_fit(fu.line, lifac_adaption_strength_range, mean_firerate_adaption_value)
|
||||
|
||||
print(popt)
|
||||
|
||||
|
||||
def test_firerate_model( boltzmann_vars):
|
||||
fr_model = FirerateModel(params={"function_params": boltzmann_vars, "adaptation_factor": 0})
|
||||
|
||||
frequencies = []
|
||||
stim_strengths = np.arange(0, 50, 0.5)
|
||||
duration = 0.5
|
||||
for stim_strength in stim_strengths:
|
||||
fr_model.simulate(StepStimulus(0, duration, stim_strength), duration)
|
||||
|
||||
frequencies.append(fr_model.get_frequency()[-1])
|
||||
|
||||
plt.plot(stim_strengths, frequencies)
|
||||
plt.plot(np.arange(20, 32, 1), [fu.line(x, 5.10369, -29.7977481) for x in np.arange(20, 32, 1)], 'o')
|
||||
plt.show()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user