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 test_sample(self): n = 1000 s = space.Sphere(2.5) positions = s.sample(n, numpy.random) assert_equal(positions.shape, (n, 3)) for axis in range(2): assert 1 < max(positions[:, axis]) < 2.5 assert -1 > min(positions[:, axis]) > -2.5 s2 = numpy.sum(positions**2, axis=1) assert max(s2) < 6.25
def test__create(self): s = space.Sphere(2.5) assert_equal(s.radius, 2.5)
debug=True, 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),
from importlib import import_module 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')
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')
def test__create(self): s = space.Sphere(1.0) self.assertEqual(s.radius, 1.0)