|
| 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() |
0 commit comments