Example #1
0
def collect_activity_statistics():
    contrib.jacommands.activity_history = numpy.concatenate((contrib.jacommands.activity_history, topo.sim["V1"].activity.flatten()), axis=1)

    if(int(topo.sim.time()) == 10000): 
        pylab.figure()
        pylab.hist(contrib.jacommands.activity_history, (numpy.arange(20.0) / 20.0))
        pylab.savefig(str(topo.sim.time()) + 'activity_histogram.png')
    #    measure_or_tuning_fullfield()
    #    cyclic_tuning_curve_batch(filename="OrientationTC:V1:[0,0]",sheet=topo.sim["V1"],coords=[(0,0)],x_axis="orientation")
        save_plotgroup('Activity')
Example #2
0
def plotting_and_saving_analysis_fn(prefix=""):
    """For use with memuse_batch() to test snapshot and plotting memory usage."""
    import topo
    from topo.command import save_snapshot
    from topo.command.analysis import measure_sine_pref,save_plotgroup
    
    print "%sMemuse at time %s: %s" % (prefix,topo.sim.timestr(),allsizes_mb())
    measure_sine_pref()
    print "%sAfter measure_sine_pref:  %s" % (prefix,allsizes_mb())
    save_plotgroup("Orientation Preference")
    print "%sAfter save_plotgroup:     %s" % (prefix,allsizes_mb())
    save_snapshot("/tmp/tmp.typ")
    print "%sAfter save_snapshot:      %s" % (prefix,allsizes_mb())
Example #3
0
def v2_analysis_function():
    """
    Basic example of an analysis command for run_batch; users are
    likely to need something similar but highly customized.
    """
    import topo
    from topo.command.analysis import save_plotgroup
    from topo.base.projection import ProjectionSheet
    from topo.sheet.basic import GeneratorSheet
    exec "from topo.analysis.vision import analyze_complexity" in __main__.__dict__
    from param import normalize_path

    topo.sim["V1Simple"].measure_maps = True
    topo.sim["V1Complex"].measure_maps = True
    topo.sim["V2"].measure_maps = True
    
    topo.sim["V2"].in_connections[0].strength=4
    
    save_plotgroup("Orientation Preference and Complexity")    

    # Plot all projections for all measured_sheets
    measured_sheets = [s for s in topo.sim.objects(ProjectionSheet).values()
                       if hasattr(s,'measure_maps') and s.measure_maps]
    for s in measured_sheets:
        for p in s.projections().values():
            save_plotgroup("Projection",projection=p)

    save_plotgroup("Activity")
#    topo.sim["V1Simple"].measure_maps = False
#    topo.sim["V1Complex"].measure_maps = False
        
    save_plotgroup("Corner OR Preference")
    from topo.command.basic import save_snapshot
def t_function():
    """
    Basic example of an analysis command for run_batch; users are
    likely to need something similar but highly customized.
    """
    print 'Called complex_analysis_function'
    import topo
    from topo.command.analysis import save_plotgroup
    from topo.base.projection import ProjectionSheet
    from topo.sheet import GeneratorSheet
    from topo.analysis.featureresponses import SinusoidalMeasureResponseCommand,FeatureCurveCommand
    import contrib.jacommands
    exec "from topo.analysis.vision import analyze_complexity" in __main__.__dict__
    
    print 'Analysing'
    
    import matplotlib
    matplotlib.rc('xtick', labelsize=17)
    matplotlib.rc('ytick', labelsize=17)					
			
    print 'Build a list of all sheets worth measuring'
    f = lambda x: hasattr(x,'measure_maps') and x.measure_maps
    measured_sheets = filter(f,topo.sim.objects(ProjectionSheet).values())
    input_sheets = topo.sim.objects(GeneratorSheet).values()
							    
    print 'Set potentially reasonable defaults; not necessarily useful'
    topo.command.analysis.coordinate=(0.0,0.0)
    if input_sheets:    topo.command.analysis.input_sheet_name=input_sheets[0].name
    if measured_sheets: topo.command.analysis.sheet_name=measured_sheets[0].name
    
    FeatureCurveCommand.curve_parameters=[{"contrast":30},{"contrast":50},{"contrast":70},{"contrast":90}]
    
    import numpy
    # reset treshold and desable noise before measuring maps
    #m = numpy.mean(topo.sim["V1Simple"].output_fns[2].t)
    #topo.sim["V1Simple"].output_fns[2].t*=0
    #topo.sim["V1Simple"].output_fns[2].t+=m
    #sc = topo.sim["V1Simple"].output_fns[1].generator.scale
    #topo.sim["V1Simple"].output_fns[1].generator.scale=0.0
    #save_plotgroup("Orientation Preference and Complexity")
    save_plotgroup("Orientation Preference")
Example #5
0
def default_analysis_function():
    """
    Basic example of an analysis command for run_batch; users are
    likely to need something similar but highly customized.
    """
    # CEBALERT: why are these imports here rather than at the top?
    import topo
    from topo.command.analysis import save_plotgroup

    # Save all plotgroups listed in default_analysis_plotgroups
    for pg in default_analysis_plotgroups:
        save_plotgroup(pg,use_cached_results=True)

    # Plot projections from each measured map
    measured_sheets = [s for s in topo.sim.objects(ProjectionSheet).values()
                       if hasattr(s,'measure_maps') and s.measure_maps]
    for s in measured_sheets:
        for p in s.in_connections:
            save_plotgroup("Projection",projection=p)

    # Test response to a standardized pattern
    from topo.pattern import Gaussian
    from math import pi
    pattern_present(inputs=Gaussian(orientation=pi/4,aspect_ratio=4.7))
    save_plotgroup("Activity",saver_params={"filename_suffix":"_45d"})
    def analyse(self, steps=[], ns=10, offset_x=0, offset_y=0):

        save_plotgroup("Orientation Preference and Complexity")

        # save_plotgroup("Position Preference")
        for (x, y) in steps:
            xindex = self.center_r + offset_x + x
            yindex = self.center_c + offset_y + y
            xcoor, ycoor = self.sheet.matrixidx2sheet(xindex, yindex)
            c = topo.command.pylabplot.measure_size_response.instance(
                sheet=self.sheet, num_phase=8, num_sizes=ns, max_size=3.0, coords=[(xcoor, ycoor)]
            )
            c.duraton = 4.0
            c(coords=[(xcoor, ycoor)], frequencies=[__main__.__dict__.get("FREQ", 2.4)])

            self.data_dict[(xindex, yindex)] = {}
            self.data_dict[(xindex, yindex)]["ST"] = self.calculate_RF_sizes(xindex, yindex)
            self.plot_size_tunning(xindex, yindex)

            self.data_dict[(xindex, yindex)]["OCT"] = self.perform_orientation_contrast_analysis(
                self.data_dict[(xindex, yindex)]["ST"], xcoor, ycoor, xindex, yindex
            )
            self.plot_orientation_contrast_tuning(xindex, yindex)
            self.plot_orientation_contrast_tuning_abs(xindex, yindex)

            # f = open(normalize_path("dict.dat"),'wb')
        # import pickle
        # pickle.dump(self.data_dict,f)
        # f.close()

        self.plot_histograms_of_measures()
        lhi = compute_local_homogeneity_index(self.sheet.sheet_views["OrientationPreference"].view()[0] * pi, 0.5)
        self.plot_map_feature_to_surround_modulation_feature_correlations(lhi, "Local Homogeneity Index")
        self.plot_map_feature_to_surround_modulation_feature_correlations(
            self.sheet.sheet_views["OrientationSelectivity"].view()[0], "OrientationSelectivity"
        )
        self.plot_map_feature_to_surround_modulation_feature_correlations(
            self.sheet.sheet_views["OrientationPreference"].view()[0] * numpy.pi, "OrientationPreference"
        )
def sa():
    import topo
    from topo.command.analysis import save_plotgroup
    from param import normalize_path
    import contrib.jacommands
    import contrib.surround_analysis_new_cleaned
    from topo.analysis.featureresponses import SinusoidalMeasureResponseCommand,FeatureCurveCommand
    reload(contrib.surround_analysis_new_cleaned)
    s =  normalize_path.prefix
    exec "from topo.analysis.vision import analyze_complexity" in __main__.__dict__
    from topo.analysis.featureresponses import FeatureResponses , PatternPresenter, FeatureMaps
    PatternPresenter.duration=4.0
    normalize_path.prefix = s
    SinusoidalMeasureResponseCommand.scale=__main__.__dict__.get("analysis_scale",1.0)
    SinusoidalMeasureResponseCommand.frequencies=[2.4]
    
    if __main__.__dict__.get("Max",False):
	    from topo.misc.distribution import DSF_MaxValue
	    preference_fn=DSF_MaxValue(value_scale=(0., 1./numpy.pi),selectivity_scale=(0.,17.0))
	    topo.command.pylabplot.measure_or_tuning_fullfield.instance(sheet=topo.sim["V1Complex"],preference_fn=preference_fn)()
    else:        
	    save_plotgroup("Orientation Preference and Complexity")
    
    contrib.surround_analysis_new_cleaned.surround_analysis("V1Complex").run_lhi_informed_analysis(max_curves=__main__.__dict__.get("max_curves",20),center_size=__main__.__dict__.get("center_size",20),index=__main__.__dict__.get("index",0))
def push_pull_analysis_function():
    print 'Push pull complex_analysis_function'
    import topo
    import numpy
    from topo.command.analysis import save_plotgroup
    from topo.base.projection import ProjectionSheet
    from topo.sheet import GeneratorSheet
    from topo.analysis.featureresponses import SinusoidalMeasureResponseCommand,FeatureCurveCommand
    import contrib.jacommands
    from contrib.push_pull.CCLISSOM_push_pull_extra import check_RF_corrleation_vs_connection_weights_correlation
    from param import normalize_path
    exec "from topo.analysis.vision import analyze_complexity" in __main__.__dict__

    SinusoidalMeasureResponseCommand.frequencies=[2.4]
    SinusoidalMeasureResponseCommand.scale=__main__.__dict__.get("analysis_scale",1.0)
    
    print 'Analysing'
    
    import matplotlib
    matplotlib.rc('xtick', labelsize=17)
    matplotlib.rc('ytick', labelsize=17)					
			
    print 'Build a list of all sheets worth measuring'
    f = lambda x: hasattr(x,'measure_maps') and x.measure_maps
    measured_sheets = filter(f,topo.sim.objects(ProjectionSheet).values())
    input_sheets = topo.sim.objects(GeneratorSheet).values()
							    
    print 'Set potentially reasonable defaults; not necessarily useful'
    topo.command.analysis.coordinate=(0.0,0.0)
    if input_sheets:    topo.command.analysis.input_sheet_name=input_sheets[0].name
    if measured_sheets: topo.command.analysis.sheet_name=measured_sheets[0].name
    
    FeatureCurveCommand.curve_parameters=[{"contrast":30},{"contrast":50},{"contrast":70},{"contrast":90}]
    
    save_plotgroup("Orientation Preference and Complexity")
    save_plotgroup("Activity",normalize="Individually")

									
    # Plot all projections for all measured_sheets
    for s in measured_sheets:
        for p in s.projections().values():
            save_plotgroup("Projection",projection=p,density=3.0)

    print 'Starting push pull analysis'	
    #analyse_push_pull_connectivity()
    check_RF_corrleation_vs_connection_weights_correlation()
    print 'Finished push pull analysis'
    return
    if(float(topo.sim.time()) >= 10005.0): 
        print 'Measuring orientations'
        SinusoidalMeasureResponseCommand.frequencies=[2.4]
        topo.command.pylabplot.measure_or_tuning_fullfield.instance(sheet=topo.sim["V1Simple"])()
        topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0]",sheet=topo.sim["V1Simple"],coords=[(0,0)])()
        topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.1,0.1]",sheet=topo.sim["V1Simple"],coords=[(0.1,0.1)])()
        topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.1,-0.1]",sheet=topo.sim["V1Simple"],coords=[(0.1,-0.1)])()
Example #9
0
def complex_analysis_function():
    """
    Analysis command for run_batch; Saves maps of orientation preference and analyzes complex cells
    using Modulation Ratio, Circular Variance and Orientation Bandwidth. Additionally, it saves projection
    plots.
    """
    import topo
    from topo.command.analysis import save_plotgroup
    from topo.base.projection import ProjectionSheet

    save_plotgroup("Orientation Preference, Modulation Ratio, Circular Variance and Orientation Bandwidth")
    save_plotgroup("Activity")

    # Plot all projections for all measured_sheets
    measured_sheets = [s for s in topo.sim.objects(ProjectionSheet).values()
                       if hasattr(s,'measure_maps') and s.measure_maps]
    for s in measured_sheets:
        for p in s.projections().values():
            save_plotgroup("Projection",projection=p)
Example #10
0
def rf_analysis():
    import topo
    import pylab
    import topo.analysis.vision
    import contrib.jacommands
    from topo.command.analysis import save_plotgroup
    from topo.base.projection import ProjectionSheet
    from topo.sheet.basic import GeneratorSheet
    from topo.command.analysis import measure_or_tuning_fullfield, measure_or_pref
    from topo.command.pylabplots import cyclic_tuning_curve
    from param import normalize_path    
    
    if(float(topo.sim.time()) <=20010): 
        save_plotgroup("Orientation Preference")
        save_plotgroup("Activity")
    
        # Plot all projections for all measured_sheets
        measured_sheets = [s for s in topo.sim.objects(ProjectionSheet).values()
                           if hasattr(s,'measure_maps') and s.measure_maps]
        for s in measured_sheets:
            for p in s.projections().values():
                save_plotgroup("Projection",projection=p)

        prefix="WithGC"   
        measure_or_tuning_fullfield()
        s=topo.sim["V1"]
        cyclic_tuning_curve(filename_suffix=prefix,filename="OrientationTC:V1:[0,0]",sheet=s,coords=[(0,0)],x_axis="orientation")
        cyclic_tuning_curve(filename_suffix=prefix,filename="OrientationTC:V1:[0.1,0.1]",sheet=s,coords=[(0.1,0.1)],x_axis="orientation")
        cyclic_tuning_curve(filename_suffix=prefix,filename="OrientationTC:V1:[-0.1,-0.1]",sheet=s,coords=[(-0.1,-0.1)],x_axis="orientation")
        cyclic_tuning_curve(filename_suffix=prefix,filename="OrientationTC:V1:[0.1,-0.1]",sheet=s,coords=[(0.1,-0.1)],x_axis="orientation")
        cyclic_tuning_curve(filename_suffix=prefix,filename="OrientationTC:V1:[-0.1,0.1]",sheet=s,coords=[(-0.1,0.1)],x_axis="orientation")
    else:
        topo.command.basic.activity_history = numpy.concatenate((contrib.jacommands.activity_history,topo.sim["V1"].activity.flatten()),axis=1)    

    if(float(topo.sim.time()) == 20000): 
        topo.sim["V1"].plastic=False
        contrib.jacommands.homeostatic_analysis_function()

    if(float(topo.sim.time()) == 20001): 
        pylab.figure()
 def test_cf_saving(self):
     save_plotgroup("Connection Fields", sheet=self.sim["B"])
     self.exists("testplotfilesaver_000000.00_Afferent_(from_A).png")
 def test_cfprojection_saving(self):
     save_plotgroup("Projection", projection=self.sim["B"].projections("Afferent"))
     self.exists("testplotfilesaver_000000.00_B_Afferent.png")
 def test_activity_saving(self):
     save_plotgroup("Activity")
     self.exists("testplotfilesaver_000000.00_A_Activity.png")
     self.exists("testplotfilesaver_000000.00_B_Activity.png")
 def test_orientation_preference_saving(self):
     save_plotgroup("Orientation Preference")
     self.exists("testplotfilesaver_000000.00_B_Orientation_Preference.png")
     self.exists("testplotfilesaver_000000.00_B_Orientation_PreferenceAndSelectivity.png")
     self.exists("testplotfilesaver_000000.00_B_Orientation_Selectivity.png")
     self.exists("testplotfilesaver_000000.00__Color_Key.png")
Example #15
0
def OR_plotgroup(times=None, **kwargs): 
    from topo.command.analysis import save_plotgroup
    save_plotgroup("Orientation Preference",use_cached_results=True)
Example #16
0
def activity_plotgroup(times=None, **kwargs): 
    from topo.command.analysis import save_plotgroup
    save_plotgroup("Activity")
def figure4():
    dirr = '/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_EI_II_LONGE'
    rhos = {}
    
    X = []
    Y = []
    qual = []

    if False:
        for a in os.listdir(dirr):
            b = os.path.join(dirr,a);

            if not stat.S_ISDIR(os.stat(b).st_mode):
                continue

            # load result file 
            f = open(os.path.join(b,'results.pickle'))
            d = pickle.load(f)
            
            # lets find out the pinwheel density
            
            X.append(abs(d['exc_inh_strength']))
            Y.append(abs(d['exc_short_long_ratio']))
	    
	    mmap = d['orprefmap'][2:-3,2:-3]

            rho = pinwheel_analysis(mmap)['metadata']['rho']
            metric = gamma_metric(rho,k=10.0)
            sel = numpy.mean(numpy.mean(mmap))
            print a, " ", str(rho) , " " , str(metric) , "SEL ", str(sel)

            qual.append(metric)
	
	print X
	print Y
	print qual
	pylab.figure()
	pylab.scatter(Y,X,s=numpy.array(qual)*50.0)

        data = np.histogram2d(Y, X, bins=[len(np.unique(Y)),len(np.unique(X))], weights=qual)
        pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
	ax = plt.gca()
	im = pylab.imshow(data[0],interpolation='none',cmap='gray')#,vmin=0.3)
        pylab.yticks([0,len(np.unique(Y))-1],[data[1][0],data[1][-1]])
        pylab.xticks([0,len(np.unique(X))-1],[data[2][0],data[2][-1]])
	divider = make_axes_locatable(ax)
	cax = divider.append_axes("right", size="5%", pad=0.05)
        pylab.colorbar(im,cax=cax)
        pylab.savefig('figure4.png',dpi=600)
    
    if True:
        plot_ortcs('/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_EI_II_LONGE/a-p_exc_strength=9_-p_exc_inh_strength=9.7_-p_exc_short_long_ratio=0.3_-p_cortex_exc_target_activity=0.003/snapshot.typ',"fig4_1_")
        plot_ortcs('/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_EI_II_LONGE/a-p_exc_strength=9_-p_exc_inh_strength=10.6_-p_exc_short_long_ratio=0.5_-p_cortex_exc_target_activity=0.003/snapshot.typ',"fig4_2_")
        plot_ortcs('/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_EI_II_LONGE/a-p_exc_strength=9_-p_exc_inh_strength=9.4_-p_exc_short_long_ratio=0.6_-p_cortex_exc_target_activity=0.003/snapshot.typ',"fig4_3_")
        plot_ortcs('/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_EI_II_LONGE/a-p_exc_strength=9_-p_exc_inh_strength=10.6_-p_exc_short_long_ratio=0.8_-p_cortex_exc_target_activity=0.003/snapshot.typ',"fig4_4_")

    
    if False:

       fname= '/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_EI_II_LONGE/a-p_exc_strength=9_-p_exc_inh_strength=9.7_-p_exc_short_long_ratio=0.3_-p_cortex_exc_target_activity=0.003'
       f = open(fname+'/results.pickle') 
       d = pickle.load(f)
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(d['orprefmap'][0:-1,0:-1],interpolation='none',cmap='hsv',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure3/generated_data/or_map1.png',  pad_inches=0)
       
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(power_spectrum(d['orprefmap'][0:-1,0:-1]),interpolation='none',cmap='gray',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure3/generated_data/fft_map1.png',  pad_inches=0)
              
       load_snapshot(fname+'/snapshot.typ')
       save_plotgroup("Projection",projection=topo.sim["V1"].projections().values()[2],density=6.0,saver_params={'filename_prefix' : '1'})

       fname= '/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_EI_II_LONGE/a-p_exc_strength=9_-p_exc_inh_strength=10.6_-p_exc_short_long_ratio=0.5_-p_cortex_exc_target_activity=0.003'
       f = open(fname+'/results.pickle') 
       d = pickle.load(f)
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(d['orprefmap'][0:-1,0:-1],interpolation='none',cmap='hsv',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure3/generated_data/or_map2.png',  pad_inches=0)
       
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(power_spectrum(d['orprefmap'][0:-1,0:-1]),interpolation='none',cmap='gray',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure3/generated_data/fft_map2.png',  pad_inches=0)
              
       load_snapshot(fname+'/snapshot.typ')
       save_plotgroup("Projection",projection=topo.sim["V1"].projections().values()[2],density=6.0,saver_params={'filename_prefix' : '2'})
    
       fname= '/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_EI_II_LONGE/a-p_exc_strength=9_-p_exc_inh_strength=9.4_-p_exc_short_long_ratio=0.6_-p_cortex_exc_target_activity=0.003'
       f = open(fname+'/results.pickle') 
       d = pickle.load(f)
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(d['orprefmap'][0:-1,0:-1],interpolation='none',cmap='hsv',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure3/generated_data/or_map3.png',  pad_inches=0)
       
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(power_spectrum(d['orprefmap'][0:-1,0:-1]),interpolation='none',cmap='gray',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure3/generated_data/fft_map3.png',  pad_inches=0)
              
       load_snapshot(fname+'/snapshot.typ')
       save_plotgroup("Projection",projection=topo.sim["V1"].projections().values()[2],density=6.0,saver_params={'filename_prefix' : '3'})

       fname= '/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_EI_II_LONGE/a-p_exc_strength=9_-p_exc_inh_strength=10.6_-p_exc_short_long_ratio=0.8_-p_cortex_exc_target_activity=0.003'
       f = open(fname+'/results.pickle') 
       d = pickle.load(f)
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(d['orprefmap'][0:-1,0:-1],interpolation='none',cmap='hsv',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure3/generated_data/or_map4.png',  pad_inches=0)
       
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(power_spectrum(d['orprefmap'][0:-1,0:-1]),interpolation='none',cmap='gray',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure3/generated_data/fft_map4.png',  pad_inches=0)
              
       load_snapshot(fname+'/snapshot.typ')
       save_plotgroup("Projection",projection=topo.sim["V1"].projections().values()[2],density=6.0,saver_params={'filename_prefix' : '4'})
def figure2():
    dirr = '/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_SHORTRANGE'
    rhos = {}
    
    X = []
    Y = []
    qual = []
    
    if False:
        for a in os.listdir(dirr):
            b = os.path.join(dirr,a);

            if not stat.S_ISDIR(os.stat(b).st_mode):
                continue

            # load result file 
            f = open(os.path.join(b,'results.pickle'))
            d = pickle.load(f)
            
            # lets find out the pinwheel density
            
            X.append(d['lat_strength_ratio'])
            Y.append(d['exc_inh_ratio'])

	    #mmap = d['orprefmap'][25:-24,25:-24]
	    mmap = d['orprefmap'][2:-3,2:-3]
	    
            rho = pinwheel_analysis(mmap)['metadata']['rho']
            metric = gamma_metric(rho,k=10.0)
            sel = numpy.mean(numpy.mean(mmap))
            print a, " ", str(rho) , " " , str(metric) , "SEL ", str(sel)

            qual.append(metric)
            
        data = np.histogram2d(Y, X, bins=[len(np.unique(Y)),len(np.unique(X))], weights=qual)
        pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
        im = pylab.imshow(data[0],interpolation='none',cmap='gray')#,vmin=0.3)
        pylab.colorbar(im,fraction=0.046, pad=0.04)
        pylab.yticks([0,len(np.unique(Y))-1],[data[1][0],data[1][-1]])
        pylab.xticks([0,len(np.unique(X))-1],[data[2][0],data[2][-1]])
        pylab.savefig('figure2.png',dpi=600)
    
    if True:
        plot_ortcs('/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_SHORTRANGE/lat_strength_ratio=2.2_exc_inh_ratio=0.85/snapshot.typ',"fig2_1_")
        plot_ortcs('/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_SHORTRANGE/lat_strength_ratio=2.6_exc_inh_ratio=0.8/snapshot.typ',"fig2_2_")
        plot_ortcs('/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_SHORTRANGE/lat_strength_ratio=2.8_exc_inh_ratio=0.65/snapshot.typ',"fig2_3_")

    if False:
       f = open('/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_SHORTRANGE/lat_strength_ratio=2.2_exc_inh_ratio=0.85/results.pickle') 
       d = pickle.load(f)
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(d['orprefmap'][61:-60,61:-60],interpolation='none',cmap='hsv',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure1/generated_data/or_map3.png',  pad_inches=0)
       
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(power_spectrum(d['orprefmap'][61:-60,61:-60]),interpolation='none',cmap='gray',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure1/generated_data/fft_map3.png',  pad_inches=0)
              
       load_snapshot('/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_SHORTRANGE/lat_strength_ratio=2.2_exc_inh_ratio=0.85/snapshot.typ')
       save_plotgroup("Projection",projection=topo.sim["V1"].projections().values()[0],density=1.5,saver_params={'filename_prefix' : '3'})
       
       f = open('/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_SHORTRANGE/lat_strength_ratio=2.6_exc_inh_ratio=0.8/results.pickle') 
       d = pickle.load(f)
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(d['orprefmap'][61:-60,61:-60],interpolation='none',cmap='hsv',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure1/generated_data/or_map2.png',  pad_inches=0)
       
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(power_spectrum(d['orprefmap'][61:-60,61:-60]),interpolation='none',cmap='gray',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure1/generated_data/fft_map2.png',  pad_inches=0)


       load_snapshot('/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_SHORTRANGE/lat_strength_ratio=2.6_exc_inh_ratio=0.8/snapshot.typ')
       save_plotgroup("Projection",projection=topo.sim["V1"].projections().values()[0],density=1.5,saver_params={'filename_prefix' : '2'})
       
       f = open('/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_SHORTRANGE/lat_strength_ratio=2.8_exc_inh_ratio=0.65/results.pickle') 
       d = pickle.load(f)
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(d['orprefmap'][61:-60,61:-60],interpolation='none',cmap='hsv',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure1/generated_data/or_map1.png',  pad_inches=0)
       
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(power_spectrum(d['orprefmap'][61:-60,61:-60]),interpolation='none',cmap='gray',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure1/generated_data/fft_map1.png',  pad_inches=0)
     
       load_snapshot('/home/jan/Doc/Papers/fast_inh_paper/DATA/GCAL_SHORTRANGE/lat_strength_ratio=2.8_exc_inh_ratio=0.65/results.pickle')
       save_plotgroup("Projection",projection=topo.sim["V1"].projections().values()[0],density=1.5,saver_params={'filename_prefix' : '1'})

    if False:
       load_snapshot('/home/jan/projects/topographica/GCAL_EI/a-p_exc_strength=3.3_-p_inh_strength=2.805/snapshot.typ')
       mmap = topo.sim["V1"].sheet_views["OrientationPreference"].view()[0]

       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(mmap[61:-60,61:-60],interpolation='none',cmap='hsv',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure1/generated_data/or_map4.png',  pad_inches=0)
       
       fig = pylab.figure(dpi=600,facecolor='w',figsize=(5,5))
       ax = plt.Axes(fig, [0., 0., 1., 1.])
       ax.set_axis_off()
       fig.add_axes(ax)
       ax.imshow(power_spectrum(mmap[61:-60,61:-60]),interpolation='none',cmap='gray',aspect='normal')
       pylab.savefig('/home/jan/Doc/Papers/fast_inh_paper/SVG/Figure1/generated_data/fft_map4.png',  pad_inches=0)
     
       
       save_plotgroup("Projection",projection=topo.sim["V1"].projections().values()[0],density=1.5,saver_params={'filename_prefix' : '4'})
Example #19
0
def gc_homeo_af():
    import contrib.jsldefs
    import topo.command.pylabplots
    import contrib.jacommands
    from topo.command.analysis import save_plotgroup
    from topo.analysis.featureresponses import FeatureResponses , PatternPresenter, FeatureMaps            
    #FeatureResponses.repetitions=10

    FeatureMaps.selectivity_multiplier=20

    PatternPresenter.duration=0.2
    PatternPresenter.apply_output_fns=False
    import topo.command.pylabplots
    reload(topo.command.pylabplots)

    
    on = topo.sim["LGNOn"].in_connections[0].strength
    off = topo.sim["LGNOff"].in_connections[0].strength
    if __main__.__dict__.get("GC",False):
       topo.sim["LGNOn"].in_connections[0].strength=0
       topo.sim["LGNOff"].in_connections[0].strength=0
    
    contrib.jsldefs.homeostatic_analysis_function()
    topo.command.pylabplots.fftplot(topo.sim["V1"].sheet_views["OrientationPreference"].view()[0],filename="V1ORMAPFFT")
    
    from topo.misc.filepath import normalize_path, application_path    
    from scipy.io import write_array
    import numpy
    write_array(normalize_path(str(topo.sim.time())+"orprefmap.txt"), topo.sim["V1"].sheet_views["OrientationPreference"].view()[0])
    write_array(normalize_path(str(topo.sim.time())+"orselmap.txt"), topo.sim["V1"].sheet_views["OrientationSelectivity"].view()[0])
    topo.sim["LGNOn"].in_connections[0].strength = on
    topo.sim["LGNOff"].in_connections[0].strength = off

    print float(topo.sim.time())
    if(float(topo.sim.time()) > 19002.0): 
	#topo.sim["V1"].output_fns[2].scale=0.0
	save_plotgroup("Position Preference")
	PatternPresenter.duration=1.0
        PatternPresenter.apply_output_fns=True
	import topo.command.pylabplots
        reload(topo.command.pylabplots)
        topo.command.pylabplots.measure_or_tuning_fullfield.instance(sheet=topo.sim["V1"],repetitions=10)(repetitions=10)
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0]",sheet=topo.sim["V1"],coords=[(0,0)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0]",sheet=topo.sim["V1"],coords=[(0.1,0)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0]",sheet=topo.sim["V1"],coords=[(0.1,0.1)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0]",sheet=topo.sim["V1"],coords=[(0,0.1)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.1,0.1]",sheet=topo.sim["V1"],coords=[(0.1,0.1)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.1,-0.1]",sheet=topo.sim["V1"],coords=[(0.1,-0.1)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.1,0.1]",sheet=topo.sim["V1"],coords=[(-0.1,0.1)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.1,-0.1]",sheet=topo.sim["V1"],coords=[(-0.1,-0.1)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.2,0.2]",sheet=topo.sim["V1"],coords=[(0.2,0.2)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.2,-0.2]",sheet=topo.sim["V1"],coords=[(0.2,-0.2)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.2,0.2]",sheet=topo.sim["V1"],coords=[(-0.2,0.2)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.2,-0.2]",sheet=topo.sim["V1"],coords=[(-0.2,-0.2)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0.1]",sheet=topo.sim["V1"],coords=[(0.0,0.1)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,-0.1]",sheet=topo.sim["V1"],coords=[(0.0,-0.1)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.1,0]",sheet=topo.sim["V1"],coords=[(-0.1,0.0)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.1,0]",sheet=topo.sim["V1"],coords=[(0.1,-0.0)])()

    if(float(topo.sim.time()) > 20000.0): 
        topo.sim["V1"].output_fns[1].plastic=False
        contrib.jacommands.measure_histogram(iterations=1000) 	
def complex_surround_analysis_function():

    """
    Basic example of an analysis command for run_batch; users are
    likely to need something similar but highly customized.
    """
    import topo
    from topo.command.analysis import save_plotgroup
    from topo.analysis.featureresponses import SinusoidalMeasureResponseCommand,FeatureCurveCommand
    from topo.base.projection import ProjectionSheet
    from topo.sheet import GeneratorSheet
    from topo.command import save_snapshot
    from param import normalize_path
    import contrib.jacommands
    import contrib.surround_analysis_new_cleaned
    exec "from topo.analysis.vision import analyze_complexity" in __main__.__dict__

    import matplotlib
    matplotlib.rc('xtick', labelsize=17)
    matplotlib.rc('ytick', labelsize=17)					
					
    SinusoidalMeasureResponseCommand.frequencies=[2.4]    
    SinusoidalMeasureResponseCommand.scale=__main__.__dict__.get("analysis_scale",0.3)
    from topo.analysis.featureresponses import PatternPresenter            
    PatternPresenter.duration=4.0
    import topo.command.pylabplot
    reload(topo.command.pylabplot)

    # Build a list of all sheets worth measuring
    f = lambda x: hasattr(x,'measure_maps') and x.measure_maps
    measured_sheets = filter(f,topo.sim.objects(ProjectionSheet).values())
    input_sheets = topo.sim.objects(GeneratorSheet).values()
    # Set potentially reasonable defaults; not necessarily useful
    topo.command.analysis.coordinate=(0.0,0.0)
    if input_sheets:    topo.command.analysis.input_sheet_name=input_sheets[0].name
    if measured_sheets: topo.command.analysis.sheet_name=measured_sheets[0].name
    save_plotgroup("Orientation Preference and Complexity")
    save_plotgroup("Activity",normalize='Individually')
    # Plot all projections for all measured_sheets
    for s in measured_sheets:
        for p in s.projections().values():
            save_plotgroup("Projection",projection=p)

    if(float(topo.sim.time()) > 6020.0):
        if __main__.__dict__.get("save",False):
                save_snapshot(normalize_path('snapshot.typ'))

 
        #contrib.surround_analysis.run_dynamics_analysis(0.0,0.0,0.7,__main__.__dict__.get("analysis_scale",0.3))
        #topo.command.pylabplot.measure_or_tuning_fullfield.instance(sheet=topo.sim["V1Complex"])()
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0]",sheet=topo.sim["V1Complex"],coords=[(0,0)])()
	#topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.1,0.1]",sheet=topo.sim["V1Complex"],coords=[(0.1,0.1)])()
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.1,-0.1]",sheet=topo.sim["V1Complex"],coords=[(0.1,-0.1)])()
	#topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.1,0.1]",sheet=topo.sim["V1Complex"],coords=[(-0.1,0.1)])()    
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.1,-0.1]",sheet=topo.sim["V1Complex"],coords=[(-0.1,-0.1)])()
	#topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.2,0.2]",sheet=topo.sim["V1Complex"],coords=[(0.2,0.2)])()
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.2,-0.2]",sheet=topo.sim["V1Complex"],coords=[(0.2,-0.2)])()
	#topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.2,0.2]",sheet=topo.sim["V1Complex"],coords=[(-0.2,0.2)])()    
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.2,-0.2]",sheet=topo.sim["V1Complex"],coords=[(-0.2,-0.2)])()
	#topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0.1]",sheet=topo.sim["V1Complex"],coords=[(0.0,0.1)])()
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,-0.1]",sheet=topo.sim["V1Complex"],coords=[(0.0,-0.1)])()
	#topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.1,0]",sheet=topo.sim["V1Complex"],coords=[(-0.1,0.0)])()    
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.1,0]",sheet=topo.sim["V1Complex"],coords=[(0.1,-0.0)])()
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.3,0.3]",sheet=topo.sim["V1Complex"],coords=[(0.3,0.3)])()
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.3,-0.3]",sheet=topo.sim["V1Complex"],coords=[(0.3,-0.3)])()
	#topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.3,0.3]",sheet=topo.sim["V1Complex"],coords=[(-0.3,0.3)])()    
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.3,-0.3]",sheet=topo.sim["V1Complex"],coords=[(-0.3,-0.3)])()
	#topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.24,0.24]",sheet=topo.sim["V1Complex"],coords=[(0.24,0.24)])()
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.24,-0.24]",sheet=topo.sim["V1Complex"],coords=[(0.24,-0.24)])()
	#topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.24,0.24]",sheet=topo.sim["V1Complex"],coords=[(-0.24,0.42)])()    
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.24,-0.24]",sheet=topo.sim["V1Complex"],coords=[(-0.24,-0.24)])()
	#topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0.24]",sheet=topo.sim["V1Complex"],coords=[(0.0,0.24)])()
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,-0.24]",sheet=topo.sim["V1Complex"],coords=[(0.0,-0.42)])()
	#topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.24,0]",sheet=topo.sim["V1Complex"],coords=[(-0.24,0.0)])()    
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.24,0]",sheet=topo.sim["V1Complex"],coords=[(0.24,-0.0)])()
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0.3]",sheet=topo.sim["V1Complex"],coords=[(0.0,0.3)])()
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,-0.3]",sheet=topo.sim["V1Complex"],coords=[(0.0,-0.3)])()
	#topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.3,0]",sheet=topo.sim["V1Complex"],coords=[(-0.3,0.0)])()    
        #topo.command.pylabplot.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.3,0]",sheet=topo.sim["V1Complex"],coords=[(0.3,-0.0)])()
	
	#contrib.surround_analysis_new_cleaned.surround_analysis("V1Complex").run_analysis_with_step_grid(4,4,max_curves=__main__.__dict__.get("max_curves",20))
	contrib.surround_analysis_new_cleaned.surround_analysis("V1Complex").run_lhi_informed_analysis(max_curves=__main__.__dict__.get("max_curves",20),center_size=__main__.__dict__.get("center_size",20))
Example #21
0
def complex_surround_analysis_function():

    """
    Basic example of an analysis command for run_batch; users are
    likely to need something similar but highly customized.
    """
    import topo
    from topo.command.analysis import save_plotgroup
    from topo.analysis.featureresponses import SinusoidalMeasureResponseCommand,FeatureCurveCommand
    from topo.base.projection import ProjectionSheet
    from topo.sheet.basic import GeneratorSheet
    import contrib.jacommands
    import contrib.surround_analysis
    exec "from topo.analysis.vision import analyze_complexity" in __main__.__dict__

    import matplotlib
    matplotlib.rc('xtick', labelsize=17)
    matplotlib.rc('ytick', labelsize=17)					
					
			
    SinusoidalMeasureResponseCommand.frequencies=[3.0]    
    SinusoidalMeasureResponseCommand.scale=__main__.__dict__.get("analysis_scale",0.3)
    from topo.analysis.featureresponses import PatternPresenter            
    PatternPresenter.duration=2.0
    import topo.command.pylabplots
    reload(topo.command.pylabplots)

    # Build a list of all sheets worth measuring
    f = lambda x: hasattr(x,'measure_maps') and x.measure_maps
    measured_sheets = filter(f,topo.sim.objects(ProjectionSheet).values())
    input_sheets = topo.sim.objects(GeneratorSheet).values()
							    
    # Set potentially reasonable defaults; not necessarily useful
    topo.command.analysis.coordinate=(0.0,0.0)
    if input_sheets:    topo.command.analysis.input_sheet_name=input_sheets[0].name
    if measured_sheets: topo.command.analysis.sheet_name=measured_sheets[0].name
									    
    save_plotgroup("Orientation Preference and Complexity")
    save_plotgroup("Activity",normalize=True)
										
    # Plot all projections for all measured_sheets
    for s in measured_sheets:
        for p in s.projections().values():
            save_plotgroup("Projection",projection=p)
    

    if(float(topo.sim.time()) > 6020.0): 
        contrib.surround_analysis.run_dynamics_analysis(0.0,0.0,0.7,__main__.__dict__.get("analysis_scale",0.3))
        topo.command.pylabplots.measure_or_tuning_fullfield.instance(sheet=topo.sim["V1Complex"])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0]",sheet=topo.sim["V1Complex"],coords=[(0,0)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.1,0.1]",sheet=topo.sim["V1Complex"],coords=[(0.1,0.1)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.1,-0.1]",sheet=topo.sim["V1Complex"],coords=[(0.1,-0.1)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.1,0.1]",sheet=topo.sim["V1Complex"],coords=[(-0.1,0.1)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.1,-0.1]",sheet=topo.sim["V1Complex"],coords=[(-0.1,-0.1)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.2,0.2]",sheet=topo.sim["V1Complex"],coords=[(0.2,0.2)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.2,-0.2]",sheet=topo.sim["V1Complex"],coords=[(0.2,-0.2)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.2,0.2]",sheet=topo.sim["V1Complex"],coords=[(-0.2,0.2)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.2,-0.2]",sheet=topo.sim["V1Complex"],coords=[(-0.2,-0.2)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0.1]",sheet=topo.sim["V1Complex"],coords=[(0.0,0.1)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,-0.1]",sheet=topo.sim["V1Complex"],coords=[(0.0,-0.1)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.1,0]",sheet=topo.sim["V1Complex"],coords=[(-0.1,0.0)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.1,0]",sheet=topo.sim["V1Complex"],coords=[(0.1,-0.0)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.3,0.3]",sheet=topo.sim["V1Complex"],coords=[(0.3,0.3)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.3,-0.3]",sheet=topo.sim["V1Complex"],coords=[(0.3,-0.3)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.3,0.3]",sheet=topo.sim["V1Complex"],coords=[(-0.3,0.3)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.3,-0.3]",sheet=topo.sim["V1Complex"],coords=[(-0.3,-0.3)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.24,0.24]",sheet=topo.sim["V1Complex"],coords=[(0.24,0.24)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.24,-0.24]",sheet=topo.sim["V1Complex"],coords=[(0.24,-0.24)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.24,0.24]",sheet=topo.sim["V1Complex"],coords=[(-0.24,0.42)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.24,-0.24]",sheet=topo.sim["V1Complex"],coords=[(-0.24,-0.24)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0.24]",sheet=topo.sim["V1Complex"],coords=[(0.0,0.24)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,-0.24]",sheet=topo.sim["V1Complex"],coords=[(0.0,-0.42)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.24,0]",sheet=topo.sim["V1Complex"],coords=[(-0.24,0.0)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.24,0]",sheet=topo.sim["V1Complex"],coords=[(0.24,-0.0)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0.3]",sheet=topo.sim["V1Complex"],coords=[(0.0,0.3)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,-0.3]",sheet=topo.sim["V1Complex"],coords=[(0.0,-0.3)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.3,0]",sheet=topo.sim["V1Complex"],coords=[(-0.3,0.0)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.3,0]",sheet=topo.sim["V1Complex"],coords=[(0.3,-0.0)])()

        #topo.command.pylabplots.measure_or_tuning_fullfield.instance(sheet=topo.sim["V1Simple"])()
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0,0]",sheet=topo.sim["V1Simple"],coords=[(0,0)])()
	#topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.1,0.1]",sheet=topo.sim["V1Simple"],coords=[(0.1,0.1)])()
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.1,-0.1]",sheet=topo.sim["V1Simple"],coords=[(0.1,-0.1)])()
	#topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.1,0.1]",sheet=topo.sim["V1Simple"],coords=[(-0.1,0.1)])()    
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.1,-0.1]",sheet=topo.sim["V1Simple"],coords=[(-0.1,-0.1)])()
	#topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.2,0.2]",sheet=topo.sim["V1Simple"],coords=[(0.2,0.2)])()
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.2,-0.2]",sheet=topo.sim["V1Simple"],coords=[(0.2,-0.2)])()
	#topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.2,0.2]",sheet=topo.sim["V1Simple"],coords=[(-0.2,0.2)])()    
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.2,-0.2]",sheet=topo.sim["V1Simple"],coords=[(-0.2,-0.2)])()
	#topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0,0.1]",sheet=topo.sim["V1Simple"],coords=[(0.0,0.1)])()
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0,-0.1]",sheet=topo.sim["V1Simple"],coords=[(0.0,-0.1)])()
	#topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.1,0]",sheet=topo.sim["V1Simple"],coords=[(-0.1,0.0)])()    
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.1,0]",sheet=topo.sim["V1Simple"],coords=[(0.1,-0.0)])()
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.3,0.3]",sheet=topo.sim["V1Simple"],coords=[(0.3,0.3)])()
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.3,-0.3]",sheet=topo.sim["V1Simple"],coords=[(0.3,-0.3)])()
	#topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.3,0.3]",sheet=topo.sim["V1Simple"],coords=[(-0.3,0.3)])()    
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.3,-0.3]",sheet=topo.sim["V1Simple"],coords=[(-0.3,-0.3)])()
	#topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.24,0.24]",sheet=topo.sim["V1Simple"],coords=[(0.24,0.24)])()
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.24,-0.24]",sheet=topo.sim["V1Simple"],coords=[(0.24,-0.24)])()
	#topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.24,0.24]",sheet=topo.sim["V1Simple"],coords=[(-0.24,0.42)])()    
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.24,-0.24]",sheet=topo.sim["V1Simple"],coords=[(-0.24,-0.24)])()
	#topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0,0.24]",sheet=topo.sim["V1Simple"],coords=[(0.0,0.24)])()
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0,-0.24]",sheet=topo.sim["V1Simple"],coords=[(0.0,-0.42)])()
	#topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.24,0]",sheet=topo.sim["V1Simple"],coords=[(-0.24,0.0)])()    
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.24,0]",sheet=topo.sim["V1Simple"],coords=[(0.24,-0.0)])()
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0,0.3]",sheet=topo.sim["V1Simple"],coords=[(0.0,0.3)])()
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0,-0.3]",sheet=topo.sim["V1Simple"],coords=[(0.0,-0.3)])()
	#topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.3,0]",sheet=topo.sim["V1Simple"],coords=[(-0.3,0.0)])()    
        #topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.3,0]",sheet=topo.sim["V1Simple"],coords=[(0.3,-0.0)])()

        contrib.surround_analysis.surround_analysis("V1Complex").analyse([(0,0),(5,0),(-5,0),(0,5),(0,-5),(5,5),(5,-5),(-5,5),(-5,-5),(8,0),(-8,0),(0,8),(0,-8),(8,8),(8,-8),(-8,8),(-8,-8)],15,5)
Example #22
0
def complex_analysis_function():
    """
    Basic example of an analysis command for run_batch; users are
    likely to need something similar but highly customized.
    """
    import topo
    from topo.command.analysis import save_plotgroup
    from topo.base.projection import ProjectionSheet
    from topo.sheet.basic import GeneratorSheet
    from topo.analysis.featureresponses import SinusoidalMeasureResponseCommand,FeatureCurveCommand
    import contrib.jacommands
    exec "from topo.analysis.vision import analyze_complexity" in __main__.__dict__
    
    print 'Analysing'
    
    import matplotlib
    matplotlib.rc('xtick', labelsize=17)
    matplotlib.rc('ytick', labelsize=17)					
			
    # Build a list of all sheets worth measuring
    f = lambda x: hasattr(x,'measure_maps') and x.measure_maps
    measured_sheets = filter(f,topo.sim.objects(ProjectionSheet).values())
    input_sheets = topo.sim.objects(GeneratorSheet).values()
							    
    # Set potentially reasonable defaults; not necessarily useful
    topo.command.analysis.coordinate=(0.0,0.0)
    if input_sheets:    topo.command.analysis.input_sheet_name=input_sheets[0].name
    if measured_sheets: topo.command.analysis.sheet_name=measured_sheets[0].name
    
    FeatureCurveCommand.curve_parameters=[{"contrast":30},{"contrast":50},{"contrast":70},{"contrast":90}]
    
    import numpy
    # reset treshold and desable noise before measuring maps
    #m = numpy.mean(topo.sim["V1Simple"].output_fns[2].t)
    #topo.sim["V1Simple"].output_fns[2].t*=0
    #topo.sim["V1Simple"].output_fns[2].t+=m
    #sc = topo.sim["V1Simple"].output_fns[1].generator.scale
    #topo.sim["V1Simple"].output_fns[1].generator.scale=0.0
    a = topo.sim["V1Complex"].in_connections[0].strength
    
    SinusoidalMeasureResponseCommand.scale=__main__.__dict__.get("analysis_scale",0.35)


    if((float(topo.sim.time()) >= 5003.0) and (float(topo.sim.time()) < 5004.0)): 
	topo.sim["V1Complex"].in_connections[0].strength=0
	SinusoidalMeasureResponseCommand.frequencies=[3.0]

    if((float(topo.sim.time()) >= 5005.0) and (float(topo.sim.time()) < 5006.0)): 
	SinusoidalMeasureResponseCommand.frequencies=[3.0]

    if((float(topo.sim.time()) >= 5006.0) and (float(topo.sim.time()) < 5007.0)): 
    	topo.sim["V1Complex"].in_connections[0].strength=0
	SinusoidalMeasureResponseCommand.frequencies=[2.4]

    if((float(topo.sim.time()) >= 5007.0) and (float(topo.sim.time()) < 5008.0)): 
	SinusoidalMeasureResponseCommand.frequencies=[2.4]



    if((float(topo.sim.time()) >= 10002.0) and (float(topo.sim.time()) < 10003.0)): 
	topo.sim["V1Complex"].in_connections[0].strength=0
	SinusoidalMeasureResponseCommand.frequencies=[2.4]

    if((float(topo.sim.time()) >= 10003.0) and (float(topo.sim.time()) < 10004.0)): 
	topo.sim["V1Complex"].in_connections[0].strength=0
	SinusoidalMeasureResponseCommand.frequencies=[3.0]

    if((float(topo.sim.time()) >= 10004.0) and (float(topo.sim.time()) < 10005.0)): 
	SinusoidalMeasureResponseCommand.frequencies=[2.4]

    if((float(topo.sim.time()) >= 10005.0) and (float(topo.sim.time()) < 10006.0)): 
	SinusoidalMeasureResponseCommand.frequencies=[3.0]


    save_plotgroup("Orientation Preference and Complexity")
    save_plotgroup("Activity")

									
    # Plot all projections for all measured_sheets
    for s in measured_sheets:
        for p in s.projections().values():
            save_plotgroup("Projection",projection=p)

    
    if(float(topo.sim.time()) >= 10005.0): 
        print 'Measuring orientations'
        SinusoidalMeasureResponseCommand.frequencies=[2.4]
        topo.command.pylabplots.measure_or_tuning_fullfield.instance(sheet=topo.sim["V1Complex"])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0]",sheet=topo.sim["V1Complex"],coords=[(0,0)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.1,0.1]",sheet=topo.sim["V1Complex"],coords=[(0.1,0.1)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.1,-0.1]",sheet=topo.sim["V1Complex"],coords=[(0.1,-0.1)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.1,0.1]",sheet=topo.sim["V1Complex"],coords=[(-0.1,0.1)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.1,-0.1]",sheet=topo.sim["V1Complex"],coords=[(-0.1,-0.1)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.2,0.2]",sheet=topo.sim["V1Complex"],coords=[(0.2,0.2)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.2,-0.2]",sheet=topo.sim["V1Complex"],coords=[(0.2,-0.2)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.2,0.2]",sheet=topo.sim["V1Complex"],coords=[(-0.2,0.2)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.2,-0.2]",sheet=topo.sim["V1Complex"],coords=[(-0.2,-0.2)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,0.1]",sheet=topo.sim["V1Complex"],coords=[(0.0,0.1)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0,-0.1]",sheet=topo.sim["V1Complex"],coords=[(0.0,-0.1)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[-0.1,0]",sheet=topo.sim["V1Complex"],coords=[(-0.1,0.0)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="ORTC[0.1,0]",sheet=topo.sim["V1Complex"],coords=[(0.1,-0.0)])()

        topo.command.pylabplots.measure_or_tuning_fullfield.instance(sheet=topo.sim["V1Simple"])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0,0]",sheet=topo.sim["V1Simple"],coords=[(0,0)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.1,0.1]",sheet=topo.sim["V1Simple"],coords=[(0.1,0.1)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.1,-0.1]",sheet=topo.sim["V1Simple"],coords=[(0.1,-0.1)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.1,0.1]",sheet=topo.sim["V1Simple"],coords=[(-0.1,0.1)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.1,-0.1]",sheet=topo.sim["V1Simple"],coords=[(-0.1,-0.1)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.2,0.2]",sheet=topo.sim["V1Simple"],coords=[(0.2,0.2)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.2,-0.2]",sheet=topo.sim["V1Simple"],coords=[(0.2,-0.2)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.2,0.2]",sheet=topo.sim["V1Simple"],coords=[(-0.2,0.2)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.2,-0.2]",sheet=topo.sim["V1Simple"],coords=[(-0.2,-0.2)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0,0.1]",sheet=topo.sim["V1Simple"],coords=[(0.0,0.1)])()
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0,-0.1]",sheet=topo.sim["V1Simple"],coords=[(0.0,-0.1)])()
	topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[-0.1,0]",sheet=topo.sim["V1Simple"],coords=[(-0.1,0.0)])()    
        topo.command.pylabplots.cyclic_tuning_curve.instance(x_axis="orientation",filename="SimpleORTC[0.1,0]",sheet=topo.sim["V1Simple"],coords=[(0.1,-0.0)])()

    #topo.sim["V1Simple"].output_fns[1].generator.scale=sc
    topo.sim["V1Complex"].in_connections[0].strength = a
 def test_cfprojection_saving(self):
     save_plotgroup('Projection',
                    projection=self.sim['B'].projections('Afferent'))
     self.exists("testplotfilesaver_000000.00_B_Afferent.png")