def createButtonBox(self): """ Creates a button box containing the buttons Render, Preview and Close """ TaskPanel.createButtonBox(self) lib.messenger.connect(None, "process_dataset", self.doColocalizationCallback)
def createButtonBox(self): """ Creates a button box containing the buttons Render, Preview and Close """ TaskPanel.createButtonBox(self) # self.processButton.SetLabel("Process Dataset Series") # self.processButton.Bind(wx.EVT_BUTTON,self.doProcessingCallback) lib.messenger.connect(None, "process_dataset", self.doProcessingCallback)
def createButtonBox(self): """ Creates a button box containing the buttons Render, Preview and Close """ TaskPanel.createButtonBox(self) #self.processButton.SetLabel("Process Dataset Series") #self.processButton.Bind(wx.EVT_BUTTON,self.doProcessingCallback) lib.messenger.connect(None, "process_dataset", self.doProcessingCallback)
def deregister(self): """ Removes all listeners """ TaskPanel.deregister(self) try: lib.messenger.disconnect(None, "timepoint_changed", self.updateTimepoint) lib.messenger.disconnect(None, "zslice_changed", self.updateZSlice) lib.messenger.disconnect(None, "threshold_changed", self.updateSettings) lib.messenger.disconnect(None, "data_changed", self.onDataChanged) except: pass
def createOptionsFrame(self): """ Creates a frame that contains the various widgets used to control the colocalization settings """ TaskPanel.createOptionsFrame(self) self.paletteLbl = wx.StaticText(self, -1, "Channel palette:") self.commonSettingsSizer.Add(self.paletteLbl, (1, 0)) self.colorBtn = CTFButton(self) self.commonSettingsSizer.Add(self.colorBtn, (2, 0)) self.Layout()
def setCombinedDataUnit(self, dataUnit): """ Set the dataunit used for the colocalization """ TaskPanel.setCombinedDataUnit(self, dataUnit) # See if the dataunit has a stored colocalizationctf # then use that. sources = self.dataUnit.getSourceDataUnits() self.updateNames() minval, maxval = sources[0].getScalarRange() minval2, maxval2 = sources[1].getScalarRange() minval = min(minval, minval2) bitmax1 = (2**sources[0].getSingleComponentBitDepth())-1 bitmax2 = (2**sources[0].getSingleComponentBitDepth())-1 maxval = max(maxval, maxval2, bitmax1, bitmax2) self.lowerthreshold1.SetRange(minval, maxval) self.lowerthreshold1.SetValue((maxval - minval + 1) / 2) self.upperthreshold1.SetRange(minval, maxval) self.upperthreshold1.SetValue(maxval) self.lowerthreshold2.SetRange(minval, maxval) self.lowerthreshold2.SetValue((maxval - minval + 1) / 2) self.upperthreshold2.SetRange(minval, maxval) self.upperthreshold2.SetValue(maxval) self.updateThreshold(None) na = sources[1].getNumericalAperture() emission = sources[1].getEmissionWavelength() if na: self.NA.SetValue("%.4f" % na) if emission: self.Ch2Lambda.SetValue("%d" % emission) self.onUpdatePSF(None) ctf = self.dataUnit.getSettings().get("ColocalizationColorTransferFunction") if not ctf: ctf = self.dataUnit.getSettings().get("ColorTransferFunction") else: Logging.info("Using ColocalizationColorTransferFunction", kw = "task") if self.colorBtn: self.colorBtn.setColorTransferFunction(ctf) self.scatterPlot.setDataUnit(dataUnit) if self.scatterPlot: #self.scatterPlot.setZSlice(self.preview.z) self.scatterPlot.setZSlice(0) self.scatterPlot.setTimepoint(self.timePoint) self.scatterPlot.updatePreview() self.colocalizationPanel.Layout()
def __init__(self, parent, tb): self.scatterPlot = None self.createItemSelection = 0 self.timePoint = 0 TaskPanel.__init__(self, parent, tb, wantNotebook = 0) self.operationName = "Colocalization" self.voxelSize = None self.mainsizer.Layout() self.mainsizer.Fit(self) lib.messenger.connect(None, "timepoint_changed", self.updateTimepoint) lib.messenger.connect(None, "zslice_changed", self.updateZSlice) lib.messenger.connect(None, "threshold_changed", self.updateSettings) lib.messenger.connect(None, bxdevents.DATA_DIMENSIONS_CHANGED, self.onDataChanged)
def doPreviewCallback(self, event = None, *args): """ A callback for the button "Preview" and other events that wish to update the preview """ self.updateBitDepth() TaskPanel.doPreviewCallback(self, event) if self.scatterPlot: self.scatterPlot.setSlope(self.dataUnit.getSettings().get("Slope")) self.scatterPlot.setIntercept(self.dataUnit.getSettings().get("Intercept")) self.scatterPlot.setZSlice(0) self.scatterPlot.setTimepoint(self.timePoint) self.scatterPlot.setDataUnit(self.dataUnit) ctf = self.dataUnit.getSettings().get("ColorTransferFunction") self.dataUnit.getSettings().set("ColocalizationColorTransferFunction", ctf) self.listctrl.updateListCtrl(self.getVariables())
def __init__(self, parent, tb): """ Initialization Parameters: root Is the parent widget of this window """ self.operationName = "Adjust" self.lbls = [] self.btns = [] self.entries = [] self.timePoint = 0 TaskPanel.__init__(self, parent, tb) # Preview has to be generated heregoto # self.colorChooser=None self.createIntensityTransferPage() lib.messenger.connect(None, "timepoint_changed", self.updateTimepoint) self.Show() self.mainsizer.Fit(self) self.mainsizer.Layout()
def setCombinedDataUnit(self, dataUnit): """ Sets the processed dataunit that is to be processed. It is then used to get the names of all the source data units and they are added to the menu. This is overwritten from TaskPanel since we only process one dataunit here, not multiple source data units """ TaskPanel.setCombinedDataUnit(self, dataUnit) ctf = self.settings.get("ColorTransferFunction") if ctf and self.colorBtn: self.colorBtn.setColorTransferFunction(ctf) # We register a callback to be notified when the timepoint changes # We do it here because the timePointChanged() code requires the dataunit # self.Bind(EVT_TIMEPOINT_CHANGED,self.timePointChanged,id=ID_TIMEPOINT) tf = self.settings.getCounted("IntensityTransferFunctions", self.timePoint) self.iTFEditor.setIntensityTransferFunction(tf) self.iTFEditor.updateCallback = self.doPreviewCallback self.restoreFromCache() self.updateSettings()
def setCombinedDataUnit(self, dataUnit): """ Sets the processed dataunit that is to be processed. It is then used to get the names of all the source data units and they are added to the menu. This is overwritten from TaskPanel since we only process one dataunit here, not multiple source data units """ TaskPanel.setCombinedDataUnit(self, dataUnit) ctf = self.settings.get("ColorTransferFunction") if ctf and self.colorBtn: self.colorBtn.setColorTransferFunction(ctf) # We register a callback to be notified when the timepoint changes # We do it here because the timePointChanged() code requires the dataunit #self.Bind(EVT_TIMEPOINT_CHANGED,self.timePointChanged,id=ID_TIMEPOINT) tf = self.settings.getCounted("IntensityTransferFunctions", self.timePoint) self.iTFEditor.setIntensityTransferFunction(tf) self.iTFEditor.updateCallback = self.doPreviewCallback self.restoreFromCache() self.updateSettings()
def createItemToolbar(self): """ Method to create a toolbar for the window that allows use to select processed channel """ n = TaskPanel.createItemToolbar(self) coloc = vtkbxd.vtkImageColocalizationFilter() coloc.SetOutputDepth(8) i = 0 for data in self.itemMips: coloc.AddInput(data) coloc.SetColocalizationLowerThreshold(i, 100) coloc.SetColocalizationUpperThreshold(i, 255) i = i + 1 coloc.Update() ctf = vtk.vtkColorTransferFunction() ctf.AddRGBPoint(0, 0, 0, 0) ctf.AddRGBPoint(255, 1, 1, 1) maptocolor = vtk.vtkImageMapToColors() maptocolor.SetInput(coloc.GetOutput()) maptocolor.SetLookupTable(ctf) maptocolor.SetOutputFormatToRGB() maptocolor.Update() imagedata = maptocolor.GetOutput() bmp = ImageOperations.vtkImageDataToWxImage(imagedata).ConvertToBitmap() bmp = self.getChannelItemBitmap(bmp, (255, 255, 0)) toolid = wx.NewId() name = "Colocalization" self.toolMgr.addChannelItem(name, bmp, toolid, lambda e, x = n, s = self:s.setPreviewedData(e, x)) for i, tid in enumerate(self.toolIds): self.dataUnit.setOutputChannel(i, 0) self.toolMgr.toggleTool(tid, 0) self.dataUnit.setOutputChannel(len(self.toolIds), 1) self.toolIds.append(toolid) self.toolMgr.toggleTool(toolid, 1) self.restoreFromCache()
def doProcessingCallback(self, *args): """ A callback for the button "Process Dataset Series" """ TaskPanel.doOperation(self)
def doColocalizationCallback(self, *args): """ A callback for the button "Do colocalization" """ self.updateBitDepth() TaskPanel.doOperation(self)