fit no dend_tau increased v_offset baseline sim 6
This commit is contained in:
parent
52e6fea5f8
commit
5cb0ee435e
@ -227,6 +227,9 @@ class Fitter:
|
||||
# time1 = time.time()
|
||||
v_offset = test_model.find_v_offset(self.baseline_freq, base_stimulus)
|
||||
self.base_model.set_variable("v_offset", v_offset)
|
||||
|
||||
|
||||
|
||||
# time2 = time.time()
|
||||
# print("time taken for finding v_offset: {:.2f}s".format(time2-time1))
|
||||
|
||||
|
@ -184,7 +184,7 @@ class LifacNoiseModel(AbstractModel):
|
||||
|
||||
def find_v_offset(self, goal_baseline_frequency, base_stimulus, threshold=2, border=50000):
|
||||
test_model = self.get_model_copy()
|
||||
simulation_length = 9
|
||||
simulation_length = 6
|
||||
|
||||
v_search_step_size = 100
|
||||
|
||||
@ -214,7 +214,7 @@ def binary_search_base_freq(model: LifacNoiseModel, base_stimulus, goal_frequenc
|
||||
counter += 1
|
||||
middle = upper_bound - (upper_bound - lower_bound) / 2
|
||||
frequency = test_v_offset(model, middle, base_stimulus, simulation_length)
|
||||
|
||||
# print("offset: {:.1f}, freq: {:.0f}".format(middle, frequency))
|
||||
# print('{:.1f}, {:.1f}, {:.1f}, {:.1f} vs {:.1f} '.format(lower_bound, middle, upper_bound, frequency, goal_frequency))
|
||||
|
||||
if abs(frequency - goal_frequency) < threshold:
|
||||
@ -231,6 +231,7 @@ def binary_search_base_freq(model: LifacNoiseModel, base_stimulus, goal_frequenc
|
||||
if abs(upper_bound - lower_bound) < 0.0001:
|
||||
print("v_offset search stopped. bounds converged! freq: {:.2f}, bounds: {:.0f}"
|
||||
.format(frequency, lower_bound))
|
||||
# print(model.parameters)
|
||||
warn("Search was stopped. Upper and lower bounds converged without finding a value closer than threshold!")
|
||||
return middle
|
||||
|
||||
@ -239,8 +240,11 @@ def test_v_offset(model: LifacNoiseModel, v_offset, base_stimulus, simulation_le
|
||||
model.set_variable("v_offset", v_offset)
|
||||
try:
|
||||
v, spiketimes = model.simulate(base_stimulus, simulation_length)
|
||||
# if len(spiketimes) > 0:
|
||||
# print("sim length", simulation_length, "last spike", max(spiketimes), "num of spikes:", len(spiketimes))
|
||||
rel_spikes = [s for s in spiketimes if s > simulation_length / 3]
|
||||
|
||||
freq = hF.mean_freq_of_spiketimes_after_time_x(spiketimes, simulation_length / 3)
|
||||
return len(rel_spikes) / (2/3 * simulation_length)
|
||||
except ZeroDivisionError:
|
||||
print("divide by zero!")
|
||||
freq = 0
|
||||
|
20
test.py
20
test.py
@ -39,14 +39,18 @@ eodf = fit.get_cell_data().get_eod_frequency()
|
||||
baseline = BaselineModel(model, eod_frequency=eodf)
|
||||
print("model BF: {:.2f}".format(baseline.get_baseline_frequency()))
|
||||
|
||||
model_no_dend = model.get_model_copy()
|
||||
model_no_dend.parameters["dend_tau"] = 0
|
||||
model_no_dend.parameters["input_scaling"] = 20
|
||||
model_no_dend = LifacNoiseModel({'step_size': 5e-05, 'mem_tau': 0.0018888888888888887, 'v_base': 0, 'v_zero': 0, 'threshold': 1, 'v_offset': -175.9718894958496, 'input_scaling': 364.44444444444446, 'delta_a': 0.03, 'tau_a': 0.1511111111111111, 'a_zero': 4.402004449113477, 'noise_strength': 0, 'dend_tau': 5e-05, 'refractory_period': 0.0007944444444444448}
|
||||
)
|
||||
|
||||
baseline = BaselineModel(model_no_dend, eod_frequency=eodf)
|
||||
print("no dend BF: {:.2f}".format(baseline.get_baseline_frequency()))
|
||||
baseline.plot_interspike_interval_histogram()
|
||||
|
||||
v1, spikes = model_no_dend.simulate(SinusoidalStepStimulus(eodf, 0, 0), 2)
|
||||
plt.plot(v1)
|
||||
plt.show()
|
||||
print("no dend BF: {:.2f}".format(baseline.get_baseline_frequency()))
|
||||
# baseline.plot_interspike_interval_histogram()
|
||||
|
||||
for i in range(10):
|
||||
v1, spikes = model.simulate(SinusoidalStepStimulus(eodf, 0, 0), 30)
|
||||
print("last spikes:", max(spikes))
|
||||
print(len(spikes) / 30)
|
||||
time, freq = hF.calculate_time_and_frequency_trace(spikes, 5e-05)
|
||||
plt.plot(time, freq)
|
||||
plt.show()
|
Loading…
Reference in New Issue
Block a user