def create_multicut_edge_layer(self): ActionInfo = ShortcutManager.ActionInfo op = self.__topLevelOperatorView if not op.Output.ready(): return None # Final segmentation -- Edges default_pen = QPen(SegmentationEdgesLayer.DEFAULT_PEN) default_pen.setColor(Qt.blue) layer = SegmentationEdgesLayer(createDataSource(op.Output), default_pen) layer.name = "Multicut Edges" layer.visible = False # Off by default... layer.opacity = 1.0 layer.shortcutRegistration = ( "m", ActionInfo( "Multicut", "MulticutEdgesVisibility", "Show/Hide Multicut Edges", layer.toggleVisible, self.viewerControlWidget(), layer, ), ) return layer
def create_multicut_edge_layer(self): ActionInfo = ShortcutManager.ActionInfo op = self.__topLevelOperatorView if not op.Output.ready(): return None # Final segmentation -- Edges default_pen = QPen(SegmentationEdgesLayer.DEFAULT_PEN) default_pen.setColor(Qt.blue) layer = SegmentationEdgesLayer(LazyflowSource(op.Output), default_pen) layer.name = "Multicut Edges" layer.visible = False # Off by default... layer.opacity = 1.0 layer.shortcutRegistration = ( "m", ActionInfo( "Multicut", "MulticutEdgesVisibility", "Show/Hide Multicut Edges", layer.toggleVisible, self.viewerControlWidget(), layer, ), ) return layer
def create_multicut_disagreement_layer(self): ActionInfo = ShortcutManager.ActionInfo op = self.__topLevelOperatorView if not op.Output.ready(): return None # Final segmentation -- Edges default_pen = QPen(SegmentationEdgesLayer.DEFAULT_PEN) default_pen.setColor(Qt.transparent) layer = SegmentationEdgesLayer(createDataSource(op.Superpixels), default_pen) layer.name = "Multicut Disagreements" layer.visible = False # Off by default... layer.opacity = 1.0 self.disagreement_layer = layer self.__update_disagreement_edges() # Initialize layer.shortcutRegistration = ( "d", ActionInfo( "Multicut", "MulticutDisagrementVisibility", "Show/Hide Multicut Disagreement Edges", layer.toggleVisible, self.viewerControlWidget(), layer, ), ) return layer
def create_multicut_disagreement_layer(self): ActionInfo = ShortcutManager.ActionInfo op = self.__topLevelOperatorView if not op.Output.ready(): return None # Final segmentation -- Edges default_pen = QPen(SegmentationEdgesLayer.DEFAULT_PEN) default_pen.setColor(Qt.transparent) layer = SegmentationEdgesLayer( LazyflowSource(op.Superpixels), default_pen ) layer.name = "Multicut Disagreements" layer.visible = False # Off by default... layer.opacity = 1.0 self.disagreement_layer = layer self.__update_disagreement_edges() # Initialize layer.shortcutRegistration = ( "d", ActionInfo( "Multicut", "MulticutDisagrementVisibility", "Show/Hide Multicut Disagreement Edges", layer.toggleVisible, self.viewerControlWidget(), layer ) ) return layer
def setupLayers(self): layers = [] op = self.__topLevelOperatorView mc_disagreement_layer = self.create_multicut_disagreement_layer() if mc_disagreement_layer: layers.append(mc_disagreement_layer) mc_edge_layer = self.create_multicut_edge_layer() if mc_edge_layer: layers.append(mc_edge_layer) # Superpixels -- Edge Probabilities # We use the RAG's superpixels, which may have different IDs self.superpixel_edge_layer = None if op.Superpixels.ready() and op.EdgeProbabilitiesDict.ready(): layer = SegmentationEdgesLayer(LazyflowSource(op.Superpixels)) layer.name = "Superpixel Edge Probabilities" layer.visible = True layer.opacity = 1.0 self.superpixel_edge_layer = layer self.__update_probability_edges() # Initialize layers.append(layer) del layer # Superpixels -- Edges if op.Superpixels.ready(): default_pen = QPen(SegmentationEdgesLayer.DEFAULT_PEN) default_pen.setColor(Qt.yellow) layer = SegmentationEdgesLayer(LazyflowSource(op.Superpixels), default_pen) layer.name = "Superpixel Edges" layer.visible = False layer.opacity = 1.0 layers.append(layer) del layer mc_seg_layer = self.create_multicut_segmentation_layer() if mc_seg_layer: layers.append(mc_seg_layer) # Superpixels if op.Superpixels.ready(): layer = self.createStandardLayerFromSlot(op.Superpixels) layer.name = "Superpixels" layer.visible = False layer.opacity = 0.5 layers.append(layer) del layer # Raw Data (grayscale) if op.RawData.ready(): layer = self.createStandardLayerFromSlot(op.RawData) layer.name = "Raw Data" layer.visible = True layer.opacity = 1.0 layers.append(layer) layer.shortcutRegistration = ("i", ActionInfo( "Multicut" "Hide all but Raw", "Hide all but Raw", partial(self.toggle_show_raw, "Raw Data"), self.viewerControlWidget(), layer)) del layer return layers
def setupLayers(self): layers = [] op = self.__topLevelOperatorView mc_disagreement_layer = self.create_multicut_disagreement_layer() if mc_disagreement_layer: layers.append(mc_disagreement_layer) mc_edge_layer = self.create_multicut_edge_layer() if mc_edge_layer: layers.append(mc_edge_layer) # Superpixels -- Edge Probabilities # We use the RAG's superpixels, which may have different IDs self.superpixel_edge_layer = None if op.Superpixels.ready() and op.EdgeProbabilitiesDict.ready(): layer = SegmentationEdgesLayer( LazyflowSource(op.Superpixels) ) layer.name = "Superpixel Edge Probabilities" layer.visible = True layer.opacity = 1.0 self.superpixel_edge_layer = layer self.__update_probability_edges() # Initialize layers.append(layer) del layer # Superpixels -- Edges if op.Superpixels.ready(): default_pen = QPen(SegmentationEdgesLayer.DEFAULT_PEN) default_pen.setColor(Qt.yellow) layer = SegmentationEdgesLayer( LazyflowSource(op.Superpixels), default_pen ) layer.name = "Superpixel Edges" layer.visible = False layer.opacity = 1.0 layers.append(layer) del layer mc_seg_layer = self.create_multicut_segmentation_layer() if mc_seg_layer: layers.append(mc_seg_layer) # Superpixels if op.Superpixels.ready(): layer = self.createStandardLayerFromSlot( op.Superpixels ) layer.name = "Superpixels" layer.visible = False layer.opacity = 0.5 layers.append(layer) del layer # Raw Data (grayscale) if op.RawData.ready(): layer = self.createStandardLayerFromSlot( op.RawData ) layer.name = "Raw Data" layer.visible = True layer.opacity = 1.0 layers.append(layer) layer.shortcutRegistration = ( "i", ActionInfo( "Multicut" "Hide all but Raw", "Hide all but Raw", partial(self.toggle_show_raw, "Raw Data"), self.viewerControlWidget(), layer ) ) del layer return layers
def setupLayers(self): layers = [] op = self.topLevelOperatorView ActionInfo = ShortcutManager.ActionInfo superpixels_ready = op.Superpixels.ready() with_training = op.TrainRandomForest.value # Superpixels -- Edge Probabilities if superpixels_ready and op.EdgeProbabilitiesDict.ready( ) and with_training: layer = SegmentationEdgesLayer(createDataSource(op.Superpixels), isHoverable=True) layer.name = "Edge Probabilities" # Name is hard-coded in multiple places: grep before changing. layer.visible = False layer.opacity = 1.0 self.update_probability_edges() # Initialize layer.contexts.append( self.create_prefetch_menu("Edge Probabilities")) layer.shortcutRegistration = ( "p", ActionInfo( "Edge Training Layers", "EdgePredictionsVisibility", "Show/Hide Edge Predictions", layer.toggleVisible, self.viewerControlWidget(), layer, ), ) layers.append(layer) del layer # Superpixels -- Edge Labels if superpixels_ready and op.EdgeLabelsDict.ready() and with_training: edge_labels = op.EdgeLabelsDict.value layer = LabelableSegmentationEdgesLayer( createDataSource(op.Superpixels), self.edge_label_pen_table, edge_labels) layer.name = "Edge Labels" layer.visible = True layer.opacity = 1.0 self.update_labeled_edges() # Initialize layer.labelsChanged.connect(self._handle_edge_label_clicked) layer.contexts.append(self.create_prefetch_menu("Edge Labels")) layer.shortcutRegistration = ( "0", ActionInfo( "Edge Training Layers", "LabelVisibility", "Show/Hide Edge Labels", layer.toggleVisible, self.viewerControlWidget(), layer, ), ) layers.append(layer) del layer # Superpixels -- Edges if superpixels_ready: layer = SegmentationEdgesLayer(createDataSource(op.Superpixels), default_pen=self.DEFAULT_PEN, isHoverable=with_training) layer.name = "Superpixel Edges" layer.visible = True layer.opacity = 1.0 layers.append(layer) del layer # Naive Segmentation if op.NaiveSegmentation.ready(): layer = self.createStandardLayerFromSlot(op.NaiveSegmentation) layer.name = "Naive Segmentation" layer.visible = False layer.opacity = 0.5 layer.shortcutRegistration = ( "n", ActionInfo( "Edge Training Layers", "NaiveSegmentationVisibility", "Show/Hide Naive Segmentation (shows output if classifier output is respected verbatim)", layer.toggleVisible, self.viewerControlWidget(), layer, ), ) layers.append(layer) del layer # Groundtruth if op.GroundtruthSegmentation.ready(): layer = self.createStandardLayerFromSlot( op.GroundtruthSegmentation) layer.name = "Groundtruth" layer.visible = False layer.opacity = 0.5 layer.shortcutRegistration = ( "g", ActionInfo( "Edge Training Layers", "GroundtruthVisibility", "Show/Hide Groundtruth", layer.toggleVisible, self.viewerControlWidget(), layer, ), ) layers.append(layer) del layer # Voxel data if op.VoxelData.ready(): layer = self._create_grayscale_layer_from_slot( op.VoxelData, op.VoxelData.meta.getTaggedShape()["c"]) layer.name = "Voxel Data" layer.visible = False layer.opacity = 1.0 layers.append(layer) del layer # Raw Data (grayscale) if op.RawData.ready(): layer = self.createStandardLayerFromSlot(op.RawData) layer.name = "Raw Data" layer.visible = True layer.opacity = 1.0 layers.append(layer) layer.shortcutRegistration = ( "i", ActionInfo( "Edge Training Layers", "Hide all but Raw", "Hide all but Raw", partial(self.toggle_show_raw, "Raw Data"), self.viewerControlWidget(), layer, ), ) del layer return layers
def setupLayers(self): layers = [] op = self.__topLevelOperatorView mc_disagreement_layer = self.create_multicut_disagreement_layer() if mc_disagreement_layer: layers.append(mc_disagreement_layer) mc_edge_layer = self.create_multicut_edge_layer() if mc_edge_layer: layers.append(mc_edge_layer) # Superpixels -- Edge Probabilities # We use the RAG's superpixels, which may have different IDs self.superpixel_edge_layer = None if op.Superpixels.ready() and op.EdgeProbabilitiesDict.ready(): layer = SegmentationEdgesLayer( LazyflowSource(op.Superpixels) ) layer.name = "Superpixel Edge Probabilities" layer.visible = True layer.opacity = 1.0 self.superpixel_edge_layer = layer self.__update_probability_edges() # Initialize layers.append(layer) del layer # Superpixels -- Edges if op.Superpixels.ready(): default_pen = QPen(SegmentationEdgesLayer.DEFAULT_PEN) default_pen.setColor(Qt.yellow) layer = SegmentationEdgesLayer( LazyflowSource(op.Superpixels), default_pen ) layer.name = "Superpixel Edges" layer.visible = False layer.opacity = 1.0 layers.append(layer) del layer mc_seg_layer = self.create_multicut_segmentation_layer() if mc_seg_layer: layers.append(mc_seg_layer) # Superpixels if op.Superpixels.ready(): layer = self.createStandardLayerFromSlot( op.Superpixels ) layer.name = "Superpixels" layer.visible = False layer.opacity = 0.5 layers.append(layer) del layer # Raw Data (grayscale) if op.RawData.ready(): layer = self.createStandardLayerFromSlot( op.RawData ) layer.name = "Raw Data" layer.visible = True layer.opacity = 1.0 layers.append(layer) raw_layer = layer def toggleTopToBottom(): index = self.layerstack.layerIndex( raw_layer ) self.layerstack.selectRow( index ) if index == 0: self.layerstack.moveSelectedToBottom() else: self.layerstack.moveSelectedToTop() layer.shortcutRegistration = ( "i", ActionInfo( "Multicut" "Bring Input To Top/Bottom", "Bring Input To Top/Bottom", toggleTopToBottom, self.viewerControlWidget(), raw_layer ) ) del layer return layers