Esempio n. 1
0
    def createLabelLayer(self, direct=False):
        """
        Return a colortable layer that displays the label slot data, along with its associated label source.
        direct: whether this layer is drawn synchronously by volumina
        """
        labelOutput = self._labelingSlots.labelOutput
        if not labelOutput.ready():
            return (None, None)
        else:
            # Add the layer to draw the labels, but don't add any labels
            labelsrc = LazyflowSinkSource( self._labelingSlots.labelOutput,
                                           self._labelingSlots.labelInput)

            labellayer = ColortableLayer(labelsrc, colorTable = self._colorTable16, direct=direct)
            labellayer.name = "Labels"
            labellayer.ref_object = None

            labellayer.contexts.append(QAction("Import...", None,
                                        triggered=partial(import_labeling_layer, labellayer, self._labelingSlots, self)))

            labellayer.shortcutRegistration = ("0", ShortcutManager.ActionInfo(
                                                        "Labeling",
                                                        "LabelVisibility",
                                                        "Show/Hide Labels",
                                                        labellayer.toggleVisible,
                                                        self.viewerControlWidget(),
                                                        labellayer))

            return labellayer, labelsrc
Esempio n. 2
0
    def _initPredictionLayers(self, predictionSlot):
        layers = []

        opLane = self.topLevelOperatorView
        colors = opLane.PmapColors.value
        names = opLane.LabelNames.value

        # Use a slicer to provide a separate slot for each channel layer
        #opSlicer = OpMultiArraySlicer2( parent=opLane.viewed_operator() )
        #opSlicer.Input.connect( predictionSlot )
        #opSlicer.AxisFlag.setValue('c')

        if predictionSlot.ready() :
            from volumina import colortables
            predictLayer = ColortableLayer(LazyflowSource(predictionSlot), colorTable = colortables.jet(), normalize = 'auto')
            #predictLayer = AlphaModulatedLayer( predictsrc,
            #                                    tintColor=QColor(*colors[channel]),
            #                                    range=(0.0, 1.0),
            #                                    normalize=(0.0, 1.0) )
            predictLayer.opacity = 0.25
            predictLayer.visible = True
            predictLayer.name = "Prediction"
            layers.append(predictLayer)

        return layers
Esempio n. 3
0
    def setupLayers(self):
        """The LayerViewer base class calls this function to obtain
        the list of layers that should be displaye in the central
        viewer.

        """
        layers = []

        inputGrid = LazyflowSource(self.topLevelOperatorView.GridOutput)
        colortable = [QColor(0, 0, 0, 0).rgba(), QColor(255, 0, 0).rgba(),]
        gridlayer = ColortableLayer(inputGrid, colortable)
        gridlayer.name = "Grid"
        gridlayer.zeroIsTransparent = True
        layers.insert(0, gridlayer)

        # Show the raw input data as a convenience for the user
        inputImageSlot = self.topLevelOperatorView.RawInput
        if inputImageSlot.ready():
            inputLayer = self.createStandardLayerFromSlot(inputImageSlot)
            inputLayer.name = "Raw Input"
            inputLayer.visible = True
            inputLayer.opacity = 1.0
            layers.append(inputLayer)

        return layers
    def setupLayers(self):
        layers = []
        
        predictionSlot = self.topLevelOperatorView.PredictionImage
        if predictionSlot.ready():
            predictlayer = ColortableLayer( LazyflowSource(predictionSlot),
                                                 colorTable=self._colorTable16 )
            predictlayer.name = "Prediction"
            predictlayer.visible = True
            layers.append(predictlayer)

        rawSlot = self.topLevelOperatorView.RawImage
        if rawSlot.ready():
            rawLayer = self.createStandardLayerFromSlot(rawSlot)
            rawLayer.name = "Raw data"
            layers.append(rawLayer)

        binarySlot = self.topLevelOperatorView.BinaryImage
        if binarySlot.ready():
            ct_binary = [QColor(0, 0, 0, 0).rgba(),
                         QColor(255, 255, 255, 255).rgba()]
            binaryLayer = ColortableLayer(LazyflowSource(binarySlot), ct_binary)
            binaryLayer.name = "Binary Image"
            layers.append(binaryLayer)

        return layers
Esempio n. 5
0
    def createLabelLayer(self, direct=False):
        """
        Return a colortable layer that displays the label slot data, along with its associated label source.
        direct: whether this layer is drawn synchronously by volumina
        """
        labelOutput = self._labelingSlots.labelOutput
        if not labelOutput.ready():
            return (None, None)
        else:
            # Add the layer to draw the labels, but don't add any labels
            labelsrc = LazyflowSinkSource(self._labelingSlots.labelOutput,
                                          self._labelingSlots.labelInput)

            labellayer = ColortableLayer(labelsrc,
                                         colorTable=self._colorTable16,
                                         direct=direct)
            labellayer.name = "Labels"
            labellayer.ref_object = None

            labellayer.contexts.append(
                QAction("Import...",
                        None,
                        triggered=partial(import_labeling_layer, labellayer,
                                          self._labelingSlots, self)))

            labellayer.shortcutRegistration = ("0",
                                               ShortcutManager.ActionInfo(
                                                   "Labeling",
                                                   "LabelVisibility",
                                                   "Show/Hide Labels",
                                                   labellayer.toggleVisible,
                                                   self.viewerControlWidget(),
                                                   labellayer))

            return labellayer, labelsrc
Esempio n. 6
0
    def createLabelLayer(self, direct=False):
        """
        Return a colortable layer that displays the label slot data, along with its associated label source.
        direct: whether this layer is drawn synchronously by volumina
        """
        labelOutput = self._labelingSlots.labelOutput
        if not labelOutput.ready():
            return (None, None)
        else:
            # Add the layer to draw the labels, but don't add any labels
            labelsrc = LazyflowSinkSource(self._labelingSlots.labelOutput,
                                          self._labelingSlots.labelInput)

            labellayer = ColortableLayer(labelsrc,
                                         colorTable=self._colorTable16,
                                         direct=direct)
            labellayer.name = "Labels"
            labellayer.ref_object = None

            labellayer.contexts.append(
                ("Import...",
                 partial(import_labeling_layer, labellayer,
                         self._labelingSlots, self)))

            return labellayer, labelsrc
Esempio n. 7
0
    def setupLayers(self):
        """The LayerViewer base class calls this function to obtain
        the list of layers that should be displaye in the central
        viewer.

        """
        layers = []

        inputGrid = LazyflowSource(self.topLevelOperatorView.GridOutput)
        colortable = [
            QColor(0, 0, 0, 0).rgba(),
            QColor(255, 0, 0).rgba(),
        ]
        gridlayer = ColortableLayer(inputGrid, colortable)
        gridlayer.name = "Grid"
        gridlayer.zeroIsTransparent = True
        layers.insert(0, gridlayer)

        # Show the raw input data as a convenience for the user
        inputImageSlot = self.topLevelOperatorView.RawInput
        if inputImageSlot.ready():
            inputLayer = self.createStandardLayerFromSlot(inputImageSlot)
            inputLayer.name = "Raw Input"
            inputLayer.visible = True
            inputLayer.opacity = 1.0
            layers.append(inputLayer)

        return layers
    def _initPredictionLayers(self, predictionSlot):
        layers = []

        opLane = self.topLevelOperatorView
        colors = opLane.PmapColors.value
        names = opLane.LabelNames.value

        # Use a slicer to provide a separate slot for each channel layer
        #opSlicer = OpMultiArraySlicer2( parent=opLane.viewed_operator() )
        #opSlicer.Input.connect( predictionSlot )
        #opSlicer.AxisFlag.setValue('c')

        if predictionSlot.ready() :
            from volumina import colortables
            predictLayer = ColortableLayer(LazyflowSource(predictionSlot), colorTable = colortables.jet(), normalize = 'auto')
            #predictLayer = AlphaModulatedLayer( predictsrc,
            #                                    tintColor=QColor(*colors[channel]),
            #                                    range=(0.0, 1.0),
            #                                    normalize=(0.0, 1.0) )
            predictLayer.opacity = 0.25
            predictLayer.visible = True
            predictLayer.name = "Prediction"
            layers.append(predictLayer)

        return layers
    def setupLayers(self):
        layers = []
        op = self.topLevelOperatorView
        binct = [QColor(Qt.black), QColor(Qt.white)]
        #binct[0] = 0
        ct = create_default_16bit()
        # associate label 0 with black/transparent?
        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 = "Connected Components"
            outputLayer.visible = False
            outputLayer.opacity = 1.0
            outputLayer.setToolTip("Results of connected component analysis")
            layers.append(outputLayer)

        if op.Input.ready():
            rawSrc = LazyflowSource(op.Input)
            rawLayer = ColortableLayer(outputSrc, binct)
            #rawLayer = self.createStandardLayerFromSlot(op.Input)
            rawLayer.name = "Raw data"
            rawLayer.visible = True
            rawLayer.opacity = 1.0
            layers.append(rawLayer)

        return layers
    def setupLayers(self):
        layers = []

        opLane = self.topLevelOperatorView

        selection_names = opLane.SelectionNames.value
        selection = selection_names[opLane.InputSelection.value]

        # This code is written to handle the specific output cases we know about.
        # If those change, update this function!
        assert selection in [
            "Object Predictions",
            "Object Probabilities",
            "Blockwise Object Predictions",
            "Blockwise Object Probabilities",
            "Object Identities",
            "Pixel Probabilities",
        ]

        if selection in ("Object Predictions", "Blockwise Object Predictions"):
            previewSlot = self.topLevelOperatorView.ImageToExport
            if previewSlot.ready():
                previewLayer = ColortableLayer(createDataSource(previewSlot),
                                               colorTable=self._colorTable16)
                previewLayer.name = "Prediction - Preview"
                previewLayer.visible = False
                layers.append(previewLayer)

        elif selection in ("Object Probabilities",
                           "Blockwise Object Probabilities"):
            previewLayers = self._initPredictionLayers(opLane.ImageToExport)
            for layer in previewLayers:
                layer.visible = False
                layer.name = layer.name + "- Preview"
            layers += previewLayers

        elif selection == "Pixel Probabilities":
            previewLayers = self._initPredictionLayers(opLane.ImageToExport)
            for layer in previewLayers:
                layer.visible = False
                layer.name = layer.name + "- Preview"
            layers += previewLayers
        elif selection == "Object Identities":
            previewSlot = self.topLevelOperatorView.ImageToExport
            layer = self._initColortableLayer(previewSlot)
            layers.append(layer)
        else:
            assert False, "Unknown selection."

        rawSlot = self.topLevelOperatorView.RawData
        if rawSlot.ready():
            rawLayer = self.createStandardLayerFromSlot(rawSlot)
            rawLayer.name = "Raw Data"
            rawLayer.opacity = 1.0
            layers.append(rawLayer)

        return layers
Esempio n. 11
0
 def _create_random_colortable_layer_from_slot(cls, slot, num_colors=256):
     colortable = generateRandomColors(num_colors,
                                       clamp={
                                           'v': 1.0,
                                           's': 0.5
                                       },
                                       zeroIsTransparent=True)
     layer = ColortableLayer(LazyflowSource(slot), colortable)
     layer.colortableIsRandom = True
     return layer
Esempio n. 12
0
    def setupLayers(self):
        """
        Called by our base class when one of our data slots has changed.
        This function creates a layer for each slot we want displayed in the volume editor.
        """
        # Base class provides the label layer.
        layers = super(Counting3dGui, self).setupLayers()

        # Add each of the predictions
        labels = self.labelListData
     


        slots = {'density' : self.op.Density}

        for name, slot in slots.items():
            if slot.ready():
                from volumina import colortables
                layer = ColortableLayer(LazyflowSource(slot), colorTable = colortables.jet(), normalize = 'auto')
                layer.name = name
                layers.append(layer)


        boxlabelsrc = LazyflowSinkSource(self.op.BoxLabelImages,self.op.BoxLabelInputs )
        boxlabellayer = ColortableLayer(boxlabelsrc, colorTable = self._colorTable16, direct = False)
        boxlabellayer.name = "boxLabels"
        boxlabellayer.opacity = 0.3
        layers.append(boxlabellayer)
        self.boxlabelsrc = boxlabelsrc


        inputDataSlot = self.topLevelOperatorView.InputImages
        if inputDataSlot.ready():
            inputLayer = self.createStandardLayerFromSlot( inputDataSlot )
            inputLayer.name = "Input Data"
            inputLayer.visible = True
            inputLayer.opacity = 1.0

            def toggleTopToBottom():
                index = self.layerstack.layerIndex( inputLayer )
                self.layerstack.selectRow( index )
                if index == 0:
                    self.layerstack.moveSelectedToBottom()
                else:
                    self.layerstack.moveSelectedToTop()

            inputLayer.shortcutRegistration = (
                "Prediction Layers",
                "Bring Input To Top/Bottom",
                QShortcut( QKeySequence("i"), self.viewerControlWidget(), toggleTopToBottom),
                inputLayer )
            layers.append(inputLayer)
        
        self.handleLabelSelectionChange()
        return layers
Esempio n. 13
0
 def _initSegmentationlayer(self, segSlot):
     if not segSlot.ready():
         return None
     opLane = self.topLevelOperatorView
     colors = opLane.PmapColors.value
     colortable = []
     colortable.append(QColor(0, 0, 0).rgba())
     for color in colors:
         colortable.append(QColor(*color).rgba())
     segsrc = LazyflowSource(segSlot)
     seglayer = ColortableLayer(segsrc, colortable)
     seglayer.name = "Simple Segmentation"
     return seglayer
 def _initSegmentationlayer(self, segSlot):
     if not segSlot.ready():
         return None
     opLane = self.topLevelOperatorView
     colors = opLane.PmapColors.value
     colortable = []
     colortable.append( QColor(0,0,0).rgba() )
     for color in colors:
         colortable.append( QColor(*color).rgba() )
     segsrc = LazyflowSource( segSlot )
     seglayer = ColortableLayer( segsrc, colortable )
     seglayer.name = "Simple Segmentation"
     return seglayer
 def addCCOperator(self):
     self.opCC = OpConnectedComponents(self.g)
     self.opCC.inputs["Input"].connect(self.opThreshold.outputs["Output"])
     #we shouldn't have to define these. But just in case...
     self.opCC.inputs["Neighborhood"].setValue(6)
     self.opCC.inputs["Background"].setValue(0)
     
     ccsrc = LazyflowSource(self.opCC.outputs["Output"][0])
     ccsrc.setObjectName("Connected Components")
     ctb = colortables.create_default_16bit()
     ctb.insert(0, QColor(0, 0, 0, 0).rgba()) # make background transparent
     ccLayer = ColortableLayer(ccsrc, ctb)
     ccLayer.name = "Connected Components"
     self.layerstack.insert(1, ccLayer)
Esempio n. 16
0
    def setupLayers(self):
        layers = []

        fromDiskSlot = self.topLevelOperatorView.ImageOnDisk
        if fromDiskSlot.ready():
            exportLayer = ColortableLayer(LazyflowSource(fromDiskSlot),
                                          colorTable=self.ct)
            exportLayer.name = "Selected Output - Exported"
            exportLayer.visible = True
            layers.append(exportLayer)

        previewSlot = self.topLevelOperatorView.ImageToExport
        if previewSlot.ready():
            previewLayer = ColortableLayer(LazyflowSource(previewSlot),
                                           colorTable=self.ct)
            previewLayer.name = "Selected Output - Preview"
            previewLayer.visible = False
            layers.append(previewLayer)

        rawSlot = self.topLevelOperatorView.RawData
        if rawSlot.ready():
            rawLayer = self.createStandardLayerFromSlot(rawSlot)
            rawLayer.name = "Raw Data"
            rawLayer.opacity = 1.0
            layers.append(rawLayer)

        return layers
Esempio n. 17
0
    def setupLayers(self):
        layers = [self.createStandardLayerFromSlot(self.topLevelOperatorView.Input)]
        layers[0].opacity = 1.0
        superVoxelBoundarySlot = self.topLevelOperatorView.BoundariesOutput
        if superVoxelBoundarySlot.ready():
            layer = AlphaModulatedLayer(
                LazyflowSource(superVoxelBoundarySlot),
                tintColor=QColor(Qt.blue),
                range=(0.0, 1.0),
                normalize=(0.0, 1.0),
            )
            layer.name = "Supervoxel Boundaries"
            layer.visible = True
            layer.opacity = 1.0
            layers.insert(0, layer)

        superVoxelSlot = self.topLevelOperatorView.Output
        if superVoxelSlot.ready():
            colortable = generateRandomColors(M=256, clamp={"v": 1.0, "s": 0.5}, zeroIsTransparent=False)
            layer = ColortableLayer(createDataSource(superVoxelSlot), colortable)
            layer.colortableIsRandom = True
            layer.name = "SLIC Superpixels"
            layer.visible = True
            layer.opacity = 1.0
            layers.insert(0, layer)

        return layers
    def setupLayers(self):
        layers = []

        predictionSlot = self.topLevelOperatorView.PredictionImage
        if predictionSlot.ready():

            predictLayer = ColortableLayer(LazyflowSource(predictionSlot),
                                           colorTable=self._colorTable16)
            predictLayer.name = "Blockwise prediction"
            predictLayer.visible = False

            layers.append(predictLayer)

        binarySlot = self.topLevelOperatorView.BinaryImage
        if binarySlot.ready():
            ct_binary = [
                QColor(0, 0, 0, 0).rgba(),
                QColor(255, 255, 255, 255).rgba()
            ]
            binaryLayer = ColortableLayer(LazyflowSource(binarySlot),
                                          ct_binary)
            binaryLayer.name = "Binary Image"
            layers.append(binaryLayer)

        rawSlot = self.topLevelOperatorView.RawImage
        if rawSlot.ready():
            rawLayer = self.createStandardLayerFromSlot(rawSlot)
            rawLayer.name = "Raw data"
            layers.append(rawLayer)

        return layers
Esempio n. 19
0
    def createLabelLayer(self, direct=False):
        """Return a colortable layer that displays the label slot
        data, along with its associated label source.

        direct: whether this layer is drawn synchronously by volumina

        """
        labelInput = self._labelingSlots.labelInput
        labelOutput = self._labelingSlots.labelOutput

        if not labelOutput.ready():
            return (None, None)
        else:
            self._colorTable16[15] = QColor(
                Qt.black).rgba()  #for the objects with NaNs in features

            labelsrc = LazyflowSinkSource(labelOutput, labelInput)
            labellayer = ColortableLayer(labelsrc,
                                         colorTable=self._colorTable16,
                                         direct=direct)

            labellayer.segmentationImageSlot = self.op.SegmentationImagesOut
            labellayer.name = "Labels"
            labellayer.ref_object = None
            labellayer.zeroIsTransparent = False
            labellayer.colortableIsRandom = True

            clickInt = ClickInterpreter(self.editor,
                                        labellayer,
                                        self.onClick,
                                        right=False,
                                        double=False)
            self.editor.brushingInterpreter = clickInt

            return labellayer, labelsrc
Esempio n. 20
0
 def _create_binary_mask_layer_from_slot(cls, slot):
     # 0: black, 1-255: transparent
     # This works perfectly for uint8.
     # For uint32, etc., values of 256,512, etc. will be appear 'off'.
     # But why would you use uint32 for a binary mask anyway?
     colortable = [QColor(0, 0, 0, 255).rgba()]
     colortable += 255 * [QColor(0, 0, 0, 0).rgba()]
     layer = ColortableLayer(LazyflowSource(slot), colortable)
     return layer
Esempio n. 21
0
    def createCropLayer(self, direct=False):
        """
        Return a colortable layer that displays the crop slot data, along with its associated crop source.
        direct: whether this layer is drawn synchronously by volumina
        """
        cropOutput = self._croppingSlots.cropOutput
        if not cropOutput.ready():
            return (None, None)
        else:
            # Add the layer to draw the crops, but don't add any crops
            cropsrc = LazyflowSinkSource( self._croppingSlots.cropOutput,
                                           self._croppingSlots.cropInput)

            croplayer = ColortableLayer(cropsrc, colorTable = self._colorTable16, direct=direct )
            croplayer.name = "Crops"
            croplayer.ref_object = None

            return croplayer, cropsrc
Esempio n. 22
0
    def createLabelLayer(self, direct=False):
        """
        Return a colortable layer that displays the label slot data, along with its associated label source.
        direct: whether this layer is drawn synchronously by volumina
        """
        labelOutput = self._labelingSlots.labelOutput
        if not labelOutput.ready():
            return (None, None)
        else:
            traceLogger.debug("Setting up labels")
            # Add the layer to draw the labels, but don't add any labels
            labelsrc = LazyflowSinkSource(self._labelingSlots.labelOutput, self._labelingSlots.labelInput)

            labellayer = ColortableLayer(labelsrc, colorTable=self._colorTable16, direct=direct)
            labellayer.name = "Labels"
            labellayer.ref_object = None

            return labellayer, labelsrc
Esempio n. 23
0
    def setupLayers(self):
        mainOperator = self.topLevelOperatorView
        layers = []

        if mainOperator.ObjectCenterImage.ready():
            self.centerimagesrc = LazyflowSource(mainOperator.ObjectCenterImage)
            #layer = RGBALayer(red=ConstantSource(255), alpha=self.centerimagesrc)
            redct = [0, QColor(255, 0, 0).rgba()]
            layer = ColortableLayer(self.centerimagesrc, redct)
            layer.name = "Object Centers"
            layer.visible = False
            layers.append(layer)

        ct = colortables.create_default_16bit()
        if mainOperator.LabelImage.ready():
            self.objectssrc = LazyflowSource(mainOperator.LabelImage)
            self.objectssrc.setObjectName("LabelImage LazyflowSrc")
            ct[0] = QColor(0, 0, 0, 0).rgba() # make 0 transparent
            layer = ColortableLayer(self.objectssrc, ct)
            layer.name = "Label Image"
            layer.visible = False
            layer.opacity = 0.5
            layers.append(layer)

        # white foreground on transparent background
        binct = [QColor(0, 0, 0, 0).rgba(), QColor(255, 255, 255, 255).rgba()]
        if mainOperator.BinaryImage.ready():
            self.binaryimagesrc = LazyflowSource(mainOperator.BinaryImage)
            self.binaryimagesrc.setObjectName("Binary LazyflowSrc")
            layer = ColortableLayer(self.binaryimagesrc, binct)
            layer.name = "Binary Image"
            layers.append(layer)

        ## raw data layer
        self.rawsrc = None
        self.rawsrc = LazyflowSource(mainOperator.RawImage)
        self.rawsrc.setObjectName("Raw Lazyflow Src")
        layerraw = GrayscaleLayer(self.rawsrc)
        layerraw.name = "Raw"
        layers.insert(len(layers), layerraw)

        mainOperator.RawImage.notifyReady(self._onReady)
        mainOperator.RawImage.notifyMetaChanged(self._onMetaChanged)

        if mainOperator.BinaryImage.meta.shape:
            self.editor.dataShape = mainOperator.BinaryImage.meta.shape
        mainOperator.BinaryImage.notifyMetaChanged(self._onMetaChanged)

        return layers
 def _initColortableLayer(self, labelSlot):
     objectssrc = createDataSource(labelSlot)
     objectssrc.setObjectName("LabelImage LazyflowSrc")
     ct = colortables.create_default_16bit()
     ct[0] = QColor(0, 0, 0, 0).rgba()  # make 0 transparent
     layer = ColortableLayer(objectssrc, ct)
     layer.name = "Object Identities - Preview"
     layer.setToolTip("Segmented objects, shown in different colors")
     layer.visible = False
     layer.opacity = 0.5
     layer.colortableIsRandom = True
     return layer
 def addThresholdOperator(self):
     if self.opThreshold is None:
         self.opThreshold = OpThreshold(self.g)
         self.opThreshold.inputs["Input"].connect(self.pCache.outputs["Output"])
     #channel, value = ThresholdDlg(self.labelListModel._labels)
     channel = 0
     value = 0.5
     ref_label = self.labelListModel._labels[channel]
     self.opThreshold.inputs["Channel"].setValue(channel)
     self.opThreshold.inputs["Threshold"].setValue(value)
     threshsrc = LazyflowSource(self.opThreshold.outputs["Output"][0])
     
     threshsrc.setObjectName("Threshold for %s" % ref_label.name)
     transparent = QColor(0,0,0,0)
     white = QColor(255,255,255)
     colorTable = [transparent.rgba(), white.rgba()]
     threshLayer = ColortableLayer(threshsrc, colorTable = colorTable )
     threshLayer.name = "Threshold for %s" % ref_label.name
     self.layerstack.insert(1, threshLayer)
     self.CCButton.setEnabled(True)
Esempio n. 26
0
    def createLabelLayer(self, direct=False):
        """
        Return a colortable layer that displays the label slot data, along with its associated label source.
        direct: whether this layer is drawn synchronously by volumina
        """
        labelOutput = self._labelingSlots.labelOutput
        if not labelOutput.ready():
            return (None, None)
        else:
            # Add the layer to draw the labels, but don't add any labels
            labelsrc = LazyflowSinkSource( self._labelingSlots.labelOutput,
                                           self._labelingSlots.labelInput)

            labellayer = ColortableLayer(labelsrc, colorTable = self._colorTable16, direct=direct )
            labellayer.name = "Labels"
            labellayer.ref_object = None

            labellayer.contexts.append(("Import...",
                                        partial( import_labeling_layer, labellayer, self._labelingSlots, self )))

            return labellayer, labelsrc
    def _initPredictionLayers(self, predictionSlot):
        layers = []

        opLane = self.topLevelOperatorView
        if predictionSlot.ready() and self.topLevelOperatorView.UpperBound.ready():
            upperBound = self.topLevelOperatorView.UpperBound.value
            layer = ColortableLayer(LazyflowSource(predictionSlot), colorTable = countingColorTable, normalize =
                               (0,upperBound))
            layer.name = "Density"
            layers.append(layer)

    

#    def _initPredictionLayers(self, predictionSlot):
#        layers = []
#
#        opLane = self.topLevelOperatorView
#        colors = opLane.PmapColors.value
#        names = opLane.LabelNames.value
#
#        # Use a slicer to provide a separate slot for each channel layer
#        opSlicer = OpMultiArraySlicer2( parent=opLane.viewed_operator() )
#        opSlicer.Input.connect( predictionSlot )
#        opSlicer.AxisFlag.setValue('c')
#
#        for channel, channelSlot in enumerate(opSlicer.Slices):
#            if channelSlot.ready() and channel < len(colors) and channel < len(names):
#                drange = channelSlot.meta.drange or (0.0, 1.0)
#                predictsrc = LazyflowSource(channelSlot)
#                predictLayer = AlphaModulatedLayer( predictsrc,
#                                                    tintColor=QColor(*colors[channel]),
#                                                    # FIXME: This is weird.  Why are range and normalize both set to the same thing?
#                                                    range=drange,
#                                                    normalize=drange )
#                predictLayer.opacity = 0.25
#                predictLayer.visible = True
#                predictLayer.name = names[channel]
#                layers.append(predictLayer)

        return layers
Esempio n. 28
0
    def _initPredictionLayers(self, predictionSlot):
        layers = []

        opLane = self.topLevelOperatorView
        if predictionSlot.ready(
        ) and self.topLevelOperatorView.UpperBound.ready():
            upperBound = self.topLevelOperatorView.UpperBound.value
            layer = ColortableLayer(createDataSource(predictionSlot),
                                    colorTable=countingColorTable,
                                    normalize=(0, upperBound))
            layer.name = "Density"
            layers.append(layer)

        #    def _initPredictionLayers(self, predictionSlot):
        #        layers = []
        #
        #        opLane = self.topLevelOperatorView
        #        colors = opLane.PmapColors.value
        #        names = opLane.LabelNames.value
        #
        #        # Use a slicer to provide a separate slot for each channel layer
        #        opSlicer = OpMultiArraySlicer2( parent=opLane.viewed_operator() )
        #        opSlicer.Input.connect( predictionSlot )
        #        opSlicer.AxisFlag.setValue('c')
        #
        #        for channel, channelSlot in enumerate(opSlicer.Slices):
        #            if channelSlot.ready() and channel < len(colors) and channel < len(names):
        #                drange = channelSlot.meta.drange or (0.0, 1.0)
        #                predictsrc = createDataSource(channelSlot)
        #                predictLayer = AlphaModulatedLayer( predictsrc,
        #                                                    tintColor=QColor(*colors[channel]),
        #                                                    # FIXME: This is weird.  Why are range and normalize both set to the same thing?
        #                                                    range=drange,
        #                                                    normalize=drange )
        #                predictLayer.opacity = 0.25
        #                predictLayer.visible = True
        #                predictLayer.name = names[channel]
        #                layers.append(predictLayer)

        return layers
Esempio n. 29
0
    def createLabelLayer(self, direct=False):
        """Return a colortable layer that displays the label slot
        data, along with its associated label source.

        direct: whether this layer is drawn synchronously by volumina

        """
        labelInput = self._labelingSlots.labelInput
        labelOutput = self._labelingSlots.labelOutput

        if not labelOutput.ready():
            return (None, None)
        else:
            self._colorTable16[15] = QColor(Qt.black).rgba() #for the objects with NaNs in features


            labelsrc = LazyflowSinkSource(labelOutput,
                                          labelInput)
            labellayer = ColortableLayer(labelsrc,
                                         colorTable=self._colorTable16,
                                         direct=direct)

            labellayer.segmentationImageSlot = self.op.SegmentationImagesOut
            labellayer.name = "Labels"
            labellayer.ref_object = None
            labellayer.zeroIsTransparent  = False
            labellayer.colortableIsRandom = True

            clickInt = ClickInterpreter(self.editor, labellayer,
                                        self.onClick, right=False,
                                        double=False)
            self.editor.brushingInterpreter = clickInt

            return labellayer, labelsrc
    def setupLayers(self):
        layers = []

        fromDiskSlot = self.topLevelOperatorView.ImageOnDisk
        if fromDiskSlot.ready():
            exportLayer = ColortableLayer( LazyflowSource(fromDiskSlot), colorTable=self.ct )
            exportLayer.name = "Tracking - Exported"
            exportLayer.visible = True
            layers.append(exportLayer)

        previewSlot = self.topLevelOperatorView.ImageToExport
        if previewSlot.ready():
            previewLayer = ColortableLayer( LazyflowSource(previewSlot), colorTable=self.ct )
            previewLayer.name = "Tracking - Preview"
            previewLayer.visible = False
            layers.append(previewLayer)

        rawSlot = self.topLevelOperatorView.RawData
        if rawSlot.ready():
            rawLayer = self.createStandardLayerFromSlot(rawSlot)
            rawLayer.name = "Raw Data"
            rawLayer.opacity = 1.0
            layers.append(rawLayer)

        return layers 
    def setupLayers(self):
        layers = []
        opLane = self.topLevelOperatorView

        labelSlot = opLane.LabelImage
        if labelSlot.ready():
            labelImageLayer = ColortableLayer(LazyflowSource(labelSlot),
                                              colorTable=self._colorTable16)
            labelImageLayer.name = "Label Image"
            labelImageLayer.visible = True
            layers.append(labelImageLayer)

        # If available, also show the raw data layer
        rawSlot = opLane.RawImage
        if rawSlot.ready():
            rawLayer = self.createStandardLayerFromSlot(rawSlot)
            rawLayer.name = "Raw Data"
            rawLayer.visible = True
            rawLayer.opacity = 1.0
            layers.append(rawLayer)

        return layers
Esempio n. 32
0
    def setupLayers(self):
        layers = []
        opLane = self.topLevelOperatorView

        labelSlot = opLane.LabelImage
        if labelSlot.ready():
            labelImageLayer = ColortableLayer( LazyflowSource(labelSlot),
                                               colorTable=self._colorTable16 )
            labelImageLayer.name = "Label Image"
            labelImageLayer.visible = True
            layers.append(labelImageLayer)
        
        # If available, also show the raw data layer
        rawSlot = opLane.RawImage
        if rawSlot.ready():
            rawLayer = self.createStandardLayerFromSlot( rawSlot )
            rawLayer.name = "Raw Data"
            rawLayer.visible = True
            rawLayer.opacity = 1.0
            layers.append( rawLayer )

        return layers
Esempio n. 33
0
    def createLabelLayer(self, currentImageIndex, direct=False):
        """
        Return a colortable layer that displays the label slot data, along with its associated label source.
        direct: whether this layer is drawn synchronously by volumina
        """
        labelOutput = self._labelingSlots.labelOutput[currentImageIndex]
        if not labelOutput.ready():
            return (None, None)
        else:
            traceLogger.debug("Setting up labels for image index={}".format(
                currentImageIndex))
            # Add the layer to draw the labels, but don't add any labels
            labelsrc = LazyflowSinkSource(
                self._labelingSlots.labelOutput[currentImageIndex],
                self._labelingSlots.labelInput[currentImageIndex])

            labellayer = ColortableLayer(labelsrc,
                                         colorTable=self._colorTable16,
                                         direct=direct)
            labellayer.name = "Labels"
            labellayer.ref_object = None

            return labellayer, labelsrc
Esempio n. 34
0
    def setupLayers(self):
        """
        Overridden from LayerViewerGui.
        Create a list of all layer objects that should be displayed.
        """
        layers = []

        # Show the raw input data
        inputImageSlot = self.topLevelOperatorView.InputImage
        if inputImageSlot.ready():
            inputLayer = self.createStandardLayerFromSlot(inputImageSlot)
            inputLayer.name = "Raw Input"
            inputLayer.visible = True
            inputLayer.opacity = 1.0
            layers.append(inputLayer)

        outputImageSlot = self.topLevelOperatorView.Output
        if outputImageSlot.ready():
            outputLayer = self.createStandardLayerFromSlot(outputImageSlot)
            outputLayer.name = "Result"
            outputLayer.visible = False
            outputLayer.opacity = 1.0
            layers.append(outputLayer)

        outputThresholdSlot = self.topLevelOperatorView.OutputThreshold
        if outputThresholdSlot.ready():
            # thresholdLayer = self.createStandardLayerFromSlot(outputThresholdSlot)
            thresholdLayer = ColortableLayer(
                LazyflowSource(outputThresholdSlot),
                colorTable=self._colorTable16)
            thresholdLayer.name = "Thresholded"
            thresholdLayer.visible = False
            thresholdLayer.opacity = 1.0
            layers.append(thresholdLayer)

        return layers
Esempio n. 35
0
 def _initColortablelayer(self, segSlot):
     """
     Used to export both segmentation and labels
     """
     if not segSlot.ready():
         return None
     opLane = self.topLevelOperatorView
     colors = opLane.PmapColors.value
     colortable = []
     colortable.append(QColor(0, 0, 0, 0).rgba())  # transparent
     for color in colors:
         colortable.append(QColor(*color).rgba())
     segsrc = LazyflowSource(segSlot)
     seglayer = ColortableLayer(segsrc, colortable)
     return seglayer
Esempio n. 36
0
    def _initColortablelayer(self, labelSlot):
        """
        Used to export labels
        """
        if not labelSlot.ready():
            return None

        opLane = self.topLevelOperatorView
        colors = opLane.PmapColors.value
        colortable = []
        colortable.append(QColor(0, 0, 0, 0).rgba())  # transparent
        for color in colors:
            colortable.append(QColor(*color).rgba())
        labelsrc = LazyflowSource(labelSlot)
        labellayer = ColortableLayer(labelsrc, colortable)
        return labellayer
Esempio n. 37
0
    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
Esempio n. 38
0
    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
Esempio n. 39
0
    def setupLayers( self ):        
        layers = []
                        
        self.ct[0] = QColor(0,0,0,0).rgba() # make 0 transparent        
        self.ct[255] = QColor(0,0,0,255).rgba() # make -1 black
        self.ct[-1] = QColor(0,0,0,255).rgba()
        self.trackingsrc = LazyflowSource( self.topLevelOperatorView.TrackImage )
        trackingLayer = ColortableLayer( self.trackingsrc, self.ct )
        trackingLayer.name = "Manual Tracking"
        trackingLayer.visible = True
        trackingLayer.opacity = 0.8

        def toggleTrackingVisibility():
            trackingLayer.visible = not trackingLayer.visible
            
        trackingLayer.shortcutRegistration = (
                "Layer Visibilities",
                "Toggle Manual Tracking Layer Visibility",
                QtGui.QShortcut( QtGui.QKeySequence("e"), self.viewerControlWidget(), toggleTrackingVisibility),
                trackingLayer )
        layers.append(trackingLayer)
        
        
        ct = colortables.create_random_16bit()
        ct[1] = QColor(230,0,0,150).rgba()
        ct[0] = QColor(0,0,0,0).rgba() # make 0 transparent
        self.untrackedsrc = LazyflowSource( self.topLevelOperatorView.UntrackedImage )
        untrackedLayer = ColortableLayer( self.untrackedsrc, ct )
        untrackedLayer.name = "Untracked Objects"
        untrackedLayer.visible = False
        untrackedLayer.opacity = 0.8
        layers.append(untrackedLayer)
        
        self.objectssrc = LazyflowSource( self.topLevelOperatorView.BinaryImage )
        ct = colortables.create_random_16bit()
        ct[0] = QColor(0,0,0,0).rgba() # make 0 transparent
        ct[1] = QColor(255,255,0,100).rgba() 
        objLayer = ColortableLayer( self.objectssrc, ct )
        objLayer.name = "Objects"
        objLayer.opacity = 0.8
        objLayer.visible = True
        
        def toggleObjectVisibility():
            objLayer.visible = not objLayer.visible
            
        objLayer.shortcutRegistration = (
                "Layer Visibilities",
                "Toggle Objects Layer Visibility",
                QtGui.QShortcut( QtGui.QKeySequence("r"), self.viewerControlWidget(), toggleObjectVisibility),
                objLayer )
        
        layers.append(objLayer)


        ## raw data layer
        self.rawsrc = None
        self.rawsrc = LazyflowSource( self.mainOperator.RawImage )
        rawLayer = GrayscaleLayer( self.rawsrc )
        rawLayer.name = "Raw"        
        layers.insert( len(layers), rawLayer )   
        
        
        if self.topLevelOperatorView.LabelImage.meta.shape:
            self.editor.dataShape = self.topLevelOperatorView.LabelImage.meta.shape    
        
        self.topLevelOperatorView.RawImage.notifyReady( self._onReady )
        self.topLevelOperatorView.RawImage.notifyMetaChanged( self._onMetaChanged )
        
        self._setDivisionsList()
        self._setActiveTrackList()
        
        return layers
Esempio n. 40
0
    def setupLayers(self):
        layers = []

        if "MergerOutput" in self.topLevelOperatorView.outputs and self.topLevelOperatorView.MergerOutput.ready(
        ):
            ct = colortables.create_default_8bit()
            for i in range(7):
                ct[i] = self.mergerColors[i].rgba()
            self.mergersrc = LazyflowSource(
                self.topLevelOperatorView.MergerOutput)
            mergerLayer = ColortableLayer(self.mergersrc, ct)
            mergerLayer.name = "Merger"
            mergerLayer.visible = True
            layers.append(mergerLayer)

        ct = colortables.create_random_16bit()
        ct[0] = QColor(0, 0, 0, 0).rgba()  # make 0 transparent
        ct[1] = QColor(128, 128, 128, 255).rgba(
        )  # misdetections have id 1 and will be indicated by grey

        if self.topLevelOperatorView.CachedOutput.ready():
            self.trackingsrc = LazyflowSource(
                self.topLevelOperatorView.CachedOutput)
            trackingLayer = ColortableLayer(self.trackingsrc, ct)
            trackingLayer.name = "Tracking"
            trackingLayer.visible = True
            trackingLayer.opacity = 1.0
            layers.append(trackingLayer)
        elif self.topLevelOperatorView.zeroProvider.Output.ready():
            # provide zeros while waiting for the tracking result
            self.trackingsrc = LazyflowSource(
                self.topLevelOperatorView.zeroProvider.Output)
            trackingLayer = ColortableLayer(self.trackingsrc, ct)
            trackingLayer.name = "Tracking"
            trackingLayer.visible = True
            trackingLayer.opacity = 1.0
            layers.append(trackingLayer)

        if self.topLevelOperatorView.LabelImage.ready():
            self.objectssrc = LazyflowSource(
                self.topLevelOperatorView.LabelImage)
            ct = colortables.create_random_16bit()
            ct[0] = QColor(0, 0, 0, 0).rgba()  # make 0 transparent
            objLayer = ColortableLayer(self.objectssrc, ct)
            objLayer.name = "Objects"
            objLayer.opacity = 1.0
            objLayer.visible = True
            layers.append(objLayer)

        if self.mainOperator.RawImage.ready():
            self.rawsrc = None
            self.rawsrc = LazyflowSource(self.mainOperator.RawImage)
            rawLayer = GrayscaleLayer(self.rawsrc)
            rawLayer.name = "Raw"
            layers.insert(len(layers), rawLayer)

        if self.topLevelOperatorView.LabelImage.meta.shape:
            self.editor.dataShape = self.topLevelOperatorView.LabelImage.meta.shape

            maxt = self.topLevelOperatorView.LabelImage.meta.shape[0] - 1
            maxx = self.topLevelOperatorView.LabelImage.meta.shape[1] - 1
            maxy = self.topLevelOperatorView.LabelImage.meta.shape[2] - 1
            maxz = self.topLevelOperatorView.LabelImage.meta.shape[3] - 1

            if not self.mainOperator.Parameters.ready():
                raise Exception("Parameter slot is not ready")

            parameters = self.mainOperator.Parameters.value
            self._setRanges()
            if 'size_range' in parameters:
                self._drawer.to_size.setValue(parameters['size_range'][1] - 1)
                self._drawer.from_size.setValue(parameters['size_range'][0])
            else:
                self._drawer.from_size.setValue(0)
                self._drawer.to_size.setValue(10000)

            if 'x_range' in parameters:
                self._drawer.to_x.setValue(parameters['x_range'][1] - 1)
                self._drawer.from_x.setValue(parameters['x_range'][0])
            else:
                self._drawer.from_x.setValue(0)
                self._drawer.to_x.setValue(maxx)

            if 'y_range' in parameters:
                self._drawer.to_y.setValue(parameters['y_range'][1] - 1)
                self._drawer.from_y.setValue(parameters['y_range'][0])
            else:
                self._drawer.from_y.setValue(0)
                self._drawer.to_y.setValue(maxy)

            if 'z_range' in parameters:
                self._drawer.to_z.setValue(parameters['z_range'][1] - 1)
                self._drawer.from_z.setValue(parameters['z_range'][0])
            else:
                self._drawer.from_z.setValue(0)
                self._drawer.to_z.setValue(maxz)

            if 'time_range' in parameters:
                self._drawer.to_time.setValue(parameters['time_range'][1])
                self._drawer.from_time.setValue(parameters['time_range'][0])
            else:
                self._drawer.from_time.setValue(0)
                self._drawer.to_time.setValue(maxt)

            if 'scales' in parameters:
                self._drawer.x_scale.setValue(parameters['scales'][0])
                self._drawer.y_scale.setValue(parameters['scales'][1])
                self._drawer.z_scale.setValue(parameters['scales'][2])
            else:
                self._drawer.x_scale.setValue(1)
                self._drawer.y_scale.setValue(1)
                self._drawer.z_scale.setValue(1)

        self.topLevelOperatorView.RawImage.notifyReady(self._onReady)
        self.topLevelOperatorView.RawImage.notifyMetaChanged(
            self._onMetaChanged)

        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.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.
        layers = super(ObjectClassificationGui, self).setupLayers()

        labelOutput = self._labelingSlots.labelOutput
        binarySlot = self.op.BinaryImages
        segmentedSlot = self.op.SegmentationImages
        rawSlot = self.op.RawImages

        if segmentedSlot.ready():
            ct = colortables.create_default_16bit()
            self.objectssrc = LazyflowSource(segmentedSlot)
            ct[0] = QColor(0, 0, 0, 0).rgba()  # make 0 transparent
            layer = ColortableLayer(self.objectssrc, ct)
            layer.name = "Objects"
            layer.opacity = 0.5
            layer.visible = True
            layers.append(layer)

        if binarySlot.ready():
            ct_binary = [QColor(0, 0, 0, 0).rgba(), QColor(255, 255, 255, 255).rgba()]
            self.binaryimagesrc = LazyflowSource(binarySlot)
            layer = ColortableLayer(self.binaryimagesrc, ct_binary)
            layer.name = "Binary Image"
            layer.visible = False
            layers.append(layer)

        # 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()

                def setLayerColor(c, predictLayer=probLayer):
                    predictLayer.tintColor = c

                def setLayerName(n, predictLayer=probLayer):
                    newName = "Prediction for %s" % n
                    predictLayer.name = newName

                setLayerName(ref_label.name)
                ref_label.pmapColorChanged.connect(setLayerColor)
                ref_label.nameChanged.connect(setLayerName)
                layers.insert(0, probLayer)

        predictionSlot = self.op.PredictionImages
        if predictionSlot.ready():
            self.predictsrc = LazyflowSource(predictionSlot)
            self.predictlayer = ColortableLayer(self.predictsrc, colorTable=self._colorTable16)
            self.predictlayer.name = "Prediction"
            self.predictlayer.ref_object = None
            self.predictlayer.visible = self.labelingDrawerUi.checkInteractive.isChecked()

            # put first, so that it is visible after hitting "live
            # predict".
            layers.insert(0, self.predictlayer)

        badObjectsSlot = self.op.BadObjectImages
        if badObjectsSlot.ready():
            ct_black = [0, QColor(Qt.black).rgba()]
            self.badSrc = LazyflowSource(badObjectsSlot)
            self.badLayer = ColortableLayer(self.badSrc, colorTable=ct_black)
            self.badLayer.name = "Ambiguous objects"
            self.badLayer.visible = False
            layers.append(self.badLayer)

        if rawSlot.ready():
            self.rawimagesrc = LazyflowSource(rawSlot)
            layer = self.createStandardLayerFromSlot(rawSlot)
            layer.name = "Raw data"
            layers.append(layer)

        # 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 = []

        # use same colortable for the following two generated layers: the merger
        # and the tracking layer
        self.tracking_colortable = colortables.create_random_16bit()
        self.tracking_colortable[0] = QColor(0,0,0,0).rgba() # make 0 transparent
        self.tracking_colortable[1] = QColor(128,128,128,255).rgba() # misdetections have id 1 and will be indicated by grey

        self.merger_colortable = colortables.create_default_16bit()
        for i in range(7):
            self.merger_colortable[i] = self.mergerColors[i].rgba()

        if "MergerOutput" in self.topLevelOperatorView.outputs:
            parameters = self.mainOperator.Parameters.value

            if 'withMergerResolution' in parameters.keys() and not parameters['withMergerResolution']:
                merger_ct = self.merger_colortable
            else:
                merger_ct = self.tracking_colortable
                
            # Using same color table for tracking with and without mergers (Is there any reason for using different color tables?)
            merger_ct = self.tracking_colortable

            if self.topLevelOperatorView.MergerCachedOutput.ready():
                self.mergersrc = LazyflowSource( self.topLevelOperatorView.MergerCachedOutput )
            else:
                self.mergersrc = LazyflowSource( self.topLevelOperatorView.zeroProvider.Output )

            mergerLayer = ColortableLayer( self.mergersrc, merger_ct )
            mergerLayer.name = "Merger"

            if 'withMergerResolution' in parameters.keys() and not parameters['withMergerResolution']:
                mergerLayer.visible = True
            else:
                mergerLayer.visible = False

            layers.append(mergerLayer)

        if self.topLevelOperatorView.CachedOutput.ready():
            self.trackingsrc = LazyflowSource( self.topLevelOperatorView.CachedOutput )
            trackingLayer = ColortableLayer( self.trackingsrc, self.tracking_colortable )
            trackingLayer.name = "Tracking"
            trackingLayer.visible = True
            trackingLayer.opacity = 1.0
            layers.append(trackingLayer)

        elif self.topLevelOperatorView.zeroProvider.Output.ready():
            # provide zeros while waiting for the tracking result
            self.trackingsrc = LazyflowSource( self.topLevelOperatorView.zeroProvider.Output )
            trackingLayer = ColortableLayer( self.trackingsrc, self.tracking_colortable )
            trackingLayer.name = "Tracking"
            trackingLayer.visible = True
            trackingLayer.opacity = 1.0
            layers.append(trackingLayer)

        if "RelabeledImage" in self.topLevelOperatorView.outputs:
            if self.topLevelOperatorView.RelabeledCachedOutput.ready():
                self.objectssrc = LazyflowSource( self.topLevelOperatorView.RelabeledCachedOutput )
            else:
                self.objectssrc = LazyflowSource( self.topLevelOperatorView.zeroProvider.Output )
        else:
            if self.topLevelOperatorView.LabelImage.ready():
                self.objectssrc = LazyflowSource( self.topLevelOperatorView.LabelImage )
        ct = colortables.create_random_16bit()
        ct[0] = QColor(0,0,0,0).rgba() # make 0 transparent
        objLayer = ColortableLayer( self.objectssrc, ct )
        objLayer.name = "Objects"
        objLayer.opacity = 1.0
        objLayer.visible = False
        layers.append(objLayer)

        if self.mainOperator.RawImage.ready():
            rawLayer = self.createStandardLayerFromSlot(self.mainOperator.RawImage)
            rawLayer.name = "Raw"
            layers.insert( len(layers), rawLayer )


        if self.topLevelOperatorView.LabelImage.meta.shape:
            maxt = self.topLevelOperatorView.LabelImage.meta.shape[0] - 1
            maxx = self.topLevelOperatorView.LabelImage.meta.shape[1] - 1
            maxy = self.topLevelOperatorView.LabelImage.meta.shape[2] - 1
            maxz = self.topLevelOperatorView.LabelImage.meta.shape[3] - 1

            if not self.mainOperator.Parameters.ready():
                raise Exception("Parameter slot is not ready")

            parameters = self.mainOperator.Parameters.value
            self._setRanges()
            if 'size_range' in parameters:
                self._drawer.to_size.setValue(parameters['size_range'][1]-1)
                self._drawer.from_size.setValue(parameters['size_range'][0])
            else:
                self._drawer.from_size.setValue(0)
                self._drawer.to_size.setValue(10000)

            if 'x_range' in parameters:
                self._drawer.to_x.setValue(parameters['x_range'][1]-1)
                self._drawer.from_x.setValue(parameters['x_range'][0])
            else:
                self._drawer.from_x.setValue(0)
                self._drawer.to_x.setValue(maxx)

            if 'y_range' in parameters:
                self._drawer.to_y.setValue(parameters['y_range'][1]-1)
                self._drawer.from_y.setValue(parameters['y_range'][0])
            else:
                self._drawer.from_y.setValue(0)
                self._drawer.to_y.setValue(maxy)

            if 'z_range' in parameters:
                self._drawer.to_z.setValue(parameters['z_range'][1]-1)
                self._drawer.from_z.setValue(parameters['z_range'][0])
            else:
                self._drawer.from_z.setValue(0)
                self._drawer.to_z.setValue(maxz)

            if 'time_range' in parameters:
                self._drawer.to_time.setValue(parameters['time_range'][1])
                self._drawer.from_time.setValue(parameters['time_range'][0])
            else:
                self._drawer.from_time.setValue(0)
                self._drawer.to_time.setValue(maxt)

            if 'scales' in parameters:
                self._drawer.x_scale.setValue(parameters['scales'][0])
                self._drawer.y_scale.setValue(parameters['scales'][1])
                self._drawer.z_scale.setValue(parameters['scales'][2])
            else:
                self._drawer.x_scale.setValue(1)
                self._drawer.y_scale.setValue(1)
                self._drawer.z_scale.setValue(1)


        return layers
Esempio n. 45
0
    def setupLayers( self ):        
        layers = []
        
        if "MergerOutput" in self.topLevelOperatorView.outputs:
            ct = colortables.create_default_8bit()
            for i in range(7):
                ct[i] = self.mergerColors[i].rgba()

            if self.topLevelOperatorView.MergerCachedOutput.ready():
                self.mergersrc = LazyflowSource( self.topLevelOperatorView.MergerCachedOutput )
            else:
                self.mergersrc = LazyflowSource( self.topLevelOperatorView.ZeroOutput )

            mergerLayer = ColortableLayer( self.mergersrc, ct )
            mergerLayer.name = "Merger"
            mergerLayer.visible = True
            layers.append(mergerLayer)
            
        ct = colortables.create_random_16bit()
        ct[0] = QColor(0,0,0,0).rgba() # make 0 transparent
        ct[1] = QColor(128,128,128,255).rgba() # misdetections have id 1 and will be indicated by grey
        
        if self.topLevelOperatorView.CachedOutput.ready():            
            self.trackingsrc = LazyflowSource( self.topLevelOperatorView.CachedOutput )
            trackingLayer = ColortableLayer( self.trackingsrc, ct )
            trackingLayer.name = "Tracking"
            trackingLayer.visible = True
            trackingLayer.opacity = 1.0
            layers.append(trackingLayer)
        elif self.topLevelOperatorView.zeroProvider.Output.ready(): 
            # provide zeros while waiting for the tracking result
            self.trackingsrc = LazyflowSource( self.topLevelOperatorView.zeroProvider.Output )
            trackingLayer = ColortableLayer( self.trackingsrc, ct )
            trackingLayer.name = "Tracking"
            trackingLayer.visible = True
            trackingLayer.opacity = 1.0
            layers.append(trackingLayer)
        
        if self.topLevelOperatorView.LabelImage.ready():
            self.objectssrc = LazyflowSource( self.topLevelOperatorView.LabelImage )    
            ct = colortables.create_random_16bit()
            ct[0] = QColor(0,0,0,0).rgba() # make 0 transparent
            objLayer = ColortableLayer( self.objectssrc, ct )
            objLayer.name = "Objects"
            objLayer.opacity = 1.0
            objLayer.visible = True
            layers.append(objLayer)


        if self.mainOperator.RawImage.ready():
            rawLayer = self.createStandardLayerFromSlot(self.mainOperator.RawImage)
            rawLayer.name = "Raw"        
            layers.insert( len(layers), rawLayer )   
        
        
        if self.topLevelOperatorView.LabelImage.meta.shape:
            self.editor.dataShape = self.topLevelOperatorView.LabelImage.meta.shape

            maxt = self.topLevelOperatorView.LabelImage.meta.shape[0] - 1
            maxx = self.topLevelOperatorView.LabelImage.meta.shape[1] - 1            
            maxy = self.topLevelOperatorView.LabelImage.meta.shape[2] - 1
            maxz = self.topLevelOperatorView.LabelImage.meta.shape[3] - 1
                    
            if not self.mainOperator.Parameters.ready():
                raise Exception("Parameter slot is not ready")
            
            parameters = self.mainOperator.Parameters.value
            self._setRanges() 
            if 'size_range' in parameters:                
                self._drawer.to_size.setValue(parameters['size_range'][1]-1)
                self._drawer.from_size.setValue(parameters['size_range'][0])
            else:
                self._drawer.from_size.setValue(0)
                self._drawer.to_size.setValue(10000)
                
            if 'x_range' in parameters:                
                self._drawer.to_x.setValue(parameters['x_range'][1]-1)
                self._drawer.from_x.setValue(parameters['x_range'][0])
            else:
                self._drawer.from_x.setValue(0)
                self._drawer.to_x.setValue(maxx)
                
            if 'y_range' in parameters:
                self._drawer.to_y.setValue(parameters['y_range'][1]-1)
                self._drawer.from_y.setValue(parameters['y_range'][0])                
            else:
                self._drawer.from_y.setValue(0)
                self._drawer.to_y.setValue(maxy)
                
            if 'z_range' in parameters:
                self._drawer.to_z.setValue(parameters['z_range'][1]-1)
                self._drawer.from_z.setValue(parameters['z_range'][0])                
            else:
                self._drawer.from_z.setValue(0)
                self._drawer.to_z.setValue(maxz)
            
            if 'time_range' in parameters:
                self._drawer.to_time.setValue(parameters['time_range'][1])
                self._drawer.from_time.setValue(parameters['time_range'][0])                
            else:
                self._drawer.from_time.setValue(0)
                self._drawer.to_time.setValue(maxt)
            
            if 'scales' in parameters:
                self._drawer.x_scale.setValue(parameters['scales'][0])
                self._drawer.y_scale.setValue(parameters['scales'][1])
                self._drawer.z_scale.setValue(parameters['scales'][2])
            else:
                self._drawer.x_scale.setValue(1)
                self._drawer.y_scale.setValue(1)
                self._drawer.z_scale.setValue(1)
               
        
        return layers
Esempio n. 46
0
    def setupLayers(self):
        layers = []

        opLane = self.topLevelOperatorView

        selection_names = opLane.SelectionNames.value
        selection = selection_names[opLane.InputSelection.value]

        # This code depends on a specific order for the export slots.
        # If those change, update this function!
        assert selection in [
            'Object Predictions', 'Object Probabilities', 'Pixel Probabilities'
        ]

        if selection == "Object Predictions":
            fromDiskSlot = self.topLevelOperatorView.ImageOnDisk
            if fromDiskSlot.ready():
                exportLayer = ColortableLayer(LazyflowSource(fromDiskSlot),
                                              colorTable=self._colorTable16)
                exportLayer.name = "Prediction - Exported"
                exportLayer.visible = True
                layers.append(exportLayer)

            previewSlot = self.topLevelOperatorView.ImageToExport
            if previewSlot.ready():
                previewLayer = ColortableLayer(LazyflowSource(previewSlot),
                                               colorTable=self._colorTable16)
                previewLayer.name = "Prediction - Preview"
                previewLayer.visible = False
                layers.append(previewLayer)

        elif selection == "Object Probabilities":
            exportedLayers = self._initPredictionLayers(opLane.ImageOnDisk)
            for layer in exportedLayers:
                layer.visible = True
                layer.name = layer.name + "- Exported"
            layers += exportedLayers

            previewLayers = self._initPredictionLayers(opLane.ImageToExport)
            for layer in previewLayers:
                layer.visible = False
                layer.name = layer.name + "- Preview"
            layers += previewLayers

        elif selection == 'Pixel Probabilities':
            exportedLayers = self._initPredictionLayers(opLane.ImageOnDisk)
            for layer in exportedLayers:
                layer.visible = True
                layer.name = layer.name + "- Exported"
            layers += exportedLayers

            previewLayers = self._initPredictionLayers(opLane.ImageToExport)
            for layer in previewLayers:
                layer.visible = False
                layer.name = layer.name + "- Preview"
            layers += previewLayers
        else:
            assert False, "Unknown selection."

        rawSlot = self.topLevelOperatorView.RawData
        if rawSlot.ready():
            rawLayer = self.createStandardLayerFromSlot(rawSlot)
            rawLayer.name = "Raw Data"
            rawLayer.opacity = 1.0
            layers.append(rawLayer)

        return layers
    def setupLayers(self):
        """
        Called by our base class when one of our data slots has changed.
        This function creates a layer for each slot we want displayed in the volume editor.
        """
        # Base class provides the label layer.
        layers = super(PixelClassificationGui, self).setupLayers()

        ActionInfo = ShortcutManager.ActionInfo

        if ilastik_config.getboolean('ilastik', 'debug'):

            # Add the label projection layer.
            labelProjectionSlot = self.topLevelOperatorView.opLabelPipeline.opLabelArray.Projection2D
            if labelProjectionSlot.ready():
                projectionSrc = LazyflowSource(labelProjectionSlot)
                try:
                    # This colortable requires matplotlib
                    from volumina.colortables import jet
                    projectionLayer = ColortableLayer( projectionSrc, 
                                                       colorTable=[QColor(0,0,0,128).rgba()]+jet(N=255), 
                                                       normalize=(0.0, 1.0) )
                except (ImportError, RuntimeError):
                    pass
                else:
                    projectionLayer.name = "Label Projection"
                    projectionLayer.visible = False
                    projectionLayer.opacity = 1.0
                    layers.append(projectionLayer)

        # Show the mask over everything except labels
        maskSlot = self.topLevelOperatorView.PredictionMasks
        if maskSlot.ready():
            maskLayer = self._create_binary_mask_layer_from_slot( maskSlot )
            maskLayer.name = "Mask"
            maskLayer.visible = True
            maskLayer.opacity = 1.0
            layers.append( maskLayer )

        # Add the uncertainty estimate layer
        uncertaintySlot = self.topLevelOperatorView.UncertaintyEstimate
        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
            uncertaintyLayer.shortcutRegistration = ( "u", ActionInfo( "Prediction Layers",
                                                                       "Uncertainty",
                                                                       "Show/Hide Uncertainty",
                                                                       uncertaintyLayer.toggleVisible,
                                                                       self.viewerControlWidget(),
                                                                       uncertaintyLayer ) )
            layers.append(uncertaintyLayer)

        labels = self.labelListData

        # Add each of the segmentations
        for channel, segmentationSlot in enumerate(self.topLevelOperatorView.SegmentationChannels):
            if segmentationSlot.ready() and channel < len(labels):
                ref_label = labels[channel]
                segsrc = LazyflowSource(segmentationSlot)
                segLayer = AlphaModulatedLayer( segsrc,
                                                tintColor=ref_label.pmapColor(),
                                                range=(0.0, 1.0),
                                                normalize=(0.0, 1.0) )

                segLayer.opacity = 1
                segLayer.visible = False #self.labelingDrawerUi.liveUpdateButton.isChecked()
                segLayer.visibleChanged.connect(self.updateShowSegmentationCheckbox)

                def setLayerColor(c, segLayer_=segLayer, initializing=False):
                    if not initializing and segLayer_ not in self.layerstack:
                        # This layer has been removed from the layerstack already.
                        # Don't touch it.
                        return
                    segLayer_.tintColor = c
                    self._update_rendering()

                def setSegLayerName(n, segLayer_=segLayer, initializing=False):
                    if not initializing and segLayer_ not in self.layerstack:
                        # This layer has been removed from the layerstack already.
                        # Don't touch it.
                        return
                    oldname = segLayer_.name
                    newName = "Segmentation (%s)" % n
                    segLayer_.name = newName
                    if not self.render:
                        return
                    if oldname in self._renderedLayers:
                        label = self._renderedLayers.pop(oldname)
                        self._renderedLayers[newName] = label

                setSegLayerName(ref_label.name, initializing=True)

                ref_label.pmapColorChanged.connect(setLayerColor)
                ref_label.nameChanged.connect(setSegLayerName)
                #check if layer is 3d before adding the "Toggle 3D" option
                #this check is done this way to match the VolumeRenderer, in
                #case different 3d-axistags should be rendered like t-x-y
                #_axiskeys = segmentationSlot.meta.getAxisKeys()
                if len(segmentationSlot.meta.shape) == 4:
                    #the Renderer will cut out the last shape-dimension, so
                    #we're checking for 4 dimensions
                    self._setup_contexts(segLayer)
                layers.append(segLayer)
        
        # Add each of the predictions
        for channel, predictionSlot in enumerate(self.topLevelOperatorView.PredictionProbabilityChannels):
            if predictionSlot.ready() and channel < len(labels):
                ref_label = labels[channel]
                predictsrc = LazyflowSource(predictionSlot)
                predictLayer = AlphaModulatedLayer( predictsrc,
                                                    tintColor=ref_label.pmapColor(),
                                                    range=(0.0, 1.0),
                                                    normalize=(0.0, 1.0) )
                predictLayer.opacity = 0.25
                predictLayer.visible = self.labelingDrawerUi.liveUpdateButton.isChecked()
                predictLayer.visibleChanged.connect(self.updateShowPredictionCheckbox)

                def setLayerColor(c, predictLayer_=predictLayer, 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 setPredLayerName(n, predictLayer_=predictLayer, 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

                setPredLayerName(ref_label.name, initializing=True)
                ref_label.pmapColorChanged.connect(setLayerColor)
                ref_label.nameChanged.connect(setPredLayerName)
                layers.append(predictLayer)

        # Add the raw data last (on the bottom)
        inputDataSlot = self.topLevelOperatorView.InputImages        
        if inputDataSlot.ready():                        
            inputLayer = self.createStandardLayerFromSlot( inputDataSlot )
            inputLayer.name = "Input Data"
            inputLayer.visible = True
            inputLayer.opacity = 1.0
            # the flag window_leveling is used to determine if the contrast 
            # of the layer is adjustable
            if isinstance( inputLayer, GrayscaleLayer ):
                inputLayer.window_leveling = True
            else:
                inputLayer.window_leveling = False

            def toggleTopToBottom():
                index = self.layerstack.layerIndex( inputLayer )
                self.layerstack.selectRow( index )
                if index == 0:
                    self.layerstack.moveSelectedToBottom()
                else:
                    self.layerstack.moveSelectedToTop()

            inputLayer.shortcutRegistration = ( "i", ActionInfo( "Prediction Layers",
                                                                 "Bring Input To Top/Bottom",
                                                                 "Bring Input To Top/Bottom",
                                                                 toggleTopToBottom,
                                                                 self.viewerControlWidget(),
                                                                 inputLayer ) )
            layers.append(inputLayer)
            
            # The thresholding button can only be used if the data is displayed as grayscale.
            if inputLayer.window_leveling:
                self.labelingDrawerUi.thresToolButton.show()
            else:
                self.labelingDrawerUi.thresToolButton.hide()
        
        self.handleLabelSelectionChange()
        return layers
Esempio n. 48
0
    def setupLayers(self):
        layers = []
        op = self.topLevelOperatorView
        binct = [QColor(Qt.black), QColor(Qt.white)]
        #binct[0] = 0
        ct = create_default_16bit()
        # associate label 0 with black/transparent?
        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 = "Connected Components"
            outputLayer.visible = False
            outputLayer.opacity = 1.0
            outputLayer.setToolTip("Results of connected component analysis")
            layers.append(outputLayer)

        if op.Input.ready():
            rawSrc = LazyflowSource(op.Input)
            rawLayer = ColortableLayer(outputSrc, binct)
            #rawLayer = self.createStandardLayerFromSlot(op.Input)
            rawLayer.name = "Raw data"
            rawLayer.visible = True
            rawLayer.opacity = 1.0
            layers.append(rawLayer)

        return layers
Esempio n. 49
0
    def setupLayers(self):
        layers = super(Counting3dGui, self).setupLayers()

        from PyQt4.QtGui import QColor
        # Base class provides the label layer.
        #layers = super(Counting3dGui, self).setupLayers()
        #This is just for colors
        #labels = self.labelListData

        #Personal Note: the standardlayer rescales its value range when
        #displaying gray value images, which, in turn, makes some data invisible
        #when being viewed after some others.


        #labelOutput = self._labelingSlots.labelOutput
        slots = {#'featureData' : self.op.FeatureData, 
                 #'filteredFeatureData' : self.op.FilteredFeatureData,
                 #'modFeatureData' : self.op.ModifiedFeatureData, 
                 'density' : self.op.Density
                 #'FilteredRawData' : self.op.FilteredRaw
                }
        colortableSlots = {
            'UserLabels' : self.op.LabelImages
        
        }
        for name, slot in colortableSlots.items():
            if slot.ready():
                self.imagesrc = LazyflowSource(slot)
                ct = colortables.default16
                ct[0] = QColor(0,0,0,0)
                layer = ColortableLayer(self.imagesrc, colorTable =
                                        colortables.default16)
                layer.zeroIsTransparent= True
                layer.name = name
                layers.append(layer)
        for name, slot in slots.items():
            if slot.ready():
                self.imagesrc = LazyflowSource(slot)
                layer = self.createStandardLayerFromSlot(slot)
                layer.name = name
                layers.append(layer)



        #if binarySlot.ready():
        #    ct_binary = [QColor(0,0,0,0).rgba(), QColor(0,0,255,255).rgba()]
        #    self.binaryimagesrc = LazyflowSource(binarySlot)
        #    #layer = GrayscaleLayer(self.binaryimagesrc, range=(0,1), normalize=(0,1))
        #    layer = ColortableLayer(self.binaryimagesrc, ct_binary)
        #    layer.name = "Binary Image"
        #    layers.append(layer)
        #predictionSlot = self.op.PredictionImages
        #if predictionSlot.ready():
        #    self.predictsrc = LazyflowSource(predictionSlot)
        #    self.predictlayer = ColortableLayer(self.predictsrc, colorTable=self._colorTable16)
        #    self.predictlayer.name = "Prediction"
        #    self.predictlayer.ref_object = None
        #    self.predictlayer.visible = self.labelingDrawerUi.checkInteractive.isChecked()

        #    # put first, so that it is visible after hitting "live
        #    # predict".
        #    layers.insert(0, self.predictlayer)

        return layers
    def setupLayers(self):
        layers = []

        opLane = self.topLevelOperatorView

        selection_names = opLane.SelectionNames.value
        selection = selection_names[ opLane.InputSelection.value ]

        # This code depends on a specific order for the export slots.
        # If those change, update this function!
        assert selection in ['Object Predictions', 'Object Probabilities', 'Pixel Probabilities']
    
        if selection == "Object Predictions":
            fromDiskSlot = self.topLevelOperatorView.ImageOnDisk
            if fromDiskSlot.ready():
                exportLayer = ColortableLayer( LazyflowSource(fromDiskSlot), colorTable=self._colorTable16 )
                exportLayer.name = "Prediction - Exported"
                exportLayer.visible = True
                layers.append(exportLayer)
    
            previewSlot = self.topLevelOperatorView.ImageToExport
            if previewSlot.ready():
                previewLayer = ColortableLayer( LazyflowSource(previewSlot), colorTable=self._colorTable16 )
                previewLayer.name = "Prediction - Preview"
                previewLayer.visible = False
                layers.append(previewLayer)

        elif selection == "Object Probabilities":
            exportedLayers = self._initPredictionLayers(opLane.ImageOnDisk)
            for layer in exportedLayers:
                layer.visible = True
                layer.name = layer.name + "- Exported"
            layers += exportedLayers
            
            previewLayers = self._initPredictionLayers(opLane.ImageToExport)
            for layer in previewLayers:
                layer.visible = False
                layer.name = layer.name + "- Preview"
            layers += previewLayers
        
        elif selection == 'Pixel Probabilities':
            exportedLayers = self._initPredictionLayers(opLane.ImageOnDisk)
            for layer in exportedLayers:
                layer.visible = True
                layer.name = layer.name + "- Exported"
            layers += exportedLayers
            
            previewLayers = self._initPredictionLayers(opLane.ImageToExport)
            for layer in previewLayers:
                layer.visible = False
                layer.name = layer.name + "- Preview"
            layers += previewLayers
        else:
            assert False, "Unknown selection."

        rawSlot = self.topLevelOperatorView.RawData
        if rawSlot.ready():
            rawLayer = self.createStandardLayerFromSlot(rawSlot)
            rawLayer.name = "Raw Data"
            rawLayer.opacity = 1.0
            layers.append(rawLayer)

        return layers 
Esempio n. 51
0
    def setupLayers(self):
        mainOperator = self.topLevelOperatorView
        layers = []

        if mainOperator.ObjectCenterImage.ready():
            self.centerimagesrc = LazyflowSource(mainOperator.ObjectCenterImage)
            redct = [0, QColor(255, 0, 0).rgba()]
            layer = ColortableLayer(self.centerimagesrc, redct)
            layer.name = "Object centers"
            layer.setToolTip("Object center positions, marked with a little red cross")
            layer.visible = False
            layers.append(layer)

        ct = colortables.create_default_16bit()
        if mainOperator.LabelImage.ready():
            self.objectssrc = LazyflowSource(mainOperator.LabelImage)
            self.objectssrc.setObjectName("LabelImage LazyflowSrc")
            ct[0] = QColor(0, 0, 0, 0).rgba() # make 0 transparent
            layer = ColortableLayer(self.objectssrc, ct)
            layer.name = "Objects (connected components)"
            layer.setToolTip("Segmented objects, shown in different colors")
            layer.visible = False
            layer.opacity = 0.5
            layers.append(layer)

        # white foreground on transparent background, even for labeled images
        binct = [QColor(255, 255, 255, 255).rgba()]*65536
        binct[0] = 0
        if mainOperator.BinaryImage.ready():
            self.binaryimagesrc = LazyflowSource(mainOperator.BinaryImage)
            self.binaryimagesrc.setObjectName("Binary LazyflowSrc")
            layer = ColortableLayer(self.binaryimagesrc, binct)
            layer.name = "Binary image"
            layer.setToolTip("Segmented objects, binary mask")
            layers.append(layer)

        ## raw data layer
        self.rawsrc = None
        self.rawsrc = LazyflowSource(mainOperator.RawImage)
        self.rawsrc.setObjectName("Raw Lazyflow Src")
        layerraw = GrayscaleLayer(self.rawsrc)
        layerraw.name = "Raw data"
        layers.insert(len(layers), layerraw)

        mainOperator.RawImage.notifyReady(self._onReady)
        self.__cleanup_fns.append( partial( mainOperator.RawImage.unregisterReady, self._onReady ) )

        mainOperator.RawImage.notifyMetaChanged(self._onMetaChanged)
        self.__cleanup_fns.append( partial( mainOperator.RawImage.unregisterMetaChanged, self._onMetaChanged ) )

        if mainOperator.BinaryImage.meta.shape:
            self.editor.dataShape = mainOperator.BinaryImage.meta.shape

        mainOperator.BinaryImage.notifyMetaChanged(self._onMetaChanged)
        self.__cleanup_fns.append( partial( mainOperator.BinaryImage.unregisterMetaChanged, self._onMetaChanged ) )

        return layers
    def setupLayers(self):
        mainOperator = self.topLevelOperatorView
        layers = []

        if mainOperator.ObjectCenterImage.ready():
            self.centerimagesrc = LazyflowSource(
                mainOperator.ObjectCenterImage)
            redct = [0, QColor(255, 0, 0).rgba()]
            layer = ColortableLayer(self.centerimagesrc, redct)
            layer.name = "Object centers"
            layer.setToolTip(
                "Object center positions, marked with a little red cross")
            layer.visible = False
            layers.append(layer)

        ct = colortables.create_default_16bit()
        if mainOperator.LabelImage.ready():
            self.objectssrc = LazyflowSource(mainOperator.LabelImage)
            self.objectssrc.setObjectName("LabelImage LazyflowSrc")
            ct[0] = QColor(0, 0, 0, 0).rgba()  # make 0 transparent
            layer = ColortableLayer(self.objectssrc, ct)
            layer.name = "Objects (connected components)"
            layer.setToolTip("Segmented objects, shown in different colors")
            layer.visible = False
            layer.opacity = 0.5
            layers.append(layer)

        # white foreground on transparent background, even for labeled images
        binct = [QColor(255, 255, 255, 255).rgba()] * 65536
        binct[0] = 0
        if mainOperator.BinaryImage.ready():
            self.binaryimagesrc = LazyflowSource(mainOperator.BinaryImage)
            self.binaryimagesrc.setObjectName("Binary LazyflowSrc")
            layer = ColortableLayer(self.binaryimagesrc, binct)
            layer.name = "Binary image"
            layer.setToolTip("Segmented objects, binary mask")
            layers.append(layer)

        ## raw data layer
        self.rawsrc = None
        self.rawsrc = LazyflowSource(mainOperator.RawImage)
        self.rawsrc.setObjectName("Raw Lazyflow Src")
        layerraw = GrayscaleLayer(self.rawsrc)
        layerraw.name = "Raw data"
        layers.insert(len(layers), layerraw)

        mainOperator.RawImage.notifyReady(self._onReady)
        self.__cleanup_fns.append(
            partial(mainOperator.RawImage.unregisterReady, self._onReady))

        mainOperator.RawImage.notifyMetaChanged(self._onMetaChanged)
        self.__cleanup_fns.append(
            partial(mainOperator.RawImage.unregisterMetaChanged,
                    self._onMetaChanged))

        mainOperator.BinaryImage.notifyMetaChanged(self._onMetaChanged)
        self.__cleanup_fns.append(
            partial(mainOperator.BinaryImage.unregisterMetaChanged,
                    self._onMetaChanged))

        return layers
Esempio n. 53
0
    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
Esempio n. 54
0
    def setupLayers(self):
        layers = []

        # use same colortable for the following two generated layers: the merger
        # and the tracking layer
        self.tracking_colortable = colortables.create_random_16bit()
        self.tracking_colortable[0] = QColor(0, 0, 0,
                                             0).rgba()  # make 0 transparent
        self.tracking_colortable[1] = QColor(128, 128, 128, 255).rgba(
        )  # misdetections have id 1 and will be indicated by grey

        self.merger_colortable = colortables.create_default_16bit()
        for i in range(7):
            self.merger_colortable[i] = self.mergerColors[i].rgba()

        if "MergerOutput" in self.topLevelOperatorView.outputs:
            parameters = self.mainOperator.Parameters.value

            if 'withMergerResolution' in list(parameters.keys(
            )) and not parameters['withMergerResolution']:
                merger_ct = self.merger_colortable
            else:
                merger_ct = self.tracking_colortable

            # Using same color table for tracking with and without mergers (Is there any reason for using different color tables?)
            merger_ct = self.tracking_colortable

            if self.topLevelOperatorView.MergerCachedOutput.ready():
                self.mergersrc = LazyflowSource(
                    self.topLevelOperatorView.MergerCachedOutput)
            else:
                self.mergersrc = LazyflowSource(
                    self.topLevelOperatorView.zeroProvider.Output)

            mergerLayer = ColortableLayer(self.mergersrc, merger_ct)
            mergerLayer.name = "Merger"

            if 'withMergerResolution' in list(parameters.keys(
            )) and not parameters['withMergerResolution']:
                mergerLayer.visible = True
            else:
                mergerLayer.visible = False

            layers.append(mergerLayer)

        if self.topLevelOperatorView.CachedOutput.ready():
            self.trackingsrc = LazyflowSource(
                self.topLevelOperatorView.CachedOutput)
            trackingLayer = ColortableLayer(self.trackingsrc,
                                            self.tracking_colortable)
            trackingLayer.name = "Tracking"
            trackingLayer.visible = True
            trackingLayer.opacity = 1.0
            layers.append(trackingLayer)

        elif self.topLevelOperatorView.zeroProvider.Output.ready():
            # provide zeros while waiting for the tracking result
            self.trackingsrc = LazyflowSource(
                self.topLevelOperatorView.zeroProvider.Output)
            trackingLayer = ColortableLayer(self.trackingsrc,
                                            self.tracking_colortable)
            trackingLayer.name = "Tracking"
            trackingLayer.visible = True
            trackingLayer.opacity = 1.0
            layers.append(trackingLayer)

        if "RelabeledImage" in self.topLevelOperatorView.outputs:
            if self.topLevelOperatorView.RelabeledCachedOutput.ready():
                self.objectssrc = LazyflowSource(
                    self.topLevelOperatorView.RelabeledCachedOutput)
            else:
                self.objectssrc = LazyflowSource(
                    self.topLevelOperatorView.zeroProvider.Output)
        else:
            if self.topLevelOperatorView.LabelImage.ready():
                self.objectssrc = LazyflowSource(
                    self.topLevelOperatorView.LabelImage)
        ct = colortables.create_random_16bit()
        ct[0] = QColor(0, 0, 0, 0).rgba()  # make 0 transparent
        objLayer = ColortableLayer(self.objectssrc, ct)
        objLayer.name = "Objects"
        objLayer.opacity = 1.0
        objLayer.visible = False
        layers.append(objLayer)

        if self.mainOperator.RawImage.ready():
            rawLayer = self.createStandardLayerFromSlot(
                self.mainOperator.RawImage)
            rawLayer.name = "Raw"
            layers.insert(len(layers), rawLayer)

        if self.topLevelOperatorView.LabelImage.meta.shape:
            maxt = self.topLevelOperatorView.LabelImage.meta.shape[0] - 1
            maxx = self.topLevelOperatorView.LabelImage.meta.shape[1] - 1
            maxy = self.topLevelOperatorView.LabelImage.meta.shape[2] - 1
            maxz = self.topLevelOperatorView.LabelImage.meta.shape[3] - 1

            if not self.mainOperator.Parameters.ready():
                raise Exception("Parameter slot is not ready")

            parameters = self.mainOperator.Parameters.value
            self._setRanges()
            if 'size_range' in parameters:
                self._drawer.to_size.setValue(parameters['size_range'][1] - 1)
                self._drawer.from_size.setValue(parameters['size_range'][0])
            else:
                self._drawer.from_size.setValue(0)
                self._drawer.to_size.setValue(10000)

            if 'x_range' in parameters:
                self._drawer.to_x.setValue(parameters['x_range'][1] - 1)
                self._drawer.from_x.setValue(parameters['x_range'][0])
            else:
                self._drawer.from_x.setValue(0)
                self._drawer.to_x.setValue(maxx)

            if 'y_range' in parameters:
                self._drawer.to_y.setValue(parameters['y_range'][1] - 1)
                self._drawer.from_y.setValue(parameters['y_range'][0])
            else:
                self._drawer.from_y.setValue(0)
                self._drawer.to_y.setValue(maxy)

            if 'z_range' in parameters:
                self._drawer.to_z.setValue(parameters['z_range'][1] - 1)
                self._drawer.from_z.setValue(parameters['z_range'][0])
            else:
                self._drawer.from_z.setValue(0)
                self._drawer.to_z.setValue(maxz)

            if 'time_range' in parameters:
                self._drawer.to_time.setValue(parameters['time_range'][1])
                self._drawer.from_time.setValue(parameters['time_range'][0])
            else:
                self._drawer.from_time.setValue(0)
                self._drawer.to_time.setValue(maxt)

            if 'scales' in parameters:
                self._drawer.x_scale.setValue(parameters['scales'][0])
                self._drawer.y_scale.setValue(parameters['scales'][1])
                self._drawer.z_scale.setValue(parameters['scales'][2])
            else:
                self._drawer.x_scale.setValue(1)
                self._drawer.y_scale.setValue(1)
                self._drawer.z_scale.setValue(1)

        return layers
Esempio n. 55
0
    def setupLayers(self):
        layers = []        
        op = self.topLevelOperatorView
        binct = [QColor(Qt.black), QColor(Qt.white)]
        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 = "Output (Cached)"
            outputLayer.visible = False
            outputLayer.opacity = 1.0
            layers.append(outputLayer)

        #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 = "Big Regions"
                lowThresholdLayer.visible = False
                lowThresholdLayer.opacity = 1.0
                layers.append(lowThresholdLayer)
    
            if op.FilteredSmallLabels.ready():
                filteredSmallLabelsLayer = self.createStandardLayerFromSlot( op.FilteredSmallLabels )
                filteredSmallLabelsLayer.name = "Filtered Small Labels"
                filteredSmallLabelsLayer.visible = False
                filteredSmallLabelsLayer.opacity = 1.0
                layers.append(filteredSmallLabelsLayer)
    
            if op.SmallRegions.ready():
                highThresholdSrc = LazyflowSource(op.SmallRegions)
                highThresholdLayer = ColortableLayer(highThresholdSrc, binct)
                highThresholdLayer.name = "Small Regions"
                highThresholdLayer.visible = False
                highThresholdLayer.opacity = 1.0
                layers.append(highThresholdLayer)
        elif curIndex==0:
            if op.BeforeSizeFilter.ready():
                thSrc = LazyflowSource(op.BeforeSizeFilter)
                thLayer = ColortableLayer(thSrc, binct)
                thLayer.name = "Thresholded Labels"
                thLayer.visible = False
                thLayer.opacity = 1.0
                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
            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 )
            channelLayer.name = "Input Ch{}".format(op.Channel.value)
            channelLayer.opacity = 1.0
            #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
Esempio n. 56
0
    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
Esempio n. 57
0
    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
Esempio n. 58
0
    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