def test_04_05_get_measurement_scales(self):
     workspace, module = self.make_workspace(
             dict(image=numpy.zeros((20, 10), bool)),
             dict(image=numpy.zeros((20, 10), bool)))
     scales = module.get_measurement_scales(
             workspace.pipeline, cellprofiler.measurement.IMAGE, cellprofiler.modules.measureimageoverlap.C_IMAGE_OVERLAP,
             cellprofiler.modules.measureimageoverlap.FTR_RAND_INDEX, None)
     self.assertEqual(len(scales), 0)
 def test_04_05_get_measurement_scales(self):
     workspace, module = self.make_workspace(
         dict(image=numpy.zeros((20, 10), bool)),
         dict(image=numpy.zeros((20, 10), bool)))
     scales = module.get_measurement_scales(
         workspace.pipeline, cellprofiler.measurement.IMAGE,
         cellprofiler.modules.measureimageoverlap.C_IMAGE_OVERLAP,
         cellprofiler.modules.measureimageoverlap.FTR_RAND_INDEX, None)
     self.assertEqual(len(scales), 0)
Esempio n. 3
0
    def test_04_05_get_measurement_scales(self):
        workspace, module = self.make_workspace(
                dict(image=numpy.zeros((20, 10), bool)),
                dict(image=numpy.zeros((20, 10), bool)))
        module.obj_or_img.value = cellprofiler.modules.measureimageoverlap.O_OBJ
        module.object_name_GT.value = GROUND_TRUTH_OBJ
        module.object_name_ID.value = ID_OBJ

        scales = module.get_measurement_scales(
                workspace.pipeline, cellprofiler.measurement.IMAGE, cellprofiler.modules.measureimageoverlap.C_IMAGE_OVERLAP,
                cellprofiler.modules.measureimageoverlap.FTR_RAND_INDEX, None)
        self.assertEqual(len(scales), 1)
        self.assertEqual(scales[0], "_".join((GROUND_TRUTH_OBJ, ID_OBJ)))

        module.obj_or_img.value = cellprofiler.modules.measureimageoverlap.O_IMG
        scales = module.get_measurement_scales(
                workspace.pipeline, cellprofiler.measurement.IMAGE, cellprofiler.modules.measureimageoverlap.C_IMAGE_OVERLAP,
                cellprofiler.modules.measureimageoverlap.FTR_RAND_INDEX, None)
        self.assertEqual(len(scales), 0)
    def test_04_05_get_measurement_scales(self):
        workspace, module = self.make_obj_workspace(
            numpy.zeros((0, 3), int), numpy.zeros((0, 3), int),
            dict(image=numpy.zeros((20, 10), bool)),
            dict(image=numpy.zeros((20, 10), bool)))

        scales = module.get_measurement_scales(
            workspace.pipeline, cellprofiler.measurement.IMAGE,
            cellprofiler.modules.measureobjectoverlap.C_IMAGE_OVERLAP,
            cellprofiler.modules.measureobjectoverlap.FTR_RAND_INDEX, None)

        self.assertEqual(len(scales), 1)
        self.assertEqual(scales[0], "_".join((GROUND_TRUTH_OBJ, ID_OBJ)))
    def test_04_05_get_measurement_scales(self):
        workspace, module = self.make_obj_workspace(
                numpy.zeros((0, 3), int),
                numpy.zeros((0, 3), int),
                dict(image=numpy.zeros((20, 10), bool)),
                dict(image=numpy.zeros((20, 10), bool)))

        scales = module.get_measurement_scales(
            workspace.pipeline,
            cellprofiler.measurement.IMAGE,
            cellprofiler.modules.measureobjectoverlap.C_IMAGE_OVERLAP,
            cellprofiler.modules.measureobjectoverlap.FTR_RAND_INDEX,
            None
        )

        self.assertEqual(len(scales), 1)
        self.assertEqual(scales[0], "_".join((GROUND_TRUTH_OBJ, ID_OBJ)))
def test_get_measurement_scales():
    workspace, module = make_obj_workspace(
        numpy.zeros((0, 3), int),
        numpy.zeros((0, 3), int),
        dict(image=numpy.zeros((20, 10), bool)),
        dict(image=numpy.zeros((20, 10), bool)),
    )

    scales = module.get_measurement_scales(
        workspace.pipeline,
        cellprofiler.measurement.IMAGE,
        cellprofiler.modules.measureobjectoverlap.C_IMAGE_OVERLAP,
        cellprofiler.modules.measureobjectoverlap.FTR_RAND_INDEX,
        None,
    )

    assert len(scales) == 1
    assert scales[0] == "_".join((GROUND_TRUTH_OBJ, ID_OBJ))
def test_02_get_zernike_measurements():
    module = (cellprofiler.modules.measureobjectintensitydistribution.
              MeasureObjectIntensityDistribution())
    for wants_zernikes, ftrs in (
        (
            cellprofiler.modules.measureobjectintensitydistribution.
            Z_MAGNITUDES,
            (cellprofiler.modules.measureobjectintensitydistribution.
             FF_ZERNIKE_MAGNITUDE, ),
        ),
        (
            cellprofiler.modules.measureobjectintensitydistribution.
            Z_MAGNITUDES_AND_PHASE,
            (
                cellprofiler.modules.measureobjectintensitydistribution.
                FF_ZERNIKE_MAGNITUDE,
                cellprofiler.modules.measureobjectintensitydistribution.
                FF_ZERNIKE_PHASE,
            ),
        ),
    ):
        module.wants_zernikes.value = wants_zernikes
        module.zernike_degree.value = 2

        for i, image_name in ((0, "DNA"), (1, "Cytoplasm"), (2, "Actin")):
            if i:
                module.add_image()
            module.images[i].image_name.value = image_name
        for i, object_name, center_name in (
            (0, "Nucleii", None),
            (1, "Cells", "Nucleii"),
            (2, "Cytoplasm", "Nucleii"),
        ):
            if i:
                module.add_object()
            module.objects[i].object_name.value = object_name
            if center_name is None:
                module.objects[i].center_choice.value = (
                    cellprofiler.modules.measureobjectintensitydistribution.
                    C_SELF)
            else:
                module.objects[i].center_choice.value = (
                    cellprofiler.modules.measureobjectintensitydistribution.
                    C_CENTERS_OF_OTHER)
                module.objects[i].center_object_name.value = center_name

        for object_name in "Nucleii", "Cells", "Cytoplasm":
            result = module.get_measurements(
                None,
                object_name,
                cellprofiler.modules.measureobjectintensitydistribution.
                M_CATEGORY,
            )
            for ftr in ftrs:
                assert ftr in result
                iresult = module.get_measurement_images(
                    None,
                    object_name,
                    cellprofiler.modules.measureobjectintensitydistribution.
                    M_CATEGORY,
                    ftr,
                )
                for image in "DNA", "Cytoplasm", "Actin":
                    assert image in iresult
                    sresult = module.get_measurement_scales(
                        None,
                        object_name,
                        cellprofiler.modules.
                        measureobjectintensitydistribution.M_CATEGORY,
                        ftr,
                        image,
                    )
                    for n, m in ((0, 0), (1, 1), (2, 0), (2, 2)):
                        assert "%d_%d" % (n, m) in sresult
def test_01_get_measurements():
    module = (cellprofiler.modules.measureobjectintensitydistribution.
              MeasureObjectIntensityDistribution())
    for i, image_name in ((0, "DNA"), (1, "Cytoplasm"), (2, "Actin")):
        if i:
            module.add_image()
        module.images[i].image_name.value = image_name
    for i, object_name, center_name in (
        (0, "Nucleii", None),
        (1, "Cells", "Nucleii"),
        (2, "Cytoplasm", "Nucleii"),
    ):
        if i:
            module.add_object()
        module.objects[i].object_name.value = object_name
        if center_name is None:
            module.objects[i].center_choice.value = (
                cellprofiler.modules.measureobjectintensitydistribution.C_SELF)
        else:
            module.objects[i].center_choice.value = (
                cellprofiler.modules.measureobjectintensitydistribution.
                C_CENTERS_OF_OTHER)
            module.objects[i].center_object_name.value = center_name
    for i, bin_count in ((0, 4), (0, 5), (0, 6)):
        if i:
            module.add_bin_count()
        module.bin_counts[i].bin_count.value = bin_count

    for object_name in [x.object_name.value for x in module.objects]:
        assert tuple(module.get_categories(None, object_name)) == (
            cellprofiler.modules.measureobjectintensitydistribution.M_CATEGORY,
        )
        for feature in cellprofiler.modules.measureobjectintensitydistribution.F_ALL:
            assert feature in module.get_measurements(
                None,
                object_name,
                cellprofiler.modules.measureobjectintensitydistribution.
                M_CATEGORY,
            )
        for image_name in [x.image_name.value for x in module.images]:
            for (
                    feature
            ) in cellprofiler.modules.measureobjectintensitydistribution.F_ALL:
                assert image_name in module.get_measurement_images(
                    None,
                    object_name,
                    cellprofiler.modules.measureobjectintensitydistribution.
                    M_CATEGORY,
                    feature,
                )
            for bin_count in [x.bin_count.value for x in module.bin_counts]:
                for bin in range(1, bin_count + 1):
                    for (
                            feature
                    ) in cellprofiler.modules.measureobjectintensitydistribution.F_ALL:
                        assert "%dof%d" % (
                            bin,
                            bin_count,
                        ) in module.get_measurement_scales(
                            None,
                            object_name,
                            cellprofiler.modules.
                            measureobjectintensitydistribution.M_CATEGORY,
                            feature,
                            image_name,
                        )