Issues with SpikeGeneratorGroup

Description of problem

I have 3 frequencies for 3 inputs and I’ve generated 3 poisson spikes using PoissonGroup for each of them. an example for the first input is :

P1 = PoissonGroup(1, rates=rate1)
MP = SpikeMonitor(P)
run(500*ms)
spikes_i1 = MP.i
spikes_t 1= MP.t

So I have spikes_t1, spikes_t2,spikes_t3 and also for their indices. because I wanted these generated poisson spikes to remain fixed, I used ‘’’ SGG = SpikeGeneratorGroup(1, spikes_i1, spikes_t1) ‘’’ to give the spikes to a NeuronGroup.
my goal is to give these 3 poisson inputs to my network consecutively during 3 continuous runs.
Since spikes_t1, spikes_t2 and spikes_t3 have generated over 500 ms, Since time continues but the spikes time were generated over 500ms , I don’t know how to set spikes_time for SpikeGeneratorGroup ( my weights are changing after each input so I want them not to reset). In fact, the only thing should change is spikes_times for SpikeGeneratorGroup .
SGG is connected to a NeuronGroup using a synapse.

I could solve this issue with adding an offset to each poisson input over run simulation.
this is an example :

def addSegmentToPoissonSpikes(spikes_t,addSegment):
for index in np.arange(len(spikes_t)):
spikes_t[index] += addSegment
return spikes_t

segment_offset=0ms
for i in np.arange(inputNum):
print("spikes_t_before "+str(i),poissonInput[i]ms)
run(500
ms)
segment_offset=segment_offset+500
ms
spikes_t=addSegmentToPoissonSpikes(poissonSpikeInput[i]*ms,segment_offset)
SGG.set_spikes(np.zeros(len(poissonSpikeInput[i])),spikes_t)
print("spikes_t_after "+str(i),spikes_t)

1 Like

Second Issue

I want to apply a 100 ms interval time between 2 consecutive inputs. (input is fed into my network through SpikeGeneratorGroup: each neuron with one input from SGG)
neuron equation is :

dv/dt = (g_l*(E_l-v) + g_e*(E_e-v) +g_i*(E_i-v)+I_ex*Input) /C_m : volt (unless refractory)
dg_e/dt = -g_e/tau_e : siemens
dg_i/dt = -g_i/tau_i : siemens
Input=stimulus(t-segment_offset):1

SGG = SpikeGeneratorGroup(1, np.zeros(100), np.zeros(100)*ms)
input_exc_syn = Synapses(SGG, exc_neurons, on_pre=‘v += w_input_e’)
input_inh_syn = Synapses(SGG, inh_neurons, on_pre=‘v += w_input_i’)
input_exc_syn.connect()
input_inh_syn.connect()

Considering SpikeGeneratorGroup gets only different spike times and I can’t apply 0 for 100 ms continously, over runs, I applied ’

stimulus = TimedArray(np.zeros(100), dt=1ms)
I_ex=1
pA
SGG.active=False

But after plotting v , I’ve noticed this doesn’t work and seems no 100 ms intervals between inputs. How can I correct it?

Hi again. I don’t quite understand what you want to do. The code for the SpikeGeneratorGroup SGG above uses indices [0, 0, ..., 0] and spike times [0*ms, 0*ms, ..., 0*ms], i.e. it asks for the neuron in the SpikeGeneratorGroup to spike 100 times within the first time step – this cannot work, a neuron cannot spike more than once within a time step.
The TimedArray creates a stimulus that is 0 for the 100ms in which it is specified, but it will stay at 0 also afterwards (since TimedArray will continue to use its last value if you go beyond its length).
Do you want to switch I_ex off for 100ms and then switch it on for 100ms? Or do you want to have I_ex switched on for one time step every 100ms? Please be specific what your input is and what you want to achieve.
For example, with something like

stimulus = TimedArray([0, 1, 0], dt=100*ms)

the value of stimulus will be 0 for the first 100ms, then 1 for the next 100ms, and then 0 for the remaining time.