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_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()
import numpy, pylab, random, sys
#import NeuroTools.signals as nt
import IPython
import pacman103.front.pynn as sim

# SpiNNaker setup
sim.setup(timestep=1.0, min_delay=1.0, max_delay=10.0)

# +-------------------------------------------------------------------+
# | General Parameters                                                |
# +-------------------------------------------------------------------+

# Population parameters
model = sim.IF_curr_exp
cell_params = {'cm'        : 0.25, # nF
                     'i_offset'  : 0.0,
                     'tau_m'     : 10.0,
                     'tau_refrac': 2.0,
                     'tau_syn_E' : 2.5,
                     'tau_syn_I' : 2.5,
                     'v_reset'   : -70.0,
                     'v_rest'    : -65.0,
                     'v_thresh'  : -55.4
                     }
# Other simulation parameters
e_rate = 200
in_rate = 350


delta_t = -10
time_between_pairs = 150
Example #5
0
"""
Synfirechain-like example
"""
#!/usr/bin/python
import pacman103.front.pynn as p
import visualiser.visualiser_modes as modes
import pylab

p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)
nNeurons = 200  # number of neurons in each population
p.set_number_of_neurons_per_core("IF_curr_exp", nNeurons / 2)
p.set_number_of_neurons_per_core("DelayExtension", nNeurons / 2)

cell_params_lif = {
    'cm': 0.25,  # nF
    'i_offset': 0.0,
    'tau_m': 20.0,
    'tau_refrac': 2.0,
    'tau_syn_E': 5.0,
    'tau_syn_I': 5.0,
    'v_reset': -70.0,
    'v_rest': -65.0,
    'v_thresh': -50.0
}

populations = list()
projections = list()

weight_to_spike = 2.0
delay = 17
"""
Synfirechain-like example
"""
#!/usr/bin/python
import pacman103.front.pynn as p
import pylab

p.setup(timestep=1.0, min_delay = 1.0, max_delay = 32.0)
p.set_number_of_neurons_per_core("IZK_curr_exp", 100)

nNeurons = 200 # number of neurons in each population

cell_params_izk = {
    'a': 0.02,
    'b': 0.2,
    'c': -65,
    'd': 8,
    'v_init': -75,
    'u_init': 0,
    'tau_syn_E': 2,
    'tau_syn_I': 2,
    'i_offset': 0
    }

populations = list()
projections = list()

weight_to_spike = 40
delay = 1

loopConnections = list()
    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=0.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()
#import gaborcreatejose as retina_lib
#import gaussiancreatejose as retina_lib

FWD = 0
BWD = 1

input_size = 128  # Size of each population
subsample_size = 32
runtime = 60000 * 2
#runtime = 60
n_orientations = 4

size_gabor = 7

# Simulation Setup
p.setup(timestep=1.0, min_delay=1.0, max_delay=11.0
        )  # Will add some extra parameters for the spinnPredef.ini in here

p.set_number_of_neurons_per_core('IF_curr_exp',
                                 128)  # this will set one population per core

cell_params = {
    'tau_m': 64,
    'i_offset': 0,
    'v_rest': -75,
    'v_reset': -95,
    'v_thresh': -40,
    'tau_syn_E': 15,
    'tau_syn_I': 15,
    'tau_refrac': 2
}
Example #9
0
"""
Test example, for getting PACMAN103 up and running
"""
#!/usr/bin/python
import pacman103.front.pynn as p
import numpy, pylab
import os

#p.setup(timestep=1.0, min_delay = 1.0, max_delay = 8.0, machine="amu12", output=os.getcwd(), db_name='simple_test.sqlite')
p.setup(timestep=1.0, min_delay = 1.0, max_delay = 8.0, machine="spinn-7", output=os.getcwd(), db_name='simple_test.sqlite')

n_pop = 16    # number of populations
nNeurons = 200  # number of neurons in each population


cell_params_lif_in = { 'tau_m'      : 32,
                'cm'        : 0.35,     # added to make PACMAN103 work
                'v_init'    : -80,
                'v_rest'     : -75,   
                'v_reset'    : -95,  
                'v_thresh'   : -55,
                'tau_syn_E'   : 5,
                'tau_syn_I'   : 10,
                '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,