class AnalysisDetailsPanel(wx.Panel): DEFAULT_PARAMS = [mde.FloatParam('Analysis.DetectionThreshold', 'Thresh:', 1.0), mde.IntParam('Analysis.DebounceRadius', 'Debounce rad:', 4), mde.IntParam('Analysis.StartAt', 'Start at:', default=30), mde.RangeParam('Analysis.BGRange', 'Background:', default=(-30,0)), mde.BoolParam('Analysis.subtractBackground', 'Subtract background in fit', default=True), mde.BoolFloatParam('Analysis.PCTBackground' , 'Use percentile for background', default=False, helpText='', ondefault=0.25, offvalue=0), #mde.FilenameParam('Camera.VarianceMapID', 'Variance Map:', prompt='Please select variance map to use ...', wildcard='TIFF Files|*.tif', filename=''), #mde.FilenameParam('Camera.DarkMapID', 'Dark Map:', prompt='Please select dark map to use ...', wildcard='TIFF Files|*.tif', filename=''), #mde.FilenameParam('Camera.FlatfieldMapID', 'Flatfield Map:', prompt='Please select flatfield map to use ...', wildcard='TIFF Files|*.tif', filename=''), mde.BoolParam('Analysis.TrackFiducials', 'Track Fiducials', default=False), mde.FloatParam('Analysis.FiducialThreshold', 'Fiducial Threshold', default=1.8), ] def __init__(self, parent, analysisSettings, mdhChangedSignal=None): wx.Panel.__init__(self, parent, -1) self.analysisSettings = analysisSettings self.analysisMDH = analysisSettings.analysisMDH self.mdhChangedSignal = mdhChangedSignal mdhChangedSignal.connect(self.OnMDChanged) self._analysisModule = '' vsizer = wx.BoxSizer(wx.VERTICAL) vsizer_std = wx.BoxSizer(wx.VERTICAL) self._populateStdOptionsPanel(self, vsizer_std) vsizer.Add(vsizer_std, 0, wx.EXPAND, 0) self.customOptionsSizer = wx.BoxSizer(wx.VERTICAL) self._populateCustomAnalysisPanel(self, self.customOptionsSizer) vsizer.Add(self.customOptionsSizer, 0, wx.EXPAND, 0) self.SetSizerAndFit(vsizer) def _populateStdOptionsPanel(self, pan, vsizer): for param in self.DEFAULT_PARAMS: pg = param.createGUI(pan, self.analysisMDH, syncMdh=True, mdhChangedSignal = self.mdhChangedSignal) vsizer.Add(pg, 0,wx.BOTTOM|wx.EXPAND, 5) vsizer.Fit(pan) def _populateCustomAnalysisPanel(self, pan, vsizer): try: #fitMod = self.fitFactories[self.cFitType.GetSelection()] self._analysisModule = self.analysisMDH['Analysis.FitModule'] fm = __import__('PYME.localization.FitFactories.' + self._analysisModule, fromlist=['PYME', 'localization', 'FitFactories']) #vsizer = wx.BoxSizer(wx.VERTICAL) for param in fm.PARAMETERS: pg = param.createGUI(pan, self.analysisMDH, syncMdh=True, mdhChangedSignal = self.mdhChangedSignal) vsizer.Add(pg, 0,wx.BOTTOM|wx.EXPAND, 5) vsizer.Fit(pan) self.Layout() self.SetMinSize([200, self.GetBestSize()[1]]) self.GetParent().Layout() print('custom analysis settings populated') except (KeyError, AttributeError): pass def OnMDChanged(self, event=None, sender=None, signal=None, mdh=None): if not self._analysisModule == self.analysisMDH['Analysis.FitModule']: self.customOptionsSizer.Clear(True) self._populateCustomAnalysisPanel(self, self.customOptionsSizer) # FIXME - can't figure out a better way to redo the vertical sizer for longer menus self.GetParent().fold1(self) self.GetParent().fold1(self)
class AnalysisSettingsView(object): FINDING_PARAMS = [ mde.FloatParam('Analysis.DetectionThreshold', 'Thresh:', 1.0), mde.IntParam('Analysis.DebounceRadius', 'Debounce rad:', 4), ] DEFAULT_PARAMS = [ mde.IntParam('Analysis.StartAt', 'Start at:', default=30), mde.ParamGroup('Background Subtraction', [ mde.RangeParam('Analysis.BGRange', 'Background:', default=(-30, 0)), mde.BoolParam('Analysis.subtractBackground', 'Subtract background in fit', default=True), mde.BoolFloatParam('Analysis.PCTBackground', 'Use percentile for background', default=False, helpText='', ondefault=0.25, offvalue=0), ], folded=False), mde.ParamGroup('sCMOS camera noise maps', [ mde.FilenameParam('Camera.VarianceMapID', 'Variance Map:', prompt='Please select variance map to use ...', wildcard=MAP_WILDCARDS, filename=''), mde.FilenameParam('Camera.DarkMapID', 'Dark Map:', prompt='Please select dark map to use ...', wildcard=MAP_WILDCARDS, filename=''), mde.FilenameParam('Camera.FlatfieldMapID', 'Flatfield Map:', prompt='Please select flatfield map to use ...', wildcard=MAP_WILDCARDS, filename=''), ]), mde.ParamGroup('Fiducial based drift tracking', [ mde.BoolParam( 'Analysis.TrackFiducials', 'Track Fiducials', default=False), mde.FloatParam('Analysis.FiducialThreshold', 'Fiducial Threshold', default=1.8), mde.IntParam( 'Analysis.FiducialROISize', 'Fiducial ROI', default=11), mde.FloatParam('Analysis.FiducialSize', 'Fiducial Diameter [nm]', default=1000.), ]), ] def __init__(self, dsviewer, analysisController, lmanal=None): self.foldAnalPanes = False self.analysisController = analysisController self.analysisMDH = analysisController.analysisMDH self.lmanal = lmanal dsviewer.paneHooks.append(self.GenPointFindingPanel) dsviewer.paneHooks.append(self.GenAnalysisPanel) self.analysisController.onMetaDataChange.connect( self.on_metadata_change) def _populateStdOptionsPanel(self, pan, vsizer): for param in self.DEFAULT_PARAMS: pg = param.createGUI( pan, self.analysisMDH, syncMdh=True, mdhChangedSignal=self.analysisController.onMetaDataChange) vsizer.Add(pg, 0, wx.BOTTOM | wx.EXPAND, 5) vsizer.Fit(pan) def _populateFindOptionsPanel(self, pan, vsizer): for param in self.FINDING_PARAMS: pg = param.createGUI( pan, self.analysisMDH, syncMdh=True, mdhChangedSignal=self.analysisController.onMetaDataChange) vsizer.Add(pg, 0, wx.BOTTOM | wx.EXPAND, 5) def _populateCustomAnalysisPanel(self, pan, vsizer): try: fitMod = self.fitFactories[self.cFitType.GetSelection()] fm = __import__('PYME.localization.FitFactories.' + fitMod, fromlist=['PYME', 'localization', 'FitFactories']) #vsizer = wx.BoxSizer(wx.VERTICAL) for param in fm.PARAMETERS: pg = param.createGUI( pan, self.analysisMDH, syncMdh=True, mdhChangedSignal=self.analysisController.onMetaDataChange) vsizer.Add(pg, 0, wx.BOTTOM | wx.EXPAND, 5) vsizer.Fit(pan) except AttributeError: pass def on_metadata_change(self, *args, **kwargs): fit_module = self.analysisMDH.getOrDefault('Analysis.FitModule', 'LatGaussFitFR') if not fit_module == self.fitFactories[self.cFitType.GetSelection()]: self.cFitType.SetSelection(self.fitFactories.index(fit_module)) self.OnFitModuleChanged(None) def OnFitModuleChanged(self, event): self.customOptionsSizer.Clear(True) self._populateCustomAnalysisPanel(self.customOptionsPan, self.customOptionsSizer) self.customOptionsPan.GetTopLevelParent().OnSize(None) self.analysisMDH['Analysis.FitModule'] = self.fitFactories[ self.cFitType.GetSelection()] def GenAnalysisPanel(self, _pnl): item = afp.foldingPane(_pnl, -1, caption="Analysis", pinned=not (self.foldAnalPanes)) ############################# #std options pan = wx.Panel(item, -1) vsizer = wx.BoxSizer(wx.VERTICAL) pan.SetSizer(vsizer) self._populateStdOptionsPanel(pan, vsizer) item.AddNewElement(pan) ####################### #Fit factory selection pan = wx.Panel(item, -1) #find out what fit factories we have self.fitFactories = PYME.localization.FitFactories.resFitFactories print((self.fitFactories)) vsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.Add(wx.StaticText(pan, -1, 'Type:'), 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5) self.cFitType = wx.Choice( pan, -1, choices=[ '{:<35} \t- {:} '.format( f, PYME.localization.FitFactories.useFor[f]) for f in self.fitFactories ], size=(110, -1)) if 'Analysis.FitModule' in self.analysisMDH.getEntryNames(): #has already been analysed - most likely to want the same method again try: self.cFitType.SetSelection( self.fitFactories.index( self.analysisMDH['Analysis.FitModule'])) #self.tThreshold.SetValue('%s' % self.image.mdh.getOrDefault('Analysis.DetectionThreshold', 1)) except ValueError: self.cFitType.SetSelection( self.fitFactories.index('LatGaussFitFR')) #elif 'Camera.ROIPosY' in self.image.mdh.getEntryNames() and (self.image.mdh.getEntry('Camera.ROIHeight') + 1 + 2*(self.image.mdh.getEntry('Camera.ROIPosY')-1)) == 512: # #we have a symetrical ROI about the centre - most likely want to analyse using splitter # self.cFitType.SetSelection(self.fitFactories.index('SplitterFitQR')) # self.tThreshold.SetValue('0.5') else: self.cFitType.SetSelection( self.fitFactories.index('LatGaussFitFR')) self.analysisMDH['Analysis.FitModule'] = 'LatGaussFitFR' self.cFitType.Bind(wx.EVT_CHOICE, self.OnFitModuleChanged) hsizer.Add(self.cFitType, 1, wx.ALIGN_CENTER_VERTICAL, 0) vsizer.Add(hsizer, 0, wx.BOTTOM | wx.EXPAND, 2) pan.SetSizer(vsizer) vsizer.Fit(pan) item.AddNewElement(pan) ######################################## #custom (fit factory dependant) options self.customOptionsPan = wx.Panel(item, -1) self.customOptionsSizer = wx.BoxSizer(wx.VERTICAL) self.customOptionsPan.SetSizer(self.customOptionsSizer) self._populateCustomAnalysisPanel(self.customOptionsPan, self.customOptionsSizer) item.AddNewElement(self.customOptionsPan) ###################### #Go if self.lmanal: self.bGo = wx.Button(item, -1, 'Go') self.bGo.Bind(wx.EVT_BUTTON, lambda e: self.lmanal.OnGo(e)) item.AddNewElement(self.bGo) _pnl.AddPane(item) self.analysisPanel = item def GenPointFindingPanel(self, _pnl): item = afp.foldingPane(_pnl, -1, caption="Point Finding", pinned=not (self.foldAnalPanes)) pan = wx.Panel(item, -1) vsizer = wx.BoxSizer(wx.VERTICAL) #load point finding settings self._populateFindOptionsPanel(pan, vsizer) if not self.lmanal is None: hsizer = wx.BoxSizer(wx.HORIZONTAL) #bTest = wx.Button(pan, -1, 'Test', style=wx.BU_EXACTFIT) #bTest.Bind(wx.EVT_BUTTON, lambda e : self.lmanal.Test()) #hsizer.Add(bTest, 0,wx.LEFT|wx.ALIGN_CENTER_VERTICAL, 5) bTestF = wx.Button(pan, -1, 'Test This Frame', style=wx.BU_EXACTFIT) bTestF.Bind(wx.EVT_BUTTON, lambda e: self.lmanal.OnTestFrame(e)) hsizer.Add(bTestF, 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5) vsizer.Add(hsizer, 0, wx.BOTTOM | wx.EXPAND, 2) pan.SetSizerAndFit(vsizer) item.AddNewElement(pan) _pnl.AddPane(item)
from PYME.cluster import HTTPRulePusher, HTTPTaskPusher FINDING_PARAMS = [ #mde.ChoiceParam('Analysis.FitModule', 'Fit module:', default='LatGaussFitFR', choices=PYME.localization.FitFactories.resFitFactories), mde.FloatParam('Analysis.DetectionThreshold', 'Detection threshold:', 1.0), mde.IntParam('Analysis.DebounceRadius', 'Debounce radius:', 4), mde.IntParam('Analysis.StartAt', 'Start at:', default=30), ] BACKGROUND_PARAMS = [ #mde.IntParam('Analysis.StartAt', 'Start at:', default=30), mde.RangeParam('Analysis.BGRange', 'Background range:', default=[-30, 0]), mde.BoolParam('Analysis.subtractBackground', 'Subtract background in fit', default=True), mde.BoolFloatParam('Analysis.PCTBackground', 'Use percentile for background', default=False, helpText='', ondefault=0.25, offvalue=0), ] SCMOS_PARAMS = [ mde.FilenameParam('Camera.VarianceMapID', 'Variance Map:', prompt='Please select variance map to use ...', wildcard='TIFF Files|*.tif', filename=''), mde.FilenameParam('Camera.DarkMapID', 'Dark Map:', prompt='Please select dark map to use ...', wildcard='TIFF Files|*.tif', filename=''),