def make_synth(N, pconnect, pfire, delay): pg = ngpu.Create("poisson_generator") ngpu.SetStatus(pg, "rate", 10000 * pfire) neuron = ngpu.Create("iaf_psc_exp", N, 2) ngpu.SetStatus(neuron, {"V_m_rel": 0, "V_reset_rel": 0, "Theta_rel": 20, "t_ref": 0}) ngpu.Connect(pg, neuron, {"rule": "all_to_all"}, {"weight": 20, "delay": 0.1, "receptor":0}) ngpu.Connect(neuron, neuron, {"rule": "fixed_total_number", "total_num": int(N * N * pconnect)}, {"weight": 0, "delay": 0.1 * delay, "receptor":0})
def make_vogels(N): NE = N // 5 * 4 NI = N // 5 * 1 N = NE + NI Wex = 0.4 * 16000000 / N / N Win = 5.1 * 16000000 / N / N neuron = ngpu.Create("iaf_psc_exp_g", N, 2) E = neuron[0:NE] # inhibitory neurons I = neuron[NE:N] ngpu.SetStatus(neuron, {"V_m_rel": -60, "V_reset_rel": -60, "Theta_rel": -50, "t_ref": 5, "G_ex": 0, "G_in": 0}) ngpu.Connect(E, E, {"rule": "fixed_total_number", "total_num": NE * NE // 50}, {"weight": Wex, "delay": 0.8, "receptor":0}) ngpu.Connect(E, I, {"rule": "fixed_total_number", "total_num": NE * NI // 50}, {"weight": Wex, "delay": 0.8, "receptor":0}) ngpu.Connect(I, E, {"rule": "fixed_total_number", "total_num": NI * NE // 50}, {"weight": Win, "delay": 0.8, "receptor":1}) ngpu.Connect(I, I, {"rule": "fixed_total_number", "total_num": NI * NI // 50}, {"weight": Win, "delay": 0.8, "receptor":1})
def make_brunel(N): NP = N // 10 * 5 NE = N // 10 * 4 NI = N // 10 * 1 N = NP + NE + NI Wex = 0.1 * 20000 / N Win = -0.5 * 20000 / N pg = ngpu.Create("poisson_generator") ngpu.SetStatus(pg, "rate", 20) neuron = ngpu.Create("iaf_psc_exp", N, 2) P = neuron[0:NP] # excitatory neurons E = neuron[NP:NP+NE] # inhibitory neurons I = neuron[NP+NE:N] ngpu.SetStatus(P, {"V_m_rel": 0, "V_reset_rel": 0, "Theta_rel": 20, "t_ref": 0}) ngpu.SetStatus(E, {"V_m_rel": 0, "V_reset_rel": 0, "Theta_rel": 20, "t_ref": 2}) ngpu.SetStatus(I, {"V_m_rel": 0, "V_reset_rel": 0, "Theta_rel": 20, "t_ref": 2}) ngpu.Connect(pg, P, {"rule": "all_to_all"}, {"weight": 20, "delay": 0.1, "receptor":0}) ngpu.Connect(P, E, {"rule": "fixed_total_number", "total_num": NP * NE // 10}, {"weight": Wex, "delay": 1.5, "receptor":0}) ngpu.Connect(P, I, {"rule": "fixed_total_number", "total_num": NP * NI // 10}, {"weight": Wex, "delay": 1.5, "receptor":0}) ngpu.Connect(E, E, {"rule": "fixed_total_number", "total_num": NE * NE // 10}, {"weight": Wex, "delay": 1.5, "receptor":0}) ngpu.Connect(E, I, {"rule": "fixed_total_number", "total_num": NE * NI // 10}, {"weight": Wex, "delay": 1.5, "receptor":0}) ngpu.Connect(I, E, {"rule": "fixed_total_number", "total_num": NI * NE // 10}, {"weight": Win, "delay": 1.5, "receptor":1}) ngpu.Connect(I, I, {"rule": "fixed_total_number", "total_num": NI * NI // 10}, {"weight": Win, "delay": 1.5, "receptor":1})
def CreateNeuronImage(nodes, n_port): dt = nest.GetKernelStatus("resolution") n_nodes = len(nodes) node_image = neurongpu.Create("ext_neuron", n_nodes, n_port) for i in range(n_nodes): nest_node_id = nodes[i].global_id i_port = AddNode(nest_node_id, node_image[i]) syn_dict = {"weight": 1.0, "delay": dt, "receptor_type": i_port} nest.Connect(nodes[i], ngpu_nest_interface, "one_to_one", syn_dict) return node_image
def __create_thalamic_stim_input(self): """ Creates the thalamic neuronal population if specified in ``stim_dict``. Thalamic neurons are of type ``parrot_neuron`` and receive input from a Poisson generator. Note that the number of thalamic neurons is not scaled with ``N_scaling``. """ if self.Rank == 0: print('Creating thalamic input for external stimulation.') self.thalamic_population = ngpu.Create( 'parrot_neuron', n=self.stim_dict['num_th_neurons']) self.poisson_th = ngpu.Create('poisson_generator') self.poisson_th.set(rate=self.stim_dict['th_rate'], start=self.stim_dict['th_start'], stop=(self.stim_dict['th_start'] + self.stim_dict['th_duration']))
def __create_poisson_bg_input(self): """ Creates the Poisson generators for ongoing background input if specified in ``network_params.py``. If ``poisson_input`` is ``False``, DC input is applied for compensation in ``create_neuronal_populations()``. """ if self.Rank == 0: print('Creating Poisson generators for background input.') self.poisson_bg_input = ngpu.Create('poisson_generator', self.num_pops) rate_list = self.net_dict['bg_rate'] * self.ext_indegrees for i_pop in range(self.num_pops): ngpu.SetStatus([self.poisson_bg_input[i_pop]], "rate", rate_list[i_pop])
syn_group_ex = ngpu.CreateSynGroup \ ("stdp", {"tau_plus":tau_plus, "tau_minus":tau_minus, \ "lambda":lambd_ex, "alpha":alpha, "mu_plus":mu_plus, \ "mu_minus":mu_minus, "Wmax":Wmax}) syn_group_in = ngpu.CreateSynGroup \ ("stdp", {"tau_plus":tau_plus, "tau_minus":tau_minus, \ "lambda":lambd_in, "alpha":alpha, "mu_plus":mu_plus, \ "mu_minus":mu_minus, "Wmax":Wmax}) # poisson generator parameters poiss_rate = 20000.0 # poisson signal rate in Hz poiss_weight = 0.37 * fact poiss_delay = 1.0 # poisson signal delay in ms # create poisson generator pg = ngpu.Create("poisson_generator") ngpu.SetStatus(pg, "rate", poiss_rate) # Create n_neurons neurons with n_receptor receptor ports neuron = ngpu.Create("izhikevich_psc_exp_5s", n_neurons, n_receptors) exc_neuron = neuron[0:NE] # excitatory neurons inh_neuron = neuron[NE:n_neurons] # inhibitory neurons # receptor parameters delay = 2.0 # Excitatory connections # connect excitatory neurons to port 0 of all neurons # normally distributed delays, weight Wex and CE connections per neuron exc_conn_dict = {"rule": "fixed_indegree", "indegree": CE}
import sys import neurongpu as ngpu import numpy as np tolerance = 0.0005 neuron = ngpu.Create('aeif_psc_alpha', 1, 2) ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6, \ "g_L":300.0, "tau_syn":[40.0, 20.0]}) spike = ngpu.Create("spike_generator") spike_times = [10.0, 400.0] n_spikes = 2 # set spike times and height ngpu.SetStatus(spike, {"spike_times": spike_times}) delay = [1.0, 100.0] weight = [1.0, -2.0] conn_spec = {"rule": "all_to_all"} syn_spec_ex = {'receptor': 0, 'weight': weight[0], 'delay': delay[0]} syn_spec_in = {'receptor': 1, 'weight': weight[1], 'delay': delay[1]} ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex) ngpu.Connect(spike, neuron, conn_spec, syn_spec_in) record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0]) #voltmeter = nest.Create('voltmeter') #nest.Connect(voltmeter, neuron) ngpu.Simulate(800.0) data_list = ngpu.GetRecordData(record)
import neurongpu as ngpu import numpy as np neuron = ngpu.Create("aeif_cond_beta", 100000) ngpu.SetStatus( neuron, { "V_m": { "distribution": "normal_clipped", "mu": -70.0, "low": -90.0, "high": -50.0, "sigma": 5.0 } }) l = ngpu.GetStatus(neuron, "V_m") d = [] for elem in l: d.append(elem[0]) print(len(d)) import matplotlib.pyplot as plt # An "interface" to matplotlib.axes.Axes.hist() method n, bins, patches = plt.hist(d, bins='auto', color='#0504aa', alpha=0.7, rwidth=0.85) plt.grid(axis='y', alpha=0.75) plt.xlabel('Value')
NI = 1 * order # number of inhibitory neurons n_neurons = NE + NI # number of neurons in total CE = 800 # number of excitatory synapses per neuron CI = CE//4 # number of inhibitory synapses per neuron Wex = 0.05 Win = 0.35 # poisson generator parameters poiss_rate = 20000.0 # poisson signal rate in Hz poiss_weight = 0.37 poiss_delay = 0.2 # poisson signal delay in ms # create poisson generator pg = ngpu.Create("poisson_generator") ngpu.SetStatus(pg, "rate", poiss_rate) pg_list = pg.ToList() # Create n_neurons neurons with n_receptor receptor ports neuron = ngpu.Create("user_m1", n_neurons, n_receptors) exc_neuron = neuron[0:NE] # excitatory neurons inh_neuron = neuron[NE:n_neurons] # inhibitory neurons neuron_list = neuron.ToList() exc_neuron_list = exc_neuron.ToList() inh_neuron_list = inh_neuron.ToList() # receptor parameters E_rev = [0.0, -85.0] tau_decay = [1.0, 1.0] tau_rise = [1.0, 1.0]
import sys import neurongpu as ngpu import numpy as np tolerance = 0.0005 neuron = ngpu.Create('izhikevich', 1) #ngpu.SetStatus(neuron, {"tau_syn": 1.0e-6}) spike = ngpu.Create("spike_generator") spike_times = [10.0, 40.0] n_spikes = 2 # set spike times and height ngpu.SetStatus(spike, {"spike_times": spike_times}) delay = [1.0, 10.0] weight = [1.0, -2.0] conn_spec = {"rule": "all_to_all"} syn_spec_ex = {'weight': weight[0], 'delay': delay[0]} syn_spec_in = {'weight': weight[1], 'delay': delay[1]} ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex) ngpu.Connect(spike, neuron, conn_spec, syn_spec_in) record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0]) #voltmeter = nest.Create('voltmeter') #nest.Connect(voltmeter, neuron) ngpu.Simulate(80.0) data_list = ngpu.GetRecordData(record) t = [row[0] for row in data_list] V_m = [row[1] for row in data_list]
import sys import neurongpu as ngpu import numpy as np tolerance = 0.0005 neuron = ngpu.Create('aeif_cond_alpha', 1, 3) ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6, "g_L":300.0, 'E_rev':[20.0, 0.0, -85.0], \ 'tau_syn':[40.0, 20.0, 30.0]}) spike = ngpu.Create("spike_generator") spike_times = [10.0, 400.0] n_spikes = 2 # set spike times and heights ngpu.SetStatus(spike, {"spike_times": spike_times}) delay = [1.0, 100.0, 130.0] weight = [0.1, 0.2, 0.5] conn_spec={"rule": "all_to_all"} for syn in range(3): syn_spec={'receptor': syn, 'weight': weight[syn], 'delay': delay[syn]} ngpu.Connect(spike, neuron, conn_spec, syn_spec) record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0]) #voltmeter = nest.Create('voltmeter') #nest.Connect(voltmeter, neuron) ngpu.Simulate(800.0) data_list = ngpu.GetRecordData(record) t=[row[0] for row in data_list] V_m=[row[1] for row in data_list]
import sys import neurongpu as ngpu import numpy as np tolerance = 0.0005 neuron = ngpu.Create('izhikevich_cond_beta', 1, 3) #ngpu.SetStatus(neuron, {'u':-0.2*70.0, 'V_m':-70.0}) ngpu.SetStatus(neuron, {'E_rev':[20.0, 0.0, -85.0], \ 'tau_decay':[40.0, 20.0, 30.0], \ 'tau_rise':[20.0, 10.0, 5.0]}) spike = ngpu.Create("spike_generator") spike_times = [10.0, 400.0] n_spikes = 2 # set spike times and heights ngpu.SetStatus(spike, {"spike_times": spike_times}) delay = [1.0, 100.0, 130.0] fact = 0.00225 weight = [0.1 * fact, 0.2 * fact, 0.5 * fact] conn_spec = {"rule": "all_to_all"} for syn in range(3): syn_spec = {'receptor': syn, 'weight': weight[syn], 'delay': delay[syn]} ngpu.Connect(spike, neuron, conn_spec, syn_spec) record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0]) #voltmeter = nest.Create('voltmeter') #nest.Connect(voltmeter, neuron) ngpu.Simulate(800.0) data_list = ngpu.GetRecordData(record)
if (Dt >= 0): fact = Wplus * math.exp(-Dt / tau_plus) w1 = w + fact * math.pow(1.0 - w / Wmax, mu_plus) if w1 > Wmax: w1 = Wmax else: fact = -alpha * Wplus * math.exp(Dt / tau_minus) w1 = w + fact * math.pow(w / Wmax, mu_minus) if w1 < 0.0: w1 = 0.0 return w1 # postsynaptic and presynaptic neurons neuron_post = ngpu.Create("parrot_neuron") ngpu.ActivateRecSpikeTimes(neuron_post, 20) neuron_pre = ngpu.Create("parrot_neuron") ngpu.ActivateRecSpikeTimes(neuron_pre, 20) #spike generators sg_post = ngpu.Create("spike_generator") sg_pre = ngpu.Create("spike_generator") # spike times spike_times_post = [1.0] spike_times_pre = [1.0] ngpu.SetStatus(sg_post, {"spike_times": spike_times_post}) ngpu.SetStatus(sg_pre, {"spike_times": spike_times_pre}) # connect spike generators to neurons
syn_group_ex = ngpu.CreateSynGroup \ ("stdp", {"tau_plus":tau_plus, "tau_minus":tau_minus, \ "lambda":lambd_ex, "alpha":alpha, "mu_plus":mu_plus, \ "mu_minus":mu_minus, "Wmax":Wmax}) syn_group_in = ngpu.CreateSynGroup \ ("stdp", {"tau_plus":tau_plus, "tau_minus":tau_minus, \ "lambda":lambd_in, "alpha":alpha, "mu_plus":mu_plus, \ "mu_minus":mu_minus, "Wmax":Wmax}) # poisson generator parameters poiss_rate = 20000.0 # poisson signal rate in Hz poiss_weight = 0.37 * fact poiss_delay = 1.0 # poisson signal delay in ms # create poisson generator pg = ngpu.Create("poisson_generator") ngpu.SetStatus(pg, "rate", poiss_rate) # Create n_neurons neurons with n_receptor receptor ports neuron = ngpu.Create("izhikevich_cond_beta", n_neurons, n_receptors) exc_neuron = neuron[0:NE] # excitatory neurons inh_neuron = neuron[NE:n_neurons] # inhibitory neurons # receptor parameters E_rev = [0.0, -85.0] tau_decay = [1.0, 1.0] tau_rise = [1.0, 1.0] ngpu.SetStatus(neuron, { "E_rev": E_rev, "tau_decay": tau_decay,
import sys import neurongpu as ngpu tolerance = 1.0e-6 neuron = ngpu.Create("aeif_cond_beta", 3) ngpu.SetStatus(neuron, {"I_e": 1000.0}) spike_det = ngpu.Create("spike_detector") conn_dict = {"rule": "one_to_one"} syn_dict1 = {"weight": 1.0, "delay": 10.0, "receptor": 0} syn_dict2 = {"weight": 2.0, "delay": 20.0, "receptor": 0} syn_dict3 = {"weight": 3.0, "delay": 30.0, "receptor": 0} ngpu.Connect(neuron[0:0], spike_det, conn_dict, syn_dict1) ngpu.Connect(neuron[1:1], spike_det, conn_dict, syn_dict2) ngpu.Connect(neuron[2:2], spike_det, conn_dict, syn_dict3) record_n = ngpu.CreateRecord("", ["spike"], [neuron[0]], [0]) record_sd = ngpu.CreateRecord("", ["spike_height"], [spike_det[0]], [0]) ngpu.Simulate() data_n = ngpu.GetRecordData(record_n) t_n = [row[0] for row in data_n] spike_n = [row[1] for row in data_n]
def __create_neuronal_populations(self): """ Creates the neuronal populations. The neuronal populations are created and the parameters are assigned to them. The initial membrane potential of the neurons is drawn from normal distributions dependent on the parameter ``V0_type``. The first and last neuron id of each population is written to file. """ if self.Rank == 0: print('Creating neuronal populations.') self.n_tot_neurons = 0 for i in np.arange(self.num_pops): self.n_tot_neurons = self.n_tot_neurons + self.num_neurons[i] self.neurons = ngpu.Create(self.net_dict['neuron_model'], self.n_tot_neurons) tau_syn = self.net_dict['neuron_params']['tau_syn'] E_L = self.net_dict['neuron_params']['E_L'] V_th = self.net_dict['neuron_params']['V_th'] V_reset = self.net_dict['neuron_params']['V_reset'] t_ref = self.net_dict['neuron_params']['t_ref'] ngpu.SetStatus( self.neurons, { "tau_syn": tau_syn, "E_L": E_L, "Theta_rel": V_th - E_L, "V_reset_rel": V_reset - E_L, "t_ref": t_ref }) self.pops = [] for i in np.arange(self.num_pops): if i == 0: i_node_0 = 0 i_node_1 = i_node_0 + self.num_neurons[i] #print("i_node_1 ", i_node_1) population = self.neurons[i_node_0:i_node_1] i_node_0 = i_node_1 I_e = self.DC_amp[i] ngpu.SetStatus(population, {"I_e": I_e}) #print(population.i0) #print(population.n) if self.net_dict['V0_type'] == 'optimized': V_rel_mean = self.net_dict['neuron_params']['V0_mean'] \ ['optimized'][i] - E_L V_std = self.net_dict['neuron_params']['V0_std'] \ ['optimized'][i] elif self.net_dict['V0_type'] == 'original': V_rel_mean = self.net_dict['neuron_params']['V0_mean'] \ ['original'] - E_L, V_std = self.net_dict['neuron_params']['V0_std']['original'] else: raise Exception( 'V0_type incorrect. ' + 'Valid options are "optimized" and "original".') #print("V_rel_mean", V_rel_mean) #print("V_std", V_std) #print("pop size: ", len(population)) ngpu.SetStatus( population, { "V_m_rel": { "distribution": "normal", "mu": V_rel_mean, "sigma": V_std } }) self.pops.append(population) # write node ids to file if self.Rank == 0: fn = os.path.join(self.data_path, 'population_nodeids.dat') with open(fn, 'w+') as f: for pop in self.pops: f.write('{} {}\n'.format(pop[0], pop[len(pop) - 1]))
import ctypes import neurongpu as ngpu N = 5 neuron = ngpu.Create("aeif_cond_beta", 2 * N) neuron_even = [] neuron_odd = [] for i in range(N): neuron_even.append(neuron[2 * i]) neuron_odd.append(neuron[2 * i + 1]) even_to_odd_delay = [] even_to_odd_weight = [] odd_to_even_delay = [] odd_to_even_weight = [] for itgt in range(N): ite = 2 * itgt ito = 2 * itgt + 1 for isrc in range(N): ise = 2 * isrc iso = 2 * isrc + 1 even_to_odd_delay.append(2.0 * N * ise + ito) even_to_odd_weight.append(100.0 * (2.0 * N * ise + ito)) odd_to_even_delay.append(2.0 * N * iso + ite) odd_to_even_weight.append(100.0 * (2.0 * N * iso + ite)) conn_dict = {"rule": "all_to_all"} even_to_odd_syn_dict = { "weight_array": even_to_odd_weight, "delay_array": even_to_odd_delay
import sys import neurongpu as ngpu import numpy as np tolerance = 0.0005 neuron = ngpu.Create('ext_neuron', 1, 3) spike = ngpu.Create("spike_generator") spike_times = [50.0, 100.0, 400.0, 600.0] n_spikes = 4 # set spike times and heights ngpu.SetStatus(spike, {"spike_times": spike_times}) delay = [1.0, 50.0, 100.0] weight = [0.1, 0.2, 0.5] conn_spec = {"rule": "all_to_all"} for syn in range(3): syn_spec = {'receptor': syn, 'weight': weight[syn], 'delay': delay[syn]} ngpu.Connect(spike, neuron, conn_spec, syn_spec) i_neuron_arr = [neuron[0], neuron[0], neuron[0]] i_receptor_arr = [0, 1, 2] var_name_arr = ["port_value", "port_value", "port_value"] record = ngpu.CreateRecord("", var_name_arr, i_neuron_arr, i_receptor_arr) ngpu.Simulate(800.0) data_list = ngpu.GetRecordData(record) t = [row[0] for row in data_list] val1 = [row[1] for row in data_list] val2 = [row[2] for row in data_list] val3 = [row[3] for row in data_list]
NI = 1 * order # number of inhibitory neurons n_neurons = NE + NI # number of neurons in total CE = 800 # number of excitatory synapses per neuron CI = CE // 4 # number of inhibitory synapses per neuron Wex = 0.05 Win = 0.35 # poisson generator parameters poiss_rate = 20000.0 # poisson signal rate in Hz poiss_weight = 0.37 poiss_delay = 0.2 # poisson signal delay in ms # create poisson generator pg = ngpu.Create("poisson_generator") ngpu.SetStatus(pg, "rate", poiss_rate) # Create n_neurons neurons with n_receptor receptor ports neuron = ngpu.Create("aeif_cond_beta", n_neurons, n_receptors) exc_neuron = neuron[0:NE] # excitatory neurons inh_neuron = neuron[NE:n_neurons] # inhibitory neurons # receptor parameters E_rev = [0.0, -85.0] tau_decay = [1.0, 1.0] tau_rise = [1.0, 1.0] ngpu.SetStatus(neuron, { "E_rev": E_rev, "tau_decay": tau_decay,
import sys import neurongpu as ngpu n_neurons = 6 # create n_neurons neurons with 2 receptor ports neuron = ngpu.Create('aeif_cond_beta', n_neurons, 2) neuron_even = [neuron[0], neuron[2], neuron[4]] neuron_odd = [neuron[3], neuron[5], neuron[1]] ngpu.SetStatus(neuron_even, { 'tau_decay': [80.0, 40.0], 'tau_rise': [60.0, 20.0] }) ngpu.SetStatus(neuron_odd, { 'tau_decay': [70.0, 30.0], 'tau_rise': [50.0, 10.0] }) ngpu.SetStatus(neuron_even, {'V_m': -80.0}) ngpu.SetStatus(neuron_odd, {'V_m': -90.0}) ngpu.SetStatus(neuron_even, {'g1': [0.4, 0.2]}) ngpu.SetStatus(neuron_odd, {'g1': [0.3, 0.1]}) ngpu.SetStatus(neuron_even, {'V_th': -40.0}) ngpu.SetStatus(neuron_odd, {'V_th': -30.0}) # reading parameters and variables test read_td = ngpu.GetNeuronStatus(neuron, "tau_decay") read_tr = ngpu.GetNeuronStatus(neuron, "tau_rise") read_Vm = ngpu.GetNeuronStatus(neuron, "V_m")
tau_plus = 20.0 tau_minus = 20.0 lambd = 1.0 alpha = 1.0 mu_plus = 1.0 mu_minus = 1.0 Wmax = 0.001 den_delay = 0.0 syn_group = ngpu.CreateSynGroup \ ("stdp", {"tau_plus":tau_plus, "tau_minus":tau_minus, \ "lambda":lambd, "alpha":alpha, "mu_plus":mu_plus, \ "mu_minus":mu_minus, "Wmax":Wmax}) sg = ngpu.Create("spike_generator") neuron0 = ngpu.Create("aeif_cond_beta") neuron1 = ngpu.Create("aeif_cond_beta", N) ngpu.SetStatus(neuron1, {"t_ref": 1000.0, "den_delay": den_delay}) time_diff = 400.0 dt_list = [] delay_stdp_list = [] for i in range(N): dt_list.append(dt_step * (-0.5 * (N - 1) + i)) delay_stdp_list.append(time_diff - dt_list[i]) spike_times = [50.0] n_spikes = 1 # set spike times and height
import sys import neurongpu as ngpu spike = ngpu.Create("spike_generator", 4) spike0 = spike[0:2] spike1 = spike[2:3] spike2 = spike[3:4] spike_time0 = [10.0, 400.0] spike_height0 = [1.0, 0.5] spike_time1 = [4.0] spike_height1 = [2.0] spike_time2 = [50.0, 20.0, 80.0] spike_height2 = [0.1, 0.3, 0.2] # set spike times and heights ngpu.SetStatus(spike0, { "spike_times": spike_time0, "spike_heights": spike_height0 }) ngpu.SetStatus(spike1, { "spike_times": spike_time1, "spike_heights": spike_height1 }) ngpu.SetStatus(spike2, { "spike_times": spike_time2, "spike_heights": spike_height2 })
import neurongpu as ngpu import nest import ngpu_nest import numpy as np ngpu_neuron = ngpu.Create("aeif_cond_beta") # receptor parameters E_rev = [0.0] tau_rise = [2.0] tau_decay = [20.0] ngpu.SetStatus(ngpu_neuron, { "E_rev": E_rev, "tau_decay": tau_decay, "tau_rise": tau_rise }) nest_neuron = nest.Create("aeif_cond_beta_multisynapse") nest.SetStatus(nest_neuron, { "E_rev": E_rev, "tau_decay": tau_decay, "tau_rise": tau_rise }) neuron_image = ngpu_nest.CreateNeuronImage(nest_neuron, 2) poiss_gen = ngpu.Create("poisson_generator") ngpu.SetStatus(poiss_gen, "rate", 12000.0) parrot = ngpu.Create("parrot_neuron") ngpu.SetStatus(parrot, {'hold_spike_height': 1})
NI = 1 * order # number of inhibitory neurons n_neurons = NE + NI # number of neurons in total CE = 800 # number of excitatory synapses per neuron CI = CE // 4 # number of inhibitory synapses per neuron Wex = 0.05 Win = 0.35 # poisson generator parameters poiss_rate = 20000.0 # poisson signal rate in Hz poiss_weight = 0.37 poiss_delay = 0.2 # poisson signal delay in ms # create poisson generator pg = ngpu.Create("poisson_generator") ngpu.SetStatus(pg, "rate", poiss_rate) pg_list = pg.ToList() # Create n_neurons neurons with n_receptor receptor ports neuron = ngpu.Create("aeif_cond_beta", n_neurons, n_receptors) exc_neuron = neuron[0:NE] # excitatory neurons inh_neuron = neuron[NE:n_neurons] # inhibitory neurons neuron_list = neuron.ToList() exc_neuron_list = exc_neuron.ToList() inh_neuron_list = exc_neuron.ToList() # receptor parameters E_rev = [0.0, -85.0] tau_decay = [1.0, 1.0] tau_rise = [1.0, 1.0]
import sys import neurongpu as ngpu neuron = ngpu.Create('aeif_psc_delta') ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6, \ "g_L":300.0, "C_m":20000.0}) spike = ngpu.Create("spike_generator") spike_times = [10.0, 400.0] n_spikes = 2 # set spike times and height ngpu.SetStatus(spike, {"spike_times": spike_times}) delay = [1.0, 100.0] weight = [1.0, -2.0] conn_spec={"rule": "all_to_all"} syn_spec_ex={'weight': weight[0], 'delay': delay[0]} syn_spec_in={'weight': weight[1], 'delay': delay[1]} ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex) ngpu.Connect(spike, neuron, conn_spec, syn_spec_in) record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0]) #voltmeter = nest.Create('voltmeter') #nest.Connect(voltmeter, neuron) ngpu.Simulate(800.0) data_list = ngpu.GetRecordData(record) t=[row[0] for row in data_list]
import sys import neurongpu as ngpu import numpy as np tolerance = 0.0005 E_L = -65.0 ngpu.SetVerbosityLevel(0) neuron = ngpu.Create('iaf_psc_exp_hc', 1) spike = ngpu.Create("spike_generator") spike_times = [10.0, 400.0] n_spikes = 2 # set spike times and height ngpu.SetStatus(spike, {"spike_times": spike_times}) delay = [1.0, 100.0] weight = [1.0, -2.0] conn_spec = {"rule": "all_to_all"} syn_spec_ex = {'weight': weight[0], 'delay': delay[0]} syn_spec_in = {'weight': weight[1], 'delay': delay[1]} ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex) ngpu.Connect(spike, neuron, conn_spec, syn_spec_in) record = ngpu.CreateRecord("", ["V_m_rel"], [neuron[0]], [0]) #voltmeter = nest.Create('voltmeter') #nest.Connect(voltmeter, neuron) ngpu.Simulate(800.0)
import sys import neurongpu as ngpu import numpy as np tolerance = 0.0005 E_L = -65.0 ngpu.SetVerbosityLevel(0) neuron = ngpu.Create('fast_iaf_psc_exp', 1) spike = ngpu.Create("spike_generator") spike_times = [10.0, 400.0] n_spikes = 2 # set spike times and height ngpu.SetStatus(spike, {"spike_times": spike_times}) delay = [1.0, 100.0] weight = [1.0, -2.0] conn_spec = {"rule": "all_to_all"} syn_spec_ex = {'weight': weight[0], 'delay': delay[0]} syn_spec_in = {'weight': weight[1], 'delay': delay[1]} ngpu.Connect(spike, neuron, conn_spec, syn_spec_ex) ngpu.Connect(spike, neuron, conn_spec, syn_spec_in) record = ngpu.CreateRecord("", ["V_m_rel"], [neuron[0]], [0]) #voltmeter = nest.Create('voltmeter') #nest.Connect(voltmeter, neuron) ngpu.Simulate(800.0)
import neurongpu as ngpu import nest import ngpu_nest import numpy as np neuron = ngpu.Create('aeif_cond_beta', 1, 4) ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b": 80.5}) ngpu.SetStatus( neuron, { 'E_rev': [0.0, 0.0, 0.0, -85.0], 'tau_decay': [50.0, 20.0, 20.0, 20.0], 'tau_rise': [10.0, 10.0, 1.0, 1.0] }) spike = nest.Create('spike_generator', params={'spike_times': np.array([10.0])}) spike_image = ngpu_nest.CreateNeuronImage(spike, 1) delay = [1.0, 300.0, 500.0, 700.0] w = [1.0, 1.0, 1.0, 1.0] conn_spec = {"rule": "all_to_all"} for syn in range(4): syn_spec = {'receptor': syn, 'weight': w[syn], 'delay': delay[syn]} ngpu.Connect(spike_image, neuron, conn_spec, syn_spec) record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0]) nest.Simulate(1000.0) data_list = ngpu.GetRecordData(record)
import sys import neurongpu as ngpu import nest import ngpu_nest import numpy as np if len(sys.argv) != 2: print("Usage: python %s n_neurons" % sys.argv[0]) quit() n_ngpu = int(sys.argv[1]) n_nest = 1000 indegree = 1000 ngpu_neuron = ngpu.Create("aeif_cond_beta", n_ngpu) # receptor parameters E_rev = [0.0] tau_rise = [2.0] tau_decay = [20.0] ngpu.SetStatus(ngpu_neuron, { "E_rev": E_rev, "tau_decay": tau_decay, "tau_rise": tau_rise }) nest_neuron = nest.Create("aeif_cond_beta_multisynapse", n_nest) nest.SetStatus(nest_neuron, { "E_rev": E_rev, "tau_decay": tau_decay, "tau_rise": tau_rise