-
Notifications
You must be signed in to change notification settings - Fork 4
/
4pop_model.py
executable file
·104 lines (89 loc) · 4.29 KB
/
4pop_model.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import sys, pathlib
import numpy as np
import matplotlib.pylab as plt
sys.path.append(str(pathlib.Path(__file__).resolve().parents[1]))
import ntwk
################################################################
## ------ Construct populations with their equations -------- ##
## ------------- with recurrent connections ----------------- ##
################################################################
Model = {
## ---------------------------------------------------------------------------------
## UNIT SYSTEM is : ms, mV, pF, nS, pA, Hz (arbitrary and unconsistent, so see code)
## ---------------------------------------------------------------------------------
# numbers of neurons in population
'N_Thal':500, 'N_Exc':4000, 'N_Inh':1000, 'N_DsInh':500, 'N_AffExc':500,
# synaptic weights
'Q_AffExc_Thal':2.,
'Q_Exc_Exc':1., 'Q_Exc_Inh':1.,
'Q_Inh_Exc':10., 'Q_Inh_Inh':10.,
'Q_DsInh_Inh':10.,
# synaptic time constants
'Tsyn_Exc':5., 'Tsyn_Inh':5.,
# synaptic reversal potentials
'Erev_Exc':0., 'Erev_Inh': -80.,
# connectivity parameters
'p_AffExc_Thal':0.1,
'p_Exc_Exc':0.02, 'p_Exc_Inh':0.02,
'p_Inh_Exc':0.02, 'p_Inh_Inh':0.02,
'p_DsInh_Inh':0.02,
'p_Thal_Exc':0.1, 'p_Thal_Inh':0.1, 'p_Thal_DsInh':0.1,
# simulation parameters
'dt':0.1, 'tstop': 1000., 'SEED':3, # low by default, see later
## ---------------------------------------------------------------------------------
# === cellular properties (based on AdExp), population by population ===
# --> Thalamic population (Thal)
'Thal_Gl':10., 'Thal_Cm':200.,'Thal_Trefrac':3.,
'Thal_El':-60., 'Thal_Vthre':-50., 'Thal_Vreset':-60., 'Thal_deltaV':0.,
'Thal_a':0., 'Thal_b': 0., 'Thal_tauw':1e9,
# --> Excitatory population (Exc, recurrent excitation)
'Exc_Gl':10., 'Exc_Cm':200.,'Exc_Trefrac':3.,
'Exc_El':-60., 'Exc_Vthre':-50., 'Exc_Vreset':-60., 'Exc_deltaV':0.,
'Exc_a':0., 'Exc_b': 0., 'Exc_tauw':1e9,
# --> Inhibitory population (Inh, recurrent inhibition)
'Inh_Gl':10., 'Inh_Cm':200.,'Inh_Trefrac':3.,
'Inh_El':-60., 'Inh_Vthre':-53., 'Inh_Vreset':-60., 'Inh_deltaV':0.,
'Inh_a':0., 'Inh_b': 0., 'Inh_tauw':1e9,
# --> Disinhibitory population (Inh, recurrent inhibition)
'DsInh_Gl':10., 'DsInh_Cm':200.,'DsInh_Trefrac':3.,
'DsInh_El':-60., 'DsInh_Vthre':-53., 'DsInh_Vreset':-60., 'DsInh_deltaV':0.,
'DsInh_a':0., 'DsInh_b': 0., 'DsInh_tauw':1e9,
}
if sys.argv[-1]=='plot':
# ######################
# ## ----- Plot ----- ##
# ######################
## load file
data = ntwk.recording.load_dict_from_hdf5('4pop_model_data.h5')
# ## plot
fig, _ = ntwk.plots.raster_and_Vm_plot(data, smooth_population_activity=10.)
plt.show()
else:
NTWK = ntwk.build.populations(Model, ['Thal', 'Exc', 'Inh', 'DsInh'],
AFFERENT_POPULATIONS=['AffExc'],
with_raster=True, with_Vm=4,
# with_synaptic_currents=True,
# with_synaptic_conductances=True,
verbose=True)
ntwk.build.recurrent_connections(NTWK, SEED=5, verbose=True)
#######################################
########### AFFERENT INPUTS ###########
#######################################
faff = 1.
t_array = ntwk.arange(int(Model['tstop']/Model['dt']))*Model['dt']
# # # afferent excitation onto thalamic excitation
ntwk.stim.construct_feedforward_input(NTWK, 'Thal', 'AffExc',
t_array, faff+0.*t_array,
verbose=True,
SEED=int(38*faff)%37)
################################################################
## --------------- Initial Condition ------------------------ ##
################################################################
ntwk.build.initialize_to_rest(NTWK)
#####################
## ----- Run ----- ##
#####################
ntwk.collect_and_run(NTWK, verbose=True)
ntwk.recording.write_as_hdf5(NTWK, filename='4pop_model_data.h5')
print('Results of the simulation are stored as:', '4pop_model_data.h5')
print('--> Run \"python 4pop_model.py plot\" to plot the results')