def fitDrift(filename): print(filename) pipe = pipeline.Pipeline(filename) im = Image.objects.get(pk=pipe.mdh['imageID']) if im.drift_settings.count() < 1: dc = driftNoGUI.DriftCorrector(pipe.filter) dc.SetNumPiecewiseSegments(5) dc.FitDrift() df = DriftFit(imageID=im, exprX=dc.driftExprX, exprY=dc.driftExprY, exprZ=dc.driftExprZ, parameters=dc.driftCorrParams, auto=True) df.save() print(df) pipe.CloseFiles()
def RunCurrentRecipe(self, event=None): if self.activeRecipe: outp = self.activeRecipe.execute(input=self.image) if isinstance(outp, ImageStack): if self.dsviewer.mode == 'visGUI': mode = 'visGUI' else: mode = 'lite' dv = ViewIm3D(outp, mode=mode, glCanvas=self.dsviewer.glCanvas) #set scaling to (0,1) for i in range(outp.data.shape[3]): dv.do.Gains[i] = 1.0 else: #assume we made measurements - put in pipeline #TODO - put an explict check in here if not 'pipeline' in dir(self.dsviewer): self.dsviewer.pipeline = pipeline.Pipeline() self.dsviewer.pipeline.OpenFile(ds=outp) self.dsviewer.view.filter = self.dsviewer.pipeline
def __init__(self, dsviewer): self.dsviewer = dsviewer self.image = dsviewer.image self.view = dsviewer.view self.do = dsviewer.do 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 #a timer object to update for us #self.timer = mytimer() #self.timer.Start(10000) self.analDispMode = 'z' self.numAnalysed = 0 self.numEvents = 0 #dsviewer.paneHooks.append(self.GenFitStatusPanel) dsviewer.paneHooks.append(self.GenPanels) dsviewer.updateHooks.append(self.update) #dsviewer.statusHooks.append(self.GetStatusText) if (len(self.fitResults) > 0) and not 'PYME_BUGGYOPENGL' in os.environ.keys(): self.GenResultsView() if not 'pipeline' in dir(dsviewer): dsviewer.pipeline = pipeline.Pipeline(visFr=self) self.pipeline = dsviewer.pipeline self.pipeline.visFr = self #self.Quads = None dsviewer.menubar.Insert(dsviewer.menubar.GetMenuCount()-1, self.CreateMenuBar(subMenu=True), 'Points') self.viewMode = 'points' #one of points, triangles, quads, or voronoi self.colData = 't' # if 'PYME_BUGGYOPENGL' in os.environ.keys(): # pylab.plot(pylab.randn(10)) self.glCanvas = gl_render.LMGLCanvas(self.dsviewer) self.dsviewer.AddPage(page=self.glCanvas, select=True, caption='View') self.glCanvas.cmap = pylab.cm.gist_rainbow #pylab.cm.hot #self.Bind(wx.EVT_IDLE, self.OnIdle) self.refv = False #statusLog.SetStatusDispFcn(self.SetStatus) renderers.renderMetadataProviders.append(self.SaveMetadata)
def __init__(self, parent, filename=None, id=wx.ID_ANY, title="PYME Visualise", pos=wx.DefaultPosition, size=(700, 650), style=wx.DEFAULT_FRAME_STYLE): wx.Frame.__init__(self, parent, id, title, pos, size, style) 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) self._mgr.SetManagedWindow(self) self._flags = 0 self.pipeline = pipeline.Pipeline(visFr=self) #self.Quads = None self.SetMenuBar(self.CreateMenuBar()) self.statusbar = self.CreateStatusBar(1, wx.ST_SIZEGRIP) self.statusbar.SetStatusText("", 0) self._leftWindow1 = wx.Panel(self, -1, size=wx.Size(220, 1000)) self._pnl = 0 self.MainWindow = self #so we can access from shell 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._mgr.AddPane( self.sh, aui.AuiPaneInfo().Name("Shell").Caption( "Console").Centre().CloseButton(False).CaptionVisible(False)) self.elv = None self.colp = None self.mdp = None self.rav = None self.generatedImages = [] self.viewMode = 'points' #one of points, triangles, quads, or voronoi self.colData = 't' # if 'PYME_BUGGYOPENGL' in os.environ.keys(): # pylab.plot(pylab.randn(10)) self.sh.Execute('from pylab import *') self.sh.Execute('from PYME.DSView.dsviewer_npy import View3D') #self.workspace = workspaceTree.WorkWrap(self.__dict__) ##### Make certain things visible in the workspace tree #components of the pipeline #col = self.workspace.newColour() #self.workspace.addKey('pipeline', col) #Generated stuff #col = self.workspace.newColour() #self.workspace.addKey('GeneratedMeasures', col) #self.workspace.addKey('generatedImages', col) #self.workspace.addKey('objects', col) #main window, so we can get everything else if needed #col = self.workspace.newColour() #self.workspace.addKey('MainWindow', col) ###### #self.workspaceView = workspaceTree.WorkspaceTree(self, workspace=self.workspace, shell=self.sh) #self.AddPage(page=wx.StaticText(self, -1, 'foo'), select=False, caption='Workspace') self.glCanvas = gl_render.LMGLCanvas(self) self.AddPage(page=self.glCanvas, select=True, caption='View') self.glCanvas.cmap = pylab.cm.gist_rainbow #pylab.cm.hot #self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_MOVE, self.OnMove) self.Bind(wx.EVT_CLOSE, self.OnQuit) self.Bind(wx.EVT_IDLE, self.OnIdle) self.refv = False statusLog.SetStatusDispFcn(self.SetStatus) self.CreateFoldPanel() self._mgr.AddPane( self._leftWindow1, aui.AuiPaneInfo().Name("sidebar").Left().CloseButton( False).CaptionVisible(False)) self._mgr.Update() if not filename == None: self.OpenFile(filename) nb = self._mgr.GetNotebooks()[0] nb.SetSelection(0) renderers.renderMetadataProviders.append(self.SaveMetadata)
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')