-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadaptive_simulation_decrease.py
83 lines (56 loc) · 1.74 KB
/
adaptive_simulation_decrease.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import nest
import numpy as np
J_parameters = np.arange(0,100,0.2)
mean_rate_string_small = ""
time_string = ""
J_string = ""
for J_s in J_parameters:
nest.SetKernelStatus({"local_num_threads":8})
neuron_population = 1000
simulation_time = 1000.0
I_e = 0.0
dict_params = {"V_peak" : 0.0
, "V_reset" : -70.0
, "t_ref" : 2.0
, "g_L" : 1.0
, "C_m" : 250.0
, "E_ex" : 0.0
, "E_in" : 0.0
, "E_L" : -70.0
, "Delta_T" : 2.0
, "tau_w" : 1.0
, "a" : 1.0
, "b" : 80.5
, "V_th" : -55.0
#, "tau_syn_ex" : 0.2
, "tau_syn_in" : 2.0
, "I_e" : 500.0
, "w": 0.0}
neurons = nest.Create("aeif_cond_exp", neuron_population)
nest.SetStatus(neurons, params=dict_params)
for neuron in neurons:
nest.SetStatus([neuron], {"V_m": dict_params["E_L"]+(dict_params["V_th"]-dict_params["E_L"])*np.random.rand()})
spikedetector = nest.Create("spike_detector", params={"withgid": True, "withtime": True})
for neuron in neurons:
nest.Connect([neuron], spikedetector)
K = 20
d = 1.0
J = float(J_s)
conn_dict = {"rule": "fixed_indegree", "indegree": K}
syn_dict = {"delay": d, "weight": J}
nest.Connect(neurons, neurons, conn_dict, syn_dict)
length = np.float64(0)
for I in range(500, -10, -10):
I_e = float(I)
nest.SetStatus(neurons, params={"I_e": I_e})
nest.Simulate(simulation_time)
dSD = nest.GetStatus(spikedetector, keys='events')[0]
evs = dSD["senders"]
ts = dSD["times"]
nest.ResumeSimulation()
nest.ResetKernel()
nest.ResetNetwork()
time_string += str(ts[-1]) + ", "
open_file = open("adaptive_decrease.txt", "w")
open_file.write(time_string)
open_file.close()