def setupLayers(self): layers = [] op = self.topLevelOperatorView ravelerLabelsSlot = op.RavelerLabels if ravelerLabelsSlot.ready(): colortable = [] for _ in range(256): r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255) colortable.append(QColor(r,g,b).rgba()) ravelerLabelLayer = ColortableLayer(LazyflowSource(ravelerLabelsSlot), colortable, direct=True) ravelerLabelLayer.name = "Raveler Labels" ravelerLabelLayer.visible = False ravelerLabelLayer.opacity = 0.4 layers.append(ravelerLabelLayer) supervoxelsSlot = op.Supervoxels if supervoxelsSlot.ready(): colortable = [] for i in range(256): r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255) colortable.append(QColor(r,g,b).rgba()) supervoxelsLayer = ColortableLayer(LazyflowSource(supervoxelsSlot), colortable) supervoxelsLayer.name = "Input Supervoxels" supervoxelsLayer.visible = False supervoxelsLayer.opacity = 1.0 layers.append(supervoxelsLayer) def addFragmentSegmentationLayers(mslot, name): if mslot.ready(): for index, slot in enumerate(mslot): if slot.ready(): raveler_label = slot.meta.selected_label colortable = [] for i in range(256): r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255) colortable.append(QColor(r,g,b).rgba()) colortable[0] = QColor(0,0,0,0).rgba() fragSegLayer = ColortableLayer(LazyflowSource(slot), colortable, direct=True) fragSegLayer.name = "{} #{} ({})".format( name, index, raveler_label ) fragSegLayer.visible = False fragSegLayer.opacity = 1.0 layers.append(fragSegLayer) addFragmentSegmentationLayers( op.MaskedSupervoxels, "Masked Supervoxels" ) addFragmentSegmentationLayers( op.FilteredMaskedSupervoxels, "Filtered Masked Supervoxels" ) addFragmentSegmentationLayers( op.HoleFilledSupervoxels, "Hole Filled Supervoxels" ) addFragmentSegmentationLayers( op.RelabeledSupervoxels, "Relabeled Supervoxels" ) mslot = op.EditedRavelerBodies for index, slot in enumerate(mslot): if slot.ready(): raveler_label = slot.meta.selected_label # 0=Black, 1=Transparent colortable = [QColor(0, 0, 0).rgba(), QColor(0, 0, 0, 0).rgba()] bodyMaskLayer = ColortableLayer(LazyflowSource(slot), colortable, direct=True) bodyMaskLayer.name = "Raveler Body Mask #{} ({})".format( index, raveler_label ) bodyMaskLayer.visible = False bodyMaskLayer.opacity = 1.0 layers.append(bodyMaskLayer) finalSegSlot = op.FinalSupervoxels if finalSegSlot.ready(): colortable = [] for _ in range(256): r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255) colortable.append(QColor(r,g,b).rgba()) finalLayer = ColortableLayer(LazyflowSource(finalSegSlot), colortable) finalLayer.name = "Final Supervoxels" finalLayer.visible = False finalLayer.opacity = 0.4 layers.append(finalLayer) inputSlot = op.InputData if inputSlot.ready(): layer = GrayscaleLayer( LazyflowSource(inputSlot) ) layer.name = "WS Input" layer.visible = False layer.opacity = 1.0 layers.append(layer) #raw data rawSlot = self.topLevelOperatorView.RawData if rawSlot.ready(): raw5D = self.topLevelOperatorView.RawData.value layer = GrayscaleLayer(ArraySource(raw5D), direct=True) #layer = GrayscaleLayer( LazyflowSource(rawSlot) ) layer.name = "raw" layer.visible = True layer.opacity = 1.0 layers.append(layer) return layers
def setupLayers(self): layers = [] op = self.topLevelOperatorView ravelerLabelsSlot = op.RavelerLabels if ravelerLabelsSlot.ready(): colortable = [] for _ in range(256): r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255) colortable.append(QColor(r,g,b).rgba()) ravelerLabelLayer = ColortableLayer(LazyflowSource(ravelerLabelsSlot), colortable, direct=True) ravelerLabelLayer.name = "Raveler Labels" ravelerLabelLayer.visible = False ravelerLabelLayer.opacity = 0.4 layers.append(ravelerLabelLayer) def addFragmentSegmentationLayers(mslot, name): if mslot.ready(): for index, slot in enumerate(mslot): if slot.ready(): raveler_label = slot.meta.selected_label colortable = map(QColor.rgba, self._fragmentColors) fragSegLayer = ColortableLayer(LazyflowSource(slot), colortable, direct=True) fragSegLayer.name = "{} #{} ({})".format( name, index, raveler_label ) fragSegLayer.visible = False fragSegLayer.opacity = 1.0 layers.append(fragSegLayer) addFragmentSegmentationLayers( op.FragmentedBodies, "Saved Fragments" ) addFragmentSegmentationLayers( op.RelabeledFragments, "Relabeled Fragments" ) addFragmentSegmentationLayers( op.FilteredFragmentedBodies, "CC-Filtered Fragments" ) addFragmentSegmentationLayers( op.WatershedFilledBodies, "Watershed-filled Fragments" ) mslot = op.EditedRavelerBodies for index, slot in enumerate(mslot): if slot.ready(): raveler_label = slot.meta.selected_label # 0=Black, 1=Transparent colortable = [QColor(0, 0, 0).rgba(), QColor(0, 0, 0, 0).rgba()] bodyMaskLayer = ColortableLayer(LazyflowSource(slot), colortable, direct=True) bodyMaskLayer.name = "Raveler Body Mask #{} ({})".format( index, raveler_label ) bodyMaskLayer.visible = False bodyMaskLayer.opacity = 1.0 layers.append(bodyMaskLayer) finalSegSlot = op.FinalSegmentation if finalSegSlot.ready(): colortable = [] for _ in range(256): r,g,b = numpy.random.randint(0,255), numpy.random.randint(0,255), numpy.random.randint(0,255) colortable.append(QColor(r,g,b).rgba()) finalLayer = ColortableLayer(LazyflowSource(finalSegSlot), colortable, direct=True) finalLayer.name = "Final Segmentation" finalLayer.visible = False finalLayer.opacity = 0.4 layers.append(finalLayer) inputSlot = op.InputData if inputSlot.ready(): layer = GrayscaleLayer( LazyflowSource(inputSlot) ) layer.name = "WS Input" layer.visible = False layer.opacity = 1.0 layers.append(layer) #raw data rawSlot = self.topLevelOperatorView.RawData rawLayer = None if rawSlot.ready(): raw5D = self.topLevelOperatorView.RawData.value rawLayer = GrayscaleLayer(ArraySource(raw5D), direct=True) #rawLayer = GrayscaleLayer( LazyflowSource(rawSlot) ) rawLayer.name = "raw" rawLayer.visible = True rawLayer.opacity = 1.0 rawLayer.shortcutRegistration = ( "g", ShortcutManager.ActionInfo( "Postprocessing", "Raw Data to Top", "Raw Data to Top", partial(self._toggleRawDataPosition, rawLayer), self.viewerControlWidget(), rawLayer ) ) layers.append(rawLayer) return layers
def setupLayers(self): layers = [] op = self.topLevelOperatorView ravelerLabelsSlot = op.RavelerLabels if ravelerLabelsSlot.ready(): colortable = [] for _ in range(256): r, g, b = numpy.random.randint(0, 255), numpy.random.randint( 0, 255), numpy.random.randint(0, 255) colortable.append(QColor(r, g, b).rgba()) ravelerLabelLayer = ColortableLayer( LazyflowSource(ravelerLabelsSlot), colortable, direct=True) ravelerLabelLayer.name = "Raveler Labels" ravelerLabelLayer.visible = False ravelerLabelLayer.opacity = 0.4 layers.append(ravelerLabelLayer) supervoxelsSlot = op.Supervoxels if supervoxelsSlot.ready(): colortable = [] for i in range(256): r, g, b = numpy.random.randint(0, 255), numpy.random.randint( 0, 255), numpy.random.randint(0, 255) colortable.append(QColor(r, g, b).rgba()) supervoxelsLayer = ColortableLayer(LazyflowSource(supervoxelsSlot), colortable) supervoxelsLayer.name = "Input Supervoxels" supervoxelsLayer.visible = False supervoxelsLayer.opacity = 1.0 layers.append(supervoxelsLayer) def addFragmentSegmentationLayers(mslot, name): if mslot.ready(): for index, slot in enumerate(mslot): if slot.ready(): raveler_label = slot.meta.selected_label colortable = [] for i in range(256): r, g, b = numpy.random.randint( 0, 255), numpy.random.randint( 0, 255), numpy.random.randint(0, 255) colortable.append(QColor(r, g, b).rgba()) colortable[0] = QColor(0, 0, 0, 0).rgba() fragSegLayer = ColortableLayer(LazyflowSource(slot), colortable, direct=True) fragSegLayer.name = "{} #{} ({})".format( name, index, raveler_label) fragSegLayer.visible = False fragSegLayer.opacity = 1.0 layers.append(fragSegLayer) addFragmentSegmentationLayers(op.MaskedSupervoxels, "Masked Supervoxels") addFragmentSegmentationLayers(op.FilteredMaskedSupervoxels, "Filtered Masked Supervoxels") addFragmentSegmentationLayers(op.HoleFilledSupervoxels, "Hole Filled Supervoxels") addFragmentSegmentationLayers(op.RelabeledSupervoxels, "Relabeled Supervoxels") mslot = op.EditedRavelerBodies for index, slot in enumerate(mslot): if slot.ready(): raveler_label = slot.meta.selected_label # 0=Black, 1=Transparent colortable = [ QColor(0, 0, 0).rgba(), QColor(0, 0, 0, 0).rgba() ] bodyMaskLayer = ColortableLayer(LazyflowSource(slot), colortable, direct=True) bodyMaskLayer.name = "Raveler Body Mask #{} ({})".format( index, raveler_label) bodyMaskLayer.visible = False bodyMaskLayer.opacity = 1.0 layers.append(bodyMaskLayer) finalSegSlot = op.FinalSupervoxels if finalSegSlot.ready(): colortable = [] for _ in range(256): r, g, b = numpy.random.randint(0, 255), numpy.random.randint( 0, 255), numpy.random.randint(0, 255) colortable.append(QColor(r, g, b).rgba()) finalLayer = ColortableLayer(LazyflowSource(finalSegSlot), colortable) finalLayer.name = "Final Supervoxels" finalLayer.visible = False finalLayer.opacity = 0.4 layers.append(finalLayer) inputSlot = op.InputData if inputSlot.ready(): layer = GrayscaleLayer(LazyflowSource(inputSlot)) layer.name = "WS Input" layer.visible = False layer.opacity = 1.0 layers.append(layer) #raw data rawSlot = self.topLevelOperatorView.RawData if rawSlot.ready(): raw5D = self.topLevelOperatorView.RawData.value layer = GrayscaleLayer(ArraySource(raw5D), direct=True) #layer = GrayscaleLayer( LazyflowSource(rawSlot) ) layer.name = "raw" layer.visible = True layer.opacity = 1.0 layers.append(layer) return layers