def create_empty_spike_source_layer_with_shape(shape):
    """
    Creates a spike source layer with the given shape and its firing rates set
    to zero. This is also a helper function of create_spike_source_layer_from().
    """
    spike_source_layer = sim.Population(
        size=shape[0] * shape[1], cellclass=sim.SpikeSourcePoisson(rate=0))
    return Layer(spike_source_layer, shape)
예제 #2
0
def test_nest_dense_shape():
    p1 = pynn.Population(12, pynn.SpikeSourcePoisson(rate = 10))
    p2 = pynn.Population(10, pynn.IF_cond_exp())
    d = v.Dense(p1, p2, v.ReLU(), weights = 1)
    pynn.run(1000)
    d.store_spikes()
    assert d.input.shape == (12,)
    assert d.output.shape[0] == 10
예제 #3
0
def test_nest_dense_increased_weight_fire():
    p1 = pynn.Population(1, pynn.SpikeSourcePoisson(rate = 1))
    p2 = pynn.Population(1, pynn.IF_cond_exp())
    p2.record('spikes')
    d = v.Dense(p1, p2, v.ReLU(), weights = 2)
    pynn.run(1000)
    spiketrains = p2.get_data().segments[-1].spiketrains
    count1 = spiketrains[0].size
    pynn.reset()
    p1 = pynn.Population(1, pynn.SpikeSourcePoisson(rate = 1))
    p2 = pynn.Population(1, pynn.IF_cond_exp())
    p2.record('spikes')
    d = v.Dense(p1, p2, v.ReLU(), weights = 2)
    pynn.run(1000)
    spiketrains = p2.get_data().segments[-1].spiketrains
    count2 = spiketrains[0].size
    assert count2 >= count1 * 2 
예제 #4
0
def test_nest_dense_chain():
    p1 = pynn.Population(12, pynn.SpikeSourcePoisson(rate = 100))
    p2 = pynn.Population(10, pynn.IF_cond_exp())
    p3 = pynn.Population(2, pynn.IF_cond_exp())
    p3.record('spikes')
    d1 = v.Dense(p1, p2, v.ReLU())
    d2 = v.Dense(p2, p3, v.ReLU())
    pynn.run(1000)
    assert len(p3.get_data().segments[-1].spiketrains) > 0
예제 #5
0
def test_ticket244():
    nest = pyNN.nest
    nest.setup(threads=4)
    p1 = nest.Population(4, nest.IF_curr_exp())
    p1.record('spikes')
    poisson_generator = nest.Population(3, nest.SpikeSourcePoisson(rate=1000.0))
    conn = nest.OneToOneConnector()
    syn = nest.StaticSynapse(weight=1.0)
    nest.Projection(poisson_generator, p1.sample(3), conn, syn, receptor_type="excitatory")
    nest.run(15)
    p1.get_data()
예제 #6
0
def test_nest_dense_projection():
    p1 = pynn.Population(12, pynn.SpikeSourcePoisson(rate = 10))
    p2 = pynn.Population(10, pynn.IF_cond_exp())
    p2.record('spikes')
    d = v.Dense(p1, p2, v.ReLU(), weights = 1)
    pynn.run(1000)
    spiketrains = p2.get_data().segments[-1].spiketrains
    assert len(spiketrains) == 10
    avg_len = np.array(list(map(len, spiketrains))).mean()
    # Should have equal activation
    for train in spiketrains:
        assert abs(len(train) - avg_len) <= 1
def presentStimuli(pres_duration, num_pres_per_stim, num_source, num_target, bright_on_weights, bright_off_weights, bright_lat_weights, dark_on_weights, dark_off_weights, dark_lat_weights, is_repeated=False):
    """
    For presenting a stimulus to the target network. Callback is used to switch between presentation rates.
    Arguments:  num_source
                num_target
                num_pres_per_stim,
                pres_duration
    """
    num_stim = 2 # two stimuli 'bright' and 'dark'
    total_duration = num_stim * num_pres_per_stim * pres_duration

    source_on_pop = pynn.Population(num_source, pynn.SpikeSourcePoisson(), label='source_on_pop')
    source_off_pop = pynn.Population(num_source, pynn.SpikeSourcePoisson(), label='source_off_pop')
    is_bright, random_on_rates, random_off_rates = getPresentationRatesForCallback(num_stim, num_source, num_pres_per_stim, is_repeated=is_repeated)

    bright_target_pop = pynn.Population(num_target, pynn.IF_cond_exp, {'i_offset':0.11, 'tau_refrac':3.0, 'v_thresh':-51.0}, label='target_pop')
    dark_target_pop = pynn.Population(num_target, pynn.IF_cond_exp, {'i_offset':0.11, 'tau_refrac':3.0, 'v_thresh':-51.0}, label='target_pop')

    bright_on_conn = pynn.Projection(source_on_pop, bright_target_pop, connector=pynn.AllToAllConnector(), synapse_type=pynn.StaticSynapse(weight=bright_on_weights), receptor_type='excitatory')
    bright_off_conn = pynn.Projection(source_off_pop, bright_target_pop, connector=pynn.AllToAllConnector(), synapse_type=pynn.StaticSynapse(weight=bright_off_weights), receptor_type='excitatory')
    bright_lat_conn = pynn.Projection(bright_target_pop, bright_target_pop, connector=pynn.AllToAllConnector(), synapse_type=pynn.StaticSynapse(weight=bright_lat_weights), receptor_type='inhibitory')
    dark_on_conn = pynn.Projection(source_on_pop, dark_target_pop, connector=pynn.AllToAllConnector(), synapse_type=pynn.StaticSynapse(weight=dark_on_weights), receptor_type='excitatory')
    dark_off_conn = pynn.Projection(source_off_pop, dark_target_pop, connector=pynn.AllToAllConnector(), synapse_type=pynn.StaticSynapse(weight=dark_off_weights), receptor_type='excitatory')
    dark_lat_conn = pynn.Projection(dark_target_pop, dark_target_pop, connector=pynn.AllToAllConnector(), synapse_type=pynn.StaticSynapse(weight=dark_lat_weights), receptor_type='inhibitory')

    source_on_pop.record('spikes')
    source_off_pop.record('spikes')
    bright_target_pop.record(['spikes'])
    dark_target_pop.record(['spikes'])

    pynn.run(total_duration, callbacks=[PoissonWeightVariation(source_on_pop, random_on_rates, pres_duration), PoissonWeightVariation(source_off_pop, random_off_rates, pres_duration)])
    pynn.end()

    source_on_spikes = source_on_pop.get_data('spikes').segments[0].spiketrains
    source_off_spikes = source_off_pop.get_data('spikes').segments[0].spiketrains
    bright_spikes = bright_target_pop.get_data('spikes').segments[0].spiketrains
    dark_spikes = dark_target_pop.get_data('spikes').segments[0].spiketrains
    return is_bright, source_on_spikes, source_off_spikes, bright_spikes, dark_spikes
예제 #8
0
def test_native_stdp_model():
    nest = pyNN.nest
    from pyNN.utility import init_logging

    init_logging(logfile=None, debug=True)

    nest.setup()

    p1 = nest.Population(10, nest.IF_cond_exp())
    p2 = nest.Population(10, nest.SpikeSourcePoisson())

    stdp_params = {'Wmax': 50.0, 'lambda': 0.015, 'weight': 0.001}
    stdp = nest.native_synapse_type("stdp_synapse")(**stdp_params)

    connector = nest.AllToAllConnector()

    prj = nest.Projection(p2, p1, connector, receptor_type='excitatory',
                          synapse_type=stdp)
                             Neurons_RS,
                             sim.FixedProbabilityConnector(
                                 0.05, allow_self_connections=False),
                             receptor_type='inhibitory',
                             synapse_type=sim.StaticSynapse(weight=0.005))
    # inh_inh
    inh_inh = sim.Projection(Neurons_FS,
                             Neurons_FS,
                             sim.FixedProbabilityConnector(
                                 0.05, allow_self_connections=False),
                             receptor_type='inhibitory',
                             synapse_type=sim.StaticSynapse(weight=0.005))

    ##FEEDFORWARD CONNECTIONS
    # feedforward input on INH pop
    input_exc = sim.Population(N_exc, sim.SpikeSourcePoisson(rate=0))
    fdfrwd_to_exc = sim.Projection(
        input_exc,
        Neurons_RS,
        sim.FixedProbabilityConnector(0.05, allow_self_connections=False),
        synapse_type=sim.StaticSynapse(weight=0.001))
    # feedforward input on EXC pop
    fdfrwd_to_inh = sim.Projection(
        input_exc,
        Neurons_FS,
        sim.FixedProbabilityConnector(0.05, allow_self_connections=False),
        synapse_type=sim.StaticSynapse(weight=0.001))

    #To calcul the firing rate
    def rate(segment, bin_size):
        if segment == []:
예제 #10
0
# Take the neuron layers that need to be updated online or that we want to take records of
LGNBright = network.get_population("LGNBright")
LGNDark = network.get_population("LGNDark")
V1 = network.get_population("V1LayerToPlot")
V2 = network.get_population("V2LayerToPlot")
V4Bright = network.get_population("V4Brightness")
V4Dark = network.get_population("V4Darkness")
LGNBright.record("spikes")
LGNDark.record("spikes")
V1.record("spikes")
V2.record("spikes")
V4Bright.record("spikes")
V4Dark.record("spikes")
if inputPoisson:
    LGNBrightInput = sim.Population(ImageNumPixelRows * ImageNumPixelColumns,
                                    sim.SpikeSourcePoisson())
    LGNDarkInput = sim.Population(ImageNumPixelRows * ImageNumPixelColumns,
                                  sim.SpikeSourcePoisson())
    sim.Projection(LGNBrightInput, LGNBright, sim.OneToOneConnector(),
                   sim.StaticSynapse(weight=connections['brightInputToLGN']))
    sim.Projection(LGNDarkInput, LGNDark, sim.OneToOneConnector(),
                   sim.StaticSynapse(weight=connections['darkInputToLGN']))
if numSegmentationLayers > 1:
    if useSurfaceSegmentation:
        SurfaceSegmentationOff = network.get_population(
            "SurfaceSegmentationOff")
        SurfaceSegmentationOn = network.get_population("SurfaceSegmentationOn")
    if useBoundarySegmentation:
        BoundarySegmentationOff = network.get_population(
            "BoundarySegmentationOff")
        BoundarySegmentationOn = network.get_population(
from scipy import signal

from common import (spike_mean_rate, generate_labeledImages,
                    print_mean_spike_rate, compute_weights)
from common import param

# All-to-all connections between input and reservoir
# Uniform weights between input and reservoir
# Unifrom weights inside reservoir
# Uniform reservoir (all excitatory neurons)

p.setup(timestep=param.dt)

###### Neurons #######

input_neurons = p.Population(param.input_nr, p.SpikeSourcePoisson())
readout_neurons = p.Population(param.readout_nr,
                               p.IF_curr_exp, {},
                               label="readout")
reservoir = p.Population(param.reservoir_nr,
                         p.IF_curr_exp, {},
                         label="reservoir")

######################

###### Synapses #######

stat_syn_res = p.StaticSynapse(weight=5.0, delay=1)
stat_syn_input = p.StaticSynapse(weight=50.0, delay=1)
stat_syn_rout = p.StaticSynapse(weight=0.0, delay=1)
예제 #12
0
import pyNN.nest as sim  # can of course replace `neuron` with `nest`, `brian`, etc.
import matplotlib.pyplot as plt
import numpy as np

sim.setup(timestep=0.01)
p_in = sim.Population(10, sim.SpikeSourcePoisson(rate=10.0), label="input")
p_out = sim.Population(10, sim.EIF_cond_exp_isfa_ista(), label="AdExp neurons")

syn = sim.StaticSynapse(weight=0.05)
random = sim.FixedProbabilityConnector(p_connect=0.5)
connections = sim.Projection(p_in,
                             p_out,
                             random,
                             syn,
                             receptor_type='excitatory')

p_in.record('spikes')
p_out.record('spikes')
# record spikes from all neurons
p_out[0:2].record(['v', 'w', 'gsyn_exc'
                   ])  # record other variables from first two neurons

sim.run(500.0)

spikes_in = p_in.get_data()
print("spikes_in : ", type(spikes_in))
print("spikes_in.segments[0].spiketrains[0]",
      spikes_in.segments[0].spiketrains[0])

#print("spikes_in.segments[-1].spiketrains",spikes_in.segments[-1].spiketrains)
spike_result = p_in.getSpikes(compatible_output=True)
예제 #13
0
import pyNN.nest as sim
import numpy
import nest
__population_views = {}


pop1 = sim.Population(10, sim.IF_cond_alpha())
__population_views['pop1'] = pop1

source = sim.Population(1, sim.SpikeSourcePoisson(rate=1000000.0))

nest_source = nest.Create('poisson_generator')
nest.SetStatus(nest_source, {'rate': 100000.0})
nest.Connect(nest_source, map(int, pop1.all_cells), 'all_to_all')

print "Network loaded"


예제 #14
0
        'v_reset': 0,
        'v_rest': 0,
        'i_offset': 0,
        'cm': 1,
        'tau_m': 1000,
        'tau_refrac': 0.001,
        'tau_syn_E': 0.01,
        'tau_syn_I': 0.01
    }
    simparams = {'duration': 10, 'dt': 1, 'delay': 1, 'input_rate': 0}

    sim.setup(simparams['dt'])

    inp = sim.Population(
        1,
        sim.SpikeSourcePoisson(duration=simparams['duration'],
                               rate=simparams['input_rate']))

    inp.label = 'input cell'
    outp = sim.Population(1, sim.IF_curr_exp, cellparams=cellparams)
    outp.label = 'output cell'

    inp.record('spikes')
    outp.record(['v', 'spikes'])

    synapse = sim.StaticSynapse(weight=1, delay=simparams['delay'])

    connector = sim.OneToOneConnector()

    connection = sim.Projection(inp, outp, connector, synapse)

    def report_time(t):
예제 #15
0
from pyNN.parameters import Sequence
from pyNN.random import RandomDistribution as rnd
import matplotlib.pyplot as plt
plt.interactive(False)
sim.setup(0.1)

neurons = sim.Population(64, sim.IF_curr_exp, {}, label="neurons")
print(neurons.celltype.recordable)

params = {
    'rate': 10000.0,  # Mean spike frequency (Hz)
    'start': 0.0,  # Start time (ms)
    'duration': 1e10  # Duration of spike sequence (ms)
}

input = sim.Population(64, sim.SpikeSourcePoisson(**params), label="input")

input_proj = sim.Projection(
    input, neurons, sim.OneToOneConnector(), receptor_type='excitatory'
)  ##https://github.com/NeuralEnsemble/PyNN/issues/273


def twoDto1D(x):
    return (8 * x[0] + x[1])


def oneDto2D(n):
    return np.array([int(n / 8.), int(n - 8 * (int(n / 8.)))])


def plot_spiketrains(segment):
예제 #16
0
                                            structure=excitatory_structure,
                                            label='Excitatory layer')
cortical_neurons_inh = simulator.Population(Ncell_inh**2,
                                            inhibitory_cell,
                                            structure=inhibitory_structure,
                                            label='Inhibitory layer')

#############################
# Add background noise
#############################

correlated = False
noise_rate = 5800  # Hz
g_noise = 0.00089 * 0  # Microsiemens (0.89 Nanosiemens)
noise_delay = 1  # ms
noise_model = simulator.SpikeSourcePoisson(rate=noise_rate)
noise_syn = simulator.StaticSynapse(weight=g_noise, delay=noise_delay)

if correlated:
    # If correlated is True all the cortical neurons receive noise from the same cell.
    noise_population = simulator.Population(1,
                                            noise_model,
                                            label='Background Noise')
    background_noise_to_exc = simulator.Projection(
        noise_population, cortical_neurons_exc, simulator.AllToAllConnector(),
        noise_syn)
    background_noise_to_inh = simulator.Projection(
        noise_population, cortical_neurons_inh, simulator.AllToAllConnector(),
        noise_syn)
else:
    # If correlated is False, all cortical neurons receive independent noise
예제 #17
0
parser.add_argument('-t', '--duration', help='duration of simulation.', default=500.0, type=float)
parser.add_argument('-s', '--stdp', help='use STDP', default=False, action='store_true')
parser.add_argument('-a', '--record_target_spikes', help='Record the target spikes.', default=False, action='store_true')
parser.add_argument('-m', '--make_plots', help='make the plots, or not.', default=False, action='store_true')
parser.add_argument('-d', '--debug', help='enter debug mode', default=False, action='store_true')
args = parser.parse_args()

pynn.setup(timestep=0.1, min_delay=2.0)

if not args.debug:
    # define target cell
    target_cell = pynn.create(pynn.IF_cond_exp, {'i_offset':0.11, 'tau_refrac':3.0, 'v_thresh':-51.0})

    # define inhibitory and excitatory populations
    inhib_rates, excit_rates = getRatesForInhibExcit(args.inhib_rates_lower, args.excit_rates_lower, args.num_inhib, args.num_excit)
    inhib_source = pynn.Population(args.num_inhib, pynn.SpikeSourcePoisson(rate=inhib_rates), label="inhib_input")
    excit_source = pynn.Population(args.num_excit, pynn.SpikeSourcePoisson(rate=excit_rates), label="excit_input")

    # define stdp rules, parameters could be messed around with here.
    stdp = pynn.STDPMechanism(weight=0.02, # this is the initial value of the weight
            timing_dependence=pynn.SpikePairRule(tau_plus=20.0, tau_minus=20.0, A_plus=0.01, A_minus=0.012),
            weight_dependence=pynn.AdditiveWeightDependence(w_min=0, w_max=0.04))
    synapse_to_use = stdp if args.stdp else pynn.StaticSynapse(weight=0.02)

    # connect inhibitory and excitatory sources to target. Could connect inhib to excit?
    inhib_conn = pynn.Projection(inhib_source, target_cell, connector=pynn.AllToAllConnector(), synapse_type=synapse_to_use, receptor_type='inhibitory')
    excit_conn = pynn.Projection(excit_source, target_cell, connector=pynn.AllToAllConnector(), synapse_type=synapse_to_use, receptor_type='excitatory')

    # tell the sim what to record
    target_cell.record(['spikes', 'v', 'gsyn_exc', 'gsyn_inh']) if args.record_target_spikes else target_cell.record(['v', 'gsyn_exc', 'gsyn_inh'])
    inhib_source.record('spikes')
예제 #18
0
def runSimGivenStim(stim_type, num_source, num_target, duration, use_stdp,
                    record_source_spikes, source_rates_params, synapse_to_use,
                    ff_conn, lat_conn):
    """
    For running the simulation and returning the required results.
    Arguments:  stim_type, 'bright' or 'dark'
                num_source, number of cells in the source layers
                num_target, number of cells in the target layer
                duration, float
                use_stdp,
                record_source_spikes,
                source_rates_params, params for 8 Gamma distributions
                synapse_to_use, either STDPMechanism or StaticSynapse
                ff_conn, either AllToAllConnector or FixedProbabilityConnector
                lat_conn, same as ff_conn but with a different probability, maybe
    Returns:    target_spikes,
                ff_on_weights,
                ff_off_weights,
                lat_weights,
                ff_on_weights_over_time,
                ff_off_weights_over_time,
                lat_weights_over_time
    """
    on_rates, off_rates = getOnOffSourceRates(
        num_source,
        stim_type,
        on_bright_params=args.source_rates_params[0],
        on_dark_params=args.source_rates_params[1],
        off_bright_params=args.source_rates_params[2],
        off_dark_params=args.source_rates_params[3])
    source_on_pop = pynn.Population(num_source,
                                    pynn.SpikeSourcePoisson(rate=on_rates),
                                    label='source_on_pop')
    source_off_pop = pynn.Population(num_source,
                                     pynn.SpikeSourcePoisson(rate=off_rates),
                                     label='source_off_pop')
    target_pop = pynn.Population(num_target,
                                 pynn.IF_cond_exp, {
                                     'i_offset': 0.11,
                                     'tau_refrac': 3.0,
                                     'v_thresh': -51.0
                                 },
                                 label='target_pop')
    ff_on_proj = pynn.Projection(source_on_pop,
                                 target_pop,
                                 connector=ff_conn,
                                 synapse_type=synapse_to_use,
                                 receptor_type='excitatory')
    ff_off_proj = pynn.Projection(source_off_pop,
                                  target_pop,
                                  connector=ff_conn,
                                  synapse_type=synapse_to_use,
                                  receptor_type='excitatory')
    lat_proj = pynn.Projection(target_pop,
                               target_pop,
                               connector=lat_conn,
                               synapse_type=synapse_to_use,
                               receptor_type='inhibitory')
    target_pop.record(['spikes'])
    [source_on_pop.record('spikes'),
     source_off_pop.record('spikes')] if args.record_source_spikes else None
    ff_on_weight_recorder = WeightRecorder(sampling_interval=1.0,
                                           projection=ff_on_proj)
    ff_off_weight_recorder = WeightRecorder(sampling_interval=1.0,
                                            projection=ff_off_proj)
    lat_weight_recorder = WeightRecorder(sampling_interval=1.0,
                                         projection=lat_proj)
    pynn.run(duration,
             callbacks=[
                 ff_on_weight_recorder, ff_off_weight_recorder,
                 lat_weight_recorder
             ])
    pynn.end()
    target_spikes = target_pop.get_data('spikes').segments[0].spiketrains
    if record_source_spikes:
        source_on_spikes = source_on_pop.get_data(
            'spikes').segments[0].spiketrains
        source_off_spikes = source_off_pop.get_data(
            'spikes').segments[0].spiketrains
    ff_on_weights = ff_on_proj.get('weight', format='array')
    ff_off_weights = ff_off_proj.get('weight', format='array')
    lat_weights = lat_proj.get('weight', format='array')
    ff_on_weights_over_time = ff_on_weight_recorder.get_weights()
    ff_off_weights_over_time = ff_off_weight_recorder.get_weights()
    lat_weights_over_time = lat_weight_recorder.get_weights()
    pynn.reset()
    return target_spikes, ff_on_weights, ff_off_weights, lat_weights, ff_on_weights_over_time, ff_off_weights_over_time, lat_weights_over_time
예제 #19
0
    def __init__(self, sim_params=None, cell_params=None, verbose=True):
        '''
        Parameters : Stimulus, Population, Synapses, Recording, Running 
        '''

        self.verbose = verbose
        self.sim_params = sim_params
        self.cell_params = cell_params

        sim.setup()  #spike_precision='on_grid')#timestep = .1)

        N_inh = int(sim_params['nb_neurons'] *
                    sim_params['p'])  #total pop * proportion of inhib
        self.spike_source = sim.Population(
            N_inh,
            sim.SpikeSourcePoisson(rate=sim_params['input_rate'],
                                   duration=sim_params['simtime'] / 2))

        #orientation stimulus, see bottom section of notebook
        angle = 1. * np.arange(N_inh)
        rates = self.tuning_function(angle,
                                     sim_params['angle_input'] / 180. * N_inh,
                                     sim_params['b_input'], N_inh)
        rates /= rates.mean()
        rates *= sim_params['input_rate']
        for i, cell in enumerate(self.spike_source):
            cell.set_parameters(rate=rates[i])

        #neuron model selection
        if sim_params['neuron_model'] == 'IF_cond_alpha':
            model = sim.IF_cond_alpha  #LIF with nice dynamics
        else:
            model = sim.IF_cond_exp  #LIF with exp dynamics

        #populations
        E_neurons = sim.Population(
            N_inh,
            model(**cell_params),
            initial_values={
                'v':
                rnd('uniform',
                    (sim_params['v_init_min'], sim_params['v_init_max']))
            },
            label="Excitateurs")
        I_neurons = sim.Population(
            int(sim_params['nb_neurons'] - N_inh),
            model(**cell_params),
            initial_values={
                'v':
                rnd('uniform',
                    (sim_params['v_init_min'], sim_params['v_init_max']))
            },
            label="Inhibiteurs")

        #input to excitatories
        input_exc = sim.Projection(
            self.spike_source, E_neurons, sim.OneToOneConnector(),
            sim.StaticSynapse(weight=sim_params['w_input_exc'],
                              delay=sim_params['s_input_exc']))

        #loop through connections type and use associated params, can be a bit slow
        conn_types = ['exc_inh', 'inh_exc', 'exc_exc',
                      'inh_inh']  #connection types
        '''
        self.proj = self.set_synapses(conn_types = conn_types, sim_params =sim_params, 
                                      E_neurons = E_neurons, I_neurons = I_neurons, 
                                      N_inh = N_inh)
        '''
        #Multi threading support NE MARCHE PAS LAISSER LE NJOBS EN 1
        self.proj = Parallel(n_jobs=1, backend='multiprocessing')(
            delayed(self.set_synapses)(conn_type,
                                       sim_params=sim_params,
                                       E_neurons=E_neurons,
                                       I_neurons=I_neurons,
                                       N_inh=N_inh,
                                       conn_types=conn_types,
                                       verbose=verbose)
            for conn_type in range(len(conn_types)))
        if verbose: print('Done building synapses !')

        #record
        self.spike_source.record('spikes')
        E_neurons.record('spikes')
        I_neurons.record('spikes')

        #run
        if verbose: print('Running simulation..')
        sim.run(sim_params['simtime'])
        if verbose: print('Done running !')

        #get the spikes
        self.E_spikes = E_neurons  #.get_data().segments[0]
        self.I_spikes = I_neurons  #.get_data().segments[0]
        self.P_spikes = self.spike_source  #.get_data().segments[0]
예제 #20
0
if not args.debug:
    # define target cell
    target_pop = pynn.Population(args.num_target, pynn.IF_cond_exp, {
        'i_offset': 0.11,
        'tau_refrac': 3.0,
        'v_thresh': -51.0
    })

    # define inhibitory and excitatory populations
    inhib_rates, excit_rates = getRatesForInhibExcit(args.inhib_rates_lower,
                                                     args.excit_rates_lower,
                                                     args.num_inhib,
                                                     args.num_excit)
    inhib_source = pynn.Population(
        args.num_inhib,
        pynn.SpikeSourcePoisson(rate=inhib_rates),
        label="inhib_input") if args.inhib_conn_type == 'ff' else None
    excit_source = pynn.Population(args.num_excit,
                                   pynn.SpikeSourcePoisson(rate=excit_rates),
                                   label="excit_input")

    # define stdp rules, parameters could be messed around with here.
    stdp = pynn.STDPMechanism(
        weight=0.02,  # this is the initial value of the weight
        timing_dependence=pynn.SpikePairRule(tau_plus=20.0,
                                             tau_minus=20.0,
                                             A_plus=0.01,
                                             A_minus=0.012),
        weight_dependence=pynn.AdditiveWeightDependence(w_min=0, w_max=0.04))
    synapse_to_use = stdp if args.stdp else pynn.StaticSynapse(weight=0.02)