コード例 #1
0
    def test_PlotTargets(self):
        """Test plotting targets."""
        ldict = {'elements': ['iaf_neuron', 'iaf_psc_alpha'], 'rows': 3,
                 'columns': 3,
                 'extent': [2., 2.], 'edge_wrap': True}
        cdict = {'connection_type': 'divergent',
                 'mask': {'grid': {'rows': 2, 'columns': 2}}}
        nest.ResetKernel()
        l = topo.CreateLayer(ldict)
        ian = [gid for gid in nest.GetLeaves(l)[0]
               if nest.GetStatus([gid], 'model')[0] == 'iaf_neuron']
        ipa = [gid for gid in nest.GetLeaves(l)[0]
               if nest.GetStatus([gid], 'model')[0] == 'iaf_psc_alpha']

        # connect ian -> all using static_synapse
        cdict.update({'sources': {'model': 'iaf_neuron'},
                      'synapse_model': 'static_synapse'})
        topo.ConnectLayers(l, l, cdict)
        for k in ['sources', 'synapse_model']:
            cdict.pop(k)

        # connect ipa -> ipa using stdp_synapse
        cdict.update({'sources': {'model': 'iaf_psc_alpha'},
                      'targets': {'model': 'iaf_psc_alpha'},
                      'synapse_model': 'stdp_synapse'})
        topo.ConnectLayers(l, l, cdict)
        for k in ['sources', 'targets', 'synapse_model']:
            cdict.pop(k)

        ctr = topo.FindCenterElement(l)
        fig = topo.PlotTargets(ctr, l)
        fig.gca().set_title('Plain call')

        self.assertTrue(True)
コード例 #2
0
    def test_GetTargetNodesPositions(self):
        """Interface check for finding targets."""
        ldict = {'elements': ['iaf_neuron', 'iaf_psc_alpha'], 'rows': 3, 'columns':3,
                 'extent': [2., 2.], 'edge_wrap': True}
        cdict = {'connection_type': 'divergent', 
                 'mask': {'grid': {'rows':2, 'columns':2}}}     
        nest.ResetKernel()
        l = topo.CreateLayer(ldict)
        ian = [gid for gid in nest.GetLeaves(l)[0]
               if nest.GetStatus([gid], 'model')[0] == 'iaf_neuron']
        ipa = [gid for gid in nest.GetLeaves(l)[0]
               if nest.GetStatus([gid], 'model')[0] == 'iaf_psc_alpha']
        
        # connect ian -> all using static_synapse
        cdict.update({'sources': {'model': 'iaf_neuron'},
                      'synapse_model': 'static_synapse'})
        topo.ConnectLayers(l, l, cdict)
        for k in ['sources', 'synapse_model']: cdict.pop(k)
        
        # connect ipa -> ipa using stdp_synapse
        cdict.update({'sources': {'model': 'iaf_psc_alpha'},
                      'targets': {'model': 'iaf_psc_alpha'},
                      'synapse_model': 'stdp_synapse'})
        topo.ConnectLayers(l, l, cdict)
        for k in ['sources', 'targets', 'synapse_model']: cdict.pop(k)
        
        t = topo.GetTargetNodes(ian[:1], l)
        self.assertEqual(len(t), 1)

        p = topo.GetTargetPositions(ian[:1], l)
        self.assertEqual(len(p), 1)
        self.assertTrue(all([len(pp)==2 for pp in p[0]]))
        
        t = topo.GetTargetNodes(ian, l)
        self.assertEqual(len(t), len(ian))
        self.assertTrue(all([len(g)==8 for g in t])) # 2x2 mask x 2 neurons / element -> eight targets  

        p = topo.GetTargetPositions(ian, l)
        self.assertEqual(len(p), len(ian))
        

        t = topo.GetTargetNodes(ian, l, tgt_model='iaf_neuron')
        self.assertEqual(len(t), len(ian))
        self.assertTrue(all([len(g)==4 for g in t])) # 2x2 mask  -> four targets  

        t = topo.GetTargetNodes(ian, l, tgt_model='iaf_psc_alpha')
        self.assertEqual(len(t), len(ian))
        self.assertTrue(all([len(g)==4 for g in t])) # 2x2 mask  -> four targets  

        t = topo.GetTargetNodes(ipa, l)
        self.assertEqual(len(t), len(ipa))
        self.assertTrue(all([len(g)==4 for g in t])) # 2x2 mask  -> four targets  

        t = topo.GetTargetNodes(ipa, l, syn_model='static_synapse')
        self.assertEqual(len(t), len(ipa))
        self.assertTrue(all([len(g)==0 for g in t])) # no static syns  

        t = topo.GetTargetNodes(ipa, l, syn_model='stdp_synapse')
        self.assertEqual(len(t), len(ipa))
        self.assertTrue(all([len(g)==4 for g in t])) # 2x2 mask  -> four targets  
コード例 #3
0
ファイル: funciones.py プロジェクト: arturodcv/Modelling
def lgn_to_v1_connections(l_exc, l_inh, sd_exc, sd_inh, l_poiss,
                          self_orientation):
    tp.ConnectLayers(l_poiss, l_exc, dict_poiss_to_v1)
    tp.ConnectLayers(l_poiss, l_inh, dict_poiss_to_v1)
    leaves_exc = nest.GetLeaves(l_exc, local_only=True)[0]
    nest.Connect(leaves_exc, sd_exc)
    leaves_inh = nest.GetLeaves(l_inh, local_only=True)[0]
    nest.Connect(leaves_inh, sd_inh)
コード例 #4
0
ファイル: simulation_utils.py プロジェクト: sunzhe839/bgmodel
def inspect_network():
    model_list, model_dict = models()
    layer_list, connect_list = network(model_dict)

    # Create neurons and synapses
    layer_dic = {}
    for name, model, props in layer_list:
        my_nest.MyLoadModels(model_dict, [model[1]])

        #! Create layer, retrieve neurons ids per elements and p
        if model[0] == 'spike_generator':
            layer = MyLayerPoissonInput(layer_props=props, sd=False)
        else:
            layer = MyLayerGroup(layer_props=props,
                                 sd=True,
                                 mm=True,
                                 mm_dt=0.1)
        layer_dic[name] = layer

    # Connect populations
    for conn in connect_list:
        my_nest.MyLoadModels(model_dict, [conn[2]['synapse_model']])
        name = conn[0] + '_' + conn[1] + '_' + conn[3]
        tp.ConnectLayers(layer_dic[conn[0]].layer_id,
                         layer_dic[conn[1]].layer_id, conn[2])
        layer_dic[conn[1]].add_connection(source=layer_dic[conn[0]],
                                          type=conn[3],
                                          props=conn[2])

    return layer_dic
コード例 #5
0
ファイル: layers.py プロジェクト: TomBugnon/deNEST
 def create(self):
     from nest import topology as tp
     import nest
     # Create sublayers
     self._layer_call('create')
     # Set the GID
     self._gid = flatten(self._layer_get('gid'))
     # Connect stimulators to parrots, one-to-one
     # IMPORTANT: This assumes that all layers are the same size!
     radius = self.extent_units(0.1)
     one_to_one_connection = {
         'sources': {
             'model': self.stimulator_model
         },
         'targets': {
             'model': self.PARROT_MODEL
         },
         'connection_type': 'convergent',
         'synapse_model': 'static_synapse',
         'mask': {
             'circular': {
                 'radius': radius
             }
         }
     }
     tp.ConnectLayers(self._gid, self._gid, one_to_one_connection)
     # Get stimulator type
     self.stimulator_type = nest.GetDefaults(self.stimulator_model,
                                             'type_id')
コード例 #6
0
    def test_DumpConns(self):
        """Test dumping connections."""
        ldict = {
            'elements': 'iaf_psc_alpha',
            'rows': 3,
            'columns': 3,
            'extent': [2., 2.],
            'edge_wrap': True
        }
        cdict = {
            'connection_type': 'divergent',
            'mask': {
                'circular': {
                    'radius': 1.
                }
            }
        }
        nest.ResetKernel()
        l = topo.CreateLayer(ldict)
        topo.ConnectLayers(l, l, cdict)

        topo.DumpLayerConnections(
            l, 'static_synapse',
            os.path.join(self.nest_tmpdir(), 'test_DumpConns.out.cnn'))
        self.assertTrue(True)
コード例 #7
0
def pn_fig(fig, loc, ldict, cdict,
           xlim=[0., .5], ylim=[0, 3.5], xticks=range(0, 51, 5),
           yticks=np.arange(0., 1.1, 0.2), clr='blue',
           label=''):
    nest.ResetKernel()
    l = tp.CreateLayer(ldict)
    tp.ConnectLayers(l, l, cdict)

    ax = fig.add_subplot(loc)

    rn = nest.GetLeaves(l)[0]
    conns = nest.GetConnections(rn)
    cstat = nest.GetStatus(conns)
    srcs = [sd['source'] for sd in cstat]
    tgts = [sd['target'] for sd in cstat]
    dist = np.array(tp.Distance(srcs, tgts))
    ax.hist(dist, bins=50, histtype='stepfilled', normed=True)
    r = np.arange(0., 0.51, 0.01)

    plt.plot(r, 2 * np.pi * r * (1 - 2 * r) * 12 / np.pi, 'r-', lw=3,
             zorder=-10)

    ax.set_xlim(xlim)
    ax.set_ylim(ylim)
    """ax.set_xticks(xticks)
    ax.set_yticks(yticks)"""
    # ax.set_aspect(100, 'box')
    ax.set_xlabel('Source-target distance d')
    ax.set_ylabel('Connection probability pconn(d)')
コード例 #8
0
def wd_fig(fig,
           loc,
           ldict,
           cdict,
           what,
           rpos=None,
           xlim=[-1, 51],
           ylim=[0, 1],
           xticks=range(0, 51, 5),
           yticks=np.arange(0., 1.1, 0.2),
           clr='blue',
           label=''):
    nest.ResetKernel()
    l = tp.CreateLayer(ldict)
    tp.ConnectLayers(l, l, cdict)

    ax = fig.add_subplot(loc)

    if rpos is None:
        rn = nest.GetLeaves(l)[0][:1]  # first node
    else:
        rn = tp.FindNearestElement(l, rpos)

    conns = nest.GetConnections(rn)
    cstat = nest.GetStatus(conns)
    vals = np.array([sd[what] for sd in cstat])
    tgts = [sd['target'] for sd in cstat]
    locs = np.array(tp.GetPosition(tgts))
    ax.plot(locs[:, 0], vals, 'o', mec='none', mfc=clr, label=label)
    ax.set_xlim(xlim)
    ax.set_ylim(ylim)
    ax.set_xticks(xticks)
    ax.set_yticks(yticks)
コード例 #9
0
def create_local_circular_connections(layer,
                                      r_loc=0.5,
                                      p_loc=0.7,
                                      allow_autapses=False,
                                      allow_multapses=False):
    """
    Create local connections with in a circular radius
    :param layer: The layer where the local connections should be established
    :param r_loc: radius for local connections
    :param p_loc: probability of establishing local connections
    :param allow_autapses: Flag to allow self-connections
    :param allow_multapses: Flag to allow multiple connections between neurons
    """

    # Define mask
    mask_dict = {"circular": {"radius": r_loc}}

    # Define connection parameters
    connection_dict = {
        "connection_type": "divergent",
        "mask": mask_dict,
        "kernel": p_loc,
        "allow_autapses": allow_autapses,
        "allow_multapses": allow_multapses,
        "synapse_model": "static_synapse"
    }

    tp.ConnectLayers(layer, layer, connection_dict)
コード例 #10
0
ファイル: func.py プロジェクト: xerebral/NEUCOGAR
def connect(pre, post, syn_type, weight_coef=1, params=None):
    """
    Connect outer parts of two 3d layers
    Args:
        pre: source layer
        post: target layer
        syn_type: synapse type
        weight_coef: weight coefficient for synapses
        params: custom connection params
    Returns: None
    """

    # Create dictionary of connection rules
    conn_dict = {
        'connection_type': 'divergent',
        'weights': float(weight_coef * synapses[syn_type][basic_weight]),
        'delays': {
            'linear': {  # linear is y = ax+c TODO appropriate function
                'c': 1.,
                'a': .5
            }
        },
        'synapse_model': synapses[syn_type][model]
    }
    if params is not None:
        conn_dict.update(params)

    tp.ConnectLayers(pre[k_outer], post[k_outer], conn_dict)

    # Show data of new connection
    count = len(
        nest.GetConnections(source=pre[k_outer_ids], target=post[k_outer_ids]))
    g.SYNAPSES += count
    log_connection(pre, post, synapses[syn_type][model], conn_dict['weights'],
                   count)
コード例 #11
0
def free_mask_fig(fig, loc, cdict):
    nest.ResetKernel()
    l = tp.CreateLayer({'rows': 11, 'columns': 11, 'extent': [11., 11.],
                        'elements': 'iaf_psc_alpha'})
    tp.ConnectLayers(l, l, cdict)

    fig.add_subplot(loc)
    conn_figure(fig, l, cdict, xticks=range(-5, 6, 2), yticks=range(-5, 6, 2))
コード例 #12
0
def kernel_fig(fig, loc, cdict, showkern=True):
    nest.ResetKernel()
    l = tp.CreateLayer({'rows': 11, 'columns': 11, 'extent': [11., 11.],
                        'elements': 'iaf_neuron'})
    tp.ConnectLayers(l, l, cdict)

    fig.add_subplot(loc)
    conn_figure(fig, l, cdict, xticks=range(-5, 6, 2), yticks=range(-5, 6, 2),
                showkern=showkern)
コード例 #13
0
def free_mask_3d_fig(fig, loc, cdict):
    nest.ResetKernel()
    l = tp.CreateLayer(
        {'rows': 11, 'columns': 11, 'layers': 11, 'extent': [11., 11., 11.],
         'elements': 'iaf_neuron'})
    tp.ConnectLayers(l, l, cdict)

    fig.add_subplot(loc, projection='3d')
    conn_figure_3d(fig, l, cdict, xticks=range(-5, 6, 2),
                   yticks=range(-5, 6, 2))
コード例 #14
0
def plot_layer_targets(cds, savename):
    layer = topo.CreateLayer(layer_dict)
    for cd in cds:
        topo.ConnectLayers(layer, layer, cd)

    ctr = topo.FindCenterElement(layer)
    fig = topo.PlotLayer(layer, nodesize=20)
    topo.PlotTargets(ctr, layer, fig=fig, tgt_color="red")

    plt.savefig("%s.png" % savename)
    plt.close()
コード例 #15
0
def plot_layer_targets(cds, savename):
    nest.ResetKernel()
    layer = topp.CreateLayer({"rows":rowcol, "columns":rowcol, 
                              "extent":extent, "elements":model})
    for cd in cds:
        topp.ConnectLayers(layer, layer, cd)
    
    ctr = topp.FindCenterElement(layer)
    fig = topp.PlotLayer(layer, nodesize=20)
    topp.PlotTargets(ctr,layer, fig=fig, tgt_color="red")
    
    pylab.savefig("%s.png"%savename)
    pylab.close()
コード例 #16
0
def check_distance():
    layer = tp.CreateLayer(l3d_specs)
    tp.ConnectLayers(layer, layer, conn_dict1)

    nodes = nest.GetChildren(layer)[0]

    positions = tp.GetPosition(nodes)
    target_positions = tp.GetTargetPositions(nodes, layer)

    deltas = filter(
        lambda x: x > 0.35,
        [[get_delta(positions[i], pos2) for pos2 in target_positions[i]]
         for i in range(len(positions))])
    print len(deltas)
コード例 #17
0
    def kolmogorov_smirnov(self, weight_dict, expected_cdf_func):
        """
        Create connections with given distribution of weights and test that it
        fits the given expected cumulative distribution using K-S.
        """

        # n = rows * cols * Nconn
        rows = 10
        cols = 10
        Nconn = 100

        nest.ResetKernel()

        # Create layer and connect with given weight distribution
        layer = topo.CreateLayer({
            'rows': rows,
            'columns': cols,
            'elements': 'iaf_psc_alpha'
        })
        topo.ConnectLayers(
            layer, layer, {
                'connection_type': 'convergent',
                'number_of_connections': Nconn,
                'weights': weight_dict
            })

        # Get connection weights and sort
        connectome = nest.GetConnections()
        weights = numpy.array(nest.GetStatus(connectome, 'weight'))
        weights.sort()
        n = len(weights)

        # The observed (empirical) cdf is simply i/n for weights[i]
        observed_cdf = numpy.arange(n + 1, dtype=float) / n
        expected_cdf = expected_cdf_func(weights)

        D = max(
            numpy.abs(expected_cdf - observed_cdf[:-1]).max(),
            numpy.abs(expected_cdf - observed_cdf[1:]).max())

        # Code to find Kalpha corresponding to level alpha:
        # alpha = 0.05
        # import scipy.optimize,scipy.stats
        # Kalpha = scipy.optimize.fmin(lambda x:
        #                              abs(alpha-scipy.stats.ksprob(x)), 1)[0]
        Kalpha = 1.3581054687500012

        self.assertTrue(sqrt(n) * D < Kalpha)
コード例 #18
0
def plot_layer_targets(cds, savename):
    nest.ResetKernel()
    layer = topp.CreateLayer({
        'rows': rowcol,
        'columns': rowcol,
        'extent': extent,
        'elements': model
    })
    for cd in cds:
        topp.ConnectLayers(layer, layer, cd)

    ctr = topp.FindCenterElement(layer)
    fig = topp.PlotLayer(layer, nodesize=20)
    topp.PlotTargets(ctr, layer, fig=fig, tgt_color='red')

    pylab.savefig('%s.png' % savename)
    pylab.close()
コード例 #19
0
def get_Relative_Weight(params, radius):

    # Create a fictional network and count the number of target connections
    layerProps = {
        'rows': params['N'],
        'columns': params['N'],
        'extent': [params['visSize'], params['visSize']],
        'edge_wrap': True,
        'elements': 'iaf_cond_exp'
    }

    l = tp.CreateLayer(layerProps)

    dict = {
        "connection_type": "convergent",
        "mask": {
            "circular": {
                "radius": radius
            }
        },
        "kernel": 1.0,
        "weights": {
            "gaussian": {
                "p_center": 1.0,
                "sigma": radius / 3.0
            }
        }
    }

    tp.ConnectLayers(l, l, dict)
    ctr = tp.FindCenterElement(l)
    targets = tp.GetTargetNodes(ctr, l)

    #    print ("Number of targets = ",len(targets[0]))

    conn = nest.GetConnections(ctr, targets[0])
    st = nest.GetStatus(conn)

    w = 0.0
    for n in np.arange(len(st)):
        w += st[n]['weight']

#    print ("Total weight = ",w)

    return w, len(targets[0])
コード例 #20
0
def plot_connections(layer_dict, conn_dict, file_name):
    conn_dict['synapse_model'] = 'static_synapse'
    layer = tp.CreateLayer(layer_dict)

    tp.ConnectLayers(layer, layer, conn_dict)

    fig = tp.PlotLayer(layer)
    tp.PlotTargets(tp.FindCenterElement(layer),
                   layer,
                   fig=fig,
                   tgt_color='red')
    pylab.savefig(file_name)
    #pylab.show()

    tp.DumpLayerConnections(layer, conn_dict['synapse_model'],
                            file_name + ".dump")

    positions = tp.GetTargetPositions(layer, layer)
コード例 #21
0
    def build_network(self, conn_type):
        """
        Build network with randomized weights.

        conn_type: 'convergent' or 'divergent'

        """

        n_vp = nest.GetKernelStatus()['total_num_virtual_procs']
        nest.SetKernelStatus({
            'grng_seed':
            self.master_seed + n_vp,
            'rng_seeds':
            range(self.master_seed + n_vp + 1, self.master_seed + 2 * n_vp + 1)
        })

        layer = topo.CreateLayer({
            'rows': 10,
            'columns': 10,
            'edge_wrap': False,
            'elements': 'iaf_psc_delta'
        })

        topo.ConnectLayers(
            layer, layer, {
                'connection_type': conn_type,
                'mask': {
                    'circular': {
                        'radius': 0.5
                    }
                },
                'kernel': 1.0,
                'weights': {
                    'uniform': {
                        'min': 1.0,
                        'max': 1.5
                    }
                },
                'delays': 1.0
            })
コード例 #22
0
def create_overlapping_patches(layer,
                               r_loc=0.5,
                               p_loc=0.7,
                               distance=2.5,
                               num_patches=3,
                               allow_multapses=False):
    """
    Create long-range patchy connections with overlapping patches such that all neurons share almost the same
    parameters for these links
    :param layer: The layer in which the connections should be established
    :param r_loc: Radius of local connections
    :param p_loc: Probability of local connections
    :param distance: Distance of patches
    :param num_patches: Number of patches
    :param allow_multapses: Flag to allow multiple links between neurons
    :return: Neurons of the layer for debugging (plotting)
    """
    # Calculate parameters for pathces
    r_p = r_loc / 2.
    p_p = get_lr_connection_probability_patches(r_loc, p_loc, r_p)

    # Create overlapping patches as every neuron shares the same patch parameter
    for n in range(1, num_patches + 1):
        angle = n * 360. / float(num_patches)
        coordinates = to_coordinates(angle, distance)
        mask_dict = {"circular": {"radius": r_p, "anchor": coordinates}}

        connection_dict = {
            "connection_type": "divergent",
            "mask": mask_dict,
            "kernel": p_p,
            "allow_autapses": False,
            "allow_multapses": allow_multapses,
            "synapse_model": "static_synapse"
        }

        tp.ConnectLayers(layer, layer, connection_dict)

    # Return nodes of layer for debugging
    return nest.GetNodes(layer)[0]
コード例 #23
0
ファイル: funciones.py プロジェクト: arturodcv/Modelling
def v1_lateral_connections(l_exc_i, l_exc_j, l_inh_i, l_inh_j, orientation_i,
                           orientation_j):
    if orientation_i == orientation_j:
        tp.ConnectLayers(l_exc_i, l_inh_j, short_range_exc_inh)
        tp.ConnectLayers(l_exc_i, l_exc_j, short_range_exc_exc)

    tp.ConnectLayers(l_inh_i, l_inh_j, short_range_inh_inh)
    tp.ConnectLayers(l_inh_i, l_exc_j, short_range_inh_exc)
    tp.ConnectLayers(
        l_exc_i, l_exc_j,
        create_lat_exc('PlosOne_J', kappa_j, orientation_i, orientation_j,
                       weight_large_range_exc_exc, delay_exc_large,
                       slowness_exc_large))
    tp.ConnectLayers(
        l_exc_i, l_inh_j,
        create_lat_exc('PlosOne_W', kappa_w, orientation_i, orientation_j,
                       weight_large_range_exc_inh, delay_exc_large,
                       slowness_exc_large))
コード例 #24
0
def create_distant_np_connections(layer,
                                  r_loc=0.5,
                                  p_loc=0.7,
                                  allow_multapses=False):
    """
    Create long distance connections without any patches
    :param layer: Layer in which the connections should be established
    :param r_loc: radius for local connections needed to calculate the long range connection probability
    :param p_loc: probability for local connections needed to calculate the long range connection probability
    :param allow_multapses: allow multiple connections between neurons
    :return Neurons of the layer for debugging (plotting)
    """
    # Mask for area to which long-range connections can be established
    mask_dict = {
        "doughnut": {
            "inner_radius": r_loc,
            "outer_radius": R_MAX / 2.
        }
    }

    # Get possibility to establish a single long-range connection
    p_lr = get_lr_connection_probability_np(r_loc, p_loc)

    connection_dict = {
        "connection_type": "divergent",
        "mask": mask_dict,
        "kernel": p_lr,
        "allow_autapses": False,
        "allow_multapses": allow_multapses,
        "allow_oversized_mask": True,
    }

    tp.ConnectLayers(layer, layer, connection_dict)

    # Return nodes of layer for debugging
    return nest.GetNodes(layer)[0]
    def test_get_in_out_degree(self):
        self.reset()
        layer = create_torus_layer_with_jitter(4, jitter=0, layer_size=2.)
        conn_dict = {
            "connection_type": "divergent",
            "mask": {
                "rectangular": {
                    "lower_left": [-1.0, -1.0],
                    "upper_right": [1.0, 1.0]
                }
            },
            "kernel": 1.0
        }

        expect_in = [9, 6, 6, 4]
        expect_out = [4, 6, 6, 9]

        tp.ConnectLayers(layer, layer, conn_dict)
        in_degree, out_degree, _, _, _, _ = tu.get_in_out_degree(
            nest.GetNodes(layer)[0])
        self.assertListEqual(expect_in, in_degree,
                             "In degree was not computed correctly")
        self.assertListEqual(expect_out, out_degree,
                             "Out degree was not computed correctly")
コード例 #26
0
#! Corticoreticular
#! ----------------

#! In this case, there is only a single connection, so we write the
#! dictionary itself; it is very similar to the corThalBase, and to
#! show that, we copy first, then update. We need no ``targets`` entry,
#! since Rp has only one neuron per location.
corRet = corThalBase.copy()
corRet.update({"sources": {"model": "L56pyr"}, "weights": 2.5})

#! Build all connections beginning in cortex
#! -----------------------------------------

#! Cortico-cortical, same orientation
print "Connecting: cortico-cortical, same orientation"
[topo.ConnectLayers(Vp_h, Vp_h, conn) for conn in ccConnections]
[topo.ConnectLayers(Vp_v, Vp_v, conn) for conn in ccConnections]

#! Cortico-cortical, cross-orientation
print "Connecting: cortico-cortical, other orientation"
[topo.ConnectLayers(Vp_h, Vp_v, conn) for conn in ccxConnections]
[topo.ConnectLayers(Vp_v, Vp_h, conn) for conn in ccxConnections]

#! Cortico-thalamic connections
print "Connecting: cortico-thalamic"
[topo.ConnectLayers(Vp_h, Tp, conn) for conn in ctConnections]
[topo.ConnectLayers(Vp_v, Tp, conn) for conn in ctConnections]
topo.ConnectLayers(Vp_h, Rp, corRet)
topo.ConnectLayers(Vp_v, Rp, corRet)

#! Thalamo-cortical connections
コード例 #27
0
def setup_network():

    print "[ Creating excitatory population ]"
    # 1) create excitatory populations
    l0_exc_population = tp.CreateLayer({
        'rows':
        1,
        'columns':
        num['l0_exc_neurons'],
        'extent': [float(num['l0_exc_neurons']), 1.],
        'elements':
        'iaf_cond_exp',
        'edge_wrap':
        True
    })

    print "[ Creating inhibitory population ]"
    # 2) create inhibitory population
    l0_inh_population = tp.CreateLayer({
        'rows':
        1,
        'columns':
        num['l0_inh_neurons'],
        'extent': [float(num['l0_inh_neurons']), 1.],
        'elements':
        'iaf_cond_exp',
        'edge_wrap':
        True
    })

    print "[ Projecting excitatory -> inhibitory population ]"
    # 3) exc -> inh
    CopyModel('static_synapse', 'exc_inh', {'weight': w_exc0_inh0})
    l0_exc_inh_dict = {
        'connection_type': 'convergent',
        'mask': {
            'rectangular': {
                'lower_left': [-0.5, -0.5],
                'upper_right': [0.5, 0.5]
            }
        },
        #'kernel':p_exc0_inh0,
        'synapse_model': 'exc_inh'
    }
    tp.ConnectLayers(l0_exc_population, l0_inh_population, l0_exc_inh_dict)

    print "[ Projecting excitatory -> excitatory population ]"
    # 4) exc -> exc
    # Since these connections are distance-dependent, we can use topological connections here
    CopyModel('static_synapse', 'exc_exc', {'weight': w_exc0_exc0_max})
    l0_exc_exc_dict = {
        'connection_type': 'convergent',
        'mask': {
            'rectangular': {
                'lower_left': [float(num['l0_exc_neurons'] / (-2.0)), -0.5],
                'upper_right': [float(num['l0_exc_neurons'] / (2.0)), 0.5]
            }
        },
        'synapse_model': 'exc_exc',
        'weights': {
            'gaussian': {
                'p_center': 1.,
                'sigma': sigma_exc0_exc0
            }
        }
    }
    #tp.ConnectLayers(l0_exc_population,l0_exc_population,l0_exc_exc_dict)

    print "[ Projecting inhibitory -> excitatory population ]"
    # 5) inh -> exc
    CopyModel('static_synapse', 'inh_exc', {'weight': w_inh0_exc0})
    l0_inh_exc_dict = {
        'connection_type': 'convergent',
        'mask': {
            'grid': {
                'rows': 1,
                'columns': num['l0_inh_neurons'] - 1,
            },
            'anchor': {
                'row': 0,
                'column': -1,
            }
        },
        #'kernel':p_inh0_exc0,
        'synapse_model': 'inh_exc'
    }
    tp.ConnectLayers(l0_inh_population, l0_exc_population, l0_inh_exc_dict)

    print "[ Creating input population ]"
    # 6) create input population
    CopyModel('poisson_generator', 'input_model', {'rate': 40.0})
    input_population = tp.CreateLayer({
        'rows': 1,
        'columns': num['inputs'],
        'extent': [float(num['inputs']), 1.],
        'elements': 'input_model',
        'edge_wrap': True
    })

    parrot_population = tp.CreateLayer({
        'rows': 1,
        'columns': num['inputs'],
        'extent': [float(num['inputs']), 1.],
        'elements': 'parrot_neuron',
        'edge_wrap': True
    })

    print "[ Projecting input -> excitatory population ]"
    # 7) input -> exc
    CopyModel('static_synapse', 'input_parrot', {'weight': 1.0})
    CopyModel(
        'rect_stdp_synapse', 'parrot_exc', {
            'tau_plus': 10.0,
            'alpha_minus': alpham_inp_exc0,
            'alpha_plus': alphap_inp_exc0,
            'Wmax': w_inp_exc0_max
        })
    #CopyModel('static_synapse','parrot_exc')
    CopyModel('static_synapse', 'parrot_inh', {'weight': w_inp_inh0})
    input_parrot_dict = {
        'connection_type': 'convergent',
        'mask': {
            'rectangular': {
                # this is intended: only connect to one neuron!
                'lower_left': [-0.5, -0.5],
                'upper_right': [0.5, 0.5]
            }
        },
        'synapse_model': 'input_parrot'
    }
    parrot_exc_dict = {
        'connection_type': 'convergent',
        'mask': {
            'grid': {
                'rows': 1,
                'columns': num['inputs'],
            },
            'anchor': {
                'row': 0,
                'column': 0,
            }
        },
        #'kernel': {'gaussian': {'p_center':1.0,'sigma':sigma_inp_exc0}},
        'weights': {
            'uniform': {
                'min': w_inp_exc0_min,
                'max': w_inp_exc0_peak
            }
        },
        'synapse_model': 'parrot_exc'
    }

    parrot_inh_dict = copy.copy(parrot_exc_dict)
    #parrot_inh_dict['synapse_model'] = 'parrot_inh'
    #parrot_inh_dict['kernel'] = {'gaussian': {'p_center':1.0,'sigma':sigma_inp_exc0}}

    tp.ConnectLayers(input_population, parrot_population, input_parrot_dict)
    tp.ConnectLayers(parrot_population, l0_exc_population, parrot_exc_dict)
    #tp.ConnectLayers(parrot_population,l0_inh_population,parrot_inh_dict)

    # 7) input -> inh
    CopyModel('poisson_generator', 'inh_bias_model', {'rate': 150.0})
    inh_bias_population = tp.CreateLayer({
        'rows':
        1,
        'columns':
        num['inputs_inh_sources'],
        'extent': [float(num['inputs_inh_sources']), 1.],
        'elements':
        'inh_bias_model',
        'edge_wrap':
        True
    })

    CopyModel('static_synapse', 'bias_inh', {'weight': w_inp_inh0})
    inh_bias_dict = {
        'connection_type': 'convergent',
        'mask': {
            'rectangular': {
                # this is intended: only connect to one neuron!
                'lower_left': [-0.5, -0.5],
                'upper_right': [0.5, 0.5]
            }
        },
        'synapse_model': 'bias_inh',
        'weights': w_inp_inh0,
    }
    tp.ConnectLayers(inh_bias_population, l0_inh_population, inh_bias_dict)

    return l0_exc_population, l0_inh_population, input_population, parrot_population
コード例 #28
0
    'connection_type': 'divergent',
    'mask': {
        'circular': {
            'radius': 0.5
        }
    },
    "synapse_model": "static_synapse",
    'kernel': {
        'gaussian': {
            'p_center': 1.0,
            'sigma': 0.15
        }
    }
}

tp.ConnectLayers(lexc, lexc, conndict)
tp.ConnectLayers(linh, lexc, conndict)

nest.DivergentConnect(mm, nest.GetLeaves(lexc)[0])
nest.DivergentConnect(exc, nest.GetLeaves(lexc)[0])
nest.DivergentConnect(inh, nest.GetLeaves(linh)[0])

d = nest.GetStatus(mm)[0]['events']['V_m']
nest.Simulate(100)

events = nest.GetStatus(mm)[0]['events']
t = events['times']
print d, t, events
pl.clf()

pl.subplot(211)
コード例 #29
0
# xext, yext = nest.GetStatus(l1, 'topology')[0]['extent']
# xctr, yctr = nest.GetStatus(l1, 'topology')[0]['center']

# l1_children is a work-around until NEST 3.0 is released
l1_children = nest.hl_api.GetChildren(l1)[0]

# extract position information, transpose to list of x, y and z positions
xpos, ypos, zpos = zip(*topo.GetPosition(l1_children))
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(xpos, ypos, zpos, s=15, facecolor='b', edgecolor='none')

# Gaussian connections in full volume [-0.75,0.75]**3
topo.ConnectLayers(l1, l1,
                   {'connection_type': 'divergent', 'allow_autapses': False,
                    'mask': {'volume': {'lower_left': [-0.75, -0.75, -0.75],
                                        'upper_right': [0.75, 0.75, 0.75]}},
                    'kernel': {'gaussian': {'p_center': 1., 'sigma': 0.25}}})

# show connections from center element
# sender shown in red, targets in green
ctr = topo.FindCenterElement(l1)
xtgt, ytgt, ztgt = zip(*topo.GetTargetPositions(ctr, l1)[0])
xctr, yctr, zctr = topo.GetPosition(ctr)[0]
ax.scatter([xctr], [yctr], [zctr], s=40, facecolor='r', edgecolor='none')
ax.scatter(xtgt, ytgt, ztgt, s=40, facecolor='g', edgecolor='g')

tgts = topo.GetTargetNodes(ctr, l1)[0]
d = topo.Distance(ctr, tgts)

plt.figure()
コード例 #30
0
l = tp.CreateLayer({
    'rows': 11,
    'columns': 11,
    'extent': [11., 11.],
    'elements': 'iaf_neuron'
})
conndict = {
    'connection_type': 'divergent',
    'mask': {
        'rectangular': {
            'lower_left': [-2., -1.],
            'upper_right': [2., 1.]
        }
    }
}
tp.ConnectLayers(l, l, conndict)
# { end #}

fig = plt.figure()
fig.add_subplot(121)
conn_figure(fig,
            l,
            conndict,
            targets=((tp.FindCenterElement(l), 'red'),
                     (tp.FindNearestElement(l, [4., 5.]), 'yellow')))

# same another time, with periodic bcs
lpbc = tp.CreateLayer({
    'rows': 11,
    'columns': 11,
    'extent': [11., 11.],