Note
Go to the end to download the full example code
Circular mask and flat probabilityΒΆ
Run this example as a Jupyter notebook
For details and troubleshooting see How to run Jupyter notebooks.
Create two populations on a 30x30 grid of iaf_psc_alpha neurons, connect with circular mask, flat probability, visualize.
BCCN Tutorial @ CNS*09 Hans Ekkehard Plesser, UMB
import nest
import matplotlib.pyplot as plt
import numpy as np
nest.ResetKernel()
pos = nest.spatial.grid(shape=[30, 30], extent=[3., 3.])
create and connect two populations
a = nest.Create('iaf_psc_alpha', positions=pos)
b = nest.Create('iaf_psc_alpha', positions=pos)
cdict = {'rule': 'pairwise_bernoulli',
'p': 0.5,
'mask': {'circular': {'radius': 0.5}}}
nest.Connect(a, b,
conn_spec=cdict,
syn_spec={'weight': nest.random.uniform(0.5, 2.)})
plot targets of neurons in different grid locations
# first, clear existing figure, get current figure
plt.clf()
fig = plt.gcf()
# plot targets of two source neurons into same figure, with mask
for src_index in [30 * 15 + 15, 0]:
# obtain node id for center
src = a[src_index:src_index + 1]
nest.PlotTargets(src, b, mask=cdict['mask'], fig=fig)
# beautify
plt.axes().set_xticks(np.arange(-1.5, 1.55, 0.5))
plt.axes().set_yticks(np.arange(-1.5, 1.55, 0.5))
plt.grid(True)
plt.axis([-2.0, 2.0, -2.0, 2.0])
plt.axes().set_aspect('equal', 'box')
plt.title('Connection targets')
plt.show()
# plt.savefig('connex.pdf')
Total running time of the script: ( 0 minutes 0.000 seconds)