示例#1
0
    def connect(self, neuronName, custom):
        """
        Connect all nodes in the model.
        """
        if self.connected: return
        if not self.built:
            self.build(neuronName, custom)

        cynest.CopyModel("static_synapse_hom_wd", "excitatory", {
            "weight": self.J_E,
            "delay": self.delay
        })
        cynest.CopyModel("static_synapse_hom_wd", "inhibitory", {
            "weight": self.J_I,
            "delay": self.delay
        })

        cynest.RandomConvergentConnect(self.nodes_E,
                                       self.nodes,
                                       self.C_E,
                                       model="excitatory")
        cynest.RandomConvergentConnect(self.nodes_I,
                                       self.nodes,
                                       self.C_I,
                                       model="inhibitory")
        cynest.DivergentConnect(self.noise, self.nodes, model="excitatory")
        cynest.ConvergentConnect(self.nodes_E[:self.N_rec], self.spikes_E)
        cynest.ConvergentConnect(self.nodes_I[:self.N_rec], self.spikes_I)
        self.connected = True
示例#2
0
    def test_DivergentConnect(self):
        """DivergentConnect pre to post"""

        nest.ResetKernel()
        pre = nest.Create("iaf_neuron", 1)
        post = nest.Create("iaf_neuron", 3)
        nest.DivergentConnect(pre, post)
        connections = nest.FindConnections(pre)
        targets = nest.GetStatus(connections, "target")
        self.assertEqual(targets, post)
示例#3
0
    def test_DivergentConnect(self):
        """DivergentConnect"""

        cynest.ResetKernel()
        
        a=cynest.Create("iaf_neuron", 10)
        source=[1]
        targets=[1 * x for x in list(range(2,11))]

        cynest.DivergentConnect(source, targets, [1.0], [1.0])
        conn1=cynest.GetConnections(source)
        stat1=cynest.GetStatus(conn1)
        target1=[ d['target'] for d in stat1]
        self.assertEqual(targets, target1)
示例#4
0
    def test_DivergentConnectWD(self):
        """DivergentConnect pre to post with weight and delay"""

        nest.ResetKernel()
        pre = nest.Create("iaf_neuron", 1)
        post = nest.Create("iaf_neuron", 3)
        nest.DivergentConnect(pre,
                              post,
                              weight=[2.0, 2.0, 2.0],
                              delay=[1.0, 2.0, 3.0])
        connections = nest.FindConnections(pre)
        weights = nest.GetStatus(connections, "weight")
        delays = nest.GetStatus(connections, "delay")
        self.assertEqual(weights, [2.0, 2.0, 2.0])
        self.assertEqual(delays, [1.0, 2.0, 3.0])
示例#5
0
    def test_FindConnections(self):
        """FindConnections"""

        nest.ResetKernel()

        a = nest.Create("iaf_neuron", 3)
        nest.DivergentConnect(a, a)
        c1 = nest.FindConnections(a)
        c2 = nest.FindConnections(a, synapse_type="static_synapse")
        self.assertEqual(c1, c2)

        d1 = [{"weight": w} for w in [2.0, 3.0, 4.0]]

        c3 = nest.FindConnections(a, a)
        nest.SetStatus(c3, d1)
        s1 = nest.GetStatus(c3, "weight")
        self.assertEqual(s1, [w["weight"] for w in d1])
示例#6
0
    def test_ThreadsFindConnections(self):
        """FindConnections with threads"""

        # Test if we have a thread-enabled NEST
        nest.sr("statusdict /have_pthreads get")
        if not nest.spp(): return

        nest.ResetKernel()
        nest.SetKernelStatus({'local_num_threads': 8})
        pre = nest.Create("iaf_neuron")
        post = nest.Create("iaf_neuron", 6)

        nest.DivergentConnect(pre, post)

        conn = nest.FindConnections(pre)
        targets = nest.GetStatus(conn, "target")

        self.assertEqual(targets, post)
示例#7
0
    def test_ThreadsGetEvents(self):
        """ Gathering events across threads """

        # Test if we have a thread-enabled NEST
        nest.sr("statusdict /have_pthreads get")
        if not nest.spp(): return

        threads = [1, 2, 4, 8]

        n_events_sd = []
        n_events_vm = []

        N = 128
        Simtime = 1000.

        for t in threads:

            nest.ResetKernel()
            nest.SetKernelStatus({'local_num_threads': t})

            n = nest.Create('iaf_psc_alpha', N,
                            {'I_e': 2000.})  # force a lot of spike events
            sd = nest.Create('spike_detector')
            vm = nest.Create('voltmeter')

            nest.ConvergentConnect(n, sd)
            nest.DivergentConnect(vm, n)

            nest.Simulate(Simtime)

            n_events_sd.append(nest.GetStatus(sd, 'n_events')[0])
            n_events_vm.append(nest.GetStatus(vm, 'n_events')[0])

        ref_vm = N * (Simtime - 1)
        ref_sd = n_events_sd[0]

        # could be done more elegantly with any(), ravel(),
        # but we dont want to be dependent on numpy et al
        [self.assertEqual(x, ref_vm) for x in n_events_vm]
        [self.assertEqual(x, ref_sd) for x in n_events_sd]
示例#8
0
    })
pp = nest.Create('pulsepacket_generator', n_neurons, {
    'pulse_times': [pulsetime],
    'activity': a,
    'sdev': sdev
})
vm = nest.Create(
    'voltmeter', 1, {
        'record_to': ['memory'],
        'withtime': True,
        'withgid': True,
        'interval': sampling_resolution
    })

nest.Connect(pp, n)
nest.DivergentConnect(vm, n)

nest.Simulate(simtime)

V = nest.GetStatus(vm, 'events')[0]['V_m']
t_V = nest.GetStatus(vm, 'events')[0]['times']
senders = nest.GetStatus(vm, 'events')[0]['senders']

#########################################################################
# plotting...

v = {}
t = {}

for s in range(senders.size):
    currentsender = senders[s]
示例#9
0
#! This recording device setup is a bit makeshift. For each population
#! we want to record from, we create one ``multimeter``, then select
#! all nodes of the right model from the target population and
#! connect. ``loc`` is the subplot location for the layer.
recorders = {}
for name, loc, population, model in [('TpRelay', 1, Tp, 'TpRelay'),
                                     ('Rp', 2, Rp, 'RpNeuron'),
                                     ('Vp_v L4pyr', 3, Vp_v, 'L4pyr'),
                                     ('Vp_h L4pyr', 4, Vp_h, 'L4pyr')]:
    recorders[name] = (nest.Create('RecordingNode'), loc)
    tgts = [
        nd for nd in nest.GetLeaves(population)[0]
        if nest.GetStatus([nd], 'model')[0] == model
    ]
    nest.DivergentConnect(recorders[name][0], tgts)

#! Example simulation
#! ====================

#! This simulation is set up to create a step-wise visualization of
#! the membrane potential. To do so, we simulate ``sim_interval``
#! milliseconds at a time, then read out data from the multimeters,
#! clear data from the multimeters and plot the data as pseudocolor
#! plots.

#! show time during simulation
nest.SetStatus([0], {'print_time': True})

#! lower and upper limits for color scale, for each of the four
#! populations recorded.
示例#10
0
def bias(n):
    # constructs the dictionary with current ramp
    return { 'I_e': (n * (bias_end-bias_begin)/N + bias_begin) }
    

driveparams  = {'amplitude':50., 'frequency':35.}
noiseparams  = {'mean':0.0, 'std':200.}
neuronparams = { 'tau_m':20., 'V_th':20., 'E_L':10.,
                 't_ref':2., 'V_reset':0., 'C_m':200., 'V_m':0.}

neurons = nest.Create('iaf_psc_alpha',N)
sd      = nest.Create('spike_detector')
noise   = nest.Create('noise_generator')
drive   = nest.Create('ac_generator')

nest.SetStatus(drive,   driveparams )
nest.SetStatus(noise,   noiseparams )
nest.SetStatus(neurons, neuronparams)
nest.SetStatus(neurons, map(bias, neurons))

nest.SetStatus(sd, {"withgid": True, "withtime": True})

nest.DivergentConnect(drive, neurons)
nest.DivergentConnect(noise, neurons)
nest.ConvergentConnect(neurons, sd)

nest.Simulate(T)

nest.raster_plot.from_device(sd, hist=True)
nest.raster_plot.show()
示例#11
0
    "withtime": True,
    "withgid": True
}])

print("Connecting devices.")

nest.CopyModel("static_synapse", "excitatory", {
    "weight": J_ex,
    "delay": delay
})
nest.CopyModel("static_synapse", "inhibitory", {
    "weight": J_in,
    "delay": delay
})

nest.DivergentConnect(noise, nodes_ex, model="excitatory")
nest.DivergentConnect(noise, nodes_in, model="excitatory")

nest.ConvergentConnect(list(range(1, N_rec + 1)), espikes, model="excitatory")
nest.ConvergentConnect(list(range(NE + 1, NE + 1 + N_rec)),
                       ispikes,
                       model="excitatory")

print("Connecting network.")

# We now iterate over all neuron IDs, and connect the neuron to
# the sources from our array. The first loop connects the excitatory neurons
# and the second loop the inhibitory neurons.

print("Excitatory connections")
示例#12
0
 def connect(self):
     nest.DivergentConnect(self.noise,self.neuron)
     nest.ConvergentConnect(self.neuron, self.spike)