Skip to content

Commit 721a52c

Browse files
committed
Adding initial analysis of cells
1 parent 65f13fb commit 721a52c

17 files changed

+368
-0
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,15 @@ ChannelTest/*.log
3737
/NMC/NeuroML2/ManyCells.net.png
3838
/NMC/Connectome/BBP.net.png
3939
/NMC/Connectome/cons_locs_pathways_mc0_Column.tar
40+
/NMC/NeuroML2/nmllite/*.mod
41+
*.gv
42+
*.gv.png
43+
/NMC/NeuroML2/nmllite/IClamp_*.json
44+
/NMC/NeuroML2/nmllite/ParamSweep_*
45+
/NMC/NeuroML2/nmllite/IClamp_*.net.nml
46+
/NMC/NeuroML2/nmllite/*.hoc
47+
/NMC/NeuroML2/nmllite/*.dat
48+
/NMC/NeuroML2/nmllite/LEMS_Sim_IClamp_*.xml
49+
/NMC/NeuroML2/nmllite/Sim_IClamp_*.json
50+
report.*.txt
51+
*_nrn.py
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
from neuromllite import *
2+
from neuromllite.NetworkGenerator import *
3+
from neuromllite.utils import create_new_model
4+
import sys
5+
6+
sys.path.append("..")
7+
8+
'''
9+
bAC217_L4_MC_5fa0a62bd0_0_0.cell.nml cADpyr229_L23_PC_c292d67a2e_0_0.cell.nml cADpyr231_L6_TPC_L4_117b9dfb71_0_0.cell.nml cNAC187_L1_HAC_f8c9772d9d_0_0.cell.nml Soma_AllNML2.cell.nml
10+
bNAC219_L1_DAC_a9ae5cbbf5_0_0.cell.nml cADpyr230_L4_SS_1afeb14f17_0_0.cell.nml cADpyr232_L5_TTPC1_0fb1ca4724_0_0.cell.nml cNAC187_L23_NBC_9d37c4b1f8_0_0.cell.nml
11+
cADpyr229_L23_PC_5ecbf9b163_0_0.cell.nml cADpyr231_L6_TPC_L1_44f2206f70_0_0.cell.nml cADpyr232_L5_UTPC_d736225429_0_0.cell.nml cSTUT189_L23_LBC_e6e8f83407_0_0.cell.nml
12+
13+
'''
14+
colors = {'RS':'0 0 0.8', 'FS':'0.8 0 0', 'LTS':'0 0 0.8', 'IB':'0.8 0 0', 'IBR':'0.8 0 0'}
15+
colors = {'cADpyr229_L23_PC_c292d67a2e_0_0':'0 0 0.8', 'cNAC187_L23_NBC_9d37c4b1f8_0_0':'0.8 0 0'}
16+
17+
def generate(cell, duration=3000, config='IClamp',parameters = None):
18+
19+
reference = "%s_%s"%(config, cell)
20+
21+
cell_id = '%s'%cell
22+
cell_nmll = Cell(id=cell_id, neuroml2_source_file='../%s.cell.nml'%(cell))
23+
24+
################################################################################
25+
### Add some inputs
26+
27+
if 'IClamp' in config:
28+
29+
if not parameters:
30+
parameters = {}
31+
parameters['stim_amp'] = '350pA'
32+
33+
input_source = InputSource(id='iclamp_0',
34+
neuroml2_input='PulseGenerator',
35+
parameters={'amplitude':'stim_amp', 'delay':'500ms', 'duration':'2000ms'})
36+
37+
38+
else:
39+
40+
if not parameters:
41+
parameters = {}
42+
parameters['average_rate'] = '100 Hz'
43+
parameters['number_per_cell'] = '10'
44+
45+
input_source = InputSource(id='pfs0',
46+
neuroml2_input='PoissonFiringSynapse',
47+
parameters={'average_rate':'average_rate',
48+
'synapse':syn_exc.id,
49+
'spike_target':"./%s"%syn_exc.id})
50+
51+
sim, net = create_new_model(reference,
52+
duration,
53+
dt=0.025, # ms
54+
temperature=34, # degC
55+
default_region='Cortex',
56+
parameters = parameters,
57+
cell_for_default_population=cell_nmll,
58+
color_for_default_population=colors[cell],
59+
input_for_default_population=input_source)
60+
61+
return sim, net
62+
63+
64+
65+
if __name__ == "__main__":
66+
67+
if '-all' in sys.argv:
68+
for cell in colors:
69+
generate(cell, 3000, config="IClamp")
70+
71+
72+
else:
73+
74+
#sim, net = generate('cADpyr229_L23_PC_c292d67a2e_0_0', 3000, config="IClamp")
75+
sim, net = generate('cNAC187_L23_NBC_9d37c4b1f8_0_0', 3000, config="IClamp",parameters={'stim_amp':'30pA'})
76+
77+
check_to_generate_or_run(sys.argv, sim)
78+

NMC/NeuroML2/nmllite/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
### BBP cell summary
2+
<table>
3+
<tr>
4+
<td width=30><b>cADpyr229_L23_PC_c292d67a2e_0_0</b></td>
5+
<td><a href="mean_spike_frequency_cADpyr229_L23_PC_c292d67a2e_0_0.png">
6+
<img alt="?" src="mean_spike_frequency_cADpyr229_L23_PC_c292d67a2e_0_0.png" height="160"/></a>
7+
</td>
8+
<td><a href="firing_rates_cADpyr229_L23_PC_c292d67a2e_0_0.png">
9+
<img alt="?" src="firing_rates_cADpyr229_L23_PC_c292d67a2e_0_0.png" height="160"/></a>
10+
</td>
11+
<td><a href="heatmap_cADpyr229_L23_PC_c292d67a2e_0_0.png">
12+
<img alt="?" src="heatmap_cADpyr229_L23_PC_c292d67a2e_0_0.png" height="160"/></a>
13+
</td>
14+
<td><a href="dt_traces_cADpyr229_L23_PC_c292d67a2e_0_0.png">
15+
<img alt="?" src="dt_traces_cADpyr229_L23_PC_c292d67a2e_0_0.png" height="160"/></a>
16+
</td>
17+
<td><a href="heatmap_dt_cADpyr229_L23_PC_c292d67a2e_0_0.png">
18+
<img alt="?" src="heatmap_dt_cADpyr229_L23_PC_c292d67a2e_0_0.png" height="160"/></a>
19+
</td>
20+
<td><a href="mean_spike_frequency_dt_cADpyr229_L23_PC_c292d67a2e_0_0.png">
21+
<img alt="?" src="mean_spike_frequency_dt_cADpyr229_L23_PC_c292d67a2e_0_0.png" height="160"/></a>
22+
</td>
23+
<tr>
24+
<tr>
25+
<td width=30><b>cNAC187_L23_NBC_9d37c4b1f8_0_0</b></td>
26+
<td><a href="mean_spike_frequency_cNAC187_L23_NBC_9d37c4b1f8_0_0.png">
27+
<img alt="?" src="mean_spike_frequency_cNAC187_L23_NBC_9d37c4b1f8_0_0.png" height="160"/></a>
28+
</td>
29+
<td><a href="firing_rates_cNAC187_L23_NBC_9d37c4b1f8_0_0.png">
30+
<img alt="?" src="firing_rates_cNAC187_L23_NBC_9d37c4b1f8_0_0.png" height="160"/></a>
31+
</td>
32+
<td><a href="heatmap_cNAC187_L23_NBC_9d37c4b1f8_0_0.png">
33+
<img alt="?" src="heatmap_cNAC187_L23_NBC_9d37c4b1f8_0_0.png" height="160"/></a>
34+
</td>
35+
<td><a href="dt_traces_cNAC187_L23_NBC_9d37c4b1f8_0_0.png">
36+
<img alt="?" src="dt_traces_cNAC187_L23_NBC_9d37c4b1f8_0_0.png" height="160"/></a>
37+
</td>
38+
<td><a href="heatmap_dt_cNAC187_L23_NBC_9d37c4b1f8_0_0.png">
39+
<img alt="?" src="heatmap_dt_cNAC187_L23_NBC_9d37c4b1f8_0_0.png" height="160"/></a>
40+
</td>
41+
<td><a href="mean_spike_frequency_dt_cNAC187_L23_NBC_9d37c4b1f8_0_0.png">
42+
<img alt="?" src="mean_spike_frequency_dt_cNAC187_L23_NBC_9d37c4b1f8_0_0.png" height="160"/></a>
43+
</td>
44+
<tr>

NMC/NeuroML2/nmllite/Sweep.py

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
import sys
2+
3+
import pprint; pp = pprint.PrettyPrinter(depth=6)
4+
5+
from neuromllite.sweep.ParameterSweep import ParameterSweep
6+
from neuromllite.sweep.ParameterSweep import NeuroMLliteRunner
7+
8+
9+
10+
from GenerateExamples import colors
11+
12+
if __name__ == '__main__':
13+
14+
heatmap_lims=[-110,-20]
15+
16+
if '-all' in sys.argv:
17+
18+
print('Generating all plots')
19+
save_fig_dir = './'
20+
html = '<table>\n'
21+
22+
fixed = {'dt':0.025, 'duration':3000}
23+
24+
25+
vary = {'stim_amp':['%spA'%(i) for i in xrange(-100,1000,50)]}
26+
#vary = {'stim_amp':['%spA'%(i/10.0) for i in xrange(-10,20,5)]}
27+
#vary = {'stim_amp':['-100pA','0pA','100pA','200pA','300pA','400pA']}
28+
29+
cells = colors.keys()
30+
31+
for type in cells:
32+
if type!='ec' and type !='ca3':
33+
34+
run = True
35+
run = False
36+
37+
if run:
38+
39+
nmllr = NeuroMLliteRunner('Sim_IClamp_%s.json'%type,
40+
simulator='jNeuroML_NEURON')
41+
ps = ParameterSweep(nmllr,
42+
vary,
43+
fixed,
44+
num_parallel_runs=16,
45+
save_plot_all_to='firing_rates_%s.png'%type,
46+
heatmap_all=True,
47+
save_heatmap_to='heatmap_%s.png'%type,
48+
heatmap_lims=heatmap_lims,
49+
plot_all=True,
50+
show_plot_already=False)
51+
52+
report = ps.run()
53+
54+
#ps.plotLines('stim_amp','average_last_1percent',save_figure_to='average_last_1percent_%s.png'%type)
55+
ps.plotLines('stim_amp','mean_spike_frequency',save_figure_to='mean_spike_frequency_%s.png'%type)
56+
57+
height = '160'
58+
html+='<tr>\n'
59+
html+=' <td width=30><b>'+type+'</b></td>\n'
60+
html+=' <td><a href="mean_spike_frequency_%s.png'%type+'">\n'
61+
html+=' <img alt="?" src="mean_spike_frequency_%s.png'%type+'" height="'+height+'"/></a>\n'
62+
html+=' </td>\n'
63+
html+=' <td><a href="firing_rates_%s.png'%type+'">\n'
64+
html+=' <img alt="?" src="firing_rates_%s.png'%type+'" height="'+height+'"/></a>\n'
65+
html+=' </td>\n'
66+
html+=' <td><a href="heatmap_%s.png'%type+'">\n'
67+
html+=' <img alt="?" src="heatmap_%s.png'%type+'" height="'+height+'"/></a>\n'
68+
html+=' </td>\n'
69+
html+=' <td><a href="dt_traces_%s.png'%type+'">\n'
70+
html+=' <img alt="?" src="dt_traces_%s.png'%type+'" height="'+height+'"/></a>\n'
71+
html+=' </td>\n'
72+
html+=' <td><a href="heatmap_dt_%s.png'%type+'">\n'
73+
html+=' <img alt="?" src="heatmap_dt_%s.png'%type+'" height="'+height+'"/></a>\n'
74+
html+=' </td>\n'
75+
html+=' <td><a href="mean_spike_frequency_dt_%s.png'%type+'">\n'
76+
html+=' <img alt="?" src="mean_spike_frequency_dt_%s.png'%type+'" height="'+height+'"/></a>\n'
77+
html+=' </td>\n'
78+
html+='<tr>\n'
79+
80+
import matplotlib.pyplot as plt
81+
if not '-nogui' in sys.argv:
82+
print("Showing plots")
83+
plt.show()
84+
85+
86+
with open(save_fig_dir+'info.html','w') as f:
87+
f.write('<html><body>\n%s\n</body></html>'%html)
88+
with open(save_fig_dir+'README.md','w') as f2:
89+
f2.write('### BBP cell summary \n%s'%(html.replace('.html','.md')))
90+
91+
elif '-dt' in sys.argv:
92+
93+
94+
optimal_stim = {'cADpyr229_L23_PC_c292d67a2e_0_0':'500',
95+
'cNAC187_L23_NBC_9d37c4b1f8_0_0':'30'}
96+
97+
vary = {'dt':[0.1,0.05,0.025,0.01,0.005,0.0025,0.001,0.0005,0.00025,0.0001]}
98+
vary = {'dt':[0.1,0.05,0.025,0.01,0.005,0.0025,0.001]}
99+
vary = {'dt':[0.05,0.025,0.01,0.005,0.0025]}
100+
#vary = {'dt':[0.05,0.025,0.01,0.005]}
101+
#vary = {'dt':[0.05,0.025,0.01]}
102+
#vary = {'dt':[0.05,0.025,0.01]}
103+
104+
for type in optimal_stim:
105+
if type!='ec' and type !='ca3':
106+
107+
run = True
108+
109+
if run:
110+
111+
fixed = {'duration':3000, 'stim_amp':'%spA'%optimal_stim[type]}
112+
113+
nmllr = NeuroMLliteRunner('Sim_IClamp_%s.json'%type,
114+
simulator='jNeuroML_NEURON')
115+
ps = ParameterSweep(nmllr,
116+
vary,
117+
fixed,
118+
num_parallel_runs=16,
119+
save_plot_all_to='dt_traces_%s.png'%type,
120+
heatmap_all=True,
121+
save_heatmap_to='heatmap_dt_%s.png'%type,
122+
heatmap_lims=heatmap_lims,
123+
plot_all=True,
124+
show_plot_already=False)
125+
126+
report = ps.run()
127+
128+
#ps.plotLines('stim_amp','average_last_1percent',save_figure_to='average_last_1percent_%s.png'%type)
129+
ps.plotLines('dt','mean_spike_frequency',save_figure_to='mean_spike_frequency_dt_%s.png'%type, logx=True)
130+
131+
132+
133+
import matplotlib.pyplot as plt
134+
if not '-nogui' in sys.argv:
135+
print("Showing plots")
136+
plt.show()
137+
138+
139+
else:
140+
141+
fixed = {'dt':0.025, 'duration':3000}
142+
143+
quick = False
144+
#quick=True
145+
146+
vary = {'stim_amp':['%spA'%(i/10.0) for i in xrange(-10,20,2)]}
147+
vary = {'dt':[0.1,0.05,0.025,0.01,0.005,0.0025,0.001,0.0005,0.00025,0.0001]}
148+
vary = {'dt':[0.1,0.05,0.025,0.01,0.005,0.0025,0.001]}
149+
vary = {'dt':[0.1,0.05,0.025,0.01,0.005]}
150+
151+
#vary = {'number_per_cell':[i for i in xrange(0,250,10)]}
152+
#vary = {'stim_amp':['1pA','1.5pA','2pA']}
153+
vary = {'stim_amp':['%spA'%(i) for i in xrange(-100,1000,50)]}
154+
155+
type = 'RS'
156+
type = 'cADpyr229_L23_PC_c292d67a2e_0_0'
157+
type = 'cNAC187_L23_NBC_9d37c4b1f8_0_0'
158+
#type='poolosyn'
159+
config = 'IClamp'
160+
#config = 'PoissonFiringSynapse'
161+
162+
nmllr = NeuroMLliteRunner('Sim_%s_%s.json'%(config,type),
163+
simulator='jNeuroML_NEURON')
164+
165+
if quick:
166+
pass
167+
168+
ps = ParameterSweep(nmllr, vary, fixed,
169+
num_parallel_runs=16,
170+
plot_all=True,
171+
save_plot_all_to='firing_rates_%s.png'%type,
172+
heatmap_all=True,
173+
save_heatmap_to='heatmap_%s.png'%type,
174+
heatmap_lims=heatmap_lims,
175+
show_plot_already=False)
176+
177+
report = ps.run()
178+
ps.print_report()
179+
180+
#ps.plotLines('stim_amp','average_last_1percent',save_figure_to='average_last_1percent_%s.png'%type)
181+
ps.plotLines('stim_amp','mean_spike_frequency',save_figure_to='mean_spike_frequency_%s.png'%type)
182+
#ps.plotLines('dt','mean_spike_frequency',save_figure_to='mean_spike_frequency_%s.png'%type, logx=True)
183+
#ps.plotLines('number_per_cell','mean_spike_frequency',save_figure_to='poisson_mean_spike_frequency_%s.png'%type)
184+
185+
import matplotlib.pyplot as plt
186+
if not '-nogui' in sys.argv:
187+
print("Showing plots")
188+
plt.show()
60.3 KB
Loading
61.7 KB
Loading
93.2 KB
Loading
63.7 KB
Loading
37.7 KB
Loading
42.2 KB
Loading

0 commit comments

Comments
 (0)