Пример #1
0
 def __init__(self, parent, id, argsdict=None):
     wx.Frame.__init__(self, parent, id, size = (1024,768), title = 'Vesicle Geometry')
     
     self.statusbar = widgets.PlotStatusBar(self)
     self.SetStatusBar(self.statusbar)
     
     self.toolbar = widgets.SimpleToolbar(self, *self.ToolbarData())
     self.SetToolBar(self.toolbar)
     self.toolbar.Realize()
     
     panel = wx.Panel(self, -1)
     pansizer = wx.BoxSizer(wx.VERTICAL)
     self.figure = Figure(facecolor = widgets.rgba_wx2mplt(panel.GetBackgroundColour()))
     self.canvas = FigureCanvas(panel, -1, self.figure)
     self.canvas.mpl_connect('motion_notify_event', self.statusbar.SetPosition)
     pansizer.Add(self.canvas, 1, wx.GROW)
     
     navtoolbar = NavigationToolbar2(self.canvas)
     navtoolbar.Realize()
     pansizer.Add(navtoolbar, 0, wx.GROW)
     
     panel.SetSizer(pansizer)
     panel.Fit()
     self.SetFrameIcons(MEASURE, (16,24,32))
     self.title_tmpl = '%%s : %%s - %s'%self.GetTitle()
     
     self.data = {}
     self.folder=''
     if argsdict:
         self.data = argsdict
         self.SetWindowTitle(parent.imagedate, parent.imagedir)
         self.folder = self.GetParent().folder
     self.Draw()
Пример #2
0
    def __init__(self, parent, id, argsdict=None):
        wx.Frame.__init__(self,
                          parent,
                          id,
                          size=(1024, 768),
                          title='Vesicle Geometry')

        self.statusbar = widgets.PlotStatusBar(self)
        self.SetStatusBar(self.statusbar)

        self.toolbar = widgets.SimpleToolbar(self, *self.ToolbarData())
        self.SetToolBar(self.toolbar)
        self.toolbar.Realize()

        panel = wx.Panel(self, -1)
        pansizer = wx.BoxSizer(wx.VERTICAL)
        self.figure = Figure(
            facecolor=widgets.rgba_wx2mplt(panel.GetBackgroundColour()))
        self.canvas = FigureCanvas(panel, -1, self.figure)
        self.canvas.mpl_connect('motion_notify_event',
                                self.statusbar.SetPosition)
        pansizer.Add(self.canvas, 1, wx.GROW)

        navtoolbar = NavigationToolbar2(self.canvas)
        navtoolbar.Realize()
        pansizer.Add(navtoolbar, 0, wx.GROW)

        panel.SetSizer(pansizer)
        panel.Fit()
        self.SetFrameIcons(MEASURE, (16, 24, 32))
        self.title_tmpl = '%%s : %%s - %s' % self.GetTitle()

        self.data = {}
        self.folder = ''
        if argsdict:
            self.data = argsdict
            self.SetWindowTitle(parent.imagedate, parent.imagedir)
            self.folder = self.GetParent().folder
        self.Draw()
Пример #3
0
    def MakeImagePanel(self):
        self.figure = Figure(facecolor = widgets.rgba_wx2mplt(self.panel.GetBackgroundColour()))
        self.canvas = FigureCanvas(self.panel, -1, self.figure)
        self.canvas.mpl_connect('motion_notify_event', self.statusbar.SetPosition)
        self.axes = self.figure.add_subplot(111)
        self.axes.set_aspect('auto')

        self.dataplot, = self.axes.plot([], [], 'ro', label = 'Measured')
        self.fitplot, = self.axes.plot([],[])
        
        labelfont = {'fontsize':'large'}
        self.axes.set_xlabel('$\\tau$, %s'%self.data['tensdim'][1], fontdict = labelfont)
        self.axes.set_ylabel('$\\alpha$')
        
        navtoolbar = NavigationToolbar2(self.canvas)
        navtoolbar.Realize()
        
        dim = self.data['tension'].shape[-1]
        if dim < 3: dim=3
        self.slider = widgets.DoubleSlider(self.panel, -1, (1, dim), 1, dim, gap=2)
        self.Bind(wx.EVT_SLIDER, self.OnSlide, self.slider)
        self.lowlabel = wx.StaticText(self.panel, -1, '  %i'%self.slider.GetLow(), style=wx.ALIGN_CENTER|wx.ST_NO_AUTORESIZE)
        self.highlabel = wx.StaticText(self.panel, -1, '  %i'%self.slider.GetHigh(), style=wx.ALIGN_CENTER|wx.ST_NO_AUTORESIZE)
        
        self.imgbox = wx.BoxSizer(wx.VERTICAL)
        self.imgbox.Add(self.canvas, 1, wx.GROW)
        self.imgbox.Add(navtoolbar, 0, wx.GROW)
        
        labelbox = wx.BoxSizer(wx.VERTICAL)
        labelbox.Add(self.lowlabel, 1, wx.GROW)
        labelbox.Add(self.highlabel, 1, wx.GROW)
        
        sliderbox = wx.BoxSizer(wx.HORIZONTAL)
        sliderbox.Add(labelbox, 0, wx.GROW)
        sliderbox.Add(self.slider, 1, wx.GROW)
        
        self.imgbox.Add(sliderbox, 0, wx.GROW)
Пример #4
0
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id, style=wx.BORDER_SUNKEN)

        self.Imgs = None

        vsizer = wx.BoxSizer(wx.VERTICAL)
        self.figure = Figure(
            facecolor=widgets.rgba_wx2mplt(self.GetBackgroundColour()))

        self.axes = self.figure.add_subplot(111)
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.canvas.mpl_connect('motion_notify_event',
                                parent.statusbar.SetPosition)
        vsizer.Add(self.canvas, 1, wx.ALIGN_LEFT | wx.ALIGN_TOP | wx.GROW)

        navtoolbar = NavigationToolbar2(self.canvas)
        navtoolbar.Realize()
        vsizer.Add(navtoolbar, 0, wx.ALIGN_LEFT | wx.GROW)

        slidersizer = wx.FlexGridSizer(cols=2)
        self.ImgNoTxt = wx.TextCtrl(self,
                                    -1,
                                    "0",
                                    size=(50, 20),
                                    style=wx.TE_READONLY | wx.TE_CENTER)
        slidersizer.Add(self.ImgNoTxt, 0)
        self.ImgNoSlider = wx.Slider(self, -1, 1, 0, 1)
        self.Bind(wx.EVT_SCROLL, self.OnSlide, self.ImgNoSlider)
        slidersizer.Add(self.ImgNoSlider, 1, wx.GROW)

        self.paramsliders = []

        regionlabel = wx.StaticText(self, -1, 'Aspirated\nVesicle')
        slidersizer.Add(regionlabel, 0, wx.ALIGN_RIGHT)
        self.regionslider = widgets.DoubleSlider(self,
                                                 -1, (0, 1),
                                                 0,
                                                 1,
                                                 gap=2,
                                                 name='aspves')
        self.Bind(wx.EVT_SLIDER, self.OnSlide, self.regionslider)
        self.paramsliders.append(self.regionslider)
        slidersizer.Add(self.regionslider, 1, wx.GROW | wx.ALIGN_LEFT)

        tiplabel = wx.StaticText(self, -1, 'Pipette Tip')
        slidersizer.Add(tiplabel, 0, wx.ALIGN_RIGHT)
        self.tipslider = widgets.DoubleSlider(self,
                                              -1, (0, 1),
                                              0,
                                              1,
                                              gap=2,
                                              name='tip')
        self.Bind(wx.EVT_SLIDER, self.OnSlide, self.tipslider)
        self.paramsliders.append(self.tipslider)
        slidersizer.Add(self.tipslider, 1, wx.GROW | wx.ALIGN_LEFT)

        slidersizer.AddGrowableCol(1, 1)
        vsizer.Add(slidersizer, 0, wx.GROW)

        hsizer = wx.BoxSizer()
        axslidersizer = wx.FlexGridSizer(rows=2)

        name = 'axis'
        label = wx.StaticText(self, -1, name)
        axslidersizer.Add(label)
        self.axisslider = widgets.DoubleSlider(self,
                                               -1, (0, 1),
                                               0,
                                               1,
                                               style=wx.SL_VERTICAL,
                                               name=name)
        self.Bind(wx.EVT_SLIDER, self.OnSlide, self.axisslider)

        name = 'pipette'
        label = wx.StaticText(self, -1, name)
        self.pipetteslider = widgets.DoubleSlider(self,
                                                  -1, (0, 1),
                                                  0,
                                                  1,
                                                  style=wx.SL_VERTICAL,
                                                  name=name)
        self.Bind(wx.EVT_SLIDER, self.OnSlide, self.pipetteslider)
        axslidersizer.Add(label)

        axslidersizer.Add(self.axisslider, 1, wx.GROW | wx.ALIGN_TOP)
        axslidersizer.Add(self.pipetteslider, 1, wx.GROW | wx.ALIGN_TOP)

        self.paramsliders.append(self.axisslider)
        self.paramsliders.append(self.pipetteslider)

        axslidersizer.AddGrowableRow(1, 1)
        hsizer.Add(axslidersizer, 0, wx.GROW)
        hsizer.Add(vsizer, 1, wx.GROW)
        for child in self.GetChildren():
            child.Enable(False)
        self.SetSizer(hsizer)
        self.Fit()
Пример #5
0
 def __init__(self, parent, id):
     wx.Panel.__init__(self, parent, id, style = wx.BORDER_SUNKEN)
     
     self.Imgs = None
     
     vsizer = wx.BoxSizer(wx.VERTICAL)
     self.figure = Figure(facecolor = widgets.rgba_wx2mplt(self.GetBackgroundColour()))
     
     self.axes = self.figure.add_subplot(111)
     self.canvas = FigureCanvas(self, -1, self.figure)
     self.canvas.mpl_connect('motion_notify_event', parent.statusbar.SetPosition)
     vsizer.Add(self.canvas, 1, wx.ALIGN_LEFT|wx.ALIGN_TOP|wx.GROW)
     
     navtoolbar = NavigationToolbar2(self.canvas)
     navtoolbar.Realize()
     vsizer.Add(navtoolbar, 0, wx.ALIGN_LEFT|wx.GROW)
     
     slidersizer = wx.FlexGridSizer(cols=2)
     self.ImgNoTxt = wx.TextCtrl(self, -1, "0", size=(50,20),
                             style = wx.TE_READONLY | wx.TE_CENTER)
     slidersizer.Add(self.ImgNoTxt, 0)
     self.ImgNoSlider = wx.Slider(self, -1, 1, 0, 1)
     self.Bind(wx.EVT_SCROLL, self.OnSlide, self.ImgNoSlider)        
     slidersizer.Add(self.ImgNoSlider, 1, wx.GROW)
     
     self.paramsliders = []
     
     regionlabel = wx.StaticText(self, -1, 'Aspirated\nVesicle')
     slidersizer.Add(regionlabel, 0, wx.ALIGN_RIGHT)
     self.regionslider = widgets.DoubleSlider(self, -1, (0,1), 0, 1, gap=2, name='aspves')
     self.Bind(wx.EVT_SLIDER, self.OnSlide, self.regionslider)
     self.paramsliders.append(self.regionslider)
     slidersizer.Add(self.regionslider, 1, wx.GROW|wx.ALIGN_LEFT)
     
     tiplabel = wx.StaticText(self, -1, 'Pipette Tip')
     slidersizer.Add(tiplabel, 0, wx.ALIGN_RIGHT)
     self.tipslider = widgets.DoubleSlider(self, -1, (0,1), 0, 1, gap=2, name='tip')
     self.Bind(wx.EVT_SLIDER, self.OnSlide, self.tipslider)
     self.paramsliders.append(self.tipslider)
     slidersizer.Add(self.tipslider, 1, wx.GROW|wx.ALIGN_LEFT)
     
     slidersizer.AddGrowableCol(1,1)
     vsizer.Add(slidersizer, 0, wx.GROW)
     
     hsizer = wx.BoxSizer()
     axslidersizer = wx.FlexGridSizer(rows=2)
     
     name = 'axis'
     label = wx.StaticText(self, -1, name)
     axslidersizer.Add(label)
     self.axisslider = widgets.DoubleSlider(self, -1, (0,1), 0, 1, style=wx.SL_VERTICAL, name=name)
     self.Bind(wx.EVT_SLIDER, self.OnSlide, self.axisslider)
     
     name = 'pipette'
     label = wx.StaticText(self, -1, name)
     self.pipetteslider = widgets.DoubleSlider(self, -1, (0,1), 0, 1, style=wx.SL_VERTICAL, name=name)
     self.Bind(wx.EVT_SLIDER, self.OnSlide, self.pipetteslider)
     axslidersizer.Add(label)
     
     axslidersizer.Add(self.axisslider, 1, wx.GROW|wx.ALIGN_TOP)
     axslidersizer.Add(self.pipetteslider, 1, wx.GROW|wx.ALIGN_TOP)
     
     self.paramsliders.append(self.axisslider)
     self.paramsliders.append(self.pipetteslider)
         
     axslidersizer.AddGrowableRow(1,1)
     hsizer.Add(axslidersizer, 0, wx.GROW)
     hsizer.Add(vsizer, 1, wx.GROW)
     for child in self.GetChildren():
         child.Enable(False)
     self.SetSizer(hsizer)
     self.Fit()
Пример #6
0
    def __init__(self, parent, id, img, out, extra_out):
        wx.Frame.__init__(self, parent, id, size=(800,600), title = 'Single Image Debug')
        
        self.statusbar = widgets.PlotStatusBar(self)
        self.SetStatusBar(self.statusbar)
        
        panel = wx.Panel(self, -1)
        pansizer = wx.BoxSizer(wx.VERTICAL)
        self.figure = Figure(facecolor = widgets.rgba_wx2mplt(panel.GetBackgroundColour()))
        self.canvas = FigureCanvas(panel, -1, self.figure)
        self.canvas.mpl_connect('motion_notify_event', self.statusbar.SetPosition)
        pansizer.Add(self.canvas, 1, wx.GROW)
        
        navtoolbar = NavigationToolbar2(self.canvas)
        navtoolbar.Realize()
        pansizer.Add(navtoolbar, 0, wx.GROW)
        
        profile = extra_out['profile']
        self.profileplot = self.figure.add_subplot(221, title = 'Axis brightness profile')
        self.profileplot.plot(profile)
        
        order = parent.analysispanel.GetParams()['order']
        window = parent.analysispanel.GetParams()['window']
        smoothmode = parent.analysispanel.GetParams()['smoothing']
        grad = abs(smooth.smooth1d(profile, smoothmode, order, window, diff=1))
        
        multiplier = profile.max()/grad.max()/2
        grad *= multiplier
        
        self.profileplot.plot(grad)
        self.profileplot.axvline(extra_out['pip'], color = 'blue')
        self.profileplot.axvline(extra_out['asp'], color = 'yellow')
        self.profileplot.axvline(extra_out['ves'], color = 'green')
        
        self.imgplot = self.figure.add_subplot(222, title = 'Image')
        refs = extra_out['refs']
        for ref in refs:
            self.imgplot.plot([ref[0][1]], [ref[0][0]], 'yo') # due to format of refs
            
        self.imgplot.imshow(img, aspect = 'equal', extent = None, cmap = cm.get_cmap('gray'))

        self.pipprofile1 = self.figure.add_subplot(223, title = 'Left pipette section')
        xleft = refs[0][0][1]
        pipprofile1 = img[:,xleft]
        self.pipprofile1.plot(pipprofile1)
        
        self.pipprofile2 = self.figure.add_subplot(224, title = 'Right pipette section')
        xright = refs[-1][0][1]
        pipprofile2 = img[:,xright]
        self.pipprofile2.plot(pipprofile2)
        
#        self.gradpipprofile1 = self.figure.add_subplot(325, title = 'Left pipette section gradient')
#        self.gradpipprofile1.plot(utils.get_gradient(pipprofile1, 3))
#        
#        self.gradpipprofile2 = self.figure.add_subplot(326, title = 'Right pipette section gradient')
#        self.gradpipprofile2.plot(utils.get_gradient(pipprofile2, 3))
#        
        panel.SetSizer(pansizer)
        panel.Fit()
        title = '%s : %s - Image %s - %s'%(parent.imagedate, parent.imagedir, parent.imgpanel.GetImgNo(), self.GetTitle())
        self.SetTitle(title)
        self.SetFrameIcons(MICROSCOPE, (16,24,32))
        self.canvas.draw()