def emulation(seed, connType=0, returnValue=None):
    numberNeurons = 192
    noInputs = 15

    pynn.setup()

    rngPrj = pynn.random.NumpyRNG(seed=seed,
                                  parallel_safe=True)  # this may not work?!
    neurons = pynn.Population(numberNeurons, pynn.IF_facets_hardware1)
    connector = None
    if connType == 0:
        connector = pynn.FixedNumberPreConnector(noInputs,
                                                 weights=pynn.minExcWeight())
    elif connType == 1:
        connector = pynn.FixedNumberPostConnector(noInputs,
                                                  weights=pynn.minExcWeight())
    elif connType == 2:
        connector = pynn.FixedProbabilityConnector(float(noInputs) /
                                                   numberNeurons,
                                                   weights=pynn.minExcWeight())
    else:
        assert False, 'invalid connector type'

    prj = pynn.Projection(neurons,
                          neurons,
                          method=connector,
                          target='inhibitory',
                          rng=rngPrj)

    connList = []
    for conn in prj.connections():
        connList.append(conn)

    assert len(connList) > 0, 'no connections'
    assert len(connList) < numberNeurons * \
        (numberNeurons - 1), 'all-to-all connection'

    pynn.run(1.0)

    pynn.end()

    if returnValue != None:
        returnValue = connList
    else:
        return connList
Exemple #2
0
import pyNN.hardware.spikey as pynn
import numpy as np

pynn.setup()

# set resting potential over spiking threshold
runtime = 1000.0  #ms
popSize = 192
weight = 7.0 * pynn.minExcWeight()
neuronParams = {'v_rest': -40.0}

neurons = pynn.Population(popSize, pynn.IF_facets_hardware1, neuronParams)
pynn.Projection(neurons,
                neurons,
                pynn.FixedNumberPreConnector(15, weights=weight),
                target='inhibitory')
neurons.record()

pynn.run(runtime)

spikes = neurons.getSpikes()

pynn.end()

# visualize
print 'mean firing rate:', round(len(spikes) / runtime / popSize * 1000.0,
                                 1), '1/s'

import matplotlib.pyplot as plt
Exemple #3
0
weight = w * pynn.minInhWeight() #default 4.0
numInhPerNeuron = k #default 25
neuronParams = {
	'v_reset'   : -80.0, # mV  # default
	'e_rev_I'   : -80.0, # mV  # default
	'v_rest'    : -35.0, # mV  # for const-current emulation set to > v_thresh #-30.0 default
	'v_thresh'  : -55.0, # mV  # default
	'g_leak'    :  20.0  # nS  -> tau_mem = 0.2nF / 20nS = 10ms
}


neurons = pynn.Population(popSize, pynn.IF_facets_hardware1, neuronParams)

# the inhibitory projection of the complete population to itself, with identical number
# of presynaptic neurons. Enable after measuring the regular-firing case.
pynn.Projection(neurons, neurons, pynn.FixedNumberPreConnector(numInhPerNeuron, weights=weight), target='inhibitory')

# record spikes
neurons.record()

# record membrane potential of first 4 neurons
pynn.record_v([neurons[0], neurons[1], neurons[2], neurons[3]], '')

# start experiment
pynn.run(runtime)

spikes = neurons.getSpikes()

# end experiment (network keeps running...)
pynn.end()
resultCollector = []

pynn.setup(
    calibTauMem=False)  #turn off calibration of membrane time constant tau_mem

#build network
stimuli = pynn.Population(noStims, pynn.SpikeSourcePoisson, {
    'start': 0,
    'duration': runtime,
    'rate': rateStim
})
neurons = pynn.Population(noNeurons, pynn.IF_facets_hardware1)
pynn.Projection(stimuli,
                neurons,
                pynn.FixedNumberPreConnector(noInputs,
                                             weights=weight *
                                             pynn.minExcWeight()),
                target='excitatory')
neurons.record()

#sweep over g_leak values, emulate network and record spikes
for gLeakValue in gLeakList:
    neurons.set({'g_leak': gLeakValue})
    pynn.run(runtime)
    resultCollector.append([
        gLeakValue,
        old_div(float(len(neurons.getSpikes())) / noNeurons, runtime) * 1e3
    ])
pynn.end()

#plot results
            'v_reset': -80.0,  # mV  # default
            'e_rev_I': -80.0,  # mV  # default
            'v_rest':
            -35.0,  # mV  # for const-current emulation set to > v_thresh #-30.0 default
            'v_thresh': -55.0,  # mV  # default
            'g_leak': 20.0  # nS  -> tau_mem = 0.2nF / 20nS = 10ms
        }

        neurons = pynn.Population(popSize, pynn.IF_facets_hardware1,
                                  neuronParams)

        # the inhibitory projection of the complete population to itself, with identical number
        # of presynaptic neurons. Enable after measuring the regular-firing case.
        pynn.Projection(neurons,
                        neurons,
                        pynn.FixedNumberPreConnector(numInhPerNeuron,
                                                     weights=weight),
                        target='inhibitory')

        # record spikes
        neurons.record()

        # record membrane potential of first 4 neurons
        pynn.record_v([neurons[0], neurons[1], neurons[2], neurons[3]], '')

        # start experiment
        pynn.run(runtime)

        spikes = neurons.getSpikes()

        # end experiment (network keeps running...)
        pynn.end()