def __init__(self, parent, sourceImage, destImage): from PYME.Deconv import wiener wx.Panel.__init__(self, parent) self.dw = wiener.dec_wiener() self.sourceImage = sourceImage self.destImage = destImage self.havePSF = False self.decT = None #GUI stuff sizer2 = wx.BoxSizer(wx.VERTICAL) sizer3 = wx.BoxSizer(wx.HORIZONTAL) sizer3.Add(wx.StaticText(self, -1, 'PSF:'), 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.fpPSF = wx.FilePickerCtrl(self, -1, wildcard='*.psf', style=wx.FLP_OPEN|wx.FLP_FILE_MUST_EXIST) self.fpPSF.Bind(wx.EVT_FILEPICKER_CHANGED, self.OnPSFFileChanged) sizer3.Add(self.fpPSF, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) sizer2.Add(sizer3, 0, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0) sizer3 = wx.BoxSizer(wx.HORIZONTAL) sizer3.Add(wx.StaticText(self, -1, 'Offset:'), 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.tOffset = wx.TextCtrl(self, -1, '0') sizer3.Add(self.tOffset, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) sizer2.Add(sizer3, 0, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0) sizer3 = wx.BoxSizer(wx.HORIZONTAL) sizer3.Add(wx.StaticText(self, -1, u'Regularisation \u03BB:'), 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.tRegLambda = wx.TextCtrl(self, -1, '1e-8') sizer3.Add(self.tRegLambda, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) sizer2.Add(sizer3, 0, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0) sizer3 = wx.BoxSizer(wx.HORIZONTAL) sizer3.AddSpacer(10) self.bCalculate = wx.Button(self, -1, 'Apply') self.bCalculate.Bind(wx.EVT_BUTTON, self.OnCalculate) self.bCalculate.Enable(False) sizer3.Add(self.bCalculate, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) sizer2.Add(sizer3, 0, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0) self.SetSizerAndFit(sizer2) self.deconTimer = mytimer() self.deconTimer.WantNotification.append(self.OnDeconTimer) self.deconTimer.Start(500)
def __init__(self, parent, dsviewer): wx.Panel.__init__(self,parent, -1) dirname = os.path.dirname(__file__) self.do = dsviewer.do self.dsviewer = dsviewer self.bmStartSeek = wx.Bitmap(os.path.join(dirname, '../icons/media-skip-backward.png')) self.bmPlay = wx.Bitmap(os.path.join(dirname,'../icons/media-playback-start.png')) self.bmPause = wx.Bitmap(os.path.join(dirname,'../icons/media-playback-pause.png')) self.mode = 'HORIZ' self.moving= False #timer for playback self.tPlay = mytimer() self.tPlay.WantNotification.append(self.OnFrame) self.do.WantChangeNotification.append(self.update) self.genContents(self.mode) self.Bind(wx.EVT_SIZE, self.OnSize)
def OnDeconvICTM(self, event, beadMode=False): from PYME.Deconv.deconvDialogs import DeconvSettingsDialog,DeconvProgressDialog,DeconvProgressPanel dlg = DeconvSettingsDialog(self.dsviewer, beadMode, self.image.data.shape[3]) if dlg.ShowModal() == wx.ID_OK: from PYME.Deconv import dec, decThread, richardsonLucy nIter = dlg.GetNumIterationss() regLambda = dlg.GetRegularisationLambda() decMDH = MetaDataHandler.NestedClassMDHandler(self.image.mdh) decMDH['Deconvolution.NumIterations'] = nIter decMDH['Deconvolution.OriginalFile'] = self.image.filename #self.dlgDeconProg = DeconvProgressDialog(self.dsviewer, nIter) #self.dlgDeconProg.Show() vx = self.image.mdh.getEntry('voxelsize.x') vy = self.image.mdh.getEntry('voxelsize.y') vz = self.image.mdh.getEntry('voxelsize.z') if beadMode: from PYME.Deconv import beadGen psf = beadGen.genBeadImage(dlg.GetBeadRadius(), (1e3*vx, 1e3*vy, 1e3*vz)) decMDH['Deconvolution.BeadRadius'] = dlg.GetBeadRadius() else: #psf, vs = numpy.load(dlg.GetPSFFilename()) #psf = numpy.atleast_3d(psf) psfFilename, psf, vs = dlg.GetPSF(vshint = vx) decMDH['Deconvolution.PSFFile'] = dlg.GetPSFFilename() if not (vs.x == vx and vs.y == vy and vs.z ==vz): #rescale psf to match data voxel size psf = ndimage.zoom(psf, [vs.x/vx, vs.y/vy, vs.z/vz]) data = self.image.data[:,:,:, dlg.GetChannel()].astype('f') - dlg.GetOffset() decMDH['Deconvolution.Offset'] = dlg.GetOffset() bg = dlg.GetBackground() decMDH['Deconvolution.Background'] = bg #crop PSF in z if bigger than stack print psf.shape, data.shape if psf.shape[2] > data.shape[2]: dz = psf.shape[2] - data.shape[2] psf = psf[:,:,numpy.floor(dz/2):(psf.shape[2]-numpy.ceil(dz/2))] print((data.shape, psf.shape)) if dlg.GetPadding(): padsize = numpy.array(dlg.GetPadSize()) decMDH['Deconvolution.Padding'] = padsize dp = numpy.ones(numpy.array(data.shape) + 2*padsize, 'f')*data.mean() weights = numpy.zeros_like(dp) px, py, pz = padsize #print data.shape, dp[px:-(px+1), py:-(py+1), pz:-(pz+1)].shape dp[px:-px, py:-py, pz:-pz] = data #if dlg.GetRemovePadding(): # data = dp[px:-px, py:-py, pz:-pz]#should be a slice #else: # data = dp weights[px:-px, py:-py, pz:-pz] = 1. weights = weights.ravel() else: dp = data weights = 1 if dlg.GetBlocking(): decMDH['Deconvolution.Method'] = 'Blocked ICTM' self.checkTQ() from PYME.Deconv import tq_block_dec bs = dlg.GetBlockSize() self.decT = tq_block_dec.blocking_deconv(self.tq, data, psf, self.image.seriesName, blocksize={'y': bs, 'x': bs, 'z': 256}) self.decT.go() else: decMDH['Deconvolution.Method'] = dlg.GetMethod() if dlg.GetMethod() == 'ICTM': decMDH['Deconvolution.RegularisationParameter'] = regLambda if beadMode: self.dec = dec.dec_bead() else: self.dec = dec.dec_conv() else: if beadMode: self.dec = richardsonLucy.rlbead() else: self.dec = richardsonLucy.dec_conv() self.dec.psf_calc(psf, dp.shape) self.decT = decThread.decThread(self.dec, dp, regLambda, nIter, weights, bg = bg) self.decT.start() tries = 0 while tries < 10 and not hasattr(self.dec, 'fs'): time.sleep(1) tries += 1 if dlg.GetPadding() and dlg.GetRemovePadding(): fs = self.dec.fs[px:-px, py:-py, pz:-pz] else: fs = self.dec.fs im = ImageStack(data = fs, mdh = decMDH, titleStub = 'Deconvolution Result') mode = 'lite' if beadMode: mode = 'psf' im.defaultExt = '*.psf' #we want to save as PSF by default self.res = ViewIm3D(im, mode=mode, parent=wx.GetTopLevelParent(self.dsviewer)) #self.res = View3D(fs, 'Deconvolution Result', mdh=decMDH, parent=wx.GetTopLevelParent(self.dsviewer), mode=mode) self.dlgDeconProg = DeconvProgressPanel(self.res, nIter) self.pinfo1 = aui.AuiPaneInfo().Name("deconvPanel").Top().Caption('Deconvolution Progress').DestroyOnClose(True).CloseButton(False)#.MinimizeButton(True).MinimizeMode(aui.AUI_MINIMIZE_CAPT_SMART|aui.AUI_MINIMIZE_POS_RIGHT)#.CaptionVisible(False) self.res._mgr.AddPane(self.dlgDeconProg, self.pinfo1) self.res._mgr.Update() self.deconTimer = mytimer() self.deconTimer.WantNotification.append(self.OnDeconTimer) self.deconTimer.Start(500)
def OnDeconvICTM(self, event, beadMode=False): from PYME.Deconv.deconvDialogs import DeconvSettingsDialog, DeconvProgressDialog, DeconvProgressPanel dlg = DeconvSettingsDialog(self.dsviewer, beadMode, self.image.data.shape[3]) if dlg.ShowModal() == wx.ID_OK: from PYME.Deconv import dec, decThread, richardsonLucy nIter = dlg.GetNumIterationss() regLambda = dlg.GetRegularisationLambda() decMDH = MetaDataHandler.NestedClassMDHandler(self.image.mdh) decMDH['Deconvolution.NumIterations'] = nIter decMDH['Deconvolution.OriginalFile'] = self.image.filename #self.dlgDeconProg = DeconvProgressDialog(self.dsviewer, nIter) #self.dlgDeconProg.Show() vx = self.image.mdh.getEntry('voxelsize.x') vy = self.image.mdh.getEntry('voxelsize.y') vz = self.image.mdh.getEntry('voxelsize.z') if beadMode: from PYME.Deconv import beadGen psf = beadGen.genBeadImage(dlg.GetBeadRadius(), (1e3 * vx, 1e3 * vy, 1e3 * vz)) decMDH['Deconvolution.BeadRadius'] = dlg.GetBeadRadius() else: #psf, vs = numpy.load(dlg.GetPSFFilename()) #psf = numpy.atleast_3d(psf) psfFilename, psf, vs = dlg.GetPSF(vshint=vx) decMDH['Deconvolution.PSFFile'] = dlg.GetPSFFilename() if not (vs.x == vx and vs.y == vy and vs.z == vz): #rescale psf to match data voxel size psf = ndimage.zoom(psf, [vs.x / vx, vs.y / vy, vs.z / vz]) data = self.image.data[:, :, :, dlg.GetChannel()].astype( 'f') - dlg.GetOffset() decMDH['Deconvolution.Offset'] = dlg.GetOffset() bg = dlg.GetBackground() decMDH['Deconvolution.Background'] = bg #crop PSF in z if bigger than stack print psf.shape, data.shape if psf.shape[2] > data.shape[2]: dz = psf.shape[2] - data.shape[2] psf = psf[:, :, numpy.floor(dz / 2):(psf.shape[2] - numpy.ceil(dz / 2))] print((data.shape, psf.shape)) if dlg.GetPadding(): padsize = numpy.array(dlg.GetPadSize()) decMDH['Deconvolution.Padding'] = padsize dp = numpy.ones(numpy.array(data.shape) + 2 * padsize, 'f') * data.mean() weights = numpy.zeros_like(dp) px, py, pz = padsize #print data.shape, dp[px:-(px+1), py:-(py+1), pz:-(pz+1)].shape dp[px:-px, py:-py, pz:-pz] = data #if dlg.GetRemovePadding(): # data = dp[px:-px, py:-py, pz:-pz]#should be a slice #else: # data = dp weights[px:-px, py:-py, pz:-pz] = 1. weights = weights.ravel() else: dp = data weights = 1 if dlg.GetBlocking(): decMDH['Deconvolution.Method'] = 'Blocked ICTM' self.checkTQ() from PYME.Deconv import tq_block_dec bs = dlg.GetBlockSize() self.decT = tq_block_dec.blocking_deconv(self.tq, data, psf, self.image.seriesName, blocksize={ 'y': bs, 'x': bs, 'z': 256 }) self.decT.go() else: decMDH['Deconvolution.Method'] = dlg.GetMethod() if dlg.GetMethod() == 'ICTM': decMDH['Deconvolution.RegularisationParameter'] = regLambda if beadMode: self.dec = dec.dec_bead() else: self.dec = dec.dec_conv() else: if beadMode: self.dec = richardsonLucy.rlbead() else: self.dec = richardsonLucy.dec_conv() self.dec.psf_calc(psf, dp.shape) self.decT = decThread.decThread(self.dec, dp, regLambda, nIter, weights, bg=bg) self.decT.start() tries = 0 while tries < 10 and not hasattr(self.dec, 'fs'): time.sleep(1) tries += 1 if dlg.GetPadding() and dlg.GetRemovePadding(): fs = self.dec.fs[px:-px, py:-py, pz:-pz] else: fs = self.dec.fs im = ImageStack(data=fs, mdh=decMDH, titleStub='Deconvolution Result') mode = 'lite' if beadMode: mode = 'psf' im.defaultExt = '*.psf' #we want to save as PSF by default self.res = ViewIm3D(im, mode=mode, parent=wx.GetTopLevelParent(self.dsviewer)) #self.res = View3D(fs, 'Deconvolution Result', mdh=decMDH, parent=wx.GetTopLevelParent(self.dsviewer), mode=mode) self.dlgDeconProg = DeconvProgressPanel(self.res, nIter) self.pinfo1 = aui.AuiPaneInfo().Name("deconvPanel").Top( ).Caption('Deconvolution Progress').DestroyOnClose( True ).CloseButton( False ) #.MinimizeButton(True).MinimizeMode(aui.AUI_MINIMIZE_CAPT_SMART|aui.AUI_MINIMIZE_POS_RIGHT)#.CaptionVisible(False) self.res._mgr.AddPane(self.dlgDeconProg, self.pinfo1) self.res._mgr.Update() self.deconTimer = mytimer() self.deconTimer.WantNotification.append(self.OnDeconTimer) self.deconTimer.Start(500)
def __init__(self, parent, options=None): self._init_ctrls(parent) self.options = options self._mgr = aui.AuiManager(agwFlags=aui.AUI_MGR_DEFAULT | aui.AUI_MGR_AUTONB_NO_CAPTION) atabstyle = self._mgr.GetAutoNotebookStyle() self._mgr.SetAutoNotebookStyle((atabstyle ^ aui.AUI_NB_BOTTOM) | aui.AUI_NB_TOP) # tell AuiManager to manage this frame self._mgr.SetManagedWindow(self) self.snapNum = 0 wx.EVT_CLOSE(self, self.OnCloseWindow) self.MainFrame = self #reference to this window for use in scripts etc... self.MainMenu = self.menuBar1 protocol.MainFrame = self self.toolPanels = [] self.camPanels = [] self.postInit = [] self.initDone = False self.scope = microscope.microscope() self.splash = splashScreen.SplashScreen(self, self.scope) self.splash.Show() # self.sh = wx.py.shell.Shell(id=-1, # parent=self.notebook1, size=wx.Size(-1, -1), style=0, locals=self.__dict__, # introText='Python SMI bindings - note that help, license etc below is for Python, not PySMI\n\n') # self.sh = wx.py.shell.Shell( id=-1, parent=self, size=wx.Size(-1, -1), style=0, locals=self.__dict__, introText= 'Python SMI bindings - note that help, license etc below is for Python, not PySMI\n\n' ) #self.notebook1.AddPage(imageId=-1, page=self.sh, select=True, text='Console') #self.notebook1.AddPage(imageId=-1, page=self.panel1, select=False, text='About') #self.notebook1.AddPage(page=self.sh, select=True, caption='Console') self._mgr.AddPane( self.sh, aui.AuiPaneInfo().Name("shell").Caption( "Console").Centre().CloseButton(False)) # self.notebook1.AddPage( page=self.panel1, select=False, caption='About') #self.SetSize((400, 800)) self.CreateToolPanel() #self.SetSize((1000, 800)) #self.sizer = wx.BoxSizer() #self.sizer.Add(self.notebook1, 1, wx.EXPAND) #self.SetSizer(self.Sizer) self.SetSize((1030, 895)) #self._mgr.Update() self.roi_on = False self.bin_on = False self.time1 = mytimer.mytimer() self.time1.Start(500) self.time1.WantNotification.append(self.runInitScript) self.time1.WantNotification.append(self.checkInitDone) self.time1.WantNotification.append(self.splash.Tick)
def __init__(self, parent, sourceImage, destImage): from PYME.Deconv import wiener wx.Panel.__init__(self, parent) self.dw = wiener.dec_wiener() self.sourceImage = sourceImage self.destImage = destImage self.havePSF = False self.decT = None #GUI stuff sizer2 = wx.BoxSizer(wx.VERTICAL) sizer3 = wx.BoxSizer(wx.HORIZONTAL) sizer3.Add(wx.StaticText(self, -1, 'PSF:'), 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.fpPSF = wx.FilePickerCtrl(self, -1, wildcard='*.psf', style=wx.FLP_OPEN | wx.FLP_FILE_MUST_EXIST) self.fpPSF.Bind(wx.EVT_FILEPICKER_CHANGED, self.OnPSFFileChanged) sizer3.Add(self.fpPSF, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) sizer2.Add(sizer3, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0) sizer3 = wx.BoxSizer(wx.HORIZONTAL) sizer3.Add(wx.StaticText(self, -1, 'Offset:'), 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.tOffset = wx.TextCtrl(self, -1, '0') sizer3.Add(self.tOffset, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) sizer2.Add(sizer3, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0) sizer3 = wx.BoxSizer(wx.HORIZONTAL) sizer3.Add(wx.StaticText(self, -1, u'Regularisation \u03BB:'), 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.tRegLambda = wx.TextCtrl(self, -1, '1e-8') sizer3.Add(self.tRegLambda, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) sizer2.Add(sizer3, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0) sizer3 = wx.BoxSizer(wx.HORIZONTAL) sizer3.AddSpacer(10) self.bCalculate = wx.Button(self, -1, 'Apply') self.bCalculate.Bind(wx.EVT_BUTTON, self.OnCalculate) self.bCalculate.Enable(False) sizer3.Add(self.bCalculate, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) sizer2.Add(sizer3, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0) self.SetSizerAndFit(sizer2) self.deconTimer = mytimer() self.deconTimer.WantNotification.append(self.OnDeconTimer) self.deconTimer.Start(500)
def __init__(self, dsviewer): self.dsviewer = dsviewer if 'tq' in dir(dsviewer): self.tq = dsviewer.tq else: self.tq = None self.image = dsviewer.image self.view = dsviewer.view self.do = dsviewer.do #this should only occur for files types which we weren't expecting to process #as LM data (eg tiffs) if not 'EstimatedLaserOnFrameNo' in self.image.mdh.getEntryNames(): from PYME.Analysis import MetaData #try: MetaData.fillInBlanks(self.image.mdh, self.image.dataSource) #except IndexError: # pass if 'fitResults' in dir(self.image): self.fitResults = self.image.fitResults else: self.fitResults = [] if 'resultsMdh' in dir(self.image): self.resultsMdh = self.image.resultsMdh mTasks = wx.Menu() TASKS_STANDARD_2D = wx.NewId() TASKS_CALIBRATE_SPLITTER = wx.NewId() TASKS_2D_SPLITTER = wx.NewId() TASKS_3D = wx.NewId() TASKS_3D_SPLITTER = wx.NewId() TASKS_PRI = wx.NewId() mTasks.Append(TASKS_STANDARD_2D, "Normal 2D analysis", "", wx.ITEM_NORMAL) mTasks.Append(TASKS_CALIBRATE_SPLITTER, "Calibrating the splitter", "", wx.ITEM_NORMAL) mTasks.Append(TASKS_2D_SPLITTER, "2D with splitter", "", wx.ITEM_NORMAL) mTasks.Append(TASKS_3D, "3D analysis", "", wx.ITEM_NORMAL) mTasks.Append(TASKS_3D_SPLITTER, "3D with splitter", "", wx.ITEM_NORMAL) mTasks.Append(TASKS_PRI, "PRI", "", wx.ITEM_NORMAL) self.dsviewer.menubar.Append(mTasks, "Set defaults for") wx.EVT_MENU(self.dsviewer, TASKS_CALIBRATE_SPLITTER, self.OnCalibrateSplitter) wx.EVT_MENU(self.dsviewer, TASKS_STANDARD_2D, self.OnStandard2D) wx.EVT_MENU(self.dsviewer, TASKS_2D_SPLITTER, self.OnSpitter2D) wx.EVT_MENU(self.dsviewer, TASKS_3D, self.OnStandard3D) wx.EVT_MENU(self.dsviewer, TASKS_3D_SPLITTER, self.OnSpliter3D) wx.EVT_MENU(self.dsviewer, TASKS_PRI, self.OnPRI3D) BG_SUBTRACT = wx.NewId() self.dsviewer.view_menu.AppendCheckItem(BG_SUBTRACT, 'Subtract Background') wx.EVT_MENU(self.dsviewer, BG_SUBTRACT, self.OnToggleBackground) #a timer object to update for us self.timer = mytimer() self.timer.Start(10000) self.analDispMode = 'z' self.numAnalysed = 0 self.numEvents = 0 dsviewer.pipeline = pipeline.Pipeline() self.ds = None dsviewer.paneHooks.append(self.GenPointFindingPanel) dsviewer.paneHooks.append(self.GenAnalysisPanel) dsviewer.paneHooks.append(self.GenFitStatusPanel) dsviewer.updateHooks.append(self.update) dsviewer.statusHooks.append(self.GetStatusText) if 'Protocol.DataStartsAt' in self.image.mdh.getEntryNames(): self.do.zp = self.image.mdh.getEntry('Protocol.DataStartsAt') else: self.do.zp = self.image.mdh.getEntry('EstimatedLaserOnFrameNo')
def __init__(self, parent, options = None): self._init_ctrls(parent) self.options = options self._mgr = aui.AuiManager(agwFlags = aui.AUI_MGR_DEFAULT | aui.AUI_MGR_AUTONB_NO_CAPTION) atabstyle = self._mgr.GetAutoNotebookStyle() self._mgr.SetAutoNotebookStyle((atabstyle ^ aui.AUI_NB_BOTTOM) | aui.AUI_NB_TOP) # tell AuiManager to manage this frame self._mgr.SetManagedWindow(self) self.snapNum = 0 wx.EVT_CLOSE(self, self.OnCloseWindow) self.MainFrame = self #reference to this window for use in scripts etc... self.MainMenu = self.menuBar1 protocol.MainFrame = self self.toolPanels = [] self.camPanels = [] self.postInit = [] self.initDone = False self.scope = microscope.microscope() self.splash = splashScreen.SplashScreen(self, self.scope) self.splash.Show() # self.sh = wx.py.shell.Shell(id=-1, # parent=self.notebook1, size=wx.Size(-1, -1), style=0, locals=self.__dict__, # introText='Python SMI bindings - note that help, license etc below is for Python, not PySMI\n\n') # self.sh = wx.py.shell.Shell(id=-1, parent=self, size=wx.Size(-1, -1), style=0, locals=self.__dict__, introText='Python SMI bindings - note that help, license etc below is for Python, not PySMI\n\n') #self.notebook1.AddPage(imageId=-1, page=self.sh, select=True, text='Console') #self.notebook1.AddPage(imageId=-1, page=self.panel1, select=False, text='About') #self.notebook1.AddPage(page=self.sh, select=True, caption='Console') self._mgr.AddPane(self.sh, aui.AuiPaneInfo(). Name("shell").Caption("Console").Centre().CloseButton(False)) # self.notebook1.AddPage( page=self.panel1, select=False, caption='About') #self.SetSize((400, 800)) self.CreateToolPanel() #self.SetSize((1000, 800)) #self.sizer = wx.BoxSizer() #self.sizer.Add(self.notebook1, 1, wx.EXPAND) #self.SetSizer(self.Sizer) self.SetSize((1030, 895)) #self._mgr.Update() self.roi_on = False self.bin_on = False self.time1 = mytimer.mytimer() self.time1.Start(500) self.time1.WantNotification.append(self.runInitScript) self.time1.WantNotification.append(self.checkInitDone) self.time1.WantNotification.append(self.splash.Tick)
def __init__(self, image, parent=None, title='', mode='LM', size = (800,700), glCanvas=None): wx.Frame.__init__(self,parent, -1, title,size=size, pos=(1100, 300)) self.SetAutoLayout(True) self.mode = mode self.glCanvas = glCanvas self.paneHooks = [] self.updateHooks = [] self.statusHooks = [] self.installedModules = [] self.dataChangeHooks = [] self.updating = False if glCanvas: self.glCanvas.wantViewChangeNotification.add(self) self.pane0 = None self.timer = mytimer() self.timer.Start(10000) self.image = image #self.image = ImageStack(data = dstack, mdh = mdh, filename = filename, queueURI = queueURI, events = None) if not self.image.filename == None and title == '': self.SetTitle(self.image.filename) self._mgr = aui.AuiManager(agwFlags = aui.AUI_MGR_DEFAULT | aui.AUI_MGR_AUTONB_NO_CAPTION) atabstyle = self._mgr.GetAutoNotebookStyle() self._mgr.SetAutoNotebookStyle((atabstyle ^ aui.AUI_NB_BOTTOM) | aui.AUI_NB_TOP) # tell AuiManager to manage this frame self._mgr.SetManagedWindow(self) self.do = DisplayOpts(self.image.data) if self.image.data.shape[1] == 1: self.do.slice = self.do.SLICE_XZ self.do.Optimise() if self.image.mdh and 'ChannelNames' in self.image.mdh.getEntryNames(): self.do.names = self.image.mdh.getEntry('ChannelNames') #self.vp = ArraySettingsAndViewPanel(self, self.image.data, wantUpdates=[self.update], mdh=self.image.mdh) #self.view = ArrayViewPanel(self, do=self.do) #self.AddPage(self.view, True, 'Data') #self._mgr.AddPane(self.vp, aui.AuiPaneInfo(). # Name("Data").Caption("Data").Centre().CloseButton(False).CaptionVisible(False)) self.mainFrame = weakref.ref(self) #self.do = self.vp.do self._menus = {} # Menu Bar self.menubar = wx.MenuBar() self.SetMenuBar(self.menubar) tmp_menu = wx.Menu() tmp_menu.Append(wx.ID_OPEN, '&Open', "", wx.ITEM_NORMAL) tmp_menu.Append(wx.ID_SAVE, "&Save As", "", wx.ITEM_NORMAL) tmp_menu.Append(wx.ID_SAVEAS, "&Export Cropped", "", wx.ITEM_NORMAL) #a submenu for modules to hook and install saving functions into self.save_menu = wx.Menu() self._menus['Save'] = self.save_menu tmp_menu.AppendMenu(-1, 'Save &Results', self.save_menu) tmp_menu.AppendSeparator() tmp_menu.Append(wx.ID_CLOSE, "Close", "", wx.ITEM_NORMAL) self.menubar.Append(tmp_menu, "File") self.view_menu = wx.Menu() self.menubar.Append(self.view_menu, "&View") self._menus['View'] = self.view_menu #'extras' menu for modules to install stuff into self.mProcessing = wx.Menu() self.menubar.Append(self.mProcessing, "&Processing") self._menus['Processing'] = self.mProcessing # Menu Bar end wx.EVT_MENU(self, wx.ID_OPEN, self.OnOpen) wx.EVT_MENU(self, wx.ID_SAVE, self.OnSave) wx.EVT_MENU(self, wx.ID_SAVEAS, self.OnExport) wx.EVT_CLOSE(self, self.OnCloseWindow) wx.EVT_SIZE(self, self.OnSize) self.statusbar = self.CreateStatusBar(1, wx.ST_SIZEGRIP) self.panesToMinimise = [] modules.loadMode(self.mode, self) self.CreateModuleMenu() self.optionspanel = OptionsPanel(self, self.do, thresholdControls=True) self.optionspanel.SetSize(self.optionspanel.GetBestSize()) pinfo = aui.AuiPaneInfo().Name("optionsPanel").Right().Caption('Display Settings').CloseButton(False).MinimizeButton(True).MinimizeMode(aui.AUI_MINIMIZE_CAPT_SMART|aui.AUI_MINIMIZE_POS_RIGHT)#.CaptionVisible(False) self._mgr.AddPane(self.optionspanel, pinfo) self.panesToMinimise.append(pinfo) self._mgr.AddPane(self.optionspanel.CreateToolBar(self), aui.AuiPaneInfo().Name("ViewTools").Caption("View Tools").CloseButton(False). ToolbarPane().Right().GripperTop()) if self.do.ds.shape[2] > 1: from PYME.DSView.modules import playback self.playbackpanel = playback.PlayPanel(self, self) self.playbackpanel.SetSize(self.playbackpanel.GetBestSize()) pinfo1 = aui.AuiPaneInfo().Name("playbackPanel").Bottom().Caption('Playback').CloseButton(False).MinimizeButton(True).MinimizeMode(aui.AUI_MINIMIZE_CAPT_SMART|aui.AUI_MINIMIZE_POS_RIGHT)#.CaptionVisible(False) self._mgr.AddPane(self.playbackpanel, pinfo1) self.do.WantChangeNotification.append(self.playbackpanel.update) #self.mWindows = wx.Menu() #self.menubar.append(self.mWindows, '&Composite With') self.do.WantChangeNotification.append(self.update) self.CreateFoldPanel() self._mgr.Update() for pn in self.panesToMinimise: self._mgr.MinimizePane(pn) #self._mgr.MinimizePane(pinfo2) self.Layout() if 'view' in dir(self): sc = pylab.floor(pylab.log2(1.0*self.view.Size[0]/self.do.ds.shape[0])) #print self.view.Size[0], self.do.ds.shape[0], sc self.do.SetScale(sc) self.view.Refresh() self.update() self.drop = dt() self.SetDropTarget(self.drop) openViewers[self.image.filename] = self