Beispiel #1
0
    def __init__(self, *args, **kwargs):
        super(OpCachedWsdt, self).__init__(*args, **kwargs)
        my_slot_names = set(
            map(lambda slot: slot.name, self.inputSlots + self.outputSlots))
        wsdt_slot_names = set(
            map(lambda slot: slot.name,
                OpWsdt.inputSlots + OpWsdt.outputSlots))
        assert wsdt_slot_names.issubset(my_slot_names), \
            "OpCachedWsdt should have all of the slots that OpWsdt has (and maybe more). "\
            "Did you add a slot to OpWsdt and forget to add it to OpCachedWsdt?"

        self._opWsdt = OpWsdt(parent=self)
        self._opWsdt.Input.connect(self.Input)
        self._opWsdt.ChannelSelection.connect(self.ChannelSelection)
        self._opWsdt.Pmin.connect(self.Pmin)
        self._opWsdt.MinMembraneSize.connect(self.MinMembraneSize)
        self._opWsdt.MinSegmentSize.connect(self.MinSegmentSize)
        self._opWsdt.SigmaMinima.connect(self.SigmaMinima)
        self._opWsdt.SigmaWeights.connect(self.SigmaWeights)
        self._opWsdt.GroupSeeds.connect(self.GroupSeeds)
        self._opWsdt.EnableDebugOutputs.connect(self.EnableDebugOutputs)

        self._opCache = OpBlockedArrayCache(parent=self)
        self._opCache.fixAtCurrent.connect(self.FreezeCache)
        self._opCache.Input.connect(self._opWsdt.Superpixels)
        self.Superpixels.connect(self._opCache.Output)
        self.CleanBlocks.connect(self._opCache.CleanBlocks)

        self._opSelectedInput = OpSingleChannelSelector(parent=self)
        self._opSelectedInput.Index.connect(self.ChannelSelection)
        self._opSelectedInput.Input.connect(self.Input)

        self._opThreshold = OpPixelOperator(parent=self)
        self._opThreshold.Input.connect(self._opSelectedInput.Output)
        self.ThresholdedInput.connect(self._opThreshold.Output)
Beispiel #2
0
 def test3d(self):
     graph = Graph()
     op = OpSingleChannelSelector(graph=graph)
     op.Input.setValue(self.data3d)
     for i in range(2):
         op.Index.setValue(i)
         out = op.Output[:].wait()
         assert numpy.all(out==i+1)
    def _onInputMetaChanged(self):
        op = self.topLevelOperatorView
        self._channelProviders = []
        if not op.InputImage.ready():
            return

        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)
            self._channelProviders.append(channelProvider)
    def connectLane(self, laneIndex):
        ## Access applet operators
        opData = self.dataSelectionApplet.topLevelOperator.getLane(laneIndex)
        opPreprocessing = self.preprocessingApplet.topLevelOperator.getLane(
            laneIndex)
        opSplitBodyCarving = self.splitBodyCarvingApplet.topLevelOperator.getLane(
            laneIndex)
        opPostprocessing = self.splitBodyPostprocessingApplet.topLevelOperator.getLane(
            laneIndex)

        op5Raw = OpReorderAxes(parent=self)
        op5Raw.AxisOrder.setValue("txyzc")
        op5Raw.Input.connect(opData.ImageGroup[self.DATA_ROLE_RAW])

        op5PixelProb = OpReorderAxes(parent=self)
        op5PixelProb.AxisOrder.setValue("txyzc")
        op5PixelProb.Input.connect(
            opData.ImageGroup[self.DATA_ROLE_PIXEL_PROB])

        op5RavelerLabels = OpReorderAxes(parent=self)
        op5RavelerLabels.AxisOrder.setValue("txyzc")
        op5RavelerLabels.Input.connect(
            opData.ImageGroup[self.DATA_ROLE_RAVELER_LABELS])

        # We assume the membrane boundaries are found in the first prediction class (channel 0)
        opSingleChannelSelector = OpSingleChannelSelector(parent=self)
        opSingleChannelSelector.Input.connect(op5PixelProb.Output)
        opSingleChannelSelector.Index.setValue(0)

        opPreprocessing.InputData.connect(opSingleChannelSelector.Output)
        opPreprocessing.RawData.connect(op5Raw.Output)
        opSplitBodyCarving.RawData.connect(op5Raw.Output)
        opSplitBodyCarving.InputData.connect(opSingleChannelSelector.Output)
        opSplitBodyCarving.RavelerLabels.connect(op5RavelerLabels.Output)
        opSplitBodyCarving.FilteredInputData.connect(
            opPreprocessing.FilteredImage)

        # Special input-input connection: WriteSeeds metadata must mirror the input data
        opSplitBodyCarving.WriteSeeds.connect(opSplitBodyCarving.InputData)

        opSplitBodyCarving.MST.connect(opPreprocessing.PreprocessedData)
        opSplitBodyCarving.UncertaintyType.setValue("none")

        opPostprocessing.RawData.connect(opSplitBodyCarving.RawData)
        opPostprocessing.InputData.connect(opSplitBodyCarving.InputData)
        opPostprocessing.RavelerLabels.connect(
            opSplitBodyCarving.RavelerLabels)
        opPostprocessing.MST.connect(opSplitBodyCarving.MstOut)

        # Split-body carving -> Postprocessing
        opPostprocessing.EditedRavelerBodyList.connect(
            opSplitBodyCarving.EditedRavelerBodyList)
        opPostprocessing.NavigationCoordinates.connect(
            opSplitBodyCarving.NavigationCoordinates)

        if not self._headless:
            self.preprocessingApplet.enableDownstream(False)

        # Supervoxel export
        opSupervoxelExport = self.splitBodySupervoxelExportApplet.topLevelOperator.getLane(
            laneIndex)
        opSupervoxelExport.DatasetInfos.connect(opData.DatasetGroup)
        opSupervoxelExport.WorkingDirectory.connect(opData.WorkingDirectory)
        opSupervoxelExport.RawData.connect(opPreprocessing.RawData)
        opSupervoxelExport.InputData.connect(opPreprocessing.InputData)
        opSupervoxelExport.Supervoxels.connect(opPreprocessing.WatershedImage)
        opSupervoxelExport.RavelerLabels.connect(
            opSplitBodyCarving.RavelerLabels)
        opSupervoxelExport.AnnotationBodyIds.connect(
            opSplitBodyCarving.AnnotationBodyIds)