示例#1
0
def create_brain():
    """
    Initializes PyNN with the minimal neuronal network
    """

    sim.setup(timestep=0.1,
              min_delay=0.1,
              max_delay=20.0,
              threads=1,
              rng_seeds=[1234])

    # Following parameters were taken from the husky braitenberg brain experiment (braitenberg.py)

    SENSORPARAMS = {
        'cm': 0.025,
        'v_rest': -60.5,
        'tau_m': 10.,
        'e_rev_E': 0.0,
        'e_rev_I': -75.0,
        'v_reset': -60.5,
        'v_thresh': -60.0,
        'tau_refrac': 10.0,
        'tau_syn_E': 2.5,
        'tau_syn_I': 2.5
    }

    SYNAPSE_PARAMS = {
        "weight": 0.5e-4,
        "delay": 20.0,
        'U': 1.0,
        'tau_rec': 1.0,
        'tau_facil': 1.0
    }

    cell_class = sim.IF_cond_alpha(**SENSORPARAMS)

    # Define the network structure: 2 neurons (1 sensor and 1 actors)
    population = sim.Population(size=2, cellclass=cell_class)

    synapse_type = sim.TsodyksMarkramSynapse(**SYNAPSE_PARAMS)
    connector = sim.AllToAllConnector()

    # Connect neurons
    sim.Projection(presynaptic_population=population[0:1],
                   postsynaptic_population=population[1:2],
                   connector=connector,
                   synapse_type=synapse_type,
                   receptor_type='excitatory')

    sim.initialize(population, v=population.get('v_rest'))

    return population
示例#2
0
        weights[i][j] = round(weight_to_spike * \
                    (1 / (sig * np.sqrt(2 * np.pi)) * \
                    (np.exp(-np.power(dist[i][j] - mu, 2.) \
                    / (2 * np.power(sig, 2.))))), 2)
        cann_connector.append((i, j, weights[i][j]))  #, delay_cann2cann))
print("Weight matrix:\n", weights)

spike_time_for_id_1 = [100.]
spike_time_for_id_2 = [500., 505., 510., 515.]
spike_time_for_id_3 = [1200., 1205., 1210., 1215.]
spike_time_for_id_4 = [2000., 2005., 2010., 2015.]
spike_time_for_id_9 = [3000., 3005., 3010., 3015.]
#[3000., 3003., 3005., 3008., 3010., 3013., 3015., 3017., 3020.]

cann_pop = sim.Population(n,
                          sim.IF_cond_alpha(**cell_params),
                          label="cann_pop")

inhib_pop = sim.Population(1,
                           sim.IF_cond_alpha(**cell_params),
                           label="inhib_pop")

spike_source_1 = sim.Population(
    1, sim.SpikeSourceArray(spike_times=spike_time_for_id_1))
spike_source_2 = sim.Population(
    1, sim.SpikeSourceArray(spike_times=spike_time_for_id_2))
spike_source_3 = sim.Population(
    1, sim.SpikeSourceArray(spike_times=spike_time_for_id_3))
spike_source_4 = sim.Population(
    1, sim.SpikeSourceArray(spike_times=spike_time_for_id_4))
spike_source_9 = sim.Population(
示例#3
0
for i in range(n):
    for j in range(n):
        dist[i][j] = abs(i - j)%(n)
        if dist[i][j] > n/2:
            dist[i][j] = n - dist[i][j]
        weights[i][j] = round(weight_to_spike * \
                    (1 / (sig * np.sqrt(2 * np.pi)) * \
                    (np.exp(-np.power(dist[i][j] - mu, 2.) \
                    / (2 * np.power(sig, 2.))))), 2)
        cann_connector.append((i, j, weights[i][j]))#, delay_cann2cann))
print("Weight matrix:\n", weights)                    

spike_times = [1000., 2000.]

cann_pop = sim.Population(n, sim.IF_cond_alpha(**cell_params),
                         label = "cann_pop")

inhib_pop = sim.Population(1, sim.IF_cond_alpha(**cell_params),
                         label = "inhib_pop")

spike_source = sim.Population(1, sim.SpikeSourceArray(
    spike_times = spike_times))

spike_2_conn = sim.Projection(spike_source, cann_pop[spiky:spiky+1], sim.AllToAllConnector(),
                      sim.StaticSynapse(weight = 0.002, delay = 0.1))

cann_2_cann = sim.Projection(cann_pop, cann_pop, sim.FromListConnector(cann_connector, column_names=["weight"]),
                          sim.StaticSynapse(weight = 0.0001, delay = 75))

cann_2_inh = sim.Projection(cann_pop, inhib_pop, sim.AllToAllConnector(),
示例#4
0
import pyNN.nest as sim
import numpy
__population_views = {}


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

source = sim.StepCurrentSource(times=[0.1], amplitudes=[.8])

source.inject_into(pop1)
print "Network loaded"
#pop1.sample(10).record('v')





示例#5
0
spiky = n // 2
cell_params = {
    'tau_m': 20.0,  # (ms)
    'tau_syn_E': 2.0,  # (ms)
    'tau_syn_I': 4.0,  # (ms)
    'e_rev_E': 0.0,  # (mV)
    'e_rev_I': -70.0,  # (mV)
    'tau_refrac': 2.0,  # (ms)
    'v_rest': -60.0,  # (mV)
    'v_reset': -70.0,  # (mV) 
    'v_thresh': -60.0,  # (mV)
    'cm': 0.5
}
sim.setup()

neuron1 = sim.Population(n, sim.IF_cond_alpha(**cell_params), label="neuron1")

neuron2 = sim.Population(n, sim.IF_cond_alpha(**cell_params), label="neuron2")

spike_times = [1000., 2000.]

spike_source = sim.Population(1, sim.SpikeSourceArray(spike_times=spike_times))

conn = sim.Projection(spike_source, neuron1[spiky:spiky + 1],
                      sim.AllToAllConnector(),
                      sim.StaticSynapse(weight=0.002, delay=1.))

n2n_conn = sim.Projection(neuron1, neuron2, sim.OneToOneConnector(),
                          sim.StaticSynapse(weight=0.002, delay=1.))

spike_source.record('spikes')
示例#6
0
spike_time_for_id_4 = [4000., 4005., 4010., 4015.]
spike_time_for_id_9 = [
    7000., 7005., 7010., 7015., 7020., 7025., 7030., 7035., 7040., 7045., 7050.
]  #[3000., 3005., 3010., 3015.]

spikes_50 = [None] * 50
for i, j in zip(range(50), range(4000, 4100, 2)):
    spikes_50[i] = j

pos_spike_times = [2000., 2005., 2010., 2015.]
neg_spike_times = [4000., 4005., 4010., 4015.]

# Populations

hd_cann_pop = sim.Population(n,
                             sim.IF_cond_alpha(**cell_params),
                             label="hd_cann_pop")

inhib_pop = sim.Population(1,
                           sim.IF_cond_alpha(**cell_params),
                           label="inhib_pop")

#pos_rot_conj = sim.Population(n, sim.IF_cond_alpha(**cell_params),
pos_rot_conj = sim.Population(n, sim.IF_cond_alpha(), label="pos_rot_conj")

#neg_rot_conj = sim.Population(n, sim.IF_cond_alpha(**cell_params),
neg_rot_conj = sim.Population(n, sim.IF_cond_alpha(), label="neg_rot_conj")

spike_source_1 = sim.Population(
    1, sim.SpikeSourceArray(spike_times=spike_time_for_id_1))
spike_source_2 = sim.Population(
示例#7
0
def create_brain():
    """
    Initializes PyNN with the neuronal network that has to be simulated
    """
    SENSORPARAMS = {
        'v_rest': -60.5,
        'cm': 0.025,
        'tau_m': 10.,
        'tau_refrac': 10.0,
        'tau_syn_E': 2.5,
        'tau_syn_I': 2.5,
        'e_rev_E': 0.0,
        'e_rev_I': -75.0,
        'v_thresh': -60.0,
        'v_reset': -60.5
    }

    GO_ON_PARAMS = {
        'v_rest': -60.5,
        'cm': 0.025,
        'tau_m': 10.0,
        'e_rev_E': 0.0,
        'e_rev_I': -75.0,
        'v_reset': -61.6,
        'v_thresh': -60.51,
        'tau_refrac': 10.0,
        'tau_syn_E': 2.5,
        'tau_syn_I': 2.5
    }

    # POPULATION_PARAMS = SENSORPARAMS * 5 + GO_ON_PARAMS + SENSORPARAMS * 2

    population = sim.Population(8, sim.IF_cond_alpha())
    population[0:5].set(**SENSORPARAMS)
    population[5:6].set(**GO_ON_PARAMS)
    population[6:8].set(**SENSORPARAMS)

    # Shared Synapse Parameters
    syn_params = {'U': 1.0, 'tau_rec': 1.0, 'tau_facil': 1.0}

    # Synaptic weights
    WEIGHT_RED_TO_ACTOR = 1.5e-4
    WEIGHT_RED_TO_GO_ON = 1.2e-3  # or -1.2e-3?
    WEIGHT_GREEN_BLUE_TO_ACTOR = 1.05e-4
    WEIGHT_GO_ON_TO_RIGHT_ACTOR = 1.4e-4
    DELAY = 0.1

    # Connect neurons
    CIRCUIT = population

    SYN = sim.TsodyksMarkramSynapse(weight=abs(WEIGHT_RED_TO_ACTOR),
                                    delay=DELAY,
                                    **syn_params)
    sim.Projection(presynaptic_population=CIRCUIT[2:3],
                   postsynaptic_population=CIRCUIT[7:8],
                   connector=sim.AllToAllConnector(),
                   synapse_type=SYN,
                   receptor_type='excitatory')
    sim.Projection(presynaptic_population=CIRCUIT[3:4],
                   postsynaptic_population=CIRCUIT[6:7],
                   connector=sim.AllToAllConnector(),
                   synapse_type=SYN,
                   receptor_type='excitatory')

    SYN = sim.TsodyksMarkramSynapse(weight=abs(WEIGHT_RED_TO_GO_ON),
                                    delay=DELAY,
                                    **syn_params)
    sim.Projection(presynaptic_population=CIRCUIT[0:2],
                   postsynaptic_population=CIRCUIT[5:6],
                   connector=sim.AllToAllConnector(),
                   synapse_type=SYN,
                   receptor_type='inhibitory')

    SYN = sim.TsodyksMarkramSynapse(weight=abs(WEIGHT_GREEN_BLUE_TO_ACTOR),
                                    delay=DELAY,
                                    **syn_params)
    sim.Projection(presynaptic_population=CIRCUIT[4:5],
                   postsynaptic_population=CIRCUIT[7:8],
                   connector=sim.AllToAllConnector(),
                   synapse_type=SYN,
                   receptor_type='excitatory')

    SYN = sim.TsodyksMarkramSynapse(weight=abs(WEIGHT_GO_ON_TO_RIGHT_ACTOR),
                                    delay=DELAY,
                                    **syn_params)
    sim.Projection(presynaptic_population=CIRCUIT[5:6],
                   postsynaptic_population=CIRCUIT[7:8],
                   connector=sim.AllToAllConnector(),
                   synapse_type=SYN,
                   receptor_type='excitatory')

    sim.initialize(population, v=population.get('v_rest'))

    logger.debug("Circuit description: " + str(population.describe()))

    return population
示例#8
0
#spike_time_for_id_2 = [1000., 1005., 1010., 1015.]
#spike_time_for_id_3 = [2000., 2005., 2010., 2015.]
spike_times = [2000., 2005., 2010., 2015.]
#spike_time_for_id_9 = [7000., 7005., 7010., 7015., 7020., 7025., 7030., 7035., 7040., 7045., 7050.] #[3000., 3005., 3010., 3015.]

spikes_in = 20 #5 #10 #50
spike_input = [None] * spikes_in
for i,j in zip(range(spikes_in), range(4000, 4100, 2)):
    spike_input[i] = j

pos_spike_times = [2000., 2005., 2010., 2015.]
neg_spike_times = [4000., 4005., 4010., 4015.]

# Populations

hd_cann_pop = sim.Population(n, sim.IF_cond_alpha(**cell_params),
                         label = "hd_cann_pop")

inhib_pop = sim.Population(1, sim.IF_cond_alpha(**cell_params),
                         label = "inhib_pop")

#pos_rot_conj = sim.Population(n, sim.IF_cond_alpha(**cell_params),
pos_rot_conj = sim.Population(n, sim.IF_cond_alpha(),
                          label = "pos_rot_conj")

#neg_rot_conj = sim.Population(n, sim.IF_cond_alpha(**cell_params),
neg_rot_conj = sim.Population(n, sim.IF_cond_alpha(),
                          label = "neg_rot_conj")

hd_spike_src = sim.Population(1, sim.SpikeSourceArray(
    spike_times = spike_times))
def create_brain():
	"""
	Initializes PyNN with the neuronal network that has to be simulated for the experiment
	"""

	GR_PARAMS = {'cm': 0.002,
                 'v_rest': -70.0,
                 'tau_m': 100.0,
                 'e_rev_E': 0.0,
                 'e_rev_I': -75.0,
                 'v_reset': -70.0,
                 'v_thresh': -40.0,
                 'tau_refrac': 1.0,
                 'tau_syn_E': 0.5,
                 'tau_syn_I': 2.0}

	GO_PARAMS = {'cm': 0.002,
                 'v_rest': -70.0,
                 'tau_m': 100.0,
                 'e_rev_E': 0.0,
                 'e_rev_I': -75.0,
                 'v_reset': -70.0,
                 'v_thresh': -40.0,
                 'tau_refrac': 1.0,
                 'tau_syn_E': 0.5,
                 'tau_syn_I': 2.0}

	PC_PARAMS = {'C_m': 0.314,
                 'g_L': 0.012,
                 'E_L': -70.0,
                 'E_ex': 0.0,
                 'E_in': -75.0,
                 'e_cs': 0.0,
                 'V_reset': -70.0,
                 'V_th': -52.0,
                 't_ref': 1.0,
                 'tau_syn_ex': 0.85,
                 'tau_syn_in': 5.45,
                 'tau_syn_cs': 0.85}

	VN_PARAMS = {'C_m': 0.002,
                 'g_L': 0.0002, 
                 'E_L': -70.0,
                 'E_ex': 0.0,
                 'E_in': -80.0,
                 'e_ts': 0.0,
                 'V_reset': -70.5,
                 'V_th': -40.0,
                 't_ref': 1.0,
                 'tau_syn_ex': 0.5,
                 'tau_syn_in': 7.0,
                 'tau_syn_ts': 0.85,
                 'tau_cos': 10.0,
                 'exponent': 2.0}
    
	##THIS MODULE CAN BE DOWNLOADED FROM https://github.com/jgarridoalcazar/SpikingCerebellum/
	#try:
	#	nest.Install('cerebellummodule')
	#except nest.NESTError:
	#	pass 
    
	
	parrot_neuron = sim.native_cell_type('parrot_neuron')
	
	# Create MF population 
	MF_population = sim.Population(num_MF_neurons,parrot_neuron,{},label='MFLayer')

	# Create GOC population    
	GOC_population = sim.Population(num_GOC_neurons,sim.IF_cond_alpha(**GO_PARAMS),label='GOCLayer')
	
	# Create MF-GO connections
	mf_go_connections = sim.Projection(MF_population,
                                           GOC_population,
                                           sim.OneToOneConnector(),
                                           sim.StaticSynapse(delay=1.0, weight=mf_go_weights))



	# Create GrC population
	GC_population = sim.Population(num_GC_neurons,sim.IF_cond_alpha(**GR_PARAMS),label='GCLayer')

	# Random distribution for synapses delays and weights
	delay_distr = RandomDistribution('uniform', (1.0, 10.0), rng=NumpyRNG(seed=85524))
	weight_distr_MF = RandomDistribution('uniform', (mf_gc_weights*0.8, mf_gc_weights*1.2), rng=NumpyRNG(seed=85524))
	weight_distr_GO = RandomDistribution('uniform', (go_gc_weights*0.8, go_gc_weights*1.2), rng=NumpyRNG(seed=24568))


	# Create MF-GC and GO-GC connections
	float_num_MF_neurons = float (num_MF_neurons)
	for i in range (num_MF_neurons):
		GC_medium_index = int(round((i / float_num_MF_neurons) * num_GC_neurons))
		GC_lower_index = GC_medium_index - 40
		GC_upper_index = GC_medium_index + 60
		if(GC_lower_index < 0):
			GC_lower_index = 0

		elif(GC_upper_index > num_GC_neurons):
			GC_upper_index = num_GC_neurons

		if(GC_lower_index < GC_medium_index):
			GO_GC_con1 = sim.Projection(sim.PopulationView(GOC_population, range(i, i+1)),
                                      sim.PopulationView(GC_population, range(GC_lower_index, GC_medium_index)),
                                      sim.AllToAllConnector(),
                                      sim.StaticSynapse(delay=delay_distr, weight=weight_distr_GO))

			MF_GC_con2 = sim.Projection(sim.PopulationView(MF_population, range(i, i+1)),
                                      sim.PopulationView(GC_population, range(GC_medium_index, GC_medium_index + 20)),
                                      sim.AllToAllConnector(),
                                      sim.StaticSynapse(delay=delay_distr, weight=weight_distr_MF))

		if((GC_medium_index + 20) < GC_upper_index):
			GO_GC_con3 = sim.Projection(sim.PopulationView(GOC_population, range(i, i+1)),
                                      sim.PopulationView(GC_population, range(GC_medium_index + 20, GC_upper_index)),
                                      sim.AllToAllConnector(),
                                      sim.StaticSynapse(delay=delay_distr, weight=weight_distr_GO))


	# Create PC population (THIS MODEL HAS BEEN DEFINED IN THE CEREBELLUMMODULE PACKAGE: https://github.com/jgarridoalcazar/SpikingCerebellum/)
	pc_neuron = sim.native_cell_type('iaf_cond_exp_cs')
	PC_population = sim.Population(num_PC_neurons,pc_neuron(**PC_PARAMS),label='PCLayer')

	# Create VN population (THIS MODEL HAS BEEN DEFINED IN THE CEREBELLUMMODULE PACKAGE: https://github.com/jgarridoalcazar/SpikingCerebellum/)
	vn_neuron = sim.native_cell_type('iaf_cond_exp_cos')
	VN_population = sim.Population(num_VN_neurons,vn_neuron(**VN_PARAMS),label='VNLayer')

	# Create IO population
	IO_population = sim.Population(num_IO_neurons,parrot_neuron,{},label='IOLayer')



	# Create MF-VN learning rule (THIS MODEL HAS BEEN DEFINED IN THE CEREBELLUMMODULE PACKAGE: https://github.com/jgarridoalcazar/SpikingCerebellum/)
	stdp_cos = sim.native_synapse_type('stdp_cos_synapse')(**{'weight':mf_vn_weights,
                                                              'delay':1.0,
                                                              'exponent': 2.0,
                                                              'tau_cos': 5.0,
                                                              'A_plus': 0.0000009,
                                                              'A_minus': 0.00001,
                                                              'Wmin': 0.0005,
                                                              'Wmax': 0.007})

    	# Create MF-VN connections
	mf_vn_connections = sim.Projection(MF_population,
					VN_population,
					sim.AllToAllConnector(),
					receptor_type='AMPA',
	#				synapse_type = sim.StaticSynapse(delay=1.0, weight=mf_vn_weights))
					synapse_type = stdp_cos)



	# Create PC-VN connections
	pc_vn_connections = sim.Projection(PC_population,
                                       VN_population,
                                       sim.OneToOneConnector(),
                                       receptor_type='GABA',
                                       synapse_type = sim.StaticSynapse(delay=1.0, weight=pc_vn_weights))

	# This second synapse with "receptor_type=TEACHING_SIGNAL" propagates the learning signals that drive the plasticity mechanisms in MF-VN synapses
	pc_vn_connections = sim.Projection(PC_population,
                                       VN_population,
                                       sim.OneToOneConnector(),
                                       receptor_type='TEACHING_SIGNAL',
                                       synapse_type = sim.StaticSynapse(delay=1.0, weight=0.0))




	
	# Create MF-VN learning rule (THIS MODEL HAS BEEN DEFINED IN THE CEREBELLUMMODULE PACKAGE: https://github.com/jgarridoalcazar/SpikingCerebellum/)
	stdp_syn = sim.native_synapse_type('stdp_sin_synapse')(**{'weight':gc_pc_weights,
                                                              'delay':1.0,
                                                              'exponent': 10,
                                                              'peak': 100.0,
                                                              'A_plus': 0.000014,
                                                              'A_minus': 0.00008,
                                                              'Wmin': 0.000,
                                                              'Wmax': 0.010})
      
	# Create GC-PC connections
	gc_pc_connections = sim.Projection(GC_population,
					PC_population,
					sim.AllToAllConnector(),
					receptor_type='AMPA',
	#				synapse_type = sim.StaticSynapse(delay=1.0, weight=gc_pc_weights))
					synapse_type = stdp_syn)


	# Create IO-PC connections. This synapse with "receptor_type=COMPLEX_SPIKE" propagates the learning signals that drive the plasticity mechanisms in GC-PC synapses
	io_pc_connections = sim.Projection(IO_population,
                                       PC_population,
                                       sim.OneToOneConnector(),
                                       receptor_type='COMPLEX_SPIKE',
                                       synapse_type = sim.StaticSynapse(delay=1.0, weight=io_pc_weights)) 




	# Group all neural layers
	population = MF_population + GOC_population + GC_population + PC_population + VN_population + IO_population 

	# Set Vm to resting potential
	# sim.initialize(PC_population, V_m=PC_population.get('E_L'))
	# sim.initialize(VN_population, V_m=VN_population.get('E_L'))
	
	return population
示例#10
0
ramps = []
for incr in increments:
    val = -0.5
    amplitudes = []
    for t in range(int(duration / dt)):
        amplitudes.append(val)
        val += incr
    ramps.append(amplitudes)

ramp_inputs = [
    sim.StepCurrentSource(times=np.arange(0, int(duration / dt)),
                          amplitudes=ramp) for ramp in ramps
]

neurons = sim.Population(
    n, sim.IF_cond_alpha(tau_m=1))  # sim.Izhikevich(**params))
for i, ramp_input in enumerate(ramp_inputs):
    ramp_input.inject_into(neurons[i:i + 1])

neurons.record(['v', 'spikes'])
neurons.initialize(v=v_init, u=-params['b'] * v_init)

# === Run the simulation =====================================================

sim.run(duration)

# === Save the results, optionally plot a figure =============================

data = neurons.get_data().segments[0]

first_spiketimes = []