forked from bernhardkaplan/bcpnn-mt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_conductances.py
executable file
·95 lines (74 loc) · 3.13 KB
/
plot_conductances.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
#import matplotlib
#matplotlib.use('Agg')
import pylab
import PlotConductances as P
import sys
import NeuroTools.parameters as ntp
import simulation_parameters
import time
def plot_conductances_vs_time(params=None, comm=None, data_fn=None, inh_spikes = None):
t_start = time.time()
if params== None:
network_params = simulation_parameters.parameter_storage() # network_params class containing the simulation parameters
# P = network_params.load_params() # params stores cell numbers, etc as a dictionary
params = network_params.params
sim_cnt = 0
if data_fn == None:
data_fn = params['exc_spiketimes_fn_merged'] + '%d.ras' % (sim_cnt)
# if inh_spikes == None:
# inh_spikes = params['inh_spiketimes_fn_merged'] + '%d.ras' % (sim_cnt)
plotter = P.PlotConductances(params, comm, data_fn)
plotter.load_spiketimes()
if plotter.no_spikes:
return
output_fn_base = '%s%s_wsigmaX_%.2f_wsigmaV%.2f_wthresh%.1e' % (params['grouped_actitivty_fig_fn_base'], params['connectivity_code'], \
params['w_sigma_x'], params['w_sigma_v'], params['w_thresh_connection'])
# fig 1
# neuronal level
plotter.create_fig() # create an empty figure
plotter.plot_rasterplot('exc', 1) # 1
plotter.plot_rasterplot('inh', 2) # 2
plotter.plot_group_spikes_vs_time(3) # 3
output_fn = output_fn_base + '_0.png'
print 'Saving figure to:', output_fn
pylab.savefig(output_fn)
# output_fn = '%sgoodcell_connections_%s_wsigmaX_%.2f_wsigmaV%.2f_wthresh%.1e.png' % (params['figures_folder'], params['connectivity_code'], \
# params['w_sigma_x'], params['w_sigma_v'], params['w_thresh_connection'])
# plotter.create_fig() # create an empty figure
# plotter.plot_good_cell_connections(1) # subplot 1 + 2
# print 'Saving figure to:', output_fn
# pylab.savefig(output_fn)
# fig 2
plotter.create_fig() # create an empty figure
plotter.plot_input_cond(1) # subplot 1 + 2
plotter.plot_conductances()
output_fn = output_fn_base + '_1.png'
print 'Saving figure to:', output_fn
pylab.savefig(output_fn)
plotter.create_fig() # create an empty figure
plotter.plot_input_cond()
t_stop = time.time()
t_run = t_stop - t_start
print "PlotConductance duration: %d sec or %.1f min for %d cells (%d exc, %d inh)" % (t_run, (t_run)/60., \
params['n_cells'], params['n_exc'], params['n_inh'])
# fig 3
# pylab.show()
def plot_conductance_composition(params=None, comm=None):
plotter = P.PlotConductances(params, comm)
if plotter.no_spikes:
return
plotter.plot_conductance_composition()
if __name__ == '__main__':
try:
from mpi4py import MPI
USE_MPI = True
comm = MPI.COMM_WORLD
pc_id, n_proc = comm.rank, comm.size
print "USE_MPI:", USE_MPI, 'pc_id, n_proc:', pc_id, n_proc
except:
USE_MPI = False
pc_id, n_proc, comm = 0, 1, None
print "MPI not used"
# plot_conductances_vs_time(params=None, comm=comm)
plot_conductance_composition()
pylab.show()