.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/spatial/connex.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_spatial_connex.py: Circular mask and flat probability ---------------------------------- 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 .. GENERATED FROM PYTHON SOURCE LINES 33-42 .. code-block:: default import nest import matplotlib.pyplot as plt import numpy as np nest.ResetKernel() pos = nest.spatial.grid(shape=[30, 30], extent=[3., 3.]) .. GENERATED FROM PYTHON SOURCE LINES 43-44 create and connect two populations .. GENERATED FROM PYTHON SOURCE LINES 44-55 .. code-block:: default 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.)}) .. GENERATED FROM PYTHON SOURCE LINES 56-57 plot targets of neurons in different grid locations .. GENERATED FROM PYTHON SOURCE LINES 57-79 .. code-block:: default # 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') .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_spatial_connex.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: connex.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: connex.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_