本文整理汇总了Python中simulation_parameters.parameter_storage函数的典型用法代码示例。如果您正苦于以下问题:Python parameter_storage函数的具体用法?Python parameter_storage怎么用?Python parameter_storage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parameter_storage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_arguments
def get_arguments():
info_txt = 'Usage: python plot_activity_as_colormap.py FOLDER_NAME CELL_TYPE [PATTERN_NR]'
try:
folder = sys.argv[1]
params_fn = os.path.abspath(folder) + '/Parameters/simulation_parameters.json'
param_tool = simulation_parameters.parameter_storage(params_fn=params_fn)
except:
print info_txt
print 'Taking the parameters currently in simulation_parameters.py'
param_tool = simulation_parameters.parameter_storage()
params = param_tool.params
print 'debug n_cells', params['n_cells']
try:
cell_type = sys.argv[2]
except:
print 'Missing cell_type argument'
print info_txt
exit(1)
try:
pn = int(sys.argv[3])
except:
print info_txt
print 'Plotting pattern 0'
pn = 0
return params, cell_type, pn
示例2: return_plot
def return_plot(cell_gids=[], subplot_code=111, fig=None, input_fn_base=None, motion_params=None):
network_params = simulation_parameters.parameter_storage() # network_params class containing the simulation parameters
params = network_params.load_params() # params stores cell numbers, etc as a dictionary
if input_fn_base == None:
input_fn_base = params['input_rate_fn_base']
fn = params['tuning_prop_means_fn']
if motion_params == None:
mp = params['motion_params']
else:
mp = motion_params
tp = np.loadtxt(fn)
if len(cell_gids) == 0:
n_cells =15
cell_gids = np.random.randint(0, params['n_exc'], n_cells)
n_cells = len(cell_gids)
ms = 5# markersize for scatterplots
bg_color = 'w'
pylab.rcParams['lines.markeredgewidth'] = 0
# input_sum = np.zeros(n_cells)
# for i, gid in enumerate(cell_gids):
# input_fn = input_fn_base + str(gid) + '.dat'
# rate = np.loadtxt(input_fn)
# input_sum[i] = rate.sum()
# input_max = input_sum.max()
if fig == None:
fig = pylab.figure(facecolor=bg_color)
ax = fig.add_subplot(subplot_code)
colors = ['b', 'g']
for i, gid in enumerate(cell_gids):
x, y, u, v = tp[gid, :]
# print 'tp[%d]:' % (gid), tp[gid, :]
# h = 240.
# l = 1. - 0.5 * input_sum[i] / input_max
# s = 1. # saturation
# assert (0 <= h and h < 360)
# assert (0 <= l and l <= 1)
# assert (0 <= s and s <= 1)
# (r, g, b) = utils.convert_hsl_to_rgb(h, s, l)
# ax.plot(x, y, 'o', c=(r,g,b), markersize=ms)
ax.plot(x, y, 'o', c=colors[i%len(colors)], markersize=ms)
ax.quiver(x, y, u, v, angles='xy', scale_units='xy', scale=1, width=0.02)#, headwidth=6)
# plot stimulus
stim_color = 'y'
ax.quiver(mp[0], mp[1], mp[2], mp[3], angles='xy', scale_units='xy', scale=1, color=stim_color, headwidth=6, width=0.02)
ax.annotate('Stimulus', (mp[0]+.5*mp[2], mp[1]+0.1), fontsize=12, color=stim_color)
ax.set_xlim((0, 1))
ax.set_ylim((0, 1))
#output_fn_fig = 'delme_test.png'
#print "Saving figure: ", output_fn_fig
#pylab.savefig(output_fn_fig)#, facecolor=bg_color)
return ax
示例3: __init__
def __init__(self, params=None, **kwargs):
print 'BasicPlotter'
if params == None:
self.network_params = simulation_parameters.parameter_storage() # network_params class containing the simulation parameters
self.params = self.network_params.load_params() # params stores cell numbers, etc as a dictionary
else:
self.params = params
self.subfig_cnt = 1
self.n_fig_x = kwargs.get('n_fig_x', 2)
self.n_fig_y = kwargs.get('n_fig_y', 2)
self.tuning_prop = np.loadtxt(self.params['tuning_prop_means_fn'])
assert (self.tuning_prop[:, 0].size == self.params['n_exc']), 'Number of cells does not match in %s and simulation_parameters!\n Wrong tuning_prop file?' % self.params['tuning_prop_means_fn']
# figure details
fig_width_pt = 800.0 # Get this from LaTeX using \showthe\columnwidth
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (np.sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt # width in inches
fig_height = fig_width*golden_mean # height in inches
# fig_size = [fig_width,fig_height]
fig_size = [fig_height,fig_width]
params = {#'backend': 'png',
'titel.fontsize': 16,
'axes.labelsize' : 12,
'text.fontsize': 12,
'figure.figsize': fig_size}
pylab.rcParams.update(params)
示例4: plot_conductances_vs_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'])
示例5: __init__
def __init__(self, params=None, comm=None, data_fn=None, sim_cnt=0):
if params == None:
self.network_params = simulation_parameters.parameter_storage() # network_params class containing the simulation parameters
self.params = self.network_params.load_params() # params stores cell numbers, etc as a dictionary
else:
self.params = params
self.no_spikes = False
self.comm = comm
self.n_fig_x = 2
self.n_fig_y = 2
self.tuning_params = np.loadtxt(self.params['tuning_prop_means_fn'])
# define parameters
self.n_cells = self.params['n_exc']
self.time_binsize = 20 # [ms]
self.n_bins = int((self.params['t_sim'] / self.time_binsize) )
self.time_bins = [self.time_binsize * i for i in xrange(self.n_bins)]
self.t_axis = np.arange(0, self.n_bins * self.time_binsize, self.time_binsize)
self.n_good = self.params['n_exc'] * .10 # fraction of 'interesting' cells
print 'Number of cells with \'good\' tuning_properties = ', self.n_good
# create data structures
self.nspikes = np.zeros(self.n_cells) # summed activity
self.nspikes_binned = np.zeros((self.n_cells, self.n_bins)) # binned activity over time
self.spiketrains = [[] for i in xrange(self.n_cells)]
self.tuning_prop = np.loadtxt(self.params['tuning_prop_means_fn'])
# sort the cells by their proximity to the stimulus into 'good_gids' and the 'rest'
# cell in 'good_gids' should have the highest response to the stimulus
print 'utils.sort_gids_by_distance_to_stimulus'
all_gids, all_distances = utils.sort_gids_by_distance_to_stimulus(self.tuning_prop, self.params['motion_params'], self.params)
self.good_gids, self.good_distances = all_gids[0:self.n_good], all_distances[0:self.n_good]
print 'Saving gids to record to', self.params['gids_to_record_fn']
np.savetxt(self.params['gids_to_record_fn'], np.array(self.good_gids), fmt='%d')
self.rest_gids = range(self.n_cells)
for gid in self.good_gids:
self.rest_gids.remove(gid)
fig_width_pt = 800.0 # Get this from LaTeX using \showthe\columnwidth
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (np.sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt # width in inches
fig_height = fig_width*golden_mean # height in inches
fig_size = [fig_width,fig_height]
params = {#'backend': 'png',
# 'axes.labelsize': 10,
# 'text.fontsize': 10,
'legend.fontsize': 10,
# 'xtick.labelsize': 8,
# 'ytick.labelsize': 8,
# 'text.usetex': True,
'figure.figsize': fig_size}
pylab.rcParams.update(params)
示例6: sort_cells_by_distance_to_stimulus
def sort_cells_by_distance_to_stimulus(n_cells, verbose=True):
import simulation_parameters
network_params = simulation_parameters.parameter_storage() # network_params class containing the simulation parameters
params = network_params.load_params() # params stores cell numbers, etc as a dictionary
tp = np.loadtxt(params['tuning_prop_means_fn'])
mp = params['motion_params']
indices, distances = sort_gids_by_distance_to_stimulus(tp , mp, params) # cells in indices should have the highest response to the stimulus
print 'Motion parameters', mp
print 'GID\tdist_to_stim\tx\ty\tu\tv\t\t'
if verbose:
for i in xrange(n_cells):
gid = indices[i]
print gid, '\t', distances[i], tp[gid, :]
return indices, distances
示例7: __init__
def __init__(self, param_fn=None, spiketimes_fn=None):
"""
params : dictionary or NeuroTools.parameters ParameterSet
"""
if params == None:
self.network_params = simulation_parameters.parameter_storage() # network_params class containing the simulation parameters
self.params = self.network_params.load_params() # params stores cell numbers, etc as a dictionary
else:
self.params = params
self.no_spikes = False
self.n_fig_x = 2
self.n_fig_y = 2
self.n_cells = self.params['n_exc']
self.nspikes = np.zeros(self.n_cells) # summed activity
self.spiketrains = [[] for i in xrange(self.n_cells)]
self.load_spiketimes(data_fn)
示例8: plot_input_colormap
def plot_input_colormap(params=None, data_fn=None, inh_spikes = None):
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
if data_fn == None:
if params.has_key('merged_input_spiketrains_fn'):
output_fn = params['merged_input_spiketrains_fn']
else:
params['merged_input_spiketrains_fn'] = "%sinput_spiketrain_merged.dat" % (params['input_folder'])
data_fn = params['merged_input_spiketrains_fn']
if not os.path.exists(data_fn):
merge_input_spiketrains(params)
plotter = P.PlotPrediction(params, data_fn)
pylab.rcParams['axes.labelsize'] = 14
pylab.rcParams['axes.titlesize'] = 16
if plotter.no_spikes:
return
plotter.compute_v_estimates()
# plotter.compute_position_estimates()
# plotter.compute_theta_estimates()
# fig 1
# neuronal level
output_fn_base = params['figures_folder'] + 'input_colormap.png'
plotter.create_fig() # create an empty figure
pylab.subplots_adjust(left=0.07, bottom=0.07, right=0.97, top=0.93, wspace=0.3, hspace=.2)
plotter.n_fig_x = 2
plotter.n_fig_y = 2
# plotter.plot_rasterplot('exc', 1) # 1
# plotter.plot_rasterplot('inh', 2) # 2
plotter.plot_vx_grid_vs_time(1) # 3
plotter.plot_vy_grid_vs_time(2) # 4
plotter.plot_x_grid_vs_time(3, ylabel='x-position of stimulus')
plotter.plot_y_grid_vs_time(4, ylabel='y-position of stimulus')
output_fn = output_fn_base + '_0.png'
print 'Saving figure to:', output_fn
pylab.savefig(output_fn)
示例9: __init__
def __init__(self, params=None):
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
self.params = network_params.params
else:
self.params = params
self.n_exc = self.params['n_exc']
self.output = []
self.g_in_histograms = []
self.output_fig = self.params['conductances_fig_fn_base']
self.n_good = self.params['n_exc'] * .05 # fraction of 'good' (well-tuned) cells
print 'Number of \'good\' (well-tuned) cells:', self.n_good
self.no_spikes = False
self.load_nspikes()
self.conn_dict = {}
for conn_type in self.params['conn_types']:
print 'Calling utils.get_conn_dict(..., %s)' % conn_fn
conn_fn = self.params['conn_list_%s_fn' % conn_type]
self.conn_dict[conn_type] = utils.get_conn_dict(self.params, conn_fn)
fig_width_pt = 800.0 # Get this from LaTeX using \showthe\columnwidth
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (np.sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt # width in inches
fig_height = fig_width*golden_mean # height in inches
fig_size = [fig_width,fig_height]
params = {#'backend': 'png',
'axes.labelsize': 12,
# 'text.fontsize': 14,
# 'legend.fontsize': 10,
# 'xtick.labelsize': 8,
# 'ytick.labelsize': 8,
# 'text.usetex': True,
'figure.figsize': fig_size}
pylab.rcParams.update(params)
pylab.subplots_adjust(bottom=0.30)
示例10: __init__
def __init__(self, argv):
if len(argv) > 1:
if argv[1].isdigit():
gid = int(argv[1])
else:
param_fn = argv[1]
if os.path.isdir(param_fn):
param_fn += '/Parameters/simulation_parameters.json'
print '\nLoading parameters from %s\n' % (param_fn)
f = file(param_fn, 'r')
params = json.load(f)
else:
print '\nLoading the default paremters...\n'
import simulation_parameters
ps = simulation_parameters.parameter_storage()
params = ps.params
self.params = params
self.conn_list_loaded = [False, False, False, False]
self.conn_mat_loaded = [False, False, False, False]
self.conn_lists = {}
示例11: __init__
def __init__(self, params=None, comm=None):
if params == None:
network_params = simulation_parameters.parameter_storage() # network_params class containing the simulation parameters
params = network_params.load_params() # params stores cell numbers, etc as a dictionary
print 'Merging connlists ...'
os.system('python merge_connlists.py')
else:
self.params = params
print 'Assuming that \n\tpython merge_connlists.py \nhas been called before in the directory %s' % params['folder_name']
self.comm = comm
if comm != None:
self.pc_id, self.n_proc = comm.rank, comm.size
self.conn_lists = {}
self.n_fig_x = 1
self.n_fig_y = 1
# cell markers
self.markersize_cell = 10
self.markersize_min = 3
self.markersize_max = 12
self.shaft_width = 0.005
self.conn_type_dict = {'e' : 'excitatory', 'i' : 'inhibitory'}
示例12: __init__
def __init__(self, param_fn=None, spiketimes_fn=None):
"""
params : dictionary or NeuroTools.parameters ParameterSet
"""
print "debug", type(param_fn)
if param_fn == None:
print "Loading default parameters stored in simulation_parameters.py"
self.network_params = simulation_parameters.parameter_storage() # network_params class containing the simulation parameters
self.params = self.network_params.load_params() # params stores cell numbers, etc as a dictionary
self.params_fn = self.params['params_fn']
else:
if type(param_fn) != type(""): raise TypeError("File name expected for param_fn")
self.params_fn = param_fn
self.params = ntp.ParameterSet(param_fn)
self.params
self.spiketimes_fn = spiketimes_fn
print os.path.abspath(self.params_fn)
print os.path.abspath(self.spiketimes_fn)
fig_width_pt = 800.0 # Get this from LaTeX using \showthe\columnwidth
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (np.sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt # width in inches
fig_height = fig_width*golden_mean # height in inches
fig_size = [fig_width,fig_height]
params = {#'backend': 'png',
# 'axes.labelsize': 10,
# 'text.fontsize': 10,
# 'legend.fontsize': 10,
# 'xtick.labelsize': 8,
# 'ytick.labelsize': 8,
# 'text.usetex': True,
'figure.figsize': fig_size}
pylab.rcParams.update(params)
示例13: not
# EPTH -> OB connections are not affected by the pattern
print "Creating connections: orn -> mit"
ConnectionClass = CreateObConnections.CreateObConnections(params)
ConnectionClass.connect_orn_mit()
ConnectionClass.connect_orn_pg()
ConnectionClass.connect_pg_mit_serial()
ConnectionClass.connect_pg_mit_reciprocal()
ConnectionClass.connect_mt_gran_local()
ConnectionClass.connect_mt_gran_global()
if __name__ == '__main__':
print info_txt
# ------------ I N I T -----------------------------
# The simulation_parameters module defines a class for simulation parameter storage
param_tool = simulation_parameters.parameter_storage()
# params is the dictionary with all parameters
params = param_tool.params
if not (params['test_pattern_rivalry']):
print '\n\n\tThis scipt is not intended to be used with the train_pattern_rivalry flag!\nWill now quit'
exit(1)
print 'New folder:', params['folder_name']
ok = raw_input('\nContinue to create this folder structure? Parameters therein will be overwritten\n\ty / Y / blank = OK; anything else --> exit\n')
if not ((ok == '') or (ok.capitalize() == 'Y')):
print 'quit'
exit(1)
OrnParamClass = CreateOrnParameters.CreateOrnParameters(params) # patterns for ORN activation must be recreated to add noise
示例14: plot_prediction
def plot_prediction(params=None, data_fn=None, inh_spikes = None):
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
if data_fn == None:
data_fn = params['exc_spiketimes_fn_merged'] + '.ras'
# if inh_spikes == None:
# inh_spikes = params['inh_spiketimes_fn_merged'] + '.ras'
# params['t_sim'] = 1200
plotter = P.PlotPrediction(params, data_fn)
pylab.rcParams['axes.labelsize'] = 14
pylab.rcParams['axes.titlesize'] = 16
if plotter.no_spikes:
return
plotter.compute_v_estimates()
# plotter.compute_position_estimates() --> happening in compute_v_estimates
plotter.compute_theta_estimates()
plotter.compute_orientation_estimates()
# fig 1
# neuronal level
output_fn_base = '%s%s_wsigmaX_%.2f_wsigmaV%.2f_delayScale%d_connRadius%.2f_wee%.2f' % (params['prediction_fig_fn_base'], params['connectivity_code'], \
params['w_sigma_x'], params['w_sigma_v'], params['delay_scale'], params['connectivity_radius'], params['w_tgt_in_per_cell_ee'])
plotter.create_fig() # create an empty figure
pylab.subplots_adjust(left=0.07, bottom=0.07, right=0.97, top=0.93, wspace=0.3, hspace=.2)
plotter.n_fig_x = 2
plotter.n_fig_y = 3
plotter.plot_rasterplot('exc', 1) # 1
plotter.plot_rasterplot('inh', 2) # 2
plotter.plot_vx_grid_vs_time(3) # 3
plotter.plot_vy_grid_vs_time(4) # 4
plotter.plot_x_grid_vs_time(5)
plotter.plot_y_grid_vs_time(6)
output_fn = output_fn_base + '_0.png'
print 'Saving figure to:', output_fn
pylab.savefig(output_fn, dpi=200)
# output_fn = output_fn_base + '_0.pdf'
# print 'Saving figure to:', output_fn
# pylab.savefig(output_fn, dpi=200)
# orientation figure
plotter.create_fig() # create an empty figure
plotter.n_fig_x = 3
plotter.n_fig_y = 2 # to have the ~same figure sizes as for the others
plotter.plot_orientation_grid_vs_time(1)
plotter.plot_orientation_estimates(2)
plotter.plot_orientation_diff(3)
output_fn = output_fn_base + '_orientation.png'
print 'Saving figure to:', output_fn
pylab.savefig(output_fn, dpi=200)
# output_fn = output_fn_base + '_0.eps'
# print 'Saving figure to:', output_fn
# pylab.savefig(output_fn, dpi=200)
# poplation level, short time-scale
plotter.n_fig_x = 3
plotter.n_fig_y = 2
plotter.create_fig()
pylab.rcParams['legend.fontsize'] = 12
pylab.subplots_adjust(left=0.07, bottom=0.07, right=0.97, top=0.93, wspace=0.3, hspace=.3)
plotter.plot_vx_estimates(1)
plotter.plot_vy_estimates(2)
plotter.plot_vdiff(3)
plotter.plot_x_estimates(4)
plotter.plot_y_estimates(5)
plotter.plot_xdiff(6)
output_fn = output_fn_base + '_1.png'
print 'Saving figure to:', output_fn
pylab.savefig(output_fn, dpi=200)
# output_fn = output_fn_base + '_1.pdf'
# print 'Saving figure to:', output_fn
# pylab.savefig(output_fn, dpi=200)
# output_fn = output_fn_base + '_1.eps'
# print 'Saving figure to:', output_fn
# pylab.savefig(output_fn, dpi=200)
# plotter.plot_theta_estimates(5)
# fig 3
# population level, long time-scale
# plotter.n_fig_x = 1
# plotter.n_fig_y = 4
# pylab.rcParams['legend.fontsize'] = 10
# pylab.subplots_adjust(hspace=0.5)
#.........这里部分代码省略.........
示例15: assert
Usage:
python plot_response_curve.py [FOLDER] [CELLTYPE]
or
python plot_response_curve.py [FOLDER] [CELLTYPE] [PATTERN_NUMBER]
"""
assert (len(sys.argv) > 2), 'ERROR: folder and cell_type not given\n' + info_txt
folder = sys.argv[1]
cell_type = sys.argv[2]
try:
pn = int(sys.argv[3])
except:
print 'WARNING: Using the default pattern number 0'
pn = 0
params_fn = os.path.abspath(folder) + '/Parameters/simulation_parameters.json'
param_tool = simulation_parameters.parameter_storage(params_fn=params_fn)
params = param_tool.params
if cell_type == 'all':
# cell_types = params['cell_types']
cell_types = ['mit', 'pg', 'gran']
else:
cell_types = [cell_type]
for cell_type in cell_types:
print 'Plotting raster for:', cell_type
plot_raster_for_celltype(params, cell_type, title='%s spikes pattern %d' % (cell_type.upper(), pn))
# plot_raster_for_celltype(params, cell_type, title='%s spikes pattern %d' % (cell_type.upper(), pn))
pylab.show()