Example #1
0
 def setUp(self):
     self.mockInput = {
         "Standard Object Features": {
             "Coord<Principal<Kurtosis>>": {},
             "Coord<Principal<Skewness>>": {},
             "Count": {},
             "Kurtosis": {},
             "Maximum": {},
             "Mean": {},
             "Minimum": {},
             "Quantiles": {
                 "something": 123456
             },
             "RegionCenter": {},
             "RegionRadii": {},
             "Skewness": {},
             "Sum": {},
             "Variance": {},
         }
     }
     self.legacyMockInput = {"0": deepcopy(self.mockInput)}
     self.operator = OpMock(graph=Graph())
     self.objFeaturesNameSlot = self.operator.OpaqueListSlot
     self.serializer = SerialObjectFeatureNamesSlot(
         self.objFeaturesNameSlot)
     self.testFilePath = os.path.join(tempfile.gettempdir(),
                                      "objFeatureNames.h5")
Example #2
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)
Example #3
0
class TestSerialObjectFeatureNamesSlot(unittest.TestCase):
    def setUp(self):
        self.mockInput = {
            "Standard Object Features": {
                "Coord<Principal<Kurtosis>>": {},
                "Coord<Principal<Skewness>>": {},
                "Count": {},
                "Kurtosis": {},
                "Maximum": {},
                "Mean": {},
                "Minimum": {},
                "Quantiles": {
                    "something": 123456
                },
                "RegionCenter": {},
                "RegionRadii": {},
                "Skewness": {},
                "Sum": {},
                "Variance": {},
            }
        }
        self.legacyMockInput = {"0": deepcopy(self.mockInput)}
        self.operator = OpMock(graph=Graph())
        self.objFeaturesNameSlot = self.operator.OpaqueListSlot
        self.serializer = SerialObjectFeatureNamesSlot(
            self.objFeaturesNameSlot)
        self.testFilePath = os.path.join(tempfile.gettempdir(),
                                         "objFeatureNames.h5")

    def testSerialization(self):
        for inp in (self.mockInput, self.legacyMockInput):
            h5file = h5py.File(self.testFilePath, "w")
            h5group = h5file.create_group("Some Group")

            self.objFeaturesNameSlot.setValue(deepcopy(inp))
            self.assertEqual(self.objFeaturesNameSlot([]).wait(), inp)
            self.serializer.serialize(h5group)

            self.objFeaturesNameSlot.setValue({"something": "else"})
            self.assertNotEqual(self.objFeaturesNameSlot([]).wait(), inp)

            self.serializer.deserialize(h5group)
            self.assertEqual(
                self.objFeaturesNameSlot([]).wait(), self.mockInput)
            h5file.close()
    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.Features),
            SerialObjectFeaturesSlot(operator.BlockwiseRegionFeatures,
                                     operator.RegionFeaturesCacheInput,
                                     operator.RegionFeaturesCleanBlocks,
                                     name="RegionFeatures"),
        ]

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