Ejemplo n.º 1
0
 def testAllToAll(self):
     """For all connections created with "allToAll" it should be possible to
     obtain the weight using the top-level HocObject"""
     for srcP in [self.source5, self.source22, self.target33]:
         for tgtP in [self.target6, self.target33]:
             #print "gid_counter = ", neuron.simulator.state.gid_counter
             if srcP == tgtP:
                 prj = neuron.Projection(srcP, tgtP, neuron.AllToAllConnector(allow_self_connections=False))
             else:
                 prj = neuron.Projection(srcP, tgtP, neuron.AllToAllConnector())
             prj.setWeights(1.234)
             weights = []
             for c in prj.connections:
                 weights.append(c.nc.weight[0])
             assert weights == [1.234]*len(prj)
Ejemplo n.º 2
0
 def testRandomizeDelays(self):
     # The probability of having two consecutive delays vector that are equal should be 0
     prj1 = neuron.Projection(self.source, self.target, neuron.AllToAllConnector())
     prj2 = neuron.Projection(self.source, self.target, neuron.AllToAllConnector())
     prj1.randomizeDelays(self.distrib_Numpy)
     prj2.randomizeDelays(self.distrib_Native)
     d1 = []; d2 = []; d3 = []; d4 = []
     for c in prj1.connections:
         d1.append(c.nc.weight[0])
         d2.append(c.nc.weight[0])
     prj1.randomizeWeights(self.distrib_Numpy)
     prj2.randomizeWeights(self.distrib_Native)
     for c in prj1.connections:
         d3.append(c.nc.weight[0])
         d4.append(c.nc.weight[0])
     self.assertNotEqual(d1, d3) and self.assertNotEqual(d2, d4) 
Ejemplo n.º 3
0
 def testRandomizeWeights(self):
     # The probability of having two consecutive weights vector that are equal should be 0
     prj1 = neuron.Projection(self.source, self.target, neuron.AllToAllConnector())
     prj2 = neuron.Projection(self.source, self.target, neuron.AllToAllConnector())
     prj1.randomizeWeights(self.distrib_Numpy)
     prj2.randomizeWeights(self.distrib_Native)
     w1 = []; w2 = []; w3 = []; w4 = []
     for c in prj1.connections:
         w1.append(c.nc.weight[0])
         w2.append(c.nc.weight[0])
     prj1.randomizeWeights(self.distrib_Numpy)
     prj2.randomizeWeights(self.distrib_Native)
     for c in prj1.connections:
         w3.append(c.nc.weight[0])
         w4.append(c.nc.weight[0])
     self.assertNotEqual(w1, w3) and self.assertNotEqual(w2, w4) 
Ejemplo n.º 4
0
 def testSetDelays(self):
     prj1 = neuron.Projection(self.source, self.target, neuron.AllToAllConnector())
     prj1.setDelays(2.345)
     delays = []
     for c in prj1.connections:
         delays.append(c.nc.delay)
     result = 2.345*numpy.ones(len(prj1.connections))
     assert (delays == result.tolist())
Ejemplo n.º 5
0
 def testSetWeights(self):
     prj1 = neuron.Projection(self.source, self.target, neuron.AllToAllConnector())
     prj1.setWeights(2.345)
     weights = []
     for c in prj1.connections:
         weights.append(c.nc.weight[0])
     result = 2.345*numpy.ones(len(prj1.connections))
     assert (weights == result.tolist())
Ejemplo n.º 6
0
 def setUp(self):
     sim.setup()
     self.p1 = sim.Population(7, sim.IF_cond_exp())
     self.p2 = sim.Population(4, sim.IF_cond_exp())
     self.p3 = sim.Population(5, sim.IF_curr_alpha())
     self.syn1 = sim.StaticSynapse(weight=0.123, delay=0.5)
     self.syn2 = sim.StaticSynapse(weight=0.456, delay=0.4)
     self.random_connect = sim.FixedNumberPostConnector(n=2)
     self.all2all = sim.AllToAllConnector()
}
p = sim.Population(1, sim.IF_curr_alpha(**cell_parameters))
p.initialize(v=0.0)

rate = 20
stim = sim.Population(
    1,
    nineml_cell_type('Poisson',
                     read("../sources/Poisson.xml")['Poisson'], {})(rate=rate))
stim.initialize(t_next=numpy.random.exponential(1000 / rate))

weight = 0.1
delay = 0.5
prj = sim.Projection(stim,
                     p,
                     sim.AllToAllConnector(),
                     sim.StaticSynapse(weight=weight, delay=delay),
                     receptor_type='excitatory')

stim.record('spikes')
p.record('v')

sim.run(t_stop)

nrn_data = p.get_data().segments[0]
stim_data = stim.get_data().segments[0]

print("Expected spike count: {}".format(t_stop * rate / 1000))
print("Actual spike count: {}".format(stim.mean_spike_count()))

Figure(
Ejemplo n.º 8
0
    "e_e": 0.0,
    "e_i": -75.0,
}

sim.setup()

p0 = sim.Population(1, sim.SpikeSourcePoisson, {'rate': 100.0})
p1 = sim.Population(10, TestCell, cell_params)
p2 = sim.Population(10, sim.IF_cond_exp)

p1.record_v(1)
p1.record()
p2.record_v(1)

#curr = sim.DCSource()
#curr.inject_into(p1)

prj01 = sim.Projection(p0, p1, sim.AllToAllConnector())
prj12 = sim.Projection(p1, p2, sim.FixedProbabilityConnector(0.5))

prj01.setWeights(0.1)
prj12.setWeights(0.1)

sim.run(1000.0)

t,v = p1.get_v()[:, 1:3].T
#print p2.get_v()
import pylab
pylab.rcParams['interactive'] = True

pylab.plot(t, v)
Ejemplo n.º 9
0
 def testSettingDelays(self):
     """Delays should be set correctly when using a Connector object."""
     for srcP in [self.source5, self.source22]:
         for tgtP in [self.target6, self.target33]:
             prj1 = neuron.Projection(srcP, tgtP, neuron.AllToAllConnector(delays=0.321))
             assert prj1.connections[0].nc.delay == 0.321, "Delay should be 0.321, actually %g" % prj1.connections[0].nc.delay
sim.setup()

celltype = sim.IF_curr_alpha(tau_m=tau, v_thresh=theta,
                             tau_refrac=2.0, v_reset=10.0,
                             v_rest=0.0, cm=tau/1.5,
                             tau_syn_E=tau_syn, tau_syn_I=tau_syn)

ext_stim = sim.SpikeSourcePoisson(rate=input_rate)

exc_cells = sim.Population(Ne, celltype, initial_values={'v': v_init}, label="Exc")
inh_cells = sim.Population(Ni, celltype, initial_values={'v': v_init}, label="Inh")
external = sim.Population(int(Cext), ext_stim, label="Ext")

all_cells = exc_cells + inh_cells

all_to_all = sim.AllToAllConnector(callback=ProgressBar())
random_uniform = sim.FixedProbabilityConnector(p_connect=epsilon, callback=ProgressBar())

static_ext = sim.StaticSynapse(delay=delay, weight=Jext)
static_exc = sim.StaticSynapse(delay=delay, weight=Je)
static_inh = sim.StaticSynapse(delay=delay, weight=Ji)

input_prj = sim.Projection(external, all_cells, all_to_all,
                           synapse_type=static_ext, receptor_type="excitatory",
                           label="External")
exc_prj = sim.Projection(exc_cells, all_cells, random_uniform,
                         synapse_type=static_exc, receptor_type="excitatory",
                         label="Excitation")
inh_prj = sim.Projection(inh_cells, all_cells, random_uniform,
                         synapse_type=static_inh, receptor_type="inhibitory",
                         label="Inhibition")