Exemplo n.º 1
0
def conn_figure_3d(fig,
                   layer,
                   connd,
                   targets=None,
                   showmask=True,
                   xticks=range(-5, 6),
                   yticks=range(-5, 6),
                   xlim=[-5.5, 5.5],
                   ylim=[-5.5, 5.5]):
    if targets is None:
        targets = ((nest.FindCenterElement(layer), 'red'), )

    nest.PlotLayer(layer, fig=fig, nodesize=20, nodecolor=(.5, .5, 1.))
    for src, clr in targets:
        if showmask:
            mask = connd['mask']
        else:
            mask = None
        nest.PlotTargets(src,
                         layer,
                         fig=fig,
                         mask=mask,
                         probability_parameter=None,
                         src_size=250,
                         tgt_color=clr,
                         tgt_size=60,
                         probability_cmap='Greens')

    ax = fig.gca()
    # ax.set_aspect('equal', 'box')
    plt.draw()
Exemplo n.º 2
0
    def test_PlotTargets(self):
        """Test plotting targets."""
        delta = 0.05
        mask = {
            'rectangular': {
                'lower_left': [-delta, -2 / 3 - delta],
                'upper_right': [2 / 3 + delta, delta]
            }
        }
        cdict = {'rule': 'pairwise_bernoulli', 'p': 1., 'mask': mask}
        sdict = {'synapse_model': 'stdp_synapse'}
        nest.ResetKernel()
        layer = nest.Create('iaf_psc_alpha',
                            positions=nest.spatial.grid(shape=[3, 3],
                                                        extent=[2., 2.],
                                                        edge_wrap=True))

        # connect layer -> layer
        nest.Connect(layer, layer, cdict, sdict)

        ctr = nest.FindCenterElement(layer)
        fig = nest.PlotTargets(ctr, layer)
        fig.gca().set_title('Plain call')

        plotted_datapoints = plt.gca().collections[0].get_offsets().data
        eps = 0.01
        pos = np.array(nest.GetPosition(layer))
        pos_xmask = pos[np.where(pos[:, 0] > -eps)]
        reference_datapoints = pos_xmask[np.where(pos_xmask[:, 1] < eps)][::-1]
        self.assertTrue(
            np.array_equal(np.sort(plotted_datapoints, axis=0),
                           np.sort(reference_datapoints, axis=0)))

        fig = nest.PlotTargets(ctr, layer, mask=mask)
        ax = fig.gca()
        ax.set_title('Call with mask')
        self.assertGreaterEqual(len(ax.patches), 1)
Exemplo n.º 3
0
def conn_figure(fig,
                layer,
                connd,
                targets=None,
                showmask=True,
                kern=None,
                xticks=range(-5, 6),
                yticks=range(-5, 6),
                xlim=[-5.5, 5.5],
                ylim=[-5.5, 5.5]):
    if targets is None:
        targets = ((nest.FindCenterElement(layer), 'red'), )

    nest.PlotLayer(layer, fig=fig, nodesize=60)
    for src, clr in targets:
        if showmask:
            mask = connd['mask']
        else:
            mask = None
        nest.PlotTargets(src,
                         layer,
                         fig=fig,
                         mask=mask,
                         probability_parameter=kern,
                         src_size=250,
                         tgt_color=clr,
                         tgt_size=20,
                         mask_color='red',
                         probability_cmap='Greens')

    beautify_layer(layer,
                   fig,
                   xlim=xlim,
                   ylim=ylim,
                   xticks=xticks,
                   yticks=yticks,
                   xlabel='',
                   ylabel='')
    fig.gca().grid(False)
nest.Connect(retina, TpRelay, retThal_conn_spec, retThal_syn_spec)
nest.Connect(retina, TpInter, retThal_conn_spec, retThal_syn_spec)

##############################################################################
# Checks on connections
# ---------------------
#
# As a very simple check on the connections created, we inspect
# the connections from the central node of various layers.

# Connections from Retina to TpRelay
retina_ctr_node_id = nest.FindCenterElement(retina)
retina_ctr_index = retina.index(retina_ctr_node_id.global_id)
conns = nest.GetConnections(retina[retina_ctr_index], TpRelay)
nest.PlotTargets(retina[retina_ctr_index], TpRelay, 'AMPA')
plt.title('Connections Retina -> TpRelay')

# Connections from TpRelay to L4pyr in Vp (horizontally tuned)
TpRelay_ctr_node_id = nest.FindCenterElement(TpRelay)
TpRelay_ctr_index = TpRelay.index(TpRelay_ctr_node_id.global_id)
nest.PlotTargets(TpRelay[TpRelay_ctr_index], Vp_h_layers['L4pyr_0'], 'AMPA')
plt.title('Connections TpRelay -> Vp(h) L4pyr')

# Connections from TpRelay to L4pyr in Vp (vertically tuned)
nest.PlotTargets(TpRelay[TpRelay_ctr_index], Vp_v_layers['L4pyr_0'], 'AMPA')
plt.title('Connections TpRelay -> Vp(v) L4pyr')

# Block until the figures are closed before we continue.
plt.show(block=True)
Exemplo n.º 5
0
#{ vislayer #}
l = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[21, 21]))
probability_param = nest.spatial_distributions.gaussian(nest.spatial.distance,
                                                        std=0.15)
conndict = {
    'rule': 'pairwise_bernoulli',
    'p': probability_param,
    'mask': {
        'circular': {
            'radius': 0.4
        }
    }
}
nest.Connect(l, l, conndict)
fig = nest.PlotLayer(l, nodesize=80)

ctr = nest.FindCenterElement(l)
nest.PlotTargets(ctr,
                 l,
                 fig=fig,
                 mask=conndict['mask'],
                 probability_parameter=probability_param,
                 src_size=250,
                 tgt_color='red',
                 tgt_size=20,
                 mask_color='red',
                 probability_cmap='Greens')
#{ end #}
plt.savefig('../user_manual_figures/vislayer.png', bbox_inches='tight')
Exemplo n.º 6
0
         'mask': {'circular': {'radius': 3.0}}}

nest.Connect(a, b, cdict)

#####################################################################
# plot targets of neurons in different grid locations
#
# plot targets of two source neurons into same figure, with mask
# use different colors

for src_index, color, cmap in [(30 * 15 + 15, 'blue', 'Blues'), (0, 'green', 'Greens')]:
    # obtain node id for center
    src = a[src_index:src_index + 1]
    fig = plt.figure()
    nest.PlotTargets(src, b, mask=cdict['mask'], probability_parameter=cdict['p'],
                     src_color=color, tgt_color=color, mask_color=color,
                     probability_cmap=cmap, src_size=100,
                     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, Gaussian kernel')

plt.show()

# plt.savefig('gaussex.pdf')
Exemplo n.º 7
0
    }
}

nest.Connect(a,
             b,
             conn_spec=cdict,
             syn_spec={'weight': nest.random.uniform(0.5, 2.)})

#####################################################################
# 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('conncon_targets.pdf')
# For each population, we create a CSA-style geometry function and a CSA metric
# based on them.

g1 = geometryFunction(pop1)
g2 = geometryFunction(pop2)
d = csa.euclidMetric2d(g1, g2)

###############################################################################
# The connection set `cs` describes a Gaussian connectivity profile with
# ``sigma = 0.2`` and cutoff at 0.5, and two values (10000.0 and 1.0) used as
# ``weight`` and ``delay``, respectively.

cs = csa.cset(csa.random * (csa.gaussian(0.2, 0.5) * d), 10000.0, 1.0)

###############################################################################
# We can now connect the populations using the ``CGConnect`` function. It
# takes the IDs of pre- and postsynaptic neurons (`pop` and `pop2`),
# the connection set (`cs`) and a dictionary that map the parameters
# weight and delay to positions in the value set associated with the
# connection set.

nest.CGConnect(pop1, pop2, cs, {"weight": 0, "delay": 1})

###############################################################################
# Finally, we use the ``PlotTargets`` function to show all targets in `pop2`
# starting at the center neuron of `pop1`.

cntr = nest.FindCenterElement(pop1)
nest.PlotTargets(cntr, pop2)
plt.show()