Exemplo n.º 1
0
    def __init__(self, operator, projectFileGroupName):
        slots = [
            SerialBlockSlot(operator.Output, operator.CacheInput,
                            operator.CleanBlocks),
            SerialBlockSlot(operator.BoundariesOutput,
                            operator.CacheBoundariesInput,
                            operator.BoundariesCleanBlocks),
            # SerialSlot(operator.NumSegments),
            # SerialSlot(operator.Compactness),
            # SerialSlot(operator.MaxIter),
        ]

        super(SlicSerializer, self).__init__(projectFileGroupName, slots,
                                             operator)
Exemplo n.º 2
0
    def __init__(self, operator, projectFileGroupName):
        self.VERSION = 1
        self._serialClassifierSlot = SerialClassifierSlot(
            operator.Classifier,
            operator.classifier_cache,
            name="ClassifierForests")
        slots = [
            SerialListSlot(operator.LabelNames),
            SerialListSlot(operator.LabelColors,
                           transform=lambda x: tuple(x.flat)),
            SerialListSlot(operator.PmapColors,
                           transform=lambda x: tuple(x.flat)),
            SerialPickleableSlot(operator.Bookmarks, self.VERSION),
            SerialBlockSlot(operator.LabelImages,
                            operator.LabelInputs,
                            operator.NonzeroLabelBlocks,
                            name='LabelSets',
                            subname='labels{:03d}',
                            selfdepends=False,
                            shrink_to_bb=True),
            SerialClassifierFactorySlot(operator.ClassifierFactory),
            self._serialClassifierSlot
        ]

        super(PixelClassificationSerializer,
              self).__init__(projectFileGroupName, slots, operator)
Exemplo n.º 3
0
 def __init__(self, operator, projectFileGroupName):
     super(NansheDictionaryLearningSerializer,
           self).__init__(projectFileGroupName,
                          slots=[
                              SerialSlot(operator.Ord, selfdepends=True),
                              SerialSlot(operator.K, selfdepends=True),
                              SerialSlot(operator.Gamma1, selfdepends=True),
                              SerialSlot(operator.Gamma2, selfdepends=True),
                              SerialSlot(operator.NumThreads,
                                         selfdepends=True),
                              SerialSlot(operator.Batchsize,
                                         selfdepends=True),
                              SerialSlot(operator.NumIter,
                                         selfdepends=True),
                              SerialSlot(operator.Lambda1,
                                         selfdepends=True),
                              SerialSlot(operator.Lambda2,
                                         selfdepends=True),
                              SerialSlot(operator.PosAlpha,
                                         selfdepends=True),
                              SerialSlot(operator.PosD, selfdepends=True),
                              SerialSlot(operator.Clean, selfdepends=True),
                              SerialSlot(operator.Mode, selfdepends=True),
                              SerialSlot(operator.ModeD, selfdepends=True),
                              SerialBlockSlot(operator.Output,
                                              operator.CacheInput,
                                              operator.CleanBlocks,
                                              selfdepends=True)
                          ])
Exemplo n.º 4
0
    def __init__(self, operator, projectFileGroupName):
        slots = [
            SerialBlockSlot(
                operator.LabelImage,
                operator.LabelImageCacheInput,
                operator.CleanLabelBlocks,
                name="LabelImage_v2",
                subname="labelimage{:03d}",
                selfdepends=False,
                shrink_to_bb=False,
                compression_level=1,
            ),
            SerialObjectFeatureNamesSlot(operator.FeatureNamesVigra),
            SerialObjectFeatureNamesSlot(operator.FeatureNamesDivision),
            SerialObjectFeaturesSlot(
                operator.BlockwiseRegionFeaturesVigra,
                operator.RegionFeaturesCacheInputVigra,
                operator.RegionFeaturesCleanBlocksVigra,
                name="RegionFeaturesVigra",
            ),
            SerialObjectFeaturesSlot(
                operator.BlockwiseRegionFeaturesDivision,
                operator.RegionFeaturesCacheInputDivision,
                operator.RegionFeaturesCleanBlocksDivision,
                name="RegionFeaturesDivision",
            ),
        ]

        super(TrackingFeatureExtractionSerializer, self).__init__(projectFileGroupName, slots=slots)
Exemplo n.º 5
0
    def __init__(self, operator, projectFileGroupName):
        self.predictionSlot = SerialPredictionSlot(
            operator.PredictionProbabilities,
            operator,
            name='Predictions',
            subname='predictions{:04d}',
        )

        slots = [
            SerialListSlot(
                operator.LabelNames,
            ),
            SerialListSlot(
                operator.LabelColors,
                transform=lambda x: tuple(x.flat),
            ),
            SerialListSlot(
                operator.PmapColors,
                transform=lambda x: tuple(x.flat),
            ),
            SerialBlockSlot(
                operator.LabelImages,
                operator.LabelInputs,
                operator.NonzeroLabelBlocks,
                name='LabelSets',
                subname='labels{:0}',
                selfdepends=False,
            ),
            self.predictionSlot,
            SerialBoxSlot(
                operator.opTrain.BoxConstraintRois,
                operator.opTrain,
                name='Rois',
                subname='rois{:04d}',
            ),
            SerialBoxSlot(
                operator.opTrain.BoxConstraintValues,
                operator.opTrain,
                name='Values',
                subname='values{:04d}',
            ),
            SerialSlot(
                operator.opTrain.Sigma,
                name='Sigma',
            ),
            SerialBoxSlot(
                operator.boxViewer.rois,
                operator.boxViewer,
                name='ViewRois',
                subname='viewrois{:04d}',
            ),
            SerialCountingSlot(
                operator.Classifier,
                operator.classifier_cache,
                name='CountingWrappers',
            ),
        ]

        super(CountingSerializer, self).__init__(projectFileGroupName, slots=slots)
        self.predictionSlot.progressSignal.subscribe(self.progressSignal)
Exemplo n.º 6
0
 def __init__(self, operator, projectFileGroupName):
     super(NanshePreprocessingSerializer, self).__init__(
         projectFileGroupName,
         slots=[
             SerialSlot(operator.ToRemoveZeroedLines, selfdepends=True),
             SerialListSlot(operator.ErosionShape, selfdepends=True),
             SerialListSlot(operator.DilationShape, selfdepends=True),
             SerialSlot(operator.ToExtractF0, selfdepends=True),
             SerialSlot(operator.HalfWindowSize, selfdepends=True),
             SerialSlot(operator.WhichQuantile, selfdepends=True),
             SerialSlot(operator.TemporalSmoothingGaussianFilterStdev,
                        selfdepends=True),
             SerialSlot(operator.SpatialSmoothingGaussianFilterStdev,
                        selfdepends=True),
             SerialSlot(operator.TemporalSmoothingGaussianFilterWindowSize,
                        selfdepends=True),
             SerialSlot(operator.SpatialSmoothingGaussianFilterWindowSize,
                        selfdepends=True),
             SerialSlot(operator.BiasEnabled, selfdepends=True),
             SerialSlot(operator.Bias, selfdepends=True),
             SerialSlot(operator.ToWaveletTransform, selfdepends=True),
             SerialListSlot(operator.Scale, selfdepends=True),
             SerialBlockSlot(operator.CacheOutput,
                             operator.CacheInput,
                             operator.CleanBlocks,
                             selfdepends=True)
         ])
Exemplo n.º 7
0
 def __init__(self, operator, projectFileGroupName):
     slots = [
         SerialBlockSlot(operator.CropInputs,
                         operator.NonzeroCropBlocks,
                         name="CropSets",
                         subname="crops{:03d}")
     ]
     super(CroppingSerializer, self).__init__(projectFileGroupName,
                                              slots=slots)
Exemplo n.º 8
0
    def __init__(self, operator, projectFileGroupName):
        self.VERSION = 1  # Make sure to bump the version in case you make any changes in the serialization
        self._serialClassifierSlot = SerialClassifierSlot(
            operator.Classifier,
            operator.classifier_cache,
            name="ClassifierForests")
        slots = [
            SerialListSlot(operator.LabelNames),
            SerialListSlot(operator.LabelColors,
                           transform=lambda x: tuple(x.flat)),
            SerialListSlot(operator.PmapColors,
                           transform=lambda x: tuple(x.flat)),
            SerialPickleableSlot(operator.Bookmarks, self.VERSION),
            SerialBlockSlot(
                operator.LabelImages,
                operator.LabelInputs,
                operator.NonzeroLabelBlocks,
                name="LabelSets",
                subname="labels{:03d}",
                selfdepends=False,
                shrink_to_bb=True,
            ),
            SerialClassifierFactorySlot(operator.ClassifierFactory),
            self._serialClassifierSlot,
            SerialBlockSlot(
                operator.opSupervoxelFeaturesAndLabels.SupervoxelFeatures,
                operator.opSupervoxelFeaturesAndLabels.
                CacheSupervoxelFeaturesInput,
                operator.opSupervoxelFeaturesAndLabels.
                SupervoxelFeaturesCleanBlocks,
            ),
            SerialBlockSlot(
                operator.opSupervoxelFeaturesAndLabels.SupervoxelLabels,
                operator.opSupervoxelFeaturesAndLabels.
                CacheSupervoxelLabelsInput,
                operator.opSupervoxelFeaturesAndLabels.
                SupervoxelLabelsCleanBlocks,
            ),
        ]

        super(VoxelSegmentationSerializer,
              self).__init__(projectFileGroupName, slots, operator)
Exemplo n.º 9
0
 def __init__(self, operator, projectFileGroupName):
     slots = [
         SerialBlockSlot(
             operator.LabelImages,
             operator.LabelInputs,
             operator.NonzeroLabelBlocks,
             name="LabelSets",
             subname="labels{:03d}",
         )
     ]
     super(LabelingSerializer, self).__init__(projectFileGroupName, slots=slots)
Exemplo n.º 10
0
    def _init_objects(self):
        raw_data = numpy.zeros((100, 100, 100, 1), dtype=numpy.uint32)
        raw_data = vigra.taggedView(raw_data, "zyxc")

        opLabelArrays = OperatorWrapper(OpCompressedUserLabelArray,
                                        graph=Graph())
        opLabelArrays.Input.resize(1)
        opLabelArrays.Input[0].setValue(raw_data)
        opLabelArrays.shape.setValue(raw_data.shape)
        opLabelArrays.eraser.setValue(255)
        opLabelArrays.deleteLabel.setValue(-1)
        opLabelArrays.blockShape.setValue((10, 10, 10, 1))

        # This will serialize/deserialize data to the h5 file.
        slotSerializer = SerialBlockSlot(opLabelArrays.Output,
                                         opLabelArrays.Input,
                                         opLabelArrays.nonzeroBlocks)
        return opLabelArrays, slotSerializer
Exemplo n.º 11
0
    def __init__(self, operator, projectFileGroupName):
        slots = [
            SerialBlockSlot(operator.LabelImage,
                            operator.LabelImageCacheInput,
                            operator.CleanLabelBlocks,
                            name='LabelImage_v2',
                            subname='labelimage{:03d}',
                            selfdepends=False,
                            shrink_to_bb=False,
                            compression_level=1),
            SerialDictSlot(operator.Features, transform=str),
            SerialObjectFeaturesSlot(operator.BlockwiseRegionFeatures,
                                     operator.RegionFeaturesCacheInput,
                                     operator.RegionFeaturesCleanBlocks,
                                     name="RegionFeatures"),
        ]

        super(ObjectExtractionSerializer, self).__init__(projectFileGroupName,
                                                         slots=slots)
Exemplo n.º 12
0
def testCompression(tmpdir, opLabelArray):
    def uncompressed_dataset_name(obj_name, obj):
        dataset_name_matches = obj_name == "data" or obj_name.split(
            "/")[-1].startswith("block")
        if isinstance(obj, h5py.Dataset
                      ) and dataset_name_matches and obj.compression is None:
            return obj_name
        return None

    h5_filepath_no_compression = tmpdir / "serial_blockslot_no-compression.h5"
    h5_filepath_compressed = tmpdir / "serial_blockslot_compressed.h5"

    # Create an operator and a serializer to write the data.
    slotSerializer_no_compression = SerialBlockSlot(opLabelArray.Output,
                                                    opLabelArray.Input,
                                                    opLabelArray.nonzeroBlocks)
    slotSerializer_compressed = SerialBlockSlot(opLabelArray.Output,
                                                opLabelArray.Input,
                                                opLabelArray.nonzeroBlocks,
                                                compression_level=1)
    # Give it some data.
    opLabelArray.Input[0][0:1, 0:1, 0:1, 0:1] = 1 * numpy.ones(
        (1, 1, 1, 1), dtype=numpy.uint8)

    with h5py.File(h5_filepath_no_compression, "w") as f:
        label_group = f.create_group("label_data")
        slotSerializer_no_compression.serialize(label_group)
        uncompressed = label_group.visititems(uncompressed_dataset_name)
        assert uncompressed, f"Expected uncompressed dataset"

    assert h5_filepath_no_compression.exists()

    with h5py.File(h5_filepath_compressed, "w") as f:
        label_group = f.create_group("label_data")
        slotSerializer_compressed.serialize(label_group)
        uncompressed = label_group.visititems(uncompressed_dataset_name)
        assert uncompressed is None, f"Found unexpected uncompressed dataset {uncompressed}"

    assert h5_filepath_compressed.exists()
Exemplo n.º 13
0
    def __init__(self, topLevelOperator, projectFileGroupName):
        self.VERSION = 1

        slots = [
            SerialListSlot(topLevelOperator.LabelNames),
            SerialListSlot(topLevelOperator.LabelColors, transform=lambda x: tuple(x.flat)),
            SerialListSlot(topLevelOperator.PmapColors, transform=lambda x: tuple(x.flat)),
            SerialBlockSlot(
                topLevelOperator.LabelImages,
                topLevelOperator.LabelInputs,
                topLevelOperator.NonzeroLabelBlocks,
                name="LabelSets",
                subname="labels{:03d}",
                selfdepends=False,
                shrink_to_bb=True,
            ),
            BinarySlot(topLevelOperator.ModelBinary),
        ]

        super().__init__(projectFileGroupName, slots)
Exemplo n.º 14
0
 def __init__(self, operator, projectFileGroupName):
     slots = [
         SerialListSlot(operator.ChannelSelections),
         SerialSlot(operator.Threshold),
         SerialSlot(operator.MinSize),
         SerialSlot(operator.Sigma),
         SerialSlot(operator.Alpha),
         SerialSlot(operator.PixelPitch),
         SerialBlockSlot(
             operator.Superpixels,
             operator.SuperpixelCacheInput,
             operator.CleanBlocks,
             name="Superpixels",
             subname="superpixels{:03d}",
             selfdepends=False,
             shrink_to_bb=False,
             compression_level=1,
         ),
     ]
     super(WsdtSerializer, self).__init__(projectFileGroupName, slots=slots, operator=operator)
    def __init__(self, operator, projectFileGroupName):
        slots = [
            SerialListSlot(operator.LabelNames, transform=str),
            SerialListSlot(operator.LabelColors,
                           transform=lambda x: tuple(x.flat)),
            SerialListSlot(operator.PmapColors,
                           transform=lambda x: tuple(x.flat)),
            SerialBlockSlot(operator.LabelImages,
                            operator.LabelInputs,
                            operator.NonzeroLabelBlocks,
                            name='LabelSets',
                            subname='labels{:03d}',
                            selfdepends=False),
            SerialClassifierSlot(operator.Classifier,
                                 operator.classifier_cache,
                                 name="ClassifierForests",
                                 subname="Forest{:04d}")
        ]

        super(PixelClassificationSerializer,
              self).__init__(projectFileGroupName, slots=slots)
Exemplo n.º 16
0
    def _init_objects(self):
        raw_data = numpy.zeros((100, 100, 100, 1), dtype=numpy.uint32)

        raw_data[0:15, 0:15, 0:15, 0:1] = numpy.ma.masked

        opLabelArrays = OperatorWrapper(OpCompressedUserLabelArray,
                                        graph=Graph())
        opLabelArrays.Input.resize(1)
        opLabelArrays.Input[0].meta.has_mask = True
        opLabelArrays.Input[0].meta.axistags = vigra.AxisTags('zyxc')
        opLabelArrays.Input[0].setValue(raw_data)
        opLabelArrays.shape.setValue(raw_data.shape)
        opLabelArrays.eraser.setValue(255)
        opLabelArrays.deleteLabel.setValue(-1)
        opLabelArrays.blockShape.setValue((10, 10, 10, 1))

        # This will serialize/deserialize data to the h5 file.
        slotSerializer = SerialBlockSlot(opLabelArrays.Output,
                                         opLabelArrays.Input,
                                         opLabelArrays.nonzeroBlocks)
        return opLabelArrays, slotSerializer
Exemplo n.º 17
0
 def __init__(self, operator, projectFileGroupName):
     slots = [
         SerialSlot(operator.ChannelSelection),
         SerialSlot(operator.Pmin),
         SerialSlot(operator.MinMembraneSize),
         SerialSlot(operator.MinSegmentSize),
         SerialSlot(operator.SigmaMinima),
         SerialSlot(operator.SigmaWeights),
         SerialSlot(operator.GroupSeeds),
         SerialBlockSlot(operator.Superpixels,
                         operator.SuperpixelCacheInput,
                         operator.CleanBlocks,
                         name='Superpixels',
                         subname='superpixels{:03d}',
                         selfdepends=False,
                         shrink_to_bb=False,
                         compression_level=1)
     ]
     super(WsdtSerializer, self).__init__(projectFileGroupName,
                                          slots=slots,
                                          operator=operator)
    def __init__(self, operator, projectFileGroupName):
        slots = [
            SerialSlot(operator.CurOperator, selfdepends=True),
            SerialSlot(operator.MinSize, selfdepends=True),
            SerialSlot(operator.MaxSize, selfdepends=True),
            SerialSlot(operator.HighThreshold, selfdepends=True),
            SerialSlot(operator.LowThreshold, selfdepends=True),
            SerialDictSlot(operator.SmootherSigma, selfdepends=True),
            SerialSlot(operator.Channel, selfdepends=True),
            SerialSlot(operator.CoreChannel, selfdepends=True),
            SerialBlockSlot(operator.CachedOutput,
                            operator.CacheInput,
                            operator.CleanBlocks,
                            name='CachedThresholdLabels',
                            subname='threshold{:03d}',
                            selfdepends=False,
                            shrink_to_bb=False,
                            compression_level=1)
        ]

        super(self.__class__, self).__init__(projectFileGroupName, slots,
                                             operator)
Exemplo n.º 19
0
    def __init__(self, operator, projectFileGroupName):
        self.predictionSlot = SerialPredictionSlot(
            operator.PredictionProbabilities,
            operator,
            name='Predictions',
            subname='predictions{:04d}',
        )
        slots = [
            SerialListSlot(operator.LabelNames, transform=str),
            SerialListSlot(operator.LabelColors,
                           transform=lambda x: tuple(x.flat)),
            SerialListSlot(operator.PmapColors,
                           transform=lambda x: tuple(x.flat)),
            SerialBlockSlot(operator.LabelImages,
                            operator.LabelInputs,
                            operator.NonzeroLabelBlocks,
                            name='LabelSets',
                            subname='labels{:0}',
                            selfdepends=False),
            SerialCountingSlot(operator.Classifier,
                               operator.classifier_cache,
                               name="CountingWrappers",
                               subname="wrapper{:04d}"), self.predictionSlot,
            SerialBoxSlot(operator.opTrain.BoxConstraintRois,
                          operator.opTrain,
                          name="Rois",
                          subname="rois{:04d}"),
            SerialBoxSlot(operator.opTrain.BoxConstraintValues,
                          operator.opTrain,
                          name="Values",
                          subname="values{:04d}")
        ]

        super(CountingSerializer, self).__init__(projectFileGroupName,
                                                 slots=slots)

        self.predictionSlot.progressSignal.connect(self.progressSignal.emit)
Exemplo n.º 20
0
 def __init__(self, operator, projectFileGroupName):
     super(NanshePostprocessingSerializer, self).__init__(projectFileGroupName,
                                                         slots=[SerialSlot(operator.SignificanceThreshold, selfdepends=True),
                                                                SerialListSlot(operator.WaveletTransformScale, selfdepends=True),
                                                                SerialSlot(operator.NoiseThreshold, selfdepends=True),
                                                                SerialSlot(operator.AcceptedRegionShapeConstraints_MajorAxisLength_Min, selfdepends=True),
                                                                SerialSlot(operator.AcceptedRegionShapeConstraints_MajorAxisLength_Min_Enabled, selfdepends=True),
                                                                SerialSlot(operator.AcceptedRegionShapeConstraints_MajorAxisLength_Max, selfdepends=True),
                                                                SerialSlot(operator.AcceptedRegionShapeConstraints_MajorAxisLength_Max_Enabled, selfdepends=True),
                                                                SerialSlot(operator.MinLocalMaxDistance, selfdepends=True),
                                                                SerialSlot(operator.AcceptedNeuronShapeConstraints_Area_Min, selfdepends=True),
                                                                SerialSlot(operator.AcceptedNeuronShapeConstraints_Area_Min_Enabled, selfdepends=True),
                                                                SerialSlot(operator.AcceptedNeuronShapeConstraints_Area_Max, selfdepends=True),
                                                                SerialSlot(operator.AcceptedNeuronShapeConstraints_Area_Max_Enabled, selfdepends=True),
                                                                SerialSlot(operator.AcceptedNeuronShapeConstraints_Eccentricity_Min, selfdepends=True),
                                                                SerialSlot(operator.AcceptedNeuronShapeConstraints_Eccentricity_Min_Enabled, selfdepends=True),
                                                                SerialSlot(operator.AcceptedNeuronShapeConstraints_Eccentricity_Max, selfdepends=True),
                                                                SerialSlot(operator.AcceptedNeuronShapeConstraints_Eccentricity_Max_Enabled, selfdepends=True),
                                                                SerialSlot(operator.AlignmentMinThreshold, selfdepends=True),
                                                                SerialSlot(operator.OverlapMinThreshold, selfdepends=True),
                                                                SerialSlot(operator.Fuse_FractionMeanNeuronMaxThreshold, selfdepends=True),
                                                                SerialBlockSlot(operator.Output,
                                                                                operator.CacheInput,
                                                                                operator.CleanBlocks, selfdepends=True)])