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 __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])
import sys import neurongpu as ngpu syn_group = ngpu.CreateSynGroup("test_syn_model", {"fact": 1.0, "offset": 2.0}) print(ngpu.GetStatus(syn_group)) ngpu.SetStatus(syn_group, "fact", 3.0) ngpu.SetStatus(syn_group, "offset", 4.0) print(ngpu.GetStatus(syn_group)) ngpu.SetStatus(syn_group, {"fact": 5.0, "offset": 6.0}) print(ngpu.GetStatus(syn_group)) fact = ngpu.GetSynGroupParam(syn_group, "fact") print("fact: ", fact) offset = ngpu.GetSynGroupParam(syn_group, "offset") print("offset: ", offset) print(ngpu.GetStatus(syn_group, "fact")) print(ngpu.GetStatus(syn_group, "offset")) print(ngpu.GetStatus(syn_group, ["fact", "offset"])) print(ngpu.GetStatus(syn_group, ["offset", "fact"]))
("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, "tau_rise": tau_rise
# 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_dict = {"weight": 1.0, "delay": 1.0} conn_dict = {"rule": "one_to_one"} ngpu.Connect(sg_post, neuron_post, conn_dict, syn_dict) ngpu.Connect(sg_pre, neuron_pre, conn_dict, syn_dict) # STDP connection parameters tau_plus = 20.0 tau_minus = 20.0 lambd = 0.01 alpha = 1.0 mu_plus = 1.0 mu_minus = 1.0
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')
Wmax = 10.0 weight_stdp = 1.0 # create presynaptic and postsynaptic parrot neurons neuron_pre = ngpu.Create("parrot_neuron", N) neuron_post = ngpu.Create("parrot_neuron", N) #spike generator sg = ngpu.Create("spike_generator") # spike generator produces n_spikes spikes with time interval Dt_spike spike_times = [] for i in range(n_spikes): spike_times.append(Dt_spike * (i + 1)) ngpu.SetStatus(sg, {"spike_times": spike_times}) #connect spike generator to parrot neurons sg_conn_dict = {"rule": "all_to_all"} syn_dict_sg_pre = {"weight": 1.0, "delay": sg_delay_m - Dt_offset / 2.0} ngpu.Connect(sg, neuron_pre, sg_conn_dict, syn_dict_sg_pre) syn_dict_sg_post = {"weight": 1.0, "delay": sg_delay_m + Dt_offset / 2.0} ngpu.Connect(sg, neuron_post, sg_conn_dict, syn_dict_sg_post) 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}) conn_dict = {"rule": "one_to_one"} for j in range(N): delay_post = 0.1 + round(Dt_max * j / N, 1)
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]
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 ngpu.SetStatus(sg, {"spike_times": spike_times}) delay0 = 1.0 delay1 = delay0 + time_diff
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 }) neuron_image = ngpu_nest.CreateNeuronImage(nest_neuron, 2) poiss_gen = ngpu.Create("poisson_generator") ngpu.SetStatus(poiss_gen, "rate", 10000.0) conn_dict = {"rule": "all_to_all"}
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", N) neuron = ngpu.Create("aeif_cond_beta", 2 * N) ngpu.SetStatus(neuron, {"t_ref": 1000.0, "den_delay": den_delay}) neuron0 = neuron[0:N] neuron1 = neuron[N:2 * N] dt_list = [] for i in range(N): dt_list.append(dt_step * (-0.5 * (N - 1) + i)) spike_time = [50.0] spike_height = [1.0] n_spikes = 1 time_diff = 400.0 # set spike times and height ngpu.SetStatus(sg, {"spike_times": spike_time, "spike_heights": spike_height}) delay0 = 1.0 delay1 = delay0 + time_diff
import sys import neurongpu as ngpu neuron = ngpu.Create('user_m1', 1, 3) ngpu.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b":80.5, "E_L":-70.6, "g_L":300.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] spike_heights = [1.0, 0.5] n_spikes = 2 # set spike times and height ngpu.SetStatus(spike, {"spike_times": spike_times, \ "spike_heights":spike_heights}) delay = [1.0, 100.0, 130.0] weight = [0.1, 0.2, 0.15] conn_spec={"rule": "all_to_all"} for syn in range(3): syn_spec={ #'model': 'static_synapse', 'receptor_type': syn, 'receptor': syn, 'weight': weight[syn], 'delay': delay[syn]} ngpu.Connect(spike, neuron, conn_spec, syn_spec) record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0]) ngpu.Simulate(800.0) data_list = ngpu.GetRecordData(record)
import neurongpu as ngpu neuron = ngpu.Create("aeif_cond_beta") poiss_gen = ngpu.Create("poisson_generator"); ngpu.SetStatus(poiss_gen, "rate", 12000.0) conn_dict={"rule": "one_to_one"} syn_dict={"weight": 0.05, "delay": 2.0, "receptor":0} ngpu.Connect(poiss_gen, neuron, conn_dict, syn_dict) record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0]) ngpu.Simulate() data_list = ngpu.GetRecordData(record) t=[row[0] for row in data_list] V_m=[row[1] for row in data_list] import matplotlib.pyplot as plt plt.figure(1) plt.plot(t, V_m) plt.draw() plt.pause(1) ngpu.waitenter("<Hit Enter To Close>") plt.close()
import ngpu_nest import numpy as np neuron = nest.Create('aeif_cond_beta_multisynapse') nest.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b": 80.5}) nest.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] }) neuron_image = ngpu_nest.CreateNeuronImage(neuron, 5) spike = ngpu.Create('spike_generator') ngpu.SetStatus(spike, {'spike_times': [10.0]}) voltmeter = nest.Create('voltmeter') delays = [1.0, 300.0, 500.0, 700.0] w = [1.0, 1.0, 1.0, 1.0] conn_spec = {"rule": "one_to_one"} for syn in range(4): syn_spec = {'receptor': 1 + syn, 'weight': w[syn], 'delay': delays[syn]} ngpu.Connect(spike, neuron_image, conn_spec, syn_spec) nest.Connect(voltmeter, neuron) nest.Simulate(1000.0) dmm = nest.GetStatus(voltmeter)[0] Vms = dmm["events"]["V_m"]
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})
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 }) print(ngpu.GetStatus(spike0, "spike_times")) print(ngpu.GetStatus(spike0, "spike_heights")) print()
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 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")
("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} exc_syn_dict = {
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 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)
import neurongpu as ngpu neuron = ngpu.Create("aeif_cond_beta", 1, 1) ngpu.SetStatus(neuron, {"t_ref": 100.0, "I_e": 1000.0}) record = ngpu.CreateRecord("", ["V_m"], [neuron[0]], [0]) ngpu.Simulate() data_list = ngpu.GetRecordData(record) t = [row[0] for row in data_list] V_m = [row[1] for row in data_list] import matplotlib.pyplot as plt plt.figure(1) plt.plot(t, V_m) plt.draw() plt.pause(1) raw_input("<Hit Enter To Close>") plt.close()
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] ngpu.SetStatus(neuron, {
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]
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)
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 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 n_neurons = 3 # create n_neurons neurons with 2 receptor ports neuron = ngpu.Create('aeif_cond_beta', n_neurons, 2) ngpu.SetStatus(neuron, {'tau_decay': [60.0, 10.0], 'tau_rise': [40.0, 5.0]}) neuron0 = neuron[0:0] neuron1 = neuron[1:1] neuron2 = neuron[2:2] ngpu.SetStatus(neuron0, {'V_m': -80.0}) ngpu.SetStatus(neuron1, {'g1': [0.0, 0.1]}) ngpu.SetStatus(neuron2, {'g1': [0.1, 0.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") read_Vth = ngpu.GetNeuronStatus(neuron, "V_th") read_g1 = ngpu.GetNeuronStatus(neuron, "g1") print("read_td", read_td) print("read_tr", read_tr) print("read_Vm", read_Vm) print("read_Vth", read_Vth) print("read_g1", read_g1) # reading parameters and variables from neuron list test