def test_generate_positions(self): n = 1000 s = space.Sphere(2.5) rs = space.RandomStructure(boundary=s, origin=(1.0, 1.0, 1.0)) positions = rs.generate_positions(n) assert_equal(positions.shape, (3, n)) for axis in range(2): assert 3 < max(positions[axis, :]) < 3.5 assert -1 > min(positions[axis, :]) > -1.5
def __init__(self, model, parameters): SheetWithMagnificationFactor.__init__(self, model, parameters) dx, dy = self.cs_2_vf(parameters.sx, parameters.sy) rs = space.RandomStructure(boundary=space.Cuboid(dx, dy, 0), origin=(0.0, 0.0, 0.0), rng=mozaik.pynn_rng) self.pop = self.sim.Population( int(parameters.sx * parameters.sy / 1000000 * parameters.density), getattr(self.model.sim, self.parameters.cell.model), self.parameters.cell.params, structure=rs, initial_values=self.parameters.cell.initial_values, label=self.name)
def __init__(self, model, parameters): SheetWithMagnificationFactor.__init__(self, model, parameters) dx, dy = self.cs_2_vf(parameters.sx, parameters.sy) rs = space.RandomStructure(boundary=space.Cuboid(dx, dy, 0), origin=(0.0, 0.0, 0.0), rng=mozaik.pynn_rng) self.pop = self.sim.Population( int(parameters.sx * parameters.sy / 1000000 * parameters.density), getattr(self.model.sim, self.parameters.cell.model), self.parameters.cell.params, structure=rs, initial_values=self.parameters.cell.initial_values, label=self.name) # Forces PyNN to generate the positions to ensure the reproducibility with multiprocessing self.pop.positions
def __init__(self, model, parameters): Sheet.__init__(self, model, parameters.sx, parameters.sy, parameters) logger.info("Creating %s with %d neurons." % (self.__class__.__name__, int(parameters.sx * parameters.sy * parameters.density))) rs = space.RandomStructure(boundary=space.Cuboid( self.size_x, self.size_y, 0), origin=(0.0, 0.0, 0.0), rng=mozaik.pynn_rng) #rs = space.Grid2D(aspect_ratio=1, dx=parameters.sx/parameters.density, dy=parameters.sy/parameters.density, x0=-parameters.sx/2,y0=-parameters.sy/2,z=0.0) self.pop = self.sim.Population( int(parameters.sx * parameters.sy * parameters.density), getattr(self.model.sim, self.parameters.cell.model), self.parameters.cell.params, structure=rs, initial_values=self.parameters.cell.initial_values, label=self.name)
def __init__(self, model, parameters): # from spynnaker8.extra_models import Izhikevich_cond # import spynnaker8.extra_models as models SheetWithMagnificationFactor.__init__(self, model, parameters) dx, dy = self.cs_2_vf(parameters.sx, parameters.sy) rs = space.RandomStructure(boundary=space.Cuboid(dx, dy, 0), origin=(0.0, 0.0, 0.0), rng=mozaik.pynn_rng) # l4_cortex_inh, l4_cortex_exc: model: EIF_cond_exp_isfa_ista # Exponential integrate and fire neuron with spike triggered and sub-threshold adaptation currents # must change to Izhikevich model self.pop = self.sim.Population( int(parameters.sx * parameters.sy / 1000000 * parameters.density), getattr(self.model.sim, self.parameters.cell.model ), # no attribute 'EIF_cond_exp_isfa_ista' # getattr(models, self.parameters.cell.model), self.parameters.cell.params, structure=rs, initial_values=self.parameters.cell.initial_values, label=self.name)
def __init__(self, model, parameters): Sheet.__init__(self, model, parameters.sx, parameters.sy, parameters) logger.info("Creating *LGN* %s with %d neurons." % (self.__class__.__name__, int(parameters.sx * parameters.sy * parameters.density))) rs = space.RandomStructure(boundary=space.Cuboid( self.size_x, self.size_y, 0), origin=(0.0, 0.0, 0.0), rng=mozaik.pynn_rng) print("* getattr(self.model.sim, self.parameters.cell.model) ", getattr(self.model.sim, self.parameters.cell.model)) #rs = space.Grid2D(aspect_ratio=1, dx=parameters.sx/parameters.density, dy=parameters.sy/parameters.density, x0=-parameters.sx/2,y0=-parameters.sy/2,z=0.0) self.pop = self.sim.Population( int(parameters.sx * parameters.sy * parameters.density), getattr( self.model.sim, self.parameters.cell.model), # replace with SpikeSourceArray self.parameters.cell.params, structure=rs, initial_values=self.parameters.cell.initial_values, # cellclass = self.sim.SpikeSourceArray(spike_times=[])) # spike times from nest/lgn output label=self.name)
reference="Positions", save_format='hdf5') pop_size = 400 cell_params = { 'tau_refrac': 5, 'v_thresh': -50.0, 'v_reset': -65.0, 'i_offset': 0.9, 'tau_syn_E': 2.0, 'tau_syn_I': 5.0 } sphere = space.Sphere(radius=100.0) struct = space.RandomStructure(sphere, origin=(0.0, 100.0, 0.0)) pop_pre = sim.Population(pop_size, sim.IF_cond_alpha(**cell_params), label="pop_pre", structure=struct) pop_pre.record('v') pop_pre.annotate(radius=5) pop_pre.annotate(color='0 0.6 0') cuboid = space.Cuboid(30, 40, 50) struct = space.RandomStructure(cuboid, origin=(-200.0, 0.0, -200.0)) pop_post = sim.Population(pop_size, sim.IF_cond_alpha(**cell_params), label="pop_post",
import numpy as np from pyNN.utility import get_script_args import pyNN.space as space simulator_name = get_script_args(1)[0] sim = import_module("pyNN.%s" % simulator_name) tstop = 500.0 time_step = 0.005 sim.setup(timestep=time_step, debug=True, reference='ConnectionsTest') sphere1 = space.Sphere(radius=100.0) struct1 = space.RandomStructure(sphere1, origin=(0.0, 0.0, 0.0)) cell_params = {'tau_refrac':5,'v_thresh':-50.0, 'v_reset':-65.0, 'i_offset': 0.9, 'tau_syn_E' : 2.0, 'tau_syn_I': 5.0} pop_pre = sim.Population(5, sim.IF_cond_alpha(**cell_params), label="pop_pre",structure=struct1) pop_pre.record('v') pop_pre.annotate(radius=5) pop_pre.annotate(color='0 0.6 0') sphere2 = space.Sphere(radius=100.0) struct2 = space.RandomStructure(sphere2, origin=(0.0, 200.0, 0.0)) pop_post = sim.Population(5, sim.IF_cond_alpha(**cell_params), label="pop_post",structure=struct2) pop_post.record('v') pop_post.annotate(radius=5) pop_post.annotate(color='0 0.2 0.6') pre_selection = sim.PopulationView(pop_pre, np.array([1,3]),label='pre_selection')
# Use CVode to calculate i_membrane_ for fast LFP calculation cvode = h.CVode() cvode.active(0) # Get the second spatial derivative (the segment current) for the collateral cvode.use_fast_imem(1) # Set initial values for cell membrane voltages v_init = -68 # Create random distribution for cell membrane noise current r_init = RandomDistribution('uniform', (0, Pop_size)) # Create Spaces for STN Population STN_Electrode_space = space.Space(axes='xy') STN_space = space.RandomStructure( boundary=space.Sphere(2000)) # Sphere with radius 2000um # Generate poisson distributed spike time striatal input striatal_spike_times = np.load( 'Striatal_Spike_Times.npy') # Load spike times from file # Generate the cortico-basal ganglia neuron populations Cortical_Pop = Population( Pop_size, Cortical_Neuron_Type(soma_bias_current_amp=0.245), structure=STN_space, label='Cortical Neurons') # Better than above (ibias=0.2575) Interneuron_Pop = Population(Pop_size, Interneuron_Type(bias_current_amp=0.070), initial_values={'v': v_init}, label='Interneurons')
'v_rest': 0.0, # (mV) 'v_reset': 0.0, # (mV) 'v_thresh': 20.0, # (mV) 'cm': 0.5 } # (nF) RateScale = 1e6 Tstep = 10.0 rngseed = 1240498 width = 1.0 depth = 1.0 height = 6.0 exc_structure = space.RandomStructure( boundary=space.Cuboid(width, height, depth)) inh_structure = space.RandomStructure( boundary=space.Cuboid(width, height, depth)) c_lambda = 1.0 exc_connector = DistanceDependentProbabilityConnector('exp(-d*d/(%f*%f))' % (c_lambda, c_lambda), weights=0.1, delays=1.0) inh_connector = DistanceDependentProbabilityConnector('exp(-d*d/(%f*%f))' % (c_lambda, c_lambda), weights=-0.4, delays=1.0)