Beispiel #1
0
 def on_handle(self):
     win = IPy.get_window()
     if win is None: return
     x, y = self.viewport.GetValue()
     win.canvas.center(x, y, 'data')
     win.ips.update()
     self.viewport.set_box(win.canvas.conbox, win.canvas.winbox)
Beispiel #2
0
 def on_apply(self, event):
     win = IPy.get_window()
     if win is None: return
     img = win.ips.img
     step = max(max(img.shape[:2]) // 300, 1)
     self.viewport.set_img(win.ips.lookup(img[::step, ::step]), img.shape)
     self.viewport.set_box(win.canvas.conbox, win.canvas.winbox)
Beispiel #3
0
 def show(self):
     self.dialog = ThresholdDialog(IPy.get_window(), self.title)
     hist = np.histogram(self.ips.lookup(),list(range(257)))[0]
     hist = (hist*(100.0/hist.max())).astype(np.uint8)
     self.dialog.init_view(self.view, self.para, hist, self.arange)
     self.dialog.set_handle(lambda x:self.preview(self.para))
     return self.dialog.ShowModal()
Beispiel #4
0
 def on_handle(self):
     win = IPy.get_window()
     if win is None: return
     x, y = self.viewport.GetValue()
     print(x, y)
     win.canvas.center(x, y)
     win.canvas.ips.update = 'pix'
     self.viewport.set_box(win.canvas.imgbox, win.canvas.box)
Beispiel #5
0
	def on_handle(self, update=False):
		if update: self.on_apply(update)
		win = IPy.get_window()
		if win is None: return
		x, y = self.viewport.GetValue()
		win.canvas.center(x, y, 'data')
		win.ips.update()
		self.viewport.set_box(win.canvas.conbox, win.canvas.winbox)
Beispiel #6
0
    def mouse_down(self, ips, x, y, btn, **key):
        if ips == self.ips1:
            self.ips1.mark.set_xy(x, y)
            self.ips.mark.set_xy(None, y)
            self.ips.cur = int(x)
            self.ips1.update()
            self.ips.update()
        elif ips == self.ips2:
            self.ips2.mark.set_xy(x, y)
            self.ips.mark.set_xy(x, None)
            self.ips.cur = int(y)
            self.ips2.update()
            self.ips.update()
        elif ips.get_nslices() == 1 or not ips.is3d:
            IPy.alert('stack required!')
            return
        elif self.view1 == None:
            img1, img2 = self.getimgs(ips.imgs, x, y)
            self.ips1 = ImagePlus([img1])
            self.ips2 = ImagePlus([img2])
            self.view1 = CanvasFrame(IPy.curapp)
            self.view2 = CanvasFrame(IPy.curapp)

            self.ips = ips
            self.view1.set_ips(self.ips1)
            self.view2.set_ips(self.ips2)
            canvas1, canvas2 = self.view1.canvas, self.view2.canvas
            canvas = IPy.get_window().canvas
            canvas1.scaleidx = canvas2.scaleidx = canvas.scaleidx
            canvas1.zoom(canvas.scales[canvas.scaleidx], 0, 0)
            canvas2.zoom(canvas.scales[canvas.scaleidx], 0, 0)
            self.view1.Show()
            self.view2.Show()
            ips.mark = Cross(*ips.size[::-1])
            ips.mark.set_xy(x, y)
            self.ips1.mark = Cross(*self.ips1.size[::-1])
            self.ips2.mark = Cross(*self.ips2.size[::-1])
            self.ips1.mark.set_xy(x, ips.cur)
            self.ips2.mark.set_xy(ips.cur, y)
            ips.update()

        else:
            img1, img2 = self.getimgs(ips.imgs, x, y)
            self.ips1.set_imgs([img1])
            self.ips2.set_imgs([img2])
            '''
            canvas1, canvas2 = self.view1.canvas, self.view2.canvas
            canvas = IPy.curwindow.canvas
            canvas1.scaleidx = canvas2.scaleidx = canvas.scaleidx
            canvas1.zoom(canvas.scales[canvas.scaleidx], 0, 0)
            canvas2.zoom(canvas.scales[canvas.scaleidx], 0, 0)
            '''
            self.ips1.mark.set_xy(ips.cur, y)
            self.ips2.mark.set_xy(x, ips.cur)
            self.ips1.update()
            self.ips2.update()
            ips.mark.set_xy(x, y)
            ips.update()
Beispiel #7
0
 def on_fit(self, event):
     win = IPy.get_window()
     if win is None: return
     win.canvas.fit()
     win.ips.update()
     self.slider.SetValue(win.canvas.scaleidx)
     k = self.scales[self.slider.GetValue()]
     self.label.SetLabel('%.2f%%' % (k * 100))
     self.viewport.set_box(win.canvas.conbox, win.canvas.winbox)
Beispiel #8
0
 def show(self):
     print('threshold show')
     self.dialog = ThresholdDialog(IPy.get_window(), self.title)
     hist = np.histogram(self.ips.lookup(), list(range(257)))[0]
     self.dialog.init_view(self.view, self.para, hist, self.ips.range)
     self.dialog.set_handle(lambda x: self.preview(self.ips, self.para))
     self.dialog.on_ok = lambda: self.ok(self.ips)
     self.dialog.on_cancel = lambda: self.cancel(self.ips)
     self.dialog.Show()
Beispiel #9
0
 def on_zoom(self, event):
     k = self.scales[self.slider.GetValue()]
     self.label.SetLabel('%.2f%%' % (k * 100))
     win = IPy.get_window()
     if win is None: return
     a, b, c, d = win.canvas.winbox
     win.canvas.scaleidx = self.slider.GetValue()
     win.canvas.zoom(k, (a + c) / 2, (b + d) / 2)
     win.ips.update()
     self.viewport.set_box(win.canvas.conbox, win.canvas.winbox)
Beispiel #10
0
 def on_one(self, event):
     win = IPy.get_window()
     if win is None: return
     a, b, c, d = win.canvas.winbox
     win.canvas.scaleidx = self.scales.index(1)
     win.canvas.zoom(1, (a + c) / 2, (b + d) / 2)
     win.ips.update()
     self.slider.SetValue(win.canvas.scaleidx)
     self.label.SetLabel('%.2f%%' % 100)
     self.viewport.set_box(win.canvas.conbox, win.canvas.winbox)
Beispiel #11
0
 def on_zoom(self, event):
     k = self.scales[self.slider.GetValue()]
     self.label.SetLabel('%.2f%%' % (k * 100))
     win = IPy.get_window()
     if win is None: return
     a, b, c, d = win.canvas.box
     x, y = win.canvas.to_data_coor(c / 2, d / 2)
     win.canvas.scaleidx = self.slider.GetValue()
     win.canvas.zoom(k, x, y)
     win.canvas.ips.update = 'pix'
     self.viewport.set_box(win.canvas.imgbox, win.canvas.box)
Beispiel #12
0
 def on_one(self, event):
     win = IPy.get_window()
     if win is None: return
     a, b, c, d = win.canvas.box
     x, y = win.canvas.to_data_coor(c / 2, d / 2)
     win.canvas.scaleidx = self.scales.index(1)
     win.canvas.zoom(1, x, y)
     win.canvas.ips.update = 'pix'
     self.slider.SetValue(win.canvas.scaleidx)
     self.label.SetLabel('%.2f%%' % 100)
     self.viewport.set_box(win.canvas.imgbox, win.canvas.box)
    def load(self):

        dirdialog = wx.DirDialog(IPy.get_window(),
                                 message=wx.DirSelectorPromptStr,
                                 defaultPath="",
                                 style=wx.DD_DEFAULT_STYLE,
                                 pos=wx.DefaultPosition,
                                 size=wx.DefaultSize,
                                 name=wx.DirDialogNameStr)

        if dirdialog.ShowModal() == wx.ID_OK:
            self.pathAPI = dirdialog.GetPath()
            self.pathAPI = self.pathAPI + os.path.sep
        else:
            return False

        if platform.system() == 'Windows':
            self.python = 'python'
        else:
            self.python = 'python3'
        subprocess.check_output(
            [self.python, self.pathAPI + 'listFrameworks.py'])
        data = json.load(open('data.json'))
        frameworks = data['frameworks']

        subprocess.check_output(
            [self.python, self.pathAPI + 'listModels.py', '-f', 'Keras'])
        data = json.load(open('data.json'))
        models = data['models']

        Para = {'f': 'Keras', 'm': 'VGG16'}
        View = [('lab', 'Select the framework and the model'),
                (list, frameworks, str, 'Framework', 'f', ''),
                (list, models, str, 'Model', 'm', '')]
        md = MyDialog(None, 'DeepClas4BioPy', self.pathAPI, self.python, View,
                      Para)
        md.initView()

        if md.ShowModal() == wx.ID_OK:
            self.framework = md.para['f']
            self.model = md.para['m']
            md.Destroy()
            return True
        else:
            md.Destroy()
            return False
Beispiel #14
0
 def show(self):
     self.dialog = ScaleDialog(IPy.get_window(), self.title)
     self.dialog.init_view(self.view, self.para)
     self.dialog.set_handle(lambda x: self.preview(self.para))
     return self.dialog.ShowModal()
Beispiel #15
0
 def show(self):
     self.dialog = Balance_Dialog(IPy.get_window(), self.title)
     self.dialog.init_view(self.para, self.view, self.ips.img)
     self.dialog.set_handle(lambda x:self.preview(self.para))
     return self.dialog.ShowModal()
Beispiel #16
0
 def show(self):
     self.dialog = ThresholdDialog(IPy.get_window(), self.title)
     hist = np.histogram(self.ips.lookup(), list(range(257)))[0]
     self.dialog.init_view(self.view, self.para, hist)
     self.dialog.set_handle(lambda x: self.preview(self.ips, self.para))
     return self.dialog.ShowModal()