def __call__(self,fullmatrix,simple_sheet_name=None,complex_sheet_name=None,bins=frange(0,2.0,0.1,inclusive=True),**params):
        p=ParamOverrides(self,params)

        from topo.analysis.vision import complexity
        if (topo.sim.objects().has_key(simple_sheet_name) and topo.sim.objects().has_key(complex_sheet_name)):
            v1s = complexity(fullmatrix[topo.sim[simple_sheet_name]]).flatten()
            v1c = complexity(fullmatrix[topo.sim[complex_sheet_name]]).flatten()
            #double the number of complex cells to reflect large width of layer 2/3
            v1c = numpy.concatenate((array(v1c),array(v1c)),axis=1)
            pylab.figure()
            n = pylab.subplot(311)
            pylab.hist(v1s,bins)
            pylab.axis([0,2.0,0,4100])
	    n.yaxis.set_major_locator(matplotlib.ticker.MaxNLocator(3))

	    n = pylab.subplot(312)
            pylab.hist(v1c,bins)
            pylab.axis([0,2.0,0,4100])
	    n.yaxis.set_major_locator(matplotlib.ticker.MaxNLocator(3))

	    n = pylab.subplot(313)
            pylab.hist(numpy.concatenate((array(v1s),array(v1c)),axis=1),bins)
            pylab.axis([0,2.0,0,4100])
	    n.yaxis.set_major_locator(matplotlib.ticker.MaxNLocator(3))

        self._generate_figure(p)
Beispiel #2
0
def test_all_directions(x=0,y=0,scale=0.6):
   results=KeyedList()
##    g=pattern.Gaussian(x=x,y=y,aspect_ratio=4.66667,
##                        size=0.088388,scale=1.0)
   g = pattern.SineGrating(frequency=2.4,phase=0.0,orientation=0,scale=scale)
   inputs = {}
   for j in range(4):
      inputs['Retina%s'%j] = pattern.Sweeper(generator=copy.deepcopy(g),
                                              speed=2.0/24.0)

   for i in frange(0.0, 2.0, 2.0/18.0, inclusive=True): 

      orientation = i*pi+pi/2

      for j in range(4):
         s = inputs['Retina%s'%j] 
         s.step = j
         s.orientation = orientation
      
      pattern_present(inputs=inputs,duration=1.0,
                      plastic=False,
                      overwrite_previous=True,
                      apply_output_fn=True)

      if hasattr(topo,'guimain'):
         topo.guimain.refresh_activity_windows()

      results[i]=decode_feature(topo.sim['V1'],
                                preference_map="DirectionPreference")

   return results
Beispiel #3
0
def test_all_orientations(x=0,y=0):
   results=KeyedList()
   for i in frange(0.0, 1.0, 1.0/36.0, inclusive=True):
       input = pattern.Gaussian(x=x, y=y, orientation=i*pi,
                        size=0.088388, aspect_ratio=4.66667, scale=1.0)
       pattern_present(inputs={'Retina' : input}, duration=1.0,
                       plastic=False,
                       overwrite_previous=True,
                       apply_output_fn=True)
       if hasattr(topo,'guimain'):
           topo.guimain.refresh_activity_windows()
       results[i]=decode_feature(topo.sim['V1'], preference_map="OrientationPreference")
   return results
Beispiel #4
0
    def __call__(self, view_name, axis, xlabel='', sheets_to_plot=[], quantiles=[0.25,0.5,0.75],**params):
        """
        Parameter sheets_to_plot can be any list of valid sheet names.
        They must have view_name view present to obtain valid plot.
        """
        p=ParamOverrides(self,params)
        if len(sheets_to_plot) > 8:
            self.warning( "Too many sheets to plot. Plotting first 8 of them." )
            sheets_to_plot=sheets_to_plot[:8]
        
        # list of values across all cortical sheets
        list_total=[]
        subplot_base_number=100*(len(sheets_to_plot)+1)+10
        num_plotted_sheets=0

        x_min,x_max,dx=axis

        pylab.figure()

        for name in sheets_to_plot:
            # get the sheet object
            try:
                sheet=topo.sim.objects()[name]
            except KeyError:
                self.warning( "Name '"+name+"' is not present in Topographica objects. Skipping.")
                continue
            # get the histogrammed view
            try:
                view=sheet.sheet_views[view_name].view()[0]
            except KeyError:
                self.warning( "View '"+view_name+"' is not present in '"+name+"' views. Skipping.")
                continue
            num_plotted_sheets += 1
            
            # get linear list of values
            list_local = [ element for row in view for element in row ]
            list_total += list_local

            # plot it
            pylab.subplot(subplot_base_number+num_plotted_sheets)
            pylab.title(name,fontsize=10)
            pylab.ylabel('Number Of Cells')
            hist = pylab.hist(list_local,frange(x_min,x_max,dx))          #,inclusive=True))
            # Compute 1000 ceil of bin with highest number of cells
            # the plot is nicer this way
            upper_bound = ceil(float(hist[0].max())/500)*500
            pylab.axis([x_min,x_max,0,upper_bound])

            # plot the quantiles right below
            list_local.sort()
            list_length=len(list_local)
            for quantile in quantiles:
                quantile_value=list_local[int(list_length*quantile)]
                pylab.plot([quantile_value]*2,[upper_bound,0],'r' if quantile == 0.5 else 'g')

    # if there would be only one sheet, sum of all sheets would be redundant
        if num_plotted_sheets > 1:    
            num_plotted_sheets += 1
            pylab.subplot(subplot_base_number + num_plotted_sheets)
            pylab.title('Sum of All sheets',fontsize=10)
            pylab.ylabel('Number Of Cells')
            pylab.xlabel(xlabel)
            hist = pylab.hist(list_total,frange(x_min,x_max,dx))          # ,inclusive=True))
            # Compute 1000 ceil of bin with highest number of cells
            # the plot is nicer this way
            upper_bound = ceil(float(hist[0].max())/1000)*1000
            pylab.axis([x_min,x_max,0,upper_bound])
                
            list_total.sort()
            list_length=len(list_total)
            for quantile in quantiles:
                quantile_value=list_total[int(list_length*quantile)]
                pylab.plot([quantile_value]*2,[upper_bound,0],'r' if quantile == 0.5 else 'g')

        self._generate_figure(p)