def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.opReorderInput = OpReorderAxes(parent=self, AxisOrder="tzyxc", Input=self.SegmentationInput) self.opSlic = OpSlicBoundaries(parent=self) self.opSlic.SegmentationInput.connect(self.opReorderInput.Output) self.opReorderOutput = OpReorderAxes(parent=self, Input=self.opSlic.BoundariesOutput) self.BoundariesOutput.connect(self.opReorderOutput.Output)
def __init__(self, filter_implementation, *args, **kwargs): super(OpFeatureSelectionNoCache, self).__init__(*args, **kwargs) # Create the operator that actually generates the features if filter_implementation == 'Original': self.opPixelFeatures = OpPixelFeaturesPresmoothed_Original(parent=self) logger.debug("Using ORIGINAL filters") elif filter_implementation == 'Refactored': self.opPixelFeatures = OpPixelFeaturesPresmoothed_Refactored(parent=self) elif filter_implementation == 'Interpolated': self.opPixelFeatures = OpPixelFeaturesPresmoothed_Interpolated(parent=self) self.opPixelFeatures.InterpolationScaleZ.setValue(2) logger.debug("Using INTERPOLATED filters") else: raise RuntimeError("Unknown filter implementation option: {}".format( filter_implementation )) # Connect our internal operators to our external inputs self.opPixelFeatures.Scales.connect( self.Scales ) self.opPixelFeatures.FeatureIds.connect( self.FeatureIds ) self.opReorderIn = OpReorderAxes(parent=self) self.opReorderIn.Input.connect(self.InputImage) self.opPixelFeatures.Input.connect(self.opReorderIn.Output) self.opReorderOut = OpReorderAxes(parent=self) self.opReorderOut.Input.connect(self.opPixelFeatures.Output) self.opReorderLayers = OperatorWrapper(OpReorderAxes, parent=self, broadcastingSlotNames=["AxisOrder"]) self.opReorderLayers.Input.connect(self.opPixelFeatures.Features) # We don't connect SelectionMatrix here because we want to # check it for errors (See setupOutputs) # self.opPixelFeatures.SelectionMatrix.connect( self.SelectionMatrix ) self.WINDOW_SIZE = self.opPixelFeatures.WINDOW_SIZE
def __init__(self, *args, **kwargs): super(OpLazyConnectedComponents, self).__init__(*args, **kwargs) self._lock = HardLock() # reordering operators - we want to handle txyzc inside this operator self._opIn = OpReorderAxes(parent=self) self._opIn.AxisOrder.setValue('txyzc') self._opIn.Input.connect(self.Input) self._Input.connect(self._opIn.Output) self._opOut = OpReorderAxes(parent=self) self._opOut.Input.connect(self._Output) self.Output.connect(self._opOut.Output) self.CachedOutput.connect(self.Output)
def __init__(self, *args, **kwargs): super(_OpCacheWrapper, self).__init__(*args, **kwargs) op1 = OpReorderAxes(parent=self) op1.name = "op1" op2 = OpReorderAxes(parent=self) op2.name = "op2" op1.AxisOrder.setValue('xyzct') op2.AxisOrder.setValue('txyzc') op1.Input.connect(self.Input) self.Output.connect(op2.Output) self._op1 = op1 self._op2 = op2 self._cache = None
def setUp(self): g = Graph() r1 = OpReorderAxes(graph=g) r1.AxisOrder.setValue('tzyxc') op = OpAnisotropicGaussianSmoothing5d(graph=g) op.Input.connect(r1.Output) self.r1 = r1 self.op = op
def __init__(self, *args, **kwargs): super(OpLazyConnectedComponents, self).__init__(*args, **kwargs) self._lock = HardLock() # be able to request usage stats right from initialization self._cache = None # reordering operators - we want to handle txyzc inside this operator self._opIn = OpReorderAxes(parent=self) self._opIn.AxisOrder.setValue("txyzc") self._opIn.Input.connect(self.Input) self._Input.connect(self._opIn.Output) self._opOut = OpReorderAxes(parent=self) self._opOut.Input.connect(self._Output) self.Output.connect(self._opOut.Output) self.CachedOutput.connect(self.Output) # Now that we're initialized, it's safe to register with the memory manager self.registerWithMemoryManager()
def __init__(self, *args, **kwargs): super(OpLabelVolume, self).__init__(*args, **kwargs) # we just want to have 5d data internally op5 = OpReorderAxes(parent=self) op5.Input.connect(self.Input) op5.AxisOrder.setValue('xyzct') self._op5 = op5 self._opLabel = None self._op5_2 = OpReorderAxes(parent=self) self._op5_2_cached = OpReorderAxes(parent=self) self.Output.connect(self._op5_2.Output) self.CachedOutput.connect(self._op5_2_cached.Output) # available OpLabelingABCs: self._labelOps = {'vigra': _OpLabelVigra, 'blocked': _OpLabelBlocked}
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # Create the operator that actually generates the features self.opPixelFeatures = OpPixelFeaturesPresmoothed(parent=self) # Connect our internal operators to our external inputs self.opPixelFeatures.Scales.connect(self.Scales) self.opPixelFeatures.FeatureIds.connect(self.FeatureIds) self.opPixelFeatures.SelectionMatrix.connect(self.SelectionMatrix) self.opPixelFeatures.ComputeIn2d.connect(self.ComputeIn2d) self.opReorderIn = OpReorderAxes(parent=self) self.opReorderIn.AxisOrder.setValue('tczyx') self.opReorderIn.Input.connect(self.InputImage) self.opPixelFeatures.Input.connect(self.opReorderIn.Output) self.opReorderOut = OpReorderAxes(parent=self) self.opReorderOut.Input.connect(self.opPixelFeatures.Output) self.opReorderLayers = OperatorWrapper( OpReorderAxes, parent=self, broadcastingSlotNames=["AxisOrder"]) self.opReorderLayers.Input.connect(self.opPixelFeatures.Features) self.WINDOW_SIZE = self.opPixelFeatures.WINDOW_SIZE
def __init__(self, *args, **kwargs): super(OpFeatureSelectionNoCache, self).__init__(*args, **kwargs) # Create the operator that actually generates the features self.opPixelFeatures = OpPixelFeaturesPresmoothed(parent=self) # Connect our internal operators to our external inputs self.opPixelFeatures.Scales.connect(self.Scales) self.opPixelFeatures.FeatureIds.connect(self.FeatureIds) self.opReorderIn = OpReorderAxes(parent=self) self.opReorderIn.Input.connect(self.InputImage) self.opPixelFeatures.Input.connect(self.opReorderIn.Output) self.opReorderOut = OpReorderAxes(parent=self) self.opReorderOut.Input.connect(self.opPixelFeatures.Output) self.opReorderLayers = OperatorWrapper( OpReorderAxes, parent=self, broadcastingSlotNames=["AxisOrder"]) self.opReorderLayers.Input.connect(self.opPixelFeatures.Features) # We don't connect SelectionMatrix here because we want to # check it for errors (See setupOutputs) # self.opPixelFeatures.SelectionMatrix.connect( self.SelectionMatrix ) self.WINDOW_SIZE = self.opPixelFeatures.WINDOW_SIZE
def __init__(self, *args, **kwargs): super(OpLabelVolume, self).__init__(*args, **kwargs) # we just want to have 5d data internally op5 = OpReorderAxes(parent=self) op5.Input.connect(self.Input) op5.AxisOrder.setValue("txyzc") self._op5 = op5 self._opLabel = None self._op5_2 = OpReorderAxes(parent=self) self._op5_2_cached = OpReorderAxes(parent=self) self.Output.connect(self._op5_2.Output) self.CachedOutput.connect(self._op5_2_cached.Output) # available OpLabelingABCs: # TODO: OpLazyConnectedComponents and _OpLabelBlocked does not conform to OpLabelingABC self._labelOps = { "vigra": _OpLabelVigra, "blocked": _OpLabelBlocked, "lazy": OpLazyConnectedComponents }
def __init__(self): graph = Graph() self._reorder_op = OpReorderAxes(graph=graph, AxisOrder=axis_order) self._feature_sel_op = OpFeatureSelection(graph=graph) self._feature_sel_op.InputImage.connect(self._reorder_op.Output) self._feature_sel_op.FeatureIds.setValue(feature_matrix.names) self._feature_sel_op.Scales.setValue(feature_matrix.scales) self._feature_sel_op.SelectionMatrix.setValue(feature_matrix.selections) self._feature_sel_op.ComputeIn2d.setValue(feature_matrix.compute_in_2d.tolist()) self._predict_op = OpClassifierPredict(graph=graph) self._predict_op.Classifier.setValue(classifer.instance) self._predict_op.Classifier.meta.classifier_factory = classifer.factory self._predict_op.Image.connect(self._feature_sel_op.OutputImage) self._predict_op.LabelsCount.setValue(classifer.label_count)
def __init__(self, *args, **kwargs): super(OpThresholdTwoLevels, self).__init__(*args, **kwargs) self.opReorderInput = OpReorderAxes(parent=self) self.opReorderInput.AxisOrder.setValue('tzyxc') self.opReorderInput.Input.connect(self.InputImage) # PROBABILITIES: Convert to float32 self.opConvertProbabilities = OpConvertDtype( parent=self ) self.opConvertProbabilities.ConversionDtype.setValue( np.float32 ) self.opConvertProbabilities.Input.connect( self.opReorderInput.Output ) # PROBABILITIES: Normalize drange to [0.0, 1.0] self.opNormalizeProbabilities = OpPixelOperator( parent=self ) def normalize_inplace(a): drange = self.opNormalizeProbabilities.Input.meta.drange if drange is None or (drange[0] == 0.0 and drange[1] == 1.0): return a a[:] -= drange[0] a[:] = a[:]/float(( drange[1] - drange[0] )) return a self.opNormalizeProbabilities.Input.connect( self.opConvertProbabilities.Output ) self.opNormalizeProbabilities.Function.setValue( normalize_inplace ) self.opSmoother = OpAnisotropicGaussianSmoothing5d(parent=self) self.opSmoother.Sigmas.connect( self.SmootherSigma ) self.opSmoother.Input.connect( self.opNormalizeProbabilities.Output ) self.opSmootherCache = OpBlockedArrayCache(parent=self) self.opSmootherCache.BlockShape.setValue((1, None, None, None, 1)) self.opSmootherCache.Input.connect( self.opSmoother.Output ) self.opCoreChannelSelector = OpSingleChannelSelector(parent=self) self.opCoreChannelSelector.Index.connect( self.CoreChannel ) self.opCoreChannelSelector.Input.connect( self.opSmootherCache.Output ) self.opCoreThreshold = OpLabeledThreshold(parent=self) self.opCoreThreshold.Method.setValue( ThresholdMethod.SIMPLE ) self.opCoreThreshold.FinalThreshold.connect( self.HighThreshold ) self.opCoreThreshold.Input.connect( self.opCoreChannelSelector.Output ) self.opCoreFilter = OpFilterLabels(parent=self) self.opCoreFilter.BinaryOut.setValue(False) self.opCoreFilter.MinLabelSize.connect( self.MinSize ) self.opCoreFilter.MaxLabelSize.connect( self.MaxSize ) self.opCoreFilter.Input.connect( self.opCoreThreshold.Output ) self.opFinalChannelSelector = OpSingleChannelSelector(parent=self) self.opFinalChannelSelector.Index.connect( self.Channel ) self.opFinalChannelSelector.Input.connect( self.opSmootherCache.Output ) self.opSumInputs = OpMultiArrayMerger(parent=self) # see setupOutputs (below) for input connections self.opSumInputs.MergingFunction.setValue( sum ) self.opFinalThreshold = OpLabeledThreshold(parent=self) self.opFinalThreshold.Method.connect( self.CurOperator ) self.opFinalThreshold.FinalThreshold.connect( self.LowThreshold ) self.opFinalThreshold.GraphcutBeta.connect( self.Beta ) self.opFinalThreshold.CoreLabels.connect( self.opCoreFilter.Output ) self.opFinalThreshold.Input.connect( self.opSumInputs.Output ) self.opFinalFilter = OpFilterLabels(parent=self) self.opFinalFilter.BinaryOut.setValue(False) self.opFinalFilter.MinLabelSize.connect( self.MinSize ) self.opFinalFilter.MaxLabelSize.connect( self.MaxSize ) self.opFinalFilter.Input.connect( self.opFinalThreshold.Output ) self.opReorderOutput = OpReorderAxes(parent=self) #self.opReorderOutput.AxisOrder.setValue('tzyxc') # See setupOutputs() self.opReorderOutput.Input.connect(self.opFinalFilter.Output) self.Output.connect( self.opReorderOutput.Output ) self.opCache = OpBlockedArrayCache(parent=self) self.opCache.CompressionEnabled.setValue(True) self.opCache.Input.connect( self.opReorderOutput.Output ) self.CachedOutput.connect( self.opCache.Output ) self.CleanBlocks.connect( self.opCache.CleanBlocks ) ## Debug outputs self.Smoothed.connect( self.opSmootherCache.Output ) self.InputChannel.connect( self.opFinalChannelSelector.Output ) self.SmallRegions.connect( self.opCoreThreshold.Output ) self.FilteredSmallLabels.connect( self.opCoreFilter.Output ) self.BeforeSizeFilter.connect( self.opFinalThreshold.Output ) # Since hysteresis thresholding creates the big regions and immediately discards the bad ones, # we have to recreate it here if the user wants to view it as a debug layer self.opBigRegionsThreshold = OpLabeledThreshold(parent=self) self.opBigRegionsThreshold.Method.setValue( ThresholdMethod.SIMPLE ) self.opBigRegionsThreshold.FinalThreshold.connect( self.LowThreshold ) self.opBigRegionsThreshold.Input.connect( self.opFinalChannelSelector.Output ) self.BigRegions.connect( self.opBigRegionsThreshold.Output )
def __init__(self, *args, **kwargs): super(OpThresholdTwoLevels, self).__init__(*args, **kwargs) self.InputImage.notifyReady(self.checkConstraints) self._opReorder1 = OpReorderAxes(parent=self) self._opReorder1.AxisOrder.setValue('txyzc') self._opReorder1.Input.connect(self.InputImage) self._opChannelSelector = OpSingleChannelSelector(parent=self) self._opChannelSelector.Input.connect(self._opReorder1.Output) self._opChannelSelector.Index.connect(self.Channel) # anisotropic gauss self._opSmoother = OpAnisotropicGaussianSmoothing5d(parent=self) self._opSmoother.Sigmas.connect(self.SmootherSigma) self._opSmoother.Input.connect(self._opChannelSelector.Output) # debug output self.Smoothed.connect(self._opSmoother.Output) # single threshold operator self.opThreshold1 = _OpThresholdOneLevel(parent=self) self.opThreshold1.Threshold.connect(self.SingleThreshold) self.opThreshold1.MinSize.connect(self.MinSize) self.opThreshold1.MaxSize.connect(self.MaxSize) # double threshold operator self.opThreshold2 = _OpThresholdTwoLevels(parent=self) self.opThreshold2.MinSize.connect(self.MinSize) self.opThreshold2.MaxSize.connect(self.MaxSize) self.opThreshold2.LowThreshold.connect(self.LowThreshold) self.opThreshold2.HighThreshold.connect(self.HighThreshold) # Identity-preserving hysteresis thresholding self.opIpht = OpIpht(parent=self) self.opIpht.MinSize.connect(self.MinSize) self.opIpht.MaxSize.connect(self.MaxSize) self.opIpht.LowThreshold.connect(self.LowThreshold) self.opIpht.HighThreshold.connect(self.HighThreshold) self.opIpht.InputImage.connect(self._opSmoother.Output) if haveGraphCut(): self.opThreshold1GC = _OpThresholdOneLevel(parent=self) self.opThreshold1GC.Threshold.connect(self.SingleThresholdGC) self.opThreshold1GC.MinSize.connect(self.MinSize) self.opThreshold1GC.MaxSize.connect(self.MaxSize) self.opObjectsGraphCut = OpObjectsSegment(parent=self) self.opObjectsGraphCut.Prediction.connect(self.Smoothed) self.opObjectsGraphCut.LabelImage.connect( self.opThreshold1GC.Output) self.opObjectsGraphCut.Beta.connect(self.Beta) self.opObjectsGraphCut.Margin.connect(self.Margin) self.opGraphCut = OpGraphCut(parent=self) self.opGraphCut.Prediction.connect(self.Smoothed) self.opGraphCut.Beta.connect(self.Beta) self._op5CacheOutput = OpReorderAxes(parent=self) self._opReorder2 = OpReorderAxes(parent=self) self.Output.connect(self._opReorder2.Output) #cache our own output, don't propagate from internal operator self._cache = _OpCacheWrapper(parent=self) self._cache.name = "OpThresholdTwoLevels.OpCacheWrapper" self.CachedOutput.connect(self._cache.Output) # Serialization slots self._cache.InputHdf5.connect(self.InputHdf5) self.CleanBlocks.connect(self._cache.CleanBlocks) self.OutputHdf5.connect(self._cache.OutputHdf5) #Debug outputs self.InputChannel.connect(self._opChannelSelector.Output)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.smoothing = OpGaussianSmoothing(parent=self) self.inReorder = OpReorderAxes(parent=self) self.outReorder = OpReorderAxes(parent=self)
def __init__(self, *args, **kwargs): super(OpThresholdTwoLevels, self).__init__(*args, **kwargs) self.opReorderInput = OpReorderAxes(parent=self) self.opReorderInput.AxisOrder.setValue('tzyxc') self.opReorderInput.Input.connect(self.InputImage) self.opSmoother = OpAnisotropicGaussianSmoothing5d(parent=self) self.opSmoother.Sigmas.connect(self.SmootherSigma) self.opSmoother.Input.connect(self.opReorderInput.Output) self.opSmootherCache = OpBlockedArrayCache(parent=self) self.opSmootherCache.BlockShape.setValue((1, None, None, None, 1)) self.opSmootherCache.Input.connect(self.opSmoother.Output) self.opCoreChannelSelector = OpSingleChannelSelector(parent=self) self.opCoreChannelSelector.Index.connect(self.CoreChannel) self.opCoreChannelSelector.Input.connect(self.opSmootherCache.Output) self.opCoreThreshold = OpLabeledThreshold(parent=self) self.opCoreThreshold.Method.setValue(ThresholdMethod.SIMPLE) self.opCoreThreshold.FinalThreshold.connect(self.HighThreshold) self.opCoreThreshold.Input.connect(self.opCoreChannelSelector.Output) self.opCoreFilter = OpFilterLabels(parent=self) self.opCoreFilter.BinaryOut.setValue(False) self.opCoreFilter.MinLabelSize.connect(self.MinSize) self.opCoreFilter.MaxLabelSize.connect(self.MaxSize) self.opCoreFilter.Input.connect(self.opCoreThreshold.Output) self.opFinalChannelSelector = OpSingleChannelSelector(parent=self) self.opFinalChannelSelector.Index.connect(self.Channel) self.opFinalChannelSelector.Input.connect(self.opSmootherCache.Output) self.opSumInputs = OpMultiArrayMerger( parent=self) # see setupOutputs (below) for input connections self.opSumInputs.MergingFunction.setValue(sum) self.opFinalThreshold = OpLabeledThreshold(parent=self) self.opFinalThreshold.Method.connect(self.CurOperator) self.opFinalThreshold.FinalThreshold.connect(self.LowThreshold) self.opFinalThreshold.GraphcutBeta.connect(self.Beta) self.opFinalThreshold.CoreLabels.connect(self.opCoreFilter.Output) self.opFinalThreshold.Input.connect(self.opSumInputs.Output) self.opFinalFilter = OpFilterLabels(parent=self) self.opFinalFilter.BinaryOut.setValue(False) self.opFinalFilter.MinLabelSize.connect(self.MinSize) self.opFinalFilter.MaxLabelSize.connect(self.MaxSize) self.opFinalFilter.Input.connect(self.opFinalThreshold.Output) self.opReorderOutput = OpReorderAxes(parent=self) #self.opReorderOutput.AxisOrder.setValue('tzyxc') # See setupOutputs() self.opReorderOutput.Input.connect(self.opFinalFilter.Output) self.Output.connect(self.opReorderOutput.Output) self.opCache = OpBlockedArrayCache(parent=self) self.opCache.CompressionEnabled.setValue(True) self.opCache.Input.connect(self.opReorderOutput.Output) self.CachedOutput.connect(self.opCache.Output) self.CleanBlocks.connect(self.opCache.CleanBlocks) ## Debug outputs self.Smoothed.connect(self.opSmootherCache.Output) self.InputChannel.connect(self.opFinalChannelSelector.Output) self.SmallRegions.connect(self.opCoreThreshold.Output) self.FilteredSmallLabels.connect(self.opCoreFilter.Output) self.BeforeSizeFilter.connect(self.opFinalThreshold.Output) # Since hysteresis thresholding creates the big regions and immediately discards the bad ones, # we have to recreate it here if the user wants to view it as a debug layer self.opBigRegionsThreshold = OpLabeledThreshold(parent=self) self.opBigRegionsThreshold.Method.setValue(ThresholdMethod.SIMPLE) self.opBigRegionsThreshold.FinalThreshold.connect(self.LowThreshold) self.opBigRegionsThreshold.Input.connect( self.opFinalChannelSelector.Output) self.BigRegions.connect(self.opBigRegionsThreshold.Output)