#return PSFFitResultR(res, self.metadata, numpy.array((sig_xl, sig_xr, sig_yu, sig_yd)),(xslice, yslice, zslice), resCode, fitErrors, numpy.array(startParameters), nchi2) return PSFFitResultR(res1, self.metadata, (xslice, yslice, zslice), resCode1, fitErrors, np.array(startParameters1), nchi21) #so that fit tasks know which class to use FitFactory = WFPSFFitFactory FitResult = PSFFitResultR FitResultsDType = fresultdtype #only defined if returning data as numarray import PYME.localization.MetaDataEdit as mde from PYME.localization.FitFactories import Interpolators #from PYME.localization.FitFactories import zEstimators #set of parameters that this fit needs to know about PARAMETERS = [ #mde.ChoiceParam('Analysis.InterpModule','Interp:','CSInterpolator', choices=Interpolators.interpolatorList, choiceNames=Interpolators.interpolatorDisplayList), mde.FilenameParam('PSFFile', 'PSF:', prompt='Please select PSF to use ...', wildcard='PSF Files|*.psf|TIFF files|*.tif'), #mde.ShiftFieldParam('chroma.ShiftFilename', 'Shifts:', prompt='Please select shiftfield to use', wildcard='Shiftfields|*.sf'), #mde.IntParam('Analysis.DebounceRadius', 'Debounce r:', 4), #mde.FloatParam('Analysis.AxialShift', 'Z Shift [nm]:', 0), #mde.ChoiceParam('Analysis.EstimatorModule', 'Z Start Est:', 'astigEstimator', choices=zEstimators.estimatorList), #mde.ChoiceParam('PRI.Axis', 'PRI Axis:', 'y', choices=['x', 'y']) ] DESCRIPTION = 'EXP. 3D, single colour fitting for widefield PSF.' LONG_DESCRIPTION = 'Experimental 3D, single colour fitting optimized for widefield PSF. Attempts to work around the symmetry problem by starting the fit both above and below the focus, and seeing which converges to the better fit. Uses an interpolated experimental PSF like the other Interp fits. Unlikely to work very well unless there are significant abberations (e.g. S.A.) in the PSF.'
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)
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=''), mde.FilenameParam('Camera.FlatfieldMapID', 'Flatfield Map:', prompt='Please select flatfield map to use ...', wildcard='TIFF Files|*.tif', filename=''), ] FIDUCIAL_PARAMS = [