Esempio n. 1
0
    def test_lif_current(self):
        """
        Simulates one LIF neuron and checks the membrane-potential trace matches
        reference data.

        TODO add assertion on comparison, rather than just graphing the result.
        TODO take parameter for machine hostname.
        """
        print "test_lif_current..."
        pynn.setup(**{
            'machine': 'bluu',
            'debug': False
        })  #TODO take machine parameter
        lif = {
            "v_rest": -70.0,
            "v_reset": -70.0,
            "v_thresh": -50.0,  # mV
            "tau_m": 40.0,
            "tau_syn_E": 20.0,
            "tau_syn_I": 5.0,  # mS
            "tau_refrac": 1.0,
            "cm": 40.0 / 50.0,
            "i_offset": 0.0
        }  # ms, nF, nA
        pop = pynn.Population(1, pynn.IF_curr_exp, lif)
        pop.set("i_offset", 0.5)
        pop.record_v()
        pynn.run(1000)

        with open('data/test_lif_current.pickle', 'r') as f:
            data = f.read()
            trace = pickle.loads(data)

        fig = pylab.figure(figsize=(8.0, 5.7))
        ax = fig.add_subplot(1, 1, 1)
        ax.plot(pop.get_v()[:, 2])
        ax.plot(trace)

        pylab.show()
        pynn.end()
    def test_pynn_basic(self):
        pass
        """
        TODO figure out how to take machine name as a parameter
        """
        print "test_pynn_basic setup....."
        pynn.setup(**{'machine': 'spinn-7'})

        n_atoms = 10

        proj1_params = {
            'source': None,
            'delays': 1,
            'weights': 1,
            'target': 'excitatory'
        }
        proj2_params = {
            'allow_self_connections': True,
            'delays': 2,
            'p_connect': 0.1,
            'weights': 2,
            'source': None,
            'target': None
        }

        cell_params = {
            'tau_m': 64,
            'v_init': -75,
            'i_offset': 0,
            'v_rest': -75,
            'v_reset': -95,
            'v_thresh': -40,
            'tau_syn_E': 15,
            'tau_syn_I': 15,
            'tau_refrac': 10
        }

        pop1 = pynn.Population(n_atoms,
                               pynn.IF_curr_exp,
                               cell_params,
                               label='pop1')
        pop2 = pynn.Population(n_atoms * 2,
                               pynn.IF_curr_exp,
                               cell_params,
                               label='pop2')

        proj1 = pynn.Projection(pop1,
                                pop2,
                                pynn.OneToOneConnector(weights=1, delays=1),
                                target='excitatory')
        proj2 = pynn.Projection(
            pop1, pop2,
            pynn.FixedProbabilityConnector(weights=2, delays=2, p_connect=.1))

        pynn.controller.map_model()  # at this stage the model is mapped
        print "checking vertices..."
        self.assertEqual(pop1.vertex.parameters, cell_params)
        self.assertEqual(pynn.controller.dao.vertices[1].parameters,
                         cell_params)

        self.assertEqual(pop1.vertex.model,
                         pacman103.front.pynn.models.IF_curr_exp)
        self.assertEqual(pynn.controller.dao.vertices[0].label, "pop1")
        self.assertEqual(pynn.controller.dao.vertices[1].label, "pop2")

        self.assertEqual(pop1.vertex.atoms, n_atoms)
        self.assertEqual(pynn.controller.dao.vertices[1].atoms, n_atoms * 2)

        print "checking edges..."
        self.assertEqual(pynn.controller.dao.edges[0].model,
                         pacman103.front.pynn.connectors.OneToOneConnector)
        self.assertEqual(
            proj2.edge.model,
            pacman103.front.pynn.connectors.FixedProbabilityConnector)

        self.assertEqual(proj1.edge.parameters, proj1_params)
        self.assertEqual(pynn.controller.dao.edges[1].parameters, proj2_params)

        # testing the mapping phase
        self.assertEqual(len(pynn.controller.dao.subedges), 2)
        self.assertEqual(len(pynn.controller.dao.subvertices), 2)

        self.assertEqual(len(pynn.controller.dao.routings), 2)

        #        pynn.run(100)
        pynn.end()
num_pre_pairs = 10
num_pairs = 100
num_post_pairs = 10
pop_size = 1


pairing_start_time = (num_pre_pairs * time_between_pairs) + delta_t
pairing_end_time = pairing_start_time + (num_pairs * time_between_pairs)
sim_time = pairing_end_time + (num_post_pairs * time_between_pairs)


# +-------------------------------------------------------------------+
# | Creation of neuron populations                                    |
# +-------------------------------------------------------------------+
# Neuron populations
pre_pop = sim.Population(pop_size, model, cell_params)
post_pop = sim.Population(pop_size, model, cell_params)


# Stimulating populations
pre_stim = sim.Population(pop_size, sim.SpikeSourceArray, {'spike_times': [[i for i in range(0, sim_time, time_between_pairs)],]})
post_stim = sim.Population(pop_size, sim.SpikeSourceArray, {'spike_times': [[i for i in range(pairing_start_time, pairing_end_time, time_between_pairs)],]})

# +-------------------------------------------------------------------+
# | Creation of connections                                           |
# +-------------------------------------------------------------------+
# Connection type between noise poisson generator and excitatory populations
ee_connector = sim.OneToOneConnector(weights=2)

sim.Projection(pre_stim, pre_pop, ee_connector, target='excitatory')
sim.Projection(post_stim, post_pop, ee_connector, target='excitatory')
Esempio n. 4
0
populations = list()
projections = list()

weight_to_spike = 2.0
delay = 17

loopConnections = list()
for i in range(0, nNeurons):
    singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, delay)
    loopConnections.append(singleConnection)

injectionConnection = [(0, 0, weight_to_spike, 1)]
spikeArray = {'spike_times': [[0]]}
populations.append(
    p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_1'))
populations.append(
    p.Population(1, p.SpikeSourceArray, spikeArray, label='inputSpikes_1'))

projections.append(
    p.Projection(populations[0], populations[0],
                 p.FromListConnector(loopConnections)))
projections.append(
    p.Projection(populations[1], populations[0],
                 p.FromListConnector(injectionConnection)))

populations[0].record_v()
populations[0].record_gsyn()
populations[0].record(visualiser_mode=modes.RASTER)

p.run(5000)
Esempio n. 5
0
start_pairing = 1500.
start_test_post_pairing = 700.

simtime = start_pairing + start_test_post_pairing + ISI * (
    n_stim_pairing + n_stim_test) + 550.  # let's make it 5000

# Initialisations of the different types of populations
IAddPre = []
IAddPost = []

# +-------------------------------------------------------------------+
# | Creation of neuron populations                                    |
# +-------------------------------------------------------------------+

# Neuron populations
pre_pop = sim.Population(pop_size, model, cell_params)
post_pop = sim.Population(pop_size, model, cell_params)

# Test of the effect of activity of the pre_pop population on the post_pop
# population prior to the "pairing" protocol : only pre_pop is stimulated
for i in range(n_stim_test):
    IAddPre.append(
        sim.Population(
            pop_size, sim.SpikeSourcePoisson, {
                'rate': in_rate,
                'start': start_test_pre_pairing + ISI * (i),
                'duration': dur_stim
            }))

# Pairing protocol : pre_pop and post_pop are stimulated with a 10 ms
# difference
#!/usr/bin/python
import pacman103.front.pynn as p
import numpy, pylab

#set up pacman103
p.setup(timestep=1.0, min_delay=1.0, max_delay=32.0)

#external stuff population requiremenets
connected_chip_coords = {'x': 0, 'y': 0}
virtual_chip_coords = {'x': 0, 'y': 5}
link = 4

populations = list()
projections = list()

populations.append(p.Population(1, p.SpikeSourcePoisson, {'rate': 10000}))

populations.append(
    p.Population(1,
                 p.RobotMotorControl, {
                     'virtual_chip_coords': virtual_chip_coords,
                     'connected_chip_coords': connected_chip_coords,
                     'connected_chip_edge': link
                 },
                 label='External motor control'))

projections.append(
    p.Projection(populations[0], populations[1], p.OneToOneConnector()))

p.run(10000)
}

v_init = -75

#external stuff population requiremenets
connected_chip_coords = {'x': 0, 'y': 0}
virtual_chip_coords = {'x': 0, 'y': 5}
link = 4

print "Creating input population: {} x {}".format(input_size, input_size)

input_pol_1_up = p.Population(
    128 * 128,
    p.ExternalRetinaDevice, {
        'virtual_chip_coords': virtual_chip_coords,
        'connected_chip_coords': connected_chip_coords,
        'connected_chip_edge': link,
        'position': p.ExternalRetinaDevice.RIGHT_RETINA,
        'polarity': p.ExternalRetinaDevice.UP_POLARITY
    },
    label='input_pol1')

input_pol_1_down = p.Population(
    128 * 128,
    p.ExternalRetinaDevice, {
        'virtual_chip_coords': virtual_chip_coords,
        'connected_chip_coords': connected_chip_coords,
        'connected_chip_edge': link,
        'position': p.ExternalRetinaDevice.RIGHT_RETINA,
        'polarity': p.ExternalRetinaDevice.DOWN_POLARITY
    },
    label='input_pol1')
Esempio n. 8
0
#inhib_in_delay  = 1.0
#inhib_out_delay = 1.0
#p_connect = 1.0
#conn_prob = 0.75
p_exc2exc = 0.10
p_exc2inh = 0.10
p_inh2exc = 0.17
p_to_inhib_connect = 1.0
p_from_inhib_connect = 1.0

spikeArray = {'spike_times': myStimulus.streams}
teachingSpikeArray = {'spike_times': teachingInput.streams}

populations.append(
    p.Population(nSourceNeurons,
                 p.SpikeSourceArray,
                 spikeArray,
                 label='excit_pop_ss_array'))  # 0
populations.append(
    p.Population(nInhibNeurons,
                 p.IF_curr_exp,
                 cell_params_lif,
                 label='inhib_pop'))  # 1
populations.append(
    p.Population(nExcitNeurons,
                 p.IF_curr_exp,
                 cell_params_lif,
                 label='excit_pop'))  # 2
populations.append(
    p.Population(nTeachNeurons,
                 p.SpikeSourceArray,
                 teachingSpikeArray,
populations = list()
projections = list()

weight_to_spike = 2
delay = 3.2

loopConnections = list()
for i in range(0, nNeurons):
    singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, delay)
    loopConnections.append(singleConnection)

injectionConnection = [(0, 0, weight_to_spike, delay)]
spikeArray = {'spike_times': [[0]]}
populations.append(
    p.Population(100, p.IF_curr_exp, cell_params_lif, label='pop_1'))
populations[0].set_mapping_constraint({'x': 0, 'y': 0})
populations.append(
    p.Population(100, p.IF_curr_exp, cell_params_lif, label='pop_2'))
populations[1].set_mapping_constraint({'x': 0, 'y': 0})
populations.append(
    p.Population(100, p.IF_curr_exp, cell_params_lif, label='pop_3'))
populations[2].set_mapping_constraint({'x': 0, 'y': 0})
populations.append(
    p.Population(100, p.IF_curr_exp, cell_params_lif, label='pop_4'))
populations[3].set_mapping_constraint({'x': 0, 'y': 0})
populations.append(
    p.Population(100, p.IF_curr_exp, cell_params_lif, label='pop_5'))
populations[4].set_mapping_constraint({'x': 0, 'y': 0})
populations.append(
    p.Population(100, p.IF_curr_exp, cell_params_lif, label='pop_6'))
Esempio n. 10
0
                'tau_refrac'   : 100, 
                'i_offset'   : 1
                }

cell_params_lif = { 'tau_m'      : 32,
                'cm'        : 0.35,     # added to make PACMAN103 work
                'v_init'    : -80,
                'v_rest'     : -70,   
                'v_reset'    : -95,  
                'v_thresh'   : -55,
                'tau_syn_E'   : 5,
                'tau_syn_I'   : 10,
                'tau_refrac'   : 5,                 
                'i_offset'   : 0
                }

populations = list()
projections = list()

populations.append(p.Population(nNeurons, p.IF_curr_exp, cell_params_lif_in, label='pop_0'))

populations.append(p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_1'))  

projections.append(p.Projection(populations[0], populations[1], p.OneToOneConnector(weights=8, delays=16)))

populations[0].set_mapping_constraint({'x':7, 'y':7})
populations[1].set_mapping_constraint({'x':3, 'y':4})

p.run(3000)

}

populations = list()
projections = list()

weight_to_spike = 2
delay = 1

loopConnections = list()
for i in range(0, nNeurons):
    singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, delay)
    loopConnections.append(singleConnection)

injectionConnection = [(0, 0, weight_to_spike, delay)]
spikeArray = {'spike_times': [[0]]}
for x in range(6):
    populations.append(p.Population(nNeurons, p.IF_curr_exp, cell_params_lif))
    populations.append(p.Population(1, p.SpikeSourceArray, spikeArray))

for x in range(0, 12, 2):
    projections.append(
        p.Projection(populations[x], populations[x],
                     p.FromListConnector(loopConnections)))
    projections.append(
        p.Projection(populations[x + 1], populations[x],
                     p.FromListConnector(injectionConnection)))
    populations[x].record()

p.run(1000)

p.end()
#external stuff population requiremenets
connected_chip_coords = {'x': 0, 'y': 0}
virtual_chip_coords = {'x': 0, 'y': 5}
link = 4
#link = 3

populations = list()
projections = list()

populations.append(
    p.Population(1,
                 p.ExternalRetinaDevice, {
                     'virtual_chip_coords': virtual_chip_coords,
                     'connected_chip_coords': connected_chip_coords,
                     'connected_chip_edge': link,
                     'polarity': p.ExternalRetinaDevice.DOWN_POLARITY,
                     'position': p.ExternalRetinaDevice.RIGHT_RETINA
                 },
                 label='External retina'))

populations.append(
    p.Population(1,
                 p.ExternalRetinaDevice, {
                     'virtual_chip_coords': virtual_chip_coords,
                     'connected_chip_coords': connected_chip_coords,
                     'connected_chip_edge': link,
                     'polarity': p.ExternalRetinaDevice.UP_POLARITY,
                     'position': p.ExternalRetinaDevice.RIGHT_RETINA
                 },
                 label='External retina'))