Beispiel #1
0
from pyNN.random import RandomDistribution, NumpyRNG

Exc_in = 32
Inh_in = 32
noSpikes = 20  # number of spikes per chanel per simulation run
stimSpikes = RandomDistribution(
    'uniform', low=0, high=500.0, rng=NumpyRNG(seed=72386)
).next(
    [Exc_in + Inh_in, noSpikes]
)  # generate a time uniform distributed signal with Exc_in + Inh_in chanels and noSpikes for each chanel
# print stimSpikes

for i in range(Exc_in):
    if i == 0:
        Excinp = sim.Population(
            1, sim.SpikeSourceArray(spike_times=stimSpikes[i, :]))
    else:
        spike_source = sim.Population(
            1, sim.SpikeSourceArray(spike_times=stimSpikes[i, :]))
        Excinp = Excinp + spike_source

for i in range(Inh_in):
    if i == 0:
        Inhinp = sim.Population(
            1, sim.SpikeSourceArray(spike_times=stimSpikes[i + Exc_in, :]))
    else:
        spike_source = sim.Population(
            1, sim.SpikeSourceArray(spike_times=stimSpikes[i + Exc_in, :]))
        Inhinp = Inhinp + spike_source

# for p in Excinp.populations:

def plot_signal(signal, index, colour='b'):
    label = "Neuron %d " % index
    plt.plot(signal.times, signal, colour, label=label)
    plt.ylabel("%s (%s)" % (signal.name, signal.units._dimensionality.string))
    plt.setp(plt.gca().get_xticklabels(), visible=False)


run_time = 500
no_run = 3

sim.setup()
# Excinp = sim.Population(10, sim.SpikeSourcePoisson(rate = 20.0, start = 0, duration = run_time))
stimSpikes = RandomDistribution('uniform', low=0, high=500.0).next([1, 10])
Excinp = sim.Population(10, sim.SpikeSourceArray(spike_times=stimSpikes[0, :]))
# cell_type_parameters = {'tau_refrac': 0.1, 'v_thresh': -50.0, 'tau_m': 20.0, 'tau_syn_E': 0.5, 'v_rest': -65.0,\
# 'cm': 1.0, 'v_reset': -65.0, 'tau_syn_I': 0.5, 'i_offset': 0.0}
# print(sim.IF_curr_alpha.default_parameters)

# cell_type = sim.IF_cond_exp(**cell_type_parameters) # neuron type of population
Pexc = sim.Population(10,
                      sim.EIF_cond_exp_isfa_ista(),
                      label="excitotary neurons")
# Pexc.set(tau_refrac = 0.1, v_thresh = -50.0, tau_m = 20.0, tau_syn_E = 0.5, v_rest = -65.0, \
# 		cm = 1.0, v_reset = -65, tau_syn_I = 0.5, i_offset = 0.0)
# Pexc.initialize(**cell_type_parameters)
# print Pexc.celltype.default_initial_values
# print Pexc.get('tau_m')
# syn = sim.StaticSynapse(weight = 0.05, delay = 0.5)
depressing_synapse_ee = sim.TsodyksMarkramSynapse(weight=0.05,
            int((stop_time_3 - start_time_3) * rate_3 * 1e-3))
    # spike_times_4 = RandomDistribution('uniform', (run_time * i + start_time_4, run_time * i + stop_time_4)).next(int((stop_time_3 - start_time_3) * rate_3 * 1e-3))
    spike_time = np.concatenate((spike_times_1, spike_times_2, spike_times_3),
                                axis=0)
    # print spike_time
    # print type(spike_times_1)
    spike_time_run = np.hstack((spike_time_run, spike_time))

# print spike_time_run
# ==========simulation setup=====================

sim.setup()

# ==========generate OR read in the input spikes data=====================
Excinp = sim.Population(Exc_in,
                        sim.SpikeSourceArray(spike_times=spike_time_run))
Inhinp = sim.Population(Inh_in,
                        sim.SpikeSourceArray(spike_times=spike_time_run))

# ==========create neuron population=====================
# todo: the initail parameters of neurons might be modified
cell_type_parameters = {'tau_refrac': 0.1, 'v_thresh': -50.0, 'tau_m': 20.0, 'tau_syn_E': 0.5, 'v_rest': -65.0,\
      'cm': 1.0, 'v_reset': -65.0, 'tau_syn_I': 0.5, 'i_offset': 0.0}
# print(sim.IF_curr_alpha.default_parameters)

cell_type = sim.IF_cond_exp(**
                            cell_type_parameters)  # neuron type of population
Pexc = sim.Population(
    N_e, cell_type, label="excitotary neurons")  # excitatory neuron population
Pinh = sim.Population(
    N_i, cell_type,
Beispiel #4
0
run_time = 500 * 500  # define the simulation time per run unit ms
exp_des = 'Robustness_dynamic'  # define the exp no for data storage

rate = 15  # unit Hz
print 'generating input ...'
spike_times = RandomDistribution('uniform', (0.00, run_time)).next(
    int((run_time - 0.00) * rate * 1e-3))

print 'input generation done'
# ==========simulation setup=====================

sim.setup()

# ==========generate OR read in the input spikes data=====================
print 'create spike source'
Excinp = sim.Population(Exc_in, sim.SpikeSourceArray(spike_times=spike_times))
Inhinp = sim.Population(Inh_in, sim.SpikeSourceArray(spike_times=spike_times))
print 'spike source created'

# ==========create neuron population=====================
# todo: the initail parameters of neurons might be modified
cell_type_parameters = {'tau_refrac': 0.1, 'v_thresh': -50.0, 'tau_m': 20.0, 'tau_syn_E': 0.5, 'v_rest': -65.0,\
      'cm': 1.0, 'v_reset': -65.0, 'tau_syn_I': 0.5, 'i_offset': 0.0}
# print(sim.IF_curr_alpha.default_parameters)

cell_type = sim.IF_cond_exp(**
                            cell_type_parameters)  # neuron type of population
Pexc = sim.Population(
    N_e, cell_type, label="excitotary neurons")  # excitatory neuron population
Pinh = sim.Population(
    N_i, cell_type,
#generate function
number = int(2 * simtime * input_rate / 1000.0)
#simtime ??


def generate_spike_times(i):
    gen = lambda: sim.Sequence(
        numpy.add.accumulate(
            numpy.random.exponential(1000.0 / input_rate, size=number)))
    if hasattr(i, "__len__"):
        return [gen() for j in i]
    else:
        return gen()


celltype = sim.SpikeSourceArray(spike_times=generate_spike_times)

cell_type = sim.GIF_cond_exp(
    # this parameter has the same value in all neurons in the population
    tau_gamma=(1.0, 10.0,
               100.0),  # Time constants for spike-frequency adaptation in ms.
    # the following parameter has different values for each neuron
    a_eta=[
        (0.1, 0.1,
         0.1),  # Post-spike increments for spike-triggered current in nA
        (0.0, 0.0, 0.0),
        (0.0, 0.0, 0.0),
        (0.0, 0.0, 0.0)
    ])
#no definition for GIF
sim.end()
)  # generate a time uniform distributed signal with Exc_in + Inh_in chanels and noSpikes for each chanel
# todo: 64 chanel represents different data

sim.setup()  # start buiding up the network topology

# ==========create the input signal neuron population==================
# # form the Exc_in chanels excitatory inputs as a assembly Inhinp
# for i in range(Exc_in):
# 	if i == 0:
# 		Excinp = sim.Population(1, sim.SpikeSourceArray(spike_times = stimSpikes[i,:]))
# 	else:
# 		spike_source = sim.Population(1, sim.SpikeSourceArray(spike_times = stimSpikes[i,:]))
# 		Excinp = Excinp + spike_source

Excinp = sim.Population(Exc_in,
                        sim.SpikeSourceArray(spike_times=stimSpikes[2, :]))
Inhinp = sim.Population(Inh_in,
                        sim.SpikeSourceArray(spike_times=stimSpikes[3, :]))

# # form the Inh_in chanels excitatory inputs as a assembly Inhinp
# for i in range(Inh_in):
# 	if i == 0:
# 		Inhinp = sim.Population(1, sim.SpikeSourceArray(spike_times = stimSpikes[i + Exc_in,:]))
# 	else:
# 		spike_source = sim.Population(1, sim.SpikeSourceArray(spike_times = stimSpikes[i + Exc_in,:]))
# 		Inhinp = Inhinp + spike_source

# ==========create neuron population=====================
# todo: the initail parameters of neurons might be modified
cell_type_parameters = {'tau_refrac': 0.1, 'v_thresh': -50.0, 'tau_m': 20.0, 'tau_syn_E': 0.5, 'v_rest': -65.0,\
      'cm': 1.0, 'v_reset': -65.0, 'tau_syn_I': 0.5, 'i_offset': 0.0}
sim.setup()

# ==========create neuron population=====================
# todo: the initail parameters of neurons might be modified
cell_type_parameters = {'tau_refrac': 0.1, 'v_thresh': -50.0, 'tau_m': 20.0, 'tau_syn_E': 0.5, 'v_rest': -65.0,\
						'cm': 1.0, 'v_reset': -65.0, 'tau_syn_I': 0.5, 'i_offset': 0.0}
# print(sim.IF_curr_alpha.default_parameters)

cell_type = sim.IF_cond_exp(**cell_type_parameters) # neuron type of population
Pexc = sim.Population(3, cell_type, label = "excitotary neurons") # excitatory neuron population

# ==========generate OR read in the input spikes data=====================
noSpikes = 20 # number of spikes per chanel per simulation run
stimSpikes = RandomDistribution('uniform', low = 0, high = 500, rng = NumpyRNG(seed = 72386)).next(noSpikes) # generate a time uniform distributed signal with Exc_in + Inh_in chanels and noSpikes for each chanel

Excinp = sim.Population(3, sim.SpikeSourceArray(spike_times = stimSpikes))

syn = sim.StaticSynapse(weight = 0.05, delay = 0.5)
Ie_A_connections = sim.Projection(Excinp, Pexc, sim.FixedProbabilityConnector(p_connect = 0.5), syn, receptor_type = 'excitatory', label = "excitatory input")

for i in range(ite_no):
	sim.run(100)
	# ==========write the data======================
	sim.reset()
	Ie_A_connections.set(weight = (i + 2) * 0.05)
	print Ie_A_connections.get('weight', format = 'list')

# Ie_A_connections.set(weight = 0.02)

# print Ie_A_connections.get('weight', format = 'list')