print(p[0].gbar_Na) #setting from an array import numpy as np p = sim.Population(6, sim.SpikeSourcePoisson(rate=np.linspace(10.0, 20.0, num=6))) print(p.get('rate')) #using function to calculate from numpy import sin, pi p = sim.Population(8, sim.IF_cond_exp(i_offset=lambda i: sin(i * pi / 8))) print(p.get('i_offset')) #Setting parameters as a function of spatial position from pyNN.space import Grid2D grid = Grid2D(dx=10.0, dy=10.0) p = sim.Population(16, sim.IF_cond_alpha(), structure=grid) def f_v_thresh(pos): x, y, z = pos.T return -50 + 0.5 * x - 0.2 * y p.set(v_thresh=lambda i: f_v_thresh(p.position_generator(i))) print(p.get('v_thresh').reshape((4, 4))) #multiple types n = 1000 parameters = { 'tau_m': RandomDistribution('uniform', (10.0, 15.0)),
from NeuroTools.parameters import ParameterSet import sys from math import sqrt from pyNN.space import Space, Grid2D P = ParameterSet(sys.argv[1]) exec("import pyNN.%s as sim" % P.simulator) sim.setup() dx1 = dy1 = 500.0 / sqrt(P.n1) dx2 = dy2 = 500.0 / sqrt(P.n2) struct1 = Grid2D(dx=dx1, dy=dy1) struct2 = Grid2D(dx=dx2, dy=dy2) p1 = sim.Population(P.n1, sim.IF_cond_exp, structure=struct1) p2 = sim.Population(P.n2, sim.IF_cond_exp, structure=struct2) space = Space() DDPC = sim.DistanceDependentProbabilityConnector c = DDPC(P.d_expression, P.allow_self_connections, P.weights, P.delays, space, P.safe) prj = sim.Projection(p1, p2, c) sys.stdout.write(p1.describe().encode('utf-8')) sys.stdout.write(p2.describe().encode('utf-8')) sys.stdout.write(prj.describe().encode('utf-8')) sim.end()
sim = import_module("pyNN.%s" % args.simulator_name) simtime = 100.0 input_rate = 20.0 n_cells = 9 sim.setup() cell_type = sim.IF_cond_exp(tau_m=10.0, # v_rest=lambda x, y, z: -60.0 - sqrt((x**2 + y**2)/100), # v_thresh=lambda x, y, z: -55.0 + x/10.0) v_rest=lambda i: -60.0 + i, v_thresh=lambda i: -55.0 + i) cells = sim.Population(n_cells, cell_type, structure=Grid2D(dx=100.0, dy=100.0), initial_values={'v': lambda i: -60.0 - i}, label="cells") print "positions:" print cells.positions for name in ('tau_m', 'v_rest', 'v_thresh'): print name, "=", cells.get(name) number = int(2*simtime*input_rate/1000.0) numpy.random.seed(26278342) def generate_spike_times(i): gen = lambda: Sequence(numpy.add.accumulate(numpy.random.exponential(1000.0/input_rate, size=number))) if hasattr(i, "__len__"): return [gen() for j in i]