Consistency Issues with Poisson Input in Timed Arrays

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:

  1. 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.
  2. Issue:
    I have constructed the input_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!


Hi @elnaz91. I am not entirely sure that I understand what makes you say that the average firing rate “shows a difference” over time. Is it because your “Population Firing Rates” plot varies over time? I think this is normal, given that you have random Poisson firing and a relatively small population. Here’s an example run/plot I did, where I plot the average firing rate with different smoothing windows:

# Example Usage
input_array = input_timeArray(np.repeat([5, 10], 100), np.repeat([1, 2], 100), np.repeat([5, 5], 100), 500*ms, sim=True)
inp_eqs = 'rate = input_array(t, i) : Hz'
p_in_v1_l4 = NeuronGroup(200, inp_eqs, threshold='rand() < rate*dt', 
                         method='euler', name='poisson_input_v1_l4')
spike_mon = SpikeMonitor(p_in_v1_l4)
rate_mon = PopulationRateMonitor(p_in_v1_l4)
run(1000*ms)
fig, axs = plt.subplots(2, 1, sharex=True)
axs[0].plot(spike_mon.t/ms, spike_mon.i, '.k')
axs[1].plot(rate_mon.t/ms, rate_mon.smooth_rate(width=5*ms)/Hz)
axs[1].plot(rate_mon.t/ms, rate_mon.smooth_rate(width=10*ms)/Hz)
axs[1].plot(rate_mon.t/ms, rate_mon.smooth_rate(width=20*ms)/Hz)
axs[1].plot(rate_mon.t/ms, rate_mon.smooth_rate(width=40*ms)/Hz)
axs[1].set_ylim(0, 25)
show()


As you can see, it varies quite a bit, but I’d say this is normal.