예제 #1
0
def advanced():
    cross_product_densities = (LinearSpecs("retina_density", 2,7,3)
                               * LinearSpecs("cortex_density", 1,6,3, fp_precision=2))

    run_batch_spec = Spec(times=[1,5,10], 
                          rationale='Avoiding default of 10000 iterations for testing purposes.')

    # Completed Specifier
    combined_spec = run_batch_spec * cross_product_densities    

    # Command
    run_batch_command = RunBatchCommand('../../../examples/tiny.ty', analysis='RunBatchAnalysis')
    run_batch_command.allowed_list = ['retina_density','cortex_density', 'times']

    run_batch_command.name_time_format = '%d-%m-%Y@%H%M'
    run_batch_command.param_formatter.abbreviations = {'retina_density':'rd', 'cortex_density':'cd'}

    # Launcher
    tasklauncher = Launcher(batch_name,combined_spec,run_batch_command)
    # tasklauncher.timestamp_format = None

    # Analysis
    batch_analysis = RunBatchAnalysis()
    # Adding map functions
    batch_analysis.add_map_fn(OR_plotgroup, 'Recording orientation preference')
    batch_analysis.add_map_fn(activity_plotgroup, 'Recording sheet activities')
    # Adding map-reduce function
    batch_analysis.add_map_reduce_fn(V1_mean_activity, V1_reduce, 
                                     'Processing the mean V1 activity')
    batch_analysis.add_map_reduce_fn(retina_std_activity, retina_reduce, 
                                     'Computing the standard deviation of the retinal activity')
    
    batch_analysis.add_map_reduce_fn(empty_map, save_simulations, ' Saving the simulation results.')
    return (tasklauncher, batch_analysis)
예제 #2
0
파일: 4-amend.py 프로젝트: ioam/svn-history
from dispatch.topographica import RunBatchAnalysis

def V1_mean_activity():  return numpy.mean(topo.sim['V1'].activity)

def V1_reduce(map_data, root_directory):      
    import pylab
    time1_rd2 = [(float(spec['cortex_density']), v) for  (v, t, spec) in map_data 
                 if ((t==1) and (spec['retina_density'] == '2.0000'))]

    cortex_density, activities = zip(*sorted(time1_rd2))
    pylab.plot(cortex_density, activities)
    pylab.title('Amended plot.')
    figure_path = os.path.join(root_directory, 'cluster_figures')
    try: os.mkdir(figure_path)
    except :pass
    pylab.savefig(os.path.join(figure_path, 'rd2_mean_activity_amend.png'))
    print "Saved figure rd2_mean_activity_amend.png in folder cluster_figures"


root_directory = os.path.abspath('./Demo_Output/2012-05-15_1110-topo_analysis_cluster')
log_path = os.path.join(root_directory, 'topo_analysis_cluster.log')

analysisfn = RunBatchAnalysis.load(root_directory)
analysisfn.source_path = os.path.abspath('./topo_amend.py')
analysisfn.set_map_reduce_fns([V1_mean_activity],[V1_reduce],['Amending the plot'])
specs = StaticSpecs.extract_log_specification(log_path)
spec_log = zip(specs[0],specs[1])

if __name__ == '__main__':
    analysisfn.reduce(spec_log, root_directory)