Hello ,
I’m working on a neural simulation where my input is a variable firing rate for the first and second half of Poisson neurons. Here’s what I intend:
-
Input Parameters:
sim=True
: The input is the same for two periods with a given duration.sim=None
: The first period is driven by the input, and the second period is just the background.sim=False
: Different inputs are specified for each period.
-
Issue:
I have constructed theinput_timeArray
function to generate the timed array based on these settings (see code below). My problem is understanding why the average firing rate, in the case where the input is the same for both periods (sim=True
), shows a difference. Shouldn’t the rates be the same?
Code Snippet:
def input_timeArray(input, amp_inp, bg_inp_rate, dur_rep, dt=0.1*ms, sim=True):
def generate_period_input(input, amp_inp, bg_inp_rate):
result = np.array([amp * inp + bg for amp, inp, bg in zip(amp_inp, input, bg_inp_rate)])
return result.reshape(1, -1)
n_time_points = int(dur_rep / dt)
if sim is True:
period_input = np.tile(generate_period_input(input, amp_inp, bg_inp_rate), (n_time_points, 1))
full_input_array = np.tile(period_input, (2, 1))
elif sim is None:
period_input = np.tile(generate_period_input(input, amp_inp, bg_inp_rate), (n_time_points, 1))
background_input = np.tile(np.array([bg for bg in bg_inp_rate]), (n_time_points, 1))
full_input_array = np.vstack([period_input, background_input])
else:
full_input_list = []
for inp in input:
period_input = np.tile(generate_period_input(inp, amp_inp, bg_inp_rate), (n_time_points, 1))
full_input_list.append(period_input)
full_input_array = np.vstack(full_input_list)
return TimedArray(full_input_array * Hz, dt=dt)
# Example Usage
input_array = input_timeArray(network_ginput, amp_inp, bg_inp_rate, durations[0], sim=True)
Neuron Group Configuration:
inp_eqs = '''
unit_idx : integer (constant)
x : 1
y : 1
rate = input_array(t, i) : Hz
'''
p_in_v1_l4 = NeuronGroup(neuron_population_sizes['input'], inp_eqs, threshold='rand() < rate*dt',
method='euler', name='poisson_input_v1_l4')
Could anyone provide insights or suggest modifications to ensure the consistency of firing rates across similar periods?
Thank you in advance!