-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrstdp_imp_test.py
48 lines (42 loc) · 1.54 KB
/
rstdp_imp_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import nest
import nest.raster_plot
import numpy as np
import matplotlib.pyplot as plt
import draw
import globalvalues as gv
gv.configure_nest()
nest.ResetKernel()
type = "iaf_psc_alpha"
inputs = nest.Create("poisson_generator", 1)
# introduce parrot neuron to fix limitation of devices with STDP synapses
parrots = nest.Create("parrot_neuron", 1)
nest.Connect(inputs, parrots)
spike_detector = nest.Create('spike_detector')
nest.Connect(parrots, spike_detector, 'all_to_all')
out = nest.Create(type,1)
vt = nest.Create('volume_transmitter')
gv.define_stdp(vt)
nest.Connect(parrots, out, syn_spec={'model': 'stdp_dopamine_synapse_ex'})
nest.SetStatus(inputs, {"start":0.,
"rate":1000.,
"stop":gv.cycle_length})
nest.Simulate(gv.cycle_length)
#now stop spiking and give reward
conn = nest.GetConnections(source=parrots, target=out)
weights = []
weights.append(np.array(nest.GetStatus(conn, keys="weight")))
nest.SetStatus(conn, {"n": 100.})
weights.append(np.array(nest.GetStatus(conn, keys="weight")))
nest.Simulate(1.)
weights.append(np.array(nest.GetStatus(conn, keys="weight")))
nest.Simulate(1.)
weights.append(np.array(nest.GetStatus(conn, keys="weight")))
nest.Simulate(1.)
weights.append(np.array(nest.GetStatus(conn, keys="weight")))
spikes = nest.GetStatus(spike_detector)[0]["events"]
draw.spikes(spikes)
#nest.raster_plot.from_device(spike_detector, hist=True, hist_binwidth=40.,
# title='Repeated stimulation by Poisson generator')
#nest.raster_plot.show()
plt.plot(weights)
plt.show()