def setupLayers(self): # Base class provides the label layer. layers = super(ObjectClassificationGui, self).setupLayers() binarySlot = self.op.BinaryImages segmentedSlot = self.op.SegmentationImages rawSlot = self.op.RawImages #This is just for colors labels = self.labelListData for channel, probSlot in enumerate(self.op.PredictionProbabilityChannels): if probSlot.ready() and channel < len(labels): ref_label = labels[channel] probsrc = LazyflowSource(probSlot) probLayer = AlphaModulatedLayer( probsrc, tintColor=ref_label.pmapColor(), range=(0.0, 1.0), normalize=(0.0, 1.0) ) probLayer.opacity = 0.25 #probLayer.visible = self.labelingDrawerUi.checkInteractive.isChecked() #False, because it's much faster to draw predictions without these layers below probLayer.visible = False probLayer.setToolTip("Probability that the object belongs to class {}".format(channel+1)) def setLayerColor(c, predictLayer_=probLayer, ch=channel, initializing=False): if not initializing and predictLayer_ not in self.layerstack: # This layer has been removed from the layerstack already. # Don't touch it. return predictLayer_.tintColor = c def setLayerName(n, predictLayer_=probLayer, initializing=False): if not initializing and predictLayer_ not in self.layerstack: # This layer has been removed from the layerstack already. # Don't touch it. return newName = "Prediction for %s" % n predictLayer_.name = newName setLayerName(ref_label.name, initializing=True) ref_label.pmapColorChanged.connect(setLayerColor) ref_label.nameChanged.connect(setLayerName) layers.append(probLayer) predictionSlot = self.op.PredictionImages if predictionSlot.ready(): predictsrc = LazyflowSource(predictionSlot) self._colorTable16_forpmaps[0] = 0 predictLayer = ColortableLayer(predictsrc, colorTable=self._colorTable16_forpmaps) predictLayer.name = self.PREDICTION_LAYER_NAME predictLayer.ref_object = None predictLayer.visible = self.labelingDrawerUi.checkInteractive.isChecked() predictLayer.opacity = 0.5 predictLayer.setToolTip("Classification results, assigning a label to each object") # This weakref stuff is a little more fancy than strictly necessary. # The idea is to use the weakref's callback to determine when this layer instance is destroyed by the garbage collector, # and then we disconnect the signal that updates that layer. weak_predictLayer = weakref.ref( predictLayer ) colortable_changed_callback = bind( self._setPredictionColorTable, weak_predictLayer ) self._labelControlUi.labelListModel.dataChanged.connect( colortable_changed_callback ) weak_predictLayer2 = weakref.ref( predictLayer, partial(self._disconnect_dataChange_callback, colortable_changed_callback) ) # We have to make sure the weakref isn't destroyed because it is responsible for calling the callback. # Therefore, we retain it by adding it to a list. self._retained_weakrefs.append( weak_predictLayer2 ) # Ensure we're up-to-date (in case this is the first time the prediction layer is being added. for row in range( self._labelControlUi.labelListModel.rowCount() ): self._setPredictionColorTableForRow( predictLayer, row ) # put right after Labels, so that it is visible after hitting "live # predict". layers.insert(1, predictLayer) badObjectsSlot = self.op.BadObjectImages if badObjectsSlot.ready(): ct_black = [0, QColor(Qt.black).rgba()] badSrc = LazyflowSource(badObjectsSlot) badLayer = ColortableLayer(badSrc, colorTable = ct_black) badLayer.name = "Ambiguous objects" badLayer.setToolTip("Objects with infinite or invalid values in features") badLayer.visible = False layers.append(badLayer) if segmentedSlot.ready(): ct = colortables.create_default_16bit() objectssrc = LazyflowSource(segmentedSlot) ct[0] = QColor(0, 0, 0, 0).rgba() # make 0 transparent objLayer = ColortableLayer(objectssrc, ct) objLayer.name = "Objects" objLayer.opacity = 0.5 objLayer.visible = False objLayer.setToolTip("Segmented objects (labeled image/connected components)") layers.append(objLayer) if binarySlot.ready(): ct_binary = [0, QColor(255, 255, 255, 255).rgba()] # white foreground on transparent background, even for labeled images binct = [QColor(255, 255, 255, 255).rgba()]*65536 binct[0] = 0 binaryimagesrc = LazyflowSource(binarySlot) binLayer = ColortableLayer(binaryimagesrc, binct) binLayer.name = "Binary image" binLayer.visible = True binLayer.opacity = 1.0 binLayer.setToolTip("Segmentation results as a binary mask") layers.append(binLayer) if rawSlot.ready(): rawLayer = self.createStandardLayerFromSlot(rawSlot) rawLayer.name = "Raw data" def toggleTopToBottom(): index = self.layerstack.layerIndex( rawLayer ) self.layerstack.selectRow( index ) if index == 0: self.layerstack.moveSelectedToBottom() else: self.layerstack.moveSelectedToTop() ActionInfo = ShortcutManager.ActionInfo rawLayer.shortcutRegistration = ( "i", ActionInfo( "Prediction Layers", "Bring Input To Top/Bottom", "Bring Input To Top/Bottom", toggleTopToBottom, self.viewerControlWidget(), rawLayer ) ) layers.append(rawLayer) # since we start with existing labels, it makes sense to start # with the first one selected. This would make more sense in # __init__(), but it does not take effect there. #self.selectLabel(0) return layers
def setupLayers(self): layers = [] op = self.topLevelOperatorView binct = [QColor(Qt.black), QColor(Qt.white)] binct[0] = 0 ct = create_default_16bit() ct[0]=0 # Show the cached output, since it goes through a blocked cache if op.CachedOutput.ready(): outputSrc = LazyflowSource(op.CachedOutput) outputLayer = ColortableLayer(outputSrc, ct) outputLayer.name = "Final output" outputLayer.visible = False outputLayer.opacity = 1.0 outputLayer.setToolTip("Results of thresholding and size filter") layers.append(outputLayer) if op.InputImage.ready(): numChannels = op.InputImage.meta.getTaggedShape()['c'] for channel in range(numChannels): channelProvider = OpSingleChannelSelector(parent=op.InputImage.getRealOperator().parent) channelProvider.Input.connect(op.InputImage) channelProvider.Index.setValue( channel ) channelSrc = LazyflowSource( channelProvider.Output ) inputChannelLayer = AlphaModulatedLayer( channelSrc, tintColor=QColor(self._channelColors[channel]), range=(0.0, 1.0), normalize=(0.0, 1.0) ) inputChannelLayer.opacity = 0.5 inputChannelLayer.visible = True inputChannelLayer.name = "Input Channel " + str(channel) inputChannelLayer.setToolTip("Select input channel " + str(channel) + \ " if this prediction image contains the objects of interest.") layers.append(inputChannelLayer) if self._showDebug: #FIXME: We have to do that, because lazyflow doesn't have a way to make an operator partially ready curIndex = self._drawer.tabWidget.currentIndex() if curIndex==1: if op.BigRegions.ready(): lowThresholdSrc = LazyflowSource(op.BigRegions) lowThresholdLayer = ColortableLayer(lowThresholdSrc, binct) lowThresholdLayer.name = "After low threshold" lowThresholdLayer.visible = False lowThresholdLayer.opacity = 1.0 lowThresholdLayer.setToolTip("Results of thresholding with the low pixel value threshold") layers.append(lowThresholdLayer) if op.FilteredSmallLabels.ready(): filteredSmallLabelsLayer = self.createStandardLayerFromSlot( op.FilteredSmallLabels ) filteredSmallLabelsLayer.name = "After high threshold and size filter" filteredSmallLabelsLayer.visible = False filteredSmallLabelsLayer.opacity = 1.0 filteredSmallLabelsLayer.setToolTip("Results of thresholding with the high pixel value threshold,\ followed by the size filter") layers.append(filteredSmallLabelsLayer) if op.SmallRegions.ready(): highThresholdSrc = LazyflowSource(op.SmallRegions) highThresholdLayer = ColortableLayer(highThresholdSrc, binct) highThresholdLayer.name = "After high threshold" highThresholdLayer.visible = False highThresholdLayer.opacity = 1.0 highThresholdLayer.setToolTip("Results of thresholding with the high pixel value threshold") layers.append(highThresholdLayer) elif curIndex==0: if op.BeforeSizeFilter.ready(): thSrc = LazyflowSource(op.BeforeSizeFilter) thLayer = ColortableLayer(thSrc, ct) thLayer.name = "Before size filter" thLayer.visible = False thLayer.opacity = 1.0 thLayer.setToolTip("Results of thresholding before the size filter is applied") layers.append(thLayer) # Selected input channel, smoothed. if op.Smoothed.ready(): smoothedLayer = self.createStandardLayerFromSlot( op.Smoothed ) smoothedLayer.name = "Smoothed input" smoothedLayer.visible = True smoothedLayer.opacity = 1.0 smoothedLayer.setToolTip("Selected channel data, smoothed with a Gaussian with user-defined sigma") layers.append(smoothedLayer) # Show the raw input data rawSlot = self.topLevelOperatorView.RawInput if rawSlot.ready(): rawLayer = self.createStandardLayerFromSlot( rawSlot ) rawLayer.name = "Raw data" rawLayer.visible = True rawLayer.opacity = 1.0 layers.append(rawLayer) return layers
def setupLayers(self): # Base class provides the label layer and the raw layer layers = super(ObjectClassificationGui, self).setupLayers() binarySlot = self.op.BinaryImages atlas_slot = self.op.Atlas segmentedSlot = self.op.SegmentationImages #This is just for colors labels = self.labelListData for channel, probSlot in enumerate( self.op.PredictionProbabilityChannels): if probSlot.ready() and channel < len(labels): ref_label = labels[channel] probsrc = LazyflowSource(probSlot) probLayer = AlphaModulatedLayer( probsrc, tintColor=ref_label.pmapColor(), range=(0.0, 1.0), normalize=(0.0, 1.0)) probLayer.opacity = 0.25 #probLayer.visible = self.labelingDrawerUi.checkInteractive.isChecked() #False, because it's much faster to draw predictions without these layers below probLayer.visible = False probLayer.setToolTip( "Probability that the object belongs to class {}".format( channel + 1)) def setLayerColor(c, predictLayer_=probLayer, ch=channel, initializing=False): if not initializing and predictLayer_ not in self.layerstack: # This layer has been removed from the layerstack already. # Don't touch it. return predictLayer_.tintColor = c def setLayerName(n, predictLayer_=probLayer, initializing=False): if not initializing and predictLayer_ not in self.layerstack: # This layer has been removed from the layerstack already. # Don't touch it. return newName = "Prediction for %s" % n predictLayer_.name = newName setLayerName(ref_label.name, initializing=True) ref_label.pmapColorChanged.connect(setLayerColor) ref_label.nameChanged.connect(setLayerName) layers.append(probLayer) predictionSlot = self.op.PredictionImages if predictionSlot.ready(): predictsrc = LazyflowSource(predictionSlot) self._colorTable16_forpmaps[0] = 0 predictLayer = ColortableLayer( predictsrc, colorTable=self._colorTable16_forpmaps) predictLayer.name = self.PREDICTION_LAYER_NAME predictLayer.ref_object = None predictLayer.opacity = 0.5 predictLayer.setToolTip( "Classification results, assigning a label to each object") # This weakref stuff is a little more fancy than strictly necessary. # The idea is to use the weakref's callback to determine when this layer instance is destroyed by the garbage collector, # and then we disconnect the signal that updates that layer. weak_predictLayer = weakref.ref(predictLayer) colortable_changed_callback = bind(self._setPredictionColorTable, weak_predictLayer) self._labelControlUi.labelListModel.dataChanged.connect( colortable_changed_callback) weak_predictLayer2 = weakref.ref( predictLayer, partial(self._disconnect_dataChange_callback, colortable_changed_callback)) # We have to make sure the weakref isn't destroyed because it is responsible for calling the callback. # Therefore, we retain it by adding it to a list. self._retained_weakrefs.append(weak_predictLayer2) # Ensure we're up-to-date (in case this is the first time the prediction layer is being added. for row in range(self._labelControlUi.labelListModel.rowCount()): self._setPredictionColorTableForRow(predictLayer, row) # put right after Labels, so that it is visible after hitting "live # predict". layers.insert(1, predictLayer) badObjectsSlot = self.op.BadObjectImages if badObjectsSlot.ready(): ct_black = [0, QColor(Qt.black).rgba()] badSrc = LazyflowSource(badObjectsSlot) badLayer = ColortableLayer(badSrc, colorTable=ct_black) badLayer.name = "Ambiguous objects" badLayer.setToolTip( "Objects with infinite or invalid values in features") badLayer.visible = False layers.append(badLayer) if segmentedSlot.ready(): ct = colortables.create_default_16bit() objectssrc = LazyflowSource(segmentedSlot) ct[0] = QColor(0, 0, 0, 0).rgba() # make 0 transparent objLayer = ColortableLayer(objectssrc, ct) objLayer.name = "Objects" objLayer.opacity = 0.5 objLayer.visible = False objLayer.setToolTip( "Segmented objects (labeled image/connected components)") layers.append(objLayer) uncertaintySlot = self.op.UncertaintyEstimateImage if uncertaintySlot.ready(): uncertaintySrc = LazyflowSource(uncertaintySlot) uncertaintyLayer = AlphaModulatedLayer(uncertaintySrc, tintColor=QColor(Qt.cyan), range=(0.0, 1.0), normalize=(0.0, 1.0)) uncertaintyLayer.name = "Uncertainty" uncertaintyLayer.visible = False uncertaintyLayer.opacity = 1.0 ActionInfo = ShortcutManager.ActionInfo uncertaintyLayer.shortcutRegistration = ( "u", ActionInfo("Uncertainty Layers", "Uncertainty", "Show/Hide Uncertainty", uncertaintyLayer.toggleVisible, self.viewerControlWidget(), uncertaintyLayer)) layers.append(uncertaintyLayer) if binarySlot.ready(): ct_binary = [0, QColor(255, 255, 255, 255).rgba()] # white foreground on transparent background, even for labeled images binct = [QColor(255, 255, 255, 255).rgba()] * 65536 binct[0] = 0 binaryimagesrc = LazyflowSource(binarySlot) binLayer = ColortableLayer(binaryimagesrc, binct) binLayer.name = "Binary image" binLayer.visible = True binLayer.opacity = 1.0 binLayer.setToolTip("Segmentation results as a binary mask") layers.append(binLayer) if atlas_slot.ready(): layers.append( self.createStandardLayerFromSlot(atlas_slot, name="Atlas", opacity=0.5)) # since we start with existing labels, it makes sense to start # with the first one selected. This would make more sense in # __init__(), but it does not take effect there. #self.selectLabel(0) return layers
def setupLayers(self): layers = [] op = self.topLevelOperatorView ct = create_default_16bit() ct[0] = 0 # Show the cached output, since it goes through a blocked cache if op.CachedOutput.ready(): outputSrc = LazyflowSource(op.CachedOutput) outputLayer = ColortableLayer(outputSrc, ct) outputLayer.name = "Final output" outputLayer.visible = False outputLayer.opacity = 1.0 outputLayer.setToolTip("Results of thresholding and size filter") layers.append(outputLayer) if op.InputChannelColors.ready(): input_channel_colors = [ QColor(r_g_b1[0], r_g_b1[1], r_g_b1[2]) for r_g_b1 in op.InputChannelColors.value ] else: input_channel_colors = list( map(QColor, self._defaultInputChannelColors)) for channel, channelProvider in enumerate(self._channelProviders): slot_drange = channelProvider.Output.meta.drange if slot_drange is not None: drange = slot_drange else: drange = (0.0, 1.0) channelSrc = LazyflowSource(channelProvider.Output) inputChannelLayer = AlphaModulatedLayer( channelSrc, tintColor=input_channel_colors[channel], range=drange, normalize=drange) inputChannelLayer.opacity = 0.5 inputChannelLayer.visible = True inputChannelLayer.name = "Input Channel " + str(channel) inputChannelLayer.setToolTip("Select input channel " + str(channel) + \ " if this prediction image contains the objects of interest.") layers.append(inputChannelLayer) if self._showDebug: #FIXME: We have to do that, because lazyflow doesn't have a way to make an operator partially ready curIndex = op.CurOperator.value if curIndex in (1, 3): if op.FilteredSmallLabels.ready(): filteredSmallLabelsSrc = LazyflowSource( op.FilteredSmallLabels) #filteredSmallLabelsLayer = self.createStandardLayerFromSlot( op.FilteredSmallLabels ) filteredSmallLabelsLayer = ColortableLayer( filteredSmallLabelsSrc, DebugLayerCmap.BINARY_SHADE_1.value) filteredSmallLabelsLayer.name = "After high threshold and size filter" filteredSmallLabelsLayer.visible = False filteredSmallLabelsLayer.opacity = 1.0 filteredSmallLabelsLayer.setToolTip( "Results of thresholding with the high pixel value threshold,\ followed by the size filter" ) layers.append(filteredSmallLabelsLayer) if op.SmallRegions.ready(): highThresholdSrc = LazyflowSource(op.SmallRegions) highThresholdLayer = ColortableLayer( highThresholdSrc, DebugLayerCmap.BINARY_SHADE_0.value) highThresholdLayer.name = "After high threshold" highThresholdLayer.visible = False highThresholdLayer.opacity = 1.0 highThresholdLayer.setToolTip( "Results of thresholding with the high pixel value threshold" ) layers.append(highThresholdLayer) if op.BigRegions.ready(): lowThresholdSrc = LazyflowSource(op.BigRegions) lowThresholdLayer = ColortableLayer( lowThresholdSrc, DebugLayerCmap.BINARY_WHITE.value) lowThresholdLayer.name = "After low threshold" lowThresholdLayer.visible = False lowThresholdLayer.opacity = 1.0 lowThresholdLayer.setToolTip( "Results of thresholding with the low pixel value threshold" ) layers.append(lowThresholdLayer) elif curIndex == 0: if op.BeforeSizeFilter.ready(): thSrc = LazyflowSource(op.BeforeSizeFilter) thLayer = ColortableLayer( thSrc, DebugLayerCmap.BINARY_WHITE.value) thLayer.name = "Before size filter" thLayer.visible = False thLayer.opacity = 1.0 thLayer.setToolTip( "Results of thresholding before the size filter is applied" ) layers.append(thLayer) # Selected input channel, smoothed. if op.Smoothed.ready(): smoothedLayer = self.createStandardLayerFromSlot(op.Smoothed) smoothedLayer.name = "Smoothed input" smoothedLayer.visible = True smoothedLayer.opacity = 1.0 smoothedLayer.setToolTip( "Selected channel data, smoothed with a Gaussian with user-defined sigma" ) layers.append(smoothedLayer) # Show the raw input data rawSlot = self.topLevelOperatorView.RawInput if rawSlot.ready(): rawLayer = self.createStandardLayerFromSlot(rawSlot) rawLayer.name = "Raw data" rawLayer.visible = True rawLayer.opacity = 1.0 layers.append(rawLayer) return layers
def setupLayers(self): layers = [] op = self.topLevelOperatorView binct = [QColor(Qt.black), QColor(Qt.white)] binct[0] = 0 ct = self._createDefault16ColorColorTable() ct[0] = 0 # Show the cached output, since it goes through a blocked cache if op.CachedOutput.ready(): outputSrc = LazyflowSource(op.CachedOutput) outputLayer = ColortableLayer(outputSrc, binct) outputLayer.name = "Final output" outputLayer.visible = False outputLayer.opacity = 1.0 outputLayer.setToolTip("Results of thresholding and size filter") layers.append(outputLayer) if self._showDebug: #FIXME: We have to do that, because lazyflow doesn't have a way to make an operator partially ready curIndex = self._drawer.tabWidget.currentIndex() if curIndex == 1: if op.BigRegions.ready(): lowThresholdSrc = LazyflowSource(op.BigRegions) lowThresholdLayer = ColortableLayer(lowThresholdSrc, binct) lowThresholdLayer.name = "After low threshold" lowThresholdLayer.visible = False lowThresholdLayer.opacity = 1.0 lowThresholdLayer.setToolTip( "Results of thresholding with the low pixel value threshold" ) layers.append(lowThresholdLayer) if op.FilteredSmallLabels.ready(): filteredSmallLabelsLayer = self.createStandardLayerFromSlot( op.FilteredSmallLabels) filteredSmallLabelsLayer.name = "After high threshold and size filter" filteredSmallLabelsLayer.visible = False filteredSmallLabelsLayer.opacity = 1.0 filteredSmallLabelsLayer.setToolTip( "Results of thresholding with the high pixel value threshold,\ followed by the size filter" ) layers.append(filteredSmallLabelsLayer) if op.SmallRegions.ready(): highThresholdSrc = LazyflowSource(op.SmallRegions) highThresholdLayer = ColortableLayer( highThresholdSrc, binct) highThresholdLayer.name = "After high threshold" highThresholdLayer.visible = False highThresholdLayer.opacity = 1.0 highThresholdLayer.setToolTip( "Results of thresholding with the high pixel value threshold" ) layers.append(highThresholdLayer) elif curIndex == 0: if op.BeforeSizeFilter.ready(): thSrc = LazyflowSource(op.BeforeSizeFilter) thLayer = ColortableLayer(thSrc, ct) thLayer.name = "Before size filter" thLayer.visible = False thLayer.opacity = 1.0 thLayer.setToolTip( "Results of thresholding before the size filter is applied" ) layers.append(thLayer) # Selected input channel, smoothed. if op.Smoothed.ready(): smoothedLayer = self.createStandardLayerFromSlot(op.Smoothed) smoothedLayer.name = "Smoothed input" smoothedLayer.visible = True smoothedLayer.opacity = 1.0 smoothedLayer.setToolTip( "Selected channel data, smoothed with a Gaussian with user-defined sigma" ) layers.append(smoothedLayer) # Show the selected channel if op.InputChannel.ready(): drange = op.InputChannel.meta.drange if drange is None: drange = (0.0, 1.0) channelSrc = LazyflowSource(op.InputChannel) #channelLayer = AlphaModulatedLayer( channelSrc, # tintColor=QColor(self._channelColors[op.Channel.value]), # range=drange, # normalize=drange ) #it used to be set to the label color, but people found it confusing channelLayer = AlphaModulatedLayer(channelSrc, tintColor=QColor(Qt.white), range=drange, normalize=drange) channelLayer.name = "Selected input channel" channelLayer.opacity = 1.0 channelLayer.setToolTip( "The selected channel of the prediction images") #channelLayer.visible = channelIndex == op.Channel.value # By default, only the selected input channel is visible. layers.append(channelLayer) # Show the raw input data rawSlot = self.topLevelOperatorView.RawInput if rawSlot.ready(): rawLayer = self.createStandardLayerFromSlot(rawSlot) rawLayer.name = "Raw data" rawLayer.visible = True rawLayer.opacity = 1.0 layers.append(rawLayer) return layers
def setupLayers(self): layers = [] op = self.topLevelOperatorView binct = [QColor(Qt.black), QColor(Qt.white)] binct[0] = 0 ct = self._createDefault16ColorColorTable() ct[0]=0 # Show the cached output, since it goes through a blocked cache if op.CachedOutput.ready(): outputSrc = LazyflowSource(op.CachedOutput) outputLayer = ColortableLayer(outputSrc, binct) outputLayer.name = "Final output" outputLayer.visible = False outputLayer.opacity = 1.0 outputLayer.setToolTip("Results of thresholding and size filter") layers.append(outputLayer) if self._showDebug: #FIXME: We have to do that, because lazyflow doesn't have a way to make an operator partially ready curIndex = self._drawer.tabWidget.currentIndex() if curIndex==1: if op.BigRegions.ready(): lowThresholdSrc = LazyflowSource(op.BigRegions) lowThresholdLayer = ColortableLayer(lowThresholdSrc, binct) lowThresholdLayer.name = "After low threshold" lowThresholdLayer.visible = False lowThresholdLayer.opacity = 1.0 lowThresholdLayer.setToolTip("Results of thresholding with the low pixel value threshold") layers.append(lowThresholdLayer) if op.FilteredSmallLabels.ready(): filteredSmallLabelsLayer = self.createStandardLayerFromSlot( op.FilteredSmallLabels ) filteredSmallLabelsLayer.name = "After high threshold and size filter" filteredSmallLabelsLayer.visible = False filteredSmallLabelsLayer.opacity = 1.0 filteredSmallLabelsLayer.setToolTip("Results of thresholding with the high pixel value threshold,\ followed by the size filter") layers.append(filteredSmallLabelsLayer) if op.SmallRegions.ready(): highThresholdSrc = LazyflowSource(op.SmallRegions) highThresholdLayer = ColortableLayer(highThresholdSrc, binct) highThresholdLayer.name = "After high threshold" highThresholdLayer.visible = False highThresholdLayer.opacity = 1.0 highThresholdLayer.setToolTip("Results of thresholding with the high pixel value threshold") layers.append(highThresholdLayer) elif curIndex==0: if op.BeforeSizeFilter.ready(): thSrc = LazyflowSource(op.BeforeSizeFilter) thLayer = ColortableLayer(thSrc, ct) thLayer.name = "Before size filter" thLayer.visible = False thLayer.opacity = 1.0 thLayer.setToolTip("Results of thresholding before the size filter is applied") layers.append(thLayer) # Selected input channel, smoothed. if op.Smoothed.ready(): smoothedLayer = self.createStandardLayerFromSlot( op.Smoothed ) smoothedLayer.name = "Smoothed input" smoothedLayer.visible = True smoothedLayer.opacity = 1.0 smoothedLayer.setToolTip("Selected channel data, smoothed with a Gaussian with user-defined sigma") layers.append(smoothedLayer) # Show the selected channel if op.InputChannel.ready(): drange = op.InputChannel.meta.drange if drange is None: drange = (0.0, 1.0) channelSrc = LazyflowSource(op.InputChannel) #channelLayer = AlphaModulatedLayer( channelSrc, # tintColor=QColor(self._channelColors[op.Channel.value]), # range=drange, # normalize=drange ) #it used to be set to the label color, but people found it confusing channelLayer = AlphaModulatedLayer( channelSrc, tintColor = QColor(Qt.white), range = drange, normalize=drange) channelLayer.name = "Selected input channel" channelLayer.opacity = 1.0 channelLayer.setToolTip("The selected channel of the prediction images") #channelLayer.visible = channelIndex == op.Channel.value # By default, only the selected input channel is visible. layers.append(channelLayer) # Show the raw input data rawSlot = self.topLevelOperatorView.RawInput if rawSlot.ready(): rawLayer = self.createStandardLayerFromSlot( rawSlot ) rawLayer.name = "Raw data" rawLayer.visible = True rawLayer.opacity = 1.0 layers.append(rawLayer) return layers
def setupLayers(self): layers = [] op = self.topLevelOperatorView binct = [QColor(Qt.black), QColor(Qt.white)] binct[0] = 0 ct = create_default_16bit() ct[0] = 0 # Show the cached output, since it goes through a blocked cache if op.CachedOutput.ready(): outputSrc = LazyflowSource(op.CachedOutput) outputLayer = ColortableLayer(outputSrc, ct) outputLayer.name = "Final output" outputLayer.visible = False outputLayer.opacity = 1.0 outputLayer.setToolTip("Results of thresholding and size filter") layers.append(outputLayer) if op.InputChannelColors.ready(): input_channel_colors = [QColor(r_g_b1[0],r_g_b1[1],r_g_b1[2]) for r_g_b1 in op.InputChannelColors.value] else: input_channel_colors = list(map(QColor, self._defaultInputChannelColors)) for channel, channelProvider in enumerate(self._channelProviders): slot_drange = channelProvider.Output.meta.drange if slot_drange is not None: drange = slot_drange else: drange = (0.0, 1.0) channelSrc = LazyflowSource(channelProvider.Output) inputChannelLayer = AlphaModulatedLayer( channelSrc, tintColor=input_channel_colors[channel], range=drange, normalize=drange) inputChannelLayer.opacity = 0.5 inputChannelLayer.visible = True inputChannelLayer.name = "Input Channel " + str(channel) inputChannelLayer.setToolTip("Select input channel " + str(channel) + \ " if this prediction image contains the objects of interest.") layers.append(inputChannelLayer) if self._showDebug: #FIXME: We have to do that, because lazyflow doesn't have a way to make an operator partially ready curIndex = op.CurOperator.value if curIndex==1: if op.BigRegions.ready(): lowThresholdSrc = LazyflowSource(op.BigRegions) lowThresholdLayer = ColortableLayer(lowThresholdSrc, binct) lowThresholdLayer.name = "After low threshold" lowThresholdLayer.visible = False lowThresholdLayer.opacity = 1.0 lowThresholdLayer.setToolTip("Results of thresholding with the low pixel value threshold") layers.append(lowThresholdLayer) if op.FilteredSmallLabels.ready(): filteredSmallLabelsSrc = LazyflowSource(op.FilteredSmallLabels) #filteredSmallLabelsLayer = self.createStandardLayerFromSlot( op.FilteredSmallLabels ) filteredSmallLabelsLayer = ColortableLayer(filteredSmallLabelsSrc, binct) filteredSmallLabelsLayer.name = "After high threshold and size filter" filteredSmallLabelsLayer.visible = False filteredSmallLabelsLayer.opacity = 1.0 filteredSmallLabelsLayer.setToolTip("Results of thresholding with the high pixel value threshold,\ followed by the size filter") layers.append(filteredSmallLabelsLayer) if op.SmallRegions.ready(): highThresholdSrc = LazyflowSource(op.SmallRegions) highThresholdLayer = ColortableLayer(highThresholdSrc, binct) highThresholdLayer.name = "After high threshold" highThresholdLayer.visible = False highThresholdLayer.opacity = 1.0 highThresholdLayer.setToolTip("Results of thresholding with the high pixel value threshold") layers.append(highThresholdLayer) elif curIndex==0: if op.BeforeSizeFilter.ready(): thSrc = LazyflowSource(op.BeforeSizeFilter) thLayer = ColortableLayer(thSrc, ct) thLayer.name = "Before size filter" thLayer.visible = False thLayer.opacity = 1.0 thLayer.setToolTip("Results of thresholding before the size filter is applied") layers.append(thLayer) # Selected input channel, smoothed. if op.Smoothed.ready(): smoothedLayer = self.createStandardLayerFromSlot( op.Smoothed ) smoothedLayer.name = "Smoothed input" smoothedLayer.visible = True smoothedLayer.opacity = 1.0 smoothedLayer.setToolTip("Selected channel data, smoothed with a Gaussian with user-defined sigma") layers.append(smoothedLayer) # Show the raw input data rawSlot = self.topLevelOperatorView.RawInput if rawSlot.ready(): rawLayer = self.createStandardLayerFromSlot( rawSlot ) rawLayer.name = "Raw data" rawLayer.visible = True rawLayer.opacity = 1.0 layers.append(rawLayer) return layers
def setupLayers(self): layers = [] op = self.topLevelOperatorView binct = [QColor(Qt.black), QColor(Qt.white)] binct[0] = 0 ct = create_default_16bit() ct[0] = 0 # Show the cached output, since it goes through a blocked cache if op.CachedOutput.ready(): outputSrc = LazyflowSource(op.CachedOutput) outputLayer = ColortableLayer(outputSrc, ct) outputLayer.name = "Final output" outputLayer.visible = False outputLayer.opacity = 1.0 outputLayer.setToolTip("Results of thresholding and size filter") layers.append(outputLayer) for channel, channelProvider in enumerate(self._channelProviders): channelSrc = LazyflowSource(channelProvider.Output) inputChannelLayer = AlphaModulatedLayer( channelSrc, tintColor=QColor(self._channelColors[channel]), range=(0.0, 1.0), normalize=(0.0, 1.0)) inputChannelLayer.opacity = 0.5 inputChannelLayer.visible = True inputChannelLayer.name = "Input Channel " + str(channel) inputChannelLayer.setToolTip("Select input channel " + str(channel) + \ " if this prediction image contains the objects of interest.") layers.append(inputChannelLayer) if self._showDebug: #FIXME: We have to do that, because lazyflow doesn't have a way to make an operator partially ready curIndex = self._drawer.tabWidget.currentIndex() if curIndex==1: if op.BigRegions.ready(): lowThresholdSrc = LazyflowSource(op.BigRegions) lowThresholdLayer = ColortableLayer(lowThresholdSrc, binct) lowThresholdLayer.name = "After low threshold" lowThresholdLayer.visible = False lowThresholdLayer.opacity = 1.0 lowThresholdLayer.setToolTip("Results of thresholding with the low pixel value threshold") layers.append(lowThresholdLayer) if op.FilteredSmallLabels.ready(): filteredSmallLabelsSrc = LazyflowSource(op.FilteredSmallLabels) #filteredSmallLabelsLayer = self.createStandardLayerFromSlot( op.FilteredSmallLabels ) filteredSmallLabelsLayer = ColortableLayer(filteredSmallLabelsSrc, binct) filteredSmallLabelsLayer.name = "After high threshold and size filter" filteredSmallLabelsLayer.visible = False filteredSmallLabelsLayer.opacity = 1.0 filteredSmallLabelsLayer.setToolTip("Results of thresholding with the high pixel value threshold,\ followed by the size filter") layers.append(filteredSmallLabelsLayer) if op.SmallRegions.ready(): highThresholdSrc = LazyflowSource(op.SmallRegions) highThresholdLayer = ColortableLayer(highThresholdSrc, binct) highThresholdLayer.name = "After high threshold" highThresholdLayer.visible = False highThresholdLayer.opacity = 1.0 highThresholdLayer.setToolTip("Results of thresholding with the high pixel value threshold") layers.append(highThresholdLayer) elif curIndex==0: if op.BeforeSizeFilter.ready(): thSrc = LazyflowSource(op.BeforeSizeFilter) thLayer = ColortableLayer(thSrc, ct) thLayer.name = "Before size filter" thLayer.visible = False thLayer.opacity = 1.0 thLayer.setToolTip("Results of thresholding before the size filter is applied") layers.append(thLayer) # Selected input channel, smoothed. if op.Smoothed.ready(): smoothedLayer = self.createStandardLayerFromSlot( op.Smoothed ) smoothedLayer.name = "Smoothed input" smoothedLayer.visible = True smoothedLayer.opacity = 1.0 smoothedLayer.setToolTip("Selected channel data, smoothed with a Gaussian with user-defined sigma") layers.append(smoothedLayer) # Show the raw input data rawSlot = self.topLevelOperatorView.RawInput if rawSlot.ready(): rawLayer = self.createStandardLayerFromSlot( rawSlot ) rawLayer.name = "Raw data" rawLayer.visible = True rawLayer.opacity = 1.0 layers.append(rawLayer) return layers