add option to fit without dendTau or ref_period
This commit is contained in:
@@ -128,8 +128,10 @@ class LifacNoiseModel(AbstractModel):
|
||||
parameters = np.array(
|
||||
[v_zero, a_zero, step_size, threshold, v_base, delta_a, tau_a, v_offset, mem_tau, noise_strength,
|
||||
time_start, input_scaling, dend_tau, ref_period])
|
||||
|
||||
voltage_trace, adaption, spiketimes, input_voltage = simulate_fast(rectified_stimulus, total_time_s, parameters)
|
||||
if dend_tau >= step_size:
|
||||
voltage_trace, adaption, spiketimes, input_voltage = simulate_fast(rectified_stimulus, total_time_s, parameters)
|
||||
else:
|
||||
voltage_trace, adaption, spiketimes, input_voltage = simulate_fast_no_dend_tau(rectified_stimulus, total_time_s, parameters)
|
||||
|
||||
self.stimulus = stimulus
|
||||
self.input_voltage = input_voltage
|
||||
@@ -304,3 +306,51 @@ def simulate_fast(rectified_stimulus_array, total_time_s, parameters: np.ndarray
|
||||
adaption[i] += delta_a / tau_a
|
||||
|
||||
return output_voltage, adaption, spiketimes, input_voltage
|
||||
|
||||
|
||||
@jit(nopython=True)
|
||||
def simulate_fast_no_dend_tau(rectified_stimulus_array, total_time_s, parameters: np.ndarray):
|
||||
v_zero = parameters[0]
|
||||
a_zero = parameters[1]
|
||||
step_size = parameters[2]
|
||||
threshold = parameters[3]
|
||||
v_base = parameters[4]
|
||||
delta_a = parameters[5]
|
||||
tau_a = parameters[6]
|
||||
v_offset = parameters[7]
|
||||
mem_tau = parameters[8]
|
||||
noise_strength = parameters[9]
|
||||
time_start = parameters[10]
|
||||
input_scaling = parameters[11]
|
||||
dend_tau = parameters[12]
|
||||
ref_period = parameters[13]
|
||||
|
||||
time = np.arange(time_start, total_time_s, step_size)
|
||||
length = len(time)
|
||||
output_voltage = np.zeros(length)
|
||||
adaption = np.zeros(length)
|
||||
input_voltage = rectified_stimulus_array
|
||||
|
||||
spiketimes = []
|
||||
output_voltage[0] = v_zero
|
||||
adaption[0] = a_zero
|
||||
|
||||
for i in range(1, len(time), 1):
|
||||
|
||||
noise_value = np.random.normal()
|
||||
noise = noise_strength * noise_value / np.sqrt(step_size)
|
||||
|
||||
output_voltage[i] = output_voltage[i - 1] + ((v_base - output_voltage[i - 1] + v_offset + (
|
||||
input_voltage[i] * input_scaling) - adaption[i - 1] + noise) / mem_tau) * step_size
|
||||
|
||||
adaption[i] = adaption[i - 1] + ((-adaption[i - 1]) / tau_a) * step_size
|
||||
|
||||
if len(spiketimes) > 0 and time[i] - spiketimes[-1] < ref_period + step_size/2:
|
||||
output_voltage[i] = v_base
|
||||
|
||||
if output_voltage[i] > threshold:
|
||||
output_voltage[i] = v_base
|
||||
spiketimes.append((i * step_size) + time_start)
|
||||
adaption[i] += delta_a / tau_a
|
||||
|
||||
return output_voltage, adaption, spiketimes, input_voltage
|
||||
Reference in New Issue
Block a user