Beispiel #1
0
    def slice_plot( self, anat, coefs, **traits ):

        p  = Plot( self.plot_data, default_origin = 'bottom left' )
        p2 = Plot( self.plot_data, default_origin = 'bottom left' )

        p.x_axis.visible = False; p2.x_axis.visible = False
        p.y_axis.visible = False; p2.y_axis.visible = False

        bounds = self.plot_data.get_data(anat).shape
        asp    = float( bounds[1] ) / float( bounds[0] )

        p.img_plot( anat,
#                    xbounds  = np.linspace( 0, 1, bounds[1] + 1 ),
#                    ybounds  = np.linspace( 0, 1, bounds[0] + 1 ),
                    colormap = chaco_colormaps.gray )
        
        p2.img_plot( coefs,
#                     xbounds  = np.linspace( 0, 1, bounds[1] + 1 ),
#                     ybounds  = np.linspace( 0, 1, bounds[0] + 1 ),
#                     bgcolor = 'transparent',
                     colormap = self.cmap,
                     interpolation = 'nearest')

#        p.aspect_ratio = asp; p2.aspect_ratio = asp
        p.aspect_ratio = asp; p2.aspect_ratio = asp

        subplot = OverlayPlotContainer( )

        subplot.add( p )
        subplot.add( p2 )

        return subplot 
def _create_plot_component():
    # Create a GridContainer to hold all of our plots
    container = GridContainer(padding=20, fill_padding=True,
                              bgcolor="lightgray", use_backbuffer=True,
                              shape=(3,3), spacing=(12,12))

    # Create the initial series of data
    x = linspace(-5, 15.0, 100)
    pd = ArrayPlotData(index = x)

    # Plot some bessel functions and add the plots to our container
    for i in range(9):
        pd.set_data("y" + str(i), jn(i,x))
        plot = Plot(pd)
        plot.plot(("index", "y" + str(i)),
                  color=tuple(COLOR_PALETTE[i]), line_width=2.0,
                  bgcolor = "white", border_visible=True)

        # Tweak some of the plot properties
        plot.border_width = 1
        plot.padding = 10

        # Set each plot's aspect ratio based on its position in the
        # 3x3 grid of plots.
        n,m = divmod(i, 3)
        plot.aspect_ratio = float(n+1) / (m+1)

        # Attach some tools to the plot
        plot.tools.append(PanTool(plot))
        zoom = ZoomTool(plot, tool_mode="box", always_on=False)
        plot.overlays.append(zoom)

        # Add to the grid container
        container.add(plot)
    return container
Beispiel #3
0
    def __init__(self, signal_instance):
        super(TemplatePicker, self).__init__()
        try:
            import cv
        except:
            print "OpenCV unavailable.  Can't do cross correlation without it.  Aborting."
            return None
        self.OK_custom=OK_custom_handler()
        self.sig=signal_instance
        if not hasattr(self.sig.mapped_parameters,"original_files"):
            self.sig.data=np.atleast_3d(self.sig.data)
            self.titles=[self.sig.mapped_parameters.name]
        else:
            self.numfiles=len(self.sig.mapped_parameters.original_files.keys())
            self.titles=self.sig.mapped_parameters.original_files.keys()
        tmp_plot_data=ArrayPlotData(imagedata=self.sig.data[self.top:self.top+self.tmp_size,self.left:self.left+self.tmp_size,self.img_idx])
        tmp_plot=Plot(tmp_plot_data,default_origin="top left")
        tmp_plot.img_plot("imagedata", colormap=jet)
        tmp_plot.aspect_ratio=1.0
        self.tmp_plot=tmp_plot
        self.tmp_plotdata=tmp_plot_data
        self.img_plotdata=ArrayPlotData(imagedata=self.sig.data[:,:,self.img_idx])
        self.img_container=self._image_plot_container()

        self.crop_sig=None
Beispiel #4
0
    def _create_plot_component(self):
        pd = self.pd

    # Create the plot
        plot = Plot(pd, default_origin="top left",orientation="h")
        shape = pd.get_data('imagedata').shape
        plot.aspect_ratio = float(shape[1]) / shape[0]
        plot.x_axis.orientation = "top"
        #plot.y_axis.orientation = "top"
        #img_plot = plot.img_plot("imagedata",colormap = jet)[0]
        img_plot = plot.img_plot("imagedata",name = 'image', colormap = jet)[0]
        
    # Tweak some of the plot properties
        #plot.bgcolor = "white"
        plot.bgcolor = bg_color
        
    # Attach some tools to the plot
        plot.tools.append(PanTool(plot,constrain_key="shift", drag_button = 'right'))
        printer = DataPrinter(component=plot, process = self.process_selection)
        plot.tools.append(printer)
        plot.overlays.append(ZoomTool(component=plot, 
                                  tool_mode="box", always_on=False))
        #plot.title = 'Default image'
        
        imgtool = ImageInspectorTool(img_plot)
        img_plot.tools.append(imgtool)
        plot.overlays.append(ImageInspectorOverlay(component=img_plot, 
                                               image_inspector=imgtool))
        return plot
 def _stage_map_default(self):
     
     # RGBA maps
     rep_map = array_to_rgba(self.PMap.stage_repr_map, cmap=cm.hot)
     cov_map = array_to_rgba(self.PMap.stage_coverage_map, cmap=cm.gray)
     
     # Data sources and plot object
     data = ArrayPlotData(fields_x=self.fdata['x'], fields_y=self.fdata['y'], 
         fields_z=self.fdata['peak'], rep=rep_map, cov=cov_map)
     p = Plot(data)
     
     # Plot the field centers
     p.plot(('fields_x', 'fields_y', 'fields_z'), name='centers', type='cmap_scatter', 
         marker='dot', marker_size=5, color_mapper=copper, line_width=1, fill_alpha=0.6)
     
     # Plot the representation and coverage maps
     p.img_plot('rep', name='rep', xbounds=(0, self.PMap.W), ybounds=(0, self.PMap.H),
         origin='top left')
     p.img_plot('cov', name='cov', xbounds=(0, self.PMap.W), ybounds=(0, self.PMap.H),
         origin='top left')
     
     # Start with only the representation map visible
     p.plots['cov'][0].visible = False
     p.plots['centers'][0].visible = False
     
     # Plot tweaks
     p.aspect_ratio = 1.0
     p.y_axis.title = 'Y (cm)'
     p.x_axis.title = 'X (cm)'
     p.x_axis.orientation = 'bottom'
     p.title = 'Stage Maps'
     
     return p
Beispiel #6
0
    def render_image(self):
        plot = Plot(self.img_plotdata, default_origin="top left")
        img = plot.img_plot("imagedata", colormap=gray)[0]
        plot.title = "%s of %s: " % (self.img_idx + 1,
                                     self.numfiles) + self.titles[self.img_idx]
        plot.aspect_ratio = float(self.sig.data.shape[1]) / float(
            self.sig.data.shape[0])

        #if not self.ShowCC:
        csr = CursorTool(img,
                         drag_button='left',
                         color='white',
                         line_width=2.0)
        self.csr = csr
        csr.current_position = self.left, self.top
        img.overlays.append(csr)

        # attach the rectangle tool
        plot.tools.append(PanTool(plot, drag_button="right"))
        zoom = ZoomTool(plot,
                        tool_mode="box",
                        always_on=False,
                        aspect_ratio=plot.aspect_ratio)
        plot.overlays.append(zoom)
        self.img_plot = plot
        return plot
Beispiel #7
0
    def __init__(self, signal_instance):
        super(TemplatePicker, self).__init__()
        try:
            import cv
        except:
            print "OpenCV unavailable.  Can't do cross correlation without it.  Aborting."
            return None
        self.OK_custom = OK_custom_handler()
        self.sig = signal_instance
        if not hasattr(self.sig.mapped_parameters, "original_files"):
            self.sig.data = np.atleast_3d(self.sig.data)
            self.titles = [self.sig.mapped_parameters.name]
        else:
            self.numfiles = len(
                self.sig.mapped_parameters.original_files.keys())
            self.titles = self.sig.mapped_parameters.original_files.keys()
        tmp_plot_data = ArrayPlotData(
            imagedata=self.sig.data[self.top:self.top + self.tmp_size,
                                    self.left:self.left + self.tmp_size,
                                    self.img_idx])
        tmp_plot = Plot(tmp_plot_data, default_origin="top left")
        tmp_plot.img_plot("imagedata", colormap=jet)
        tmp_plot.aspect_ratio = 1.0
        self.tmp_plot = tmp_plot
        self.tmp_plotdata = tmp_plot_data
        self.img_plotdata = ArrayPlotData(
            imagedata=self.sig.data[:, :, self.img_idx])
        self.img_container = self._image_plot_container()

        self.crop_sig = None
Beispiel #8
0
    def _vr_image_plot_default(self):
        plot = Plot(self.vr_image_data, default_origin="top left",
                    size=(512,512))
        plot.aspect_ratio = 1.0
        #plot.x_axis.orientation = "top"
        img_plot = plot.img_plot("vr_image_data")[0]

        plot.bgcolor = "black"
        return plot
Beispiel #9
0
 def _update_img_plot(self, plot_name, image, title):
     """Update an image plot."""
     plotdata = ArrayPlotData(imagedata=image)
     xbounds = (0, image.shape[1] - 1)
     ybounds = (0, image.shape[0] - 1)
     
     plot = Plot(plotdata)
     plot.aspect_ratio = float(xbounds[1]) / float(ybounds[1])
     plot.img_plot("imagedata", colormap=bone, xbounds=xbounds,
         ybounds=ybounds)
     plot.title = title
     
     setattr(self, plot_name, plot)
     getattr(self, plot_name).request_redraw()
Beispiel #10
0
    def _update_img_plot(self, plot_name, image, title):
        """Update an image plot."""
        plotdata = ArrayPlotData(imagedata=image)
        xbounds = (0, image.shape[1] - 1)
        ybounds = (0, image.shape[0] - 1)

        plot = Plot(plotdata)
        plot.aspect_ratio = float(xbounds[1]) / float(ybounds[1])
        plot.img_plot("imagedata",
                      colormap=bone,
                      xbounds=xbounds,
                      ybounds=ybounds)
        plot.title = title

        setattr(self, plot_name, plot)
        getattr(self, plot_name).request_redraw()
 def _unit_map_default(self):
     
     # Set the initial unit map
     data = ArrayPlotData(unit_map=self._get_unit_map_data())
     p = Plot(data)
     
     # Plot the map
     p.img_plot('unit_map', name='unit', xbounds=(0, self.PMap.W), ybounds=(0, self.PMap.H),
         origin='top left')
     
     # Plot tweaks
     p.aspect_ratio = 1.0
     p.y_axis.title = 'Y (cm)'
     p.x_axis.title = 'X (cm)'
     p.x_axis.orientation = 'bottom'
     p.title = 'Single Unit Maps'
     
     return p
Beispiel #12
0
    def render_image(self):
        plot = Plot(self.img_plotdata,default_origin="top left")
        img=plot.img_plot("imagedata", colormap=gray)[0]
        plot.title="%s of %s: "%(self.img_idx+1,self.numfiles)+self.titles[self.img_idx]
        plot.aspect_ratio=float(self.sig.data.shape[1])/float(self.sig.data.shape[0])

        #if not self.ShowCC:
        csr = CursorTool(img, drag_button='left', color='white',
                         line_width=2.0)
        self.csr=csr
        csr.current_position=self.left, self.top
        img.overlays.append(csr)

        # attach the rectangle tool
        plot.tools.append(PanTool(plot,drag_button="right"))
        zoom = ZoomTool(plot, tool_mode="box", always_on=False, aspect_ratio=plot.aspect_ratio)
        plot.overlays.append(zoom)
        self.img_plot=plot
        return plot
Beispiel #13
0
    def rate_plot( self, rates, **traits ):

        rp = Plot( self.rate_data, default_origin = 'bottom left' )

        rp.x_axis.visible = False 
        rp.y_axis.visible = False 

        bounds = self.rate_data.get_data( rates ).shape

#        rp.img_plot( rates,
#                     xbounds  = np.linspace( 0, 1, bounds[1] + 1 ),
#                     ybounds  = np.linspace( 0, 1, bounds[0] + 1 ),
#                     colormap = chaco_colormaps.jet,
#                     interpolation = 'nearest')

        rp.contour_plot( rates,
                         type = 'line',
#                         xbounds  = np.linspace( 0, 1, bounds[1] + 1 ),
#                         ybounds  = np.linspace( 0, 1, bounds[0] + 1 ),
                         bgcolor  = 'black',
                         levels   = 15,
                         styles   = 'solid',
                         widths   = list( np.linspace( 4.0, 0.1, 15 )),
                         colors   = gmt_drywet )

        rp.aspect_ratio = 1

#        zoom = ZoomTool( rp, tool_mode = 'box', always_on = False )
#        rp.overlays.append(zoom)

#        rp.tools.append( PanTool( rp, constrain_key = 'shift' ) )
        
        subplot = OverlayPlotContainer( )
        subplot.add( rp )
        
        return subplot
    def _plot_default(self):
        outcomes, results, time = self._prepare_data()
        
        self.outcomes = outcomes
        self.time = time
        self.low = int(np.min(time))
        self.high = int(np.max(time))
        

        self.data = {}
        for outcome in outcomes:
            self.data[outcome] = results[outcome]
        
        # Create some data
        pd = ArrayPlotData()
        
        for entry in outcomes:
            if self.startValue == 'low':
                pd.set_data(entry, self.data[entry][:,0])
            elif self.startValue == 'high':
                pd.set_data(entry, self.data[entry][:,-1])
        self.plotdata = pd
        
#        outcomes = outcomes[0:3]

        container = GridContainer(shape=(len(outcomes),len(outcomes)))
        combis = [(field1, field2) for field1 in outcomes for field2 in outcomes]
        
        selectorTools = []
        for entry1, entry2 in combis:

            # Create the plot
            if entry1 == entry2:
                plot = Plot(pd)
            else:
                plot = Plot(pd)
                
                #set limits for x and y to global limits
                plot.range2d._xrange._high_setting = np.max(self.data[entry1])
                plot.range2d._xrange._high_value = np.max(self.data[entry1])
                plot.range2d._xrange._low_setting = np.min(self.data[entry1])
                plot.range2d._xrange._low_value = np.min(self.data[entry1])
                
                plot.range2d._yrange._high_setting =np.max(self.data[entry2])
                plot.range2d._yrange._high_value = np.max(self.data[entry2])
                plot.range2d._yrange._low_setting = np.min(self.data[entry2])
                plot.range2d._yrange._low_value = np.min(self.data[entry2])

                #make the scatter plot
                plot.plot((entry1, entry2),
                            type="scatter",
                            marker="circle",
                            color="blue",
                            marker_size=3,
                            bgcolor="white")[0]                
            
                tool = ScatterSelectorTool(component=plot)
                tool._index = entry1
                plot.tools.append(tool)
                selectorTools.append(tool)
            
            plot.height = 500
            plot.width = 500
            plot.border_width = 1
            plot.aspect_ratio  = 1.
            
            container.add(plot)
        
        for tool in selectorTools:
            tool._other_selectors = list(set(selectorTools) - set([tool]))
            tool._demo = self
        return container