本文整理汇总了Python中mozaik.tools.mozaik_parametrized.MozaikParametrized.idd_to_instance方法的典型用法代码示例。如果您正苦于以下问题:Python MozaikParametrized.idd_to_instance方法的具体用法?Python MozaikParametrized.idd_to_instance怎么用?Python MozaikParametrized.idd_to_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozaik.tools.mozaik_parametrized.MozaikParametrized
的用法示例。
在下文中一共展示了MozaikParametrized.idd_to_instance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: perform_analysis_and_visualization
# 需要导入模块: from mozaik.tools.mozaik_parametrized import MozaikParametrized [as 别名]
# 或者: from mozaik.tools.mozaik_parametrized.MozaikParametrized import idd_to_instance [as 别名]
def perform_analysis_and_visualization(data_store):
analog_ids = param_filter_query(data_store,sheet_name="V1_Exc_L4").get_segments()[0].get_stored_esyn_ids()
analog_ids_inh = param_filter_query(data_store,sheet_name="V1_Inh_L4").get_segments()[0].get_stored_esyn_ids()
spike_ids = param_filter_query(data_store,sheet_name="V1_Exc_L4").get_segments()[0].get_stored_spike_train_ids()
number_of_cells = len(analog_ids)
numberOfCells_str = str(number_of_cells)
print 'NUMBER OF CELLS' + numberOfCells_str
stimuli_list = list(('SparseNoise', 'DenseNoise'))
#stimuli_list = ['SparseNoise']
save_to = './Data/'
print stimuli_list
for stimuli_type in stimuli_list:
print 'Getting voltage and images for ' + stimuli_type
# Saving parameters
format = '.pickle'
quality = '_15000_21_' # This is the number of images followed by the interval that they take in ms
# Load the segments
dsv = queries.param_filter_query(data_store, sheet_name="V1_Exc_L4",st_name=stimuli_type)
segments = dsv.get_segments()
stimuli = [MozaikParametrized.idd(s) for s in dsv.get_stimuli()]
# Take the seeds
seeds = [s.experiment_seed for s in stimuli]
print seeds,segments,stimuli
# Sort them based on their seeds
seeds,segments,stimuli = zip(*sorted(zip(seeds,segments,stimuli)))
segment_length = segments[0].get_spiketrain(spike_ids[0]).t_stop
# Values to obtain
spikes = [[] for i in segments[0].get_spiketrain(spike_ids)]
images = []
## Extract images
print 'Extracting and processing images'
for i, seg in enumerate(segments):
"""
First we take out the stimuli and make them as small as we can First we take out the stimuli and make them
as small as we can than one pixel assigned to each value of luminance. In order to do so, we first call the class
And re-adjust is parameter st.density = st.grid_size. After that we successively call the class to extract the images
frames
"""
# First we take the class
st = MozaikParametrized.idd_to_instance(stimuli[i])
st.size_x = 1.0
st.size_y = 1.0
st.density = st.grid_size
fr = st.frames()
# First we call as many frames as many frames as we need (total time / time per image = total # of images)
ims = [fr.next()[0] for i in xrange(0,st.duration/st.frame_duration)]
# Now, we take the images that repeat themselves
ims = [ims[i] for i in xrange(0,len(ims)) if ((i % (st.time_per_image/st.frame_duration)) == 0)]
images.append(ims)
# Saving images
print 'Saving Images '
# Concatenate and save
ims = numpy.concatenate(images,axis=0)
images_filename = save_to + 'images' + quality + stimuli_type + format
f = open(images_filename,'wb')
cPickle.dump(ims,f)
## Get the voltage for all the cells
for cell_number in range(number_of_cells):
print 'Extracting Voltage for cell ', cell_number
vm = [] # Intialize voltage list
for i,seg in enumerate(segments):
# get vm
v = seg.get_vm(analog_ids[cell_number])
# Check that the voltage between segments match
if vm != []:
assert vm[-1][-1] == v.magnitude[0]
# Append
vm.append(v.magnitude)
# Concatenate the experiments
print 'Concatenating Voltage'
vm = [v[:-1] for v in vm] # Take the last element out
vm = numpy.concatenate(vm,axis=0)
print 'voltage shape=', numpy.shape(vm)
# Save the voltage
print 'Saving Voltage for cell', cell_number
voltage_filename = save_to + 'vm' + '_cell_'+ str(cell_number) + quality + stimuli_type + '.pickle'
f = open(voltage_filename,'wb')
cPickle.dump(vm,f)