예제 #1
0
 def test_04_02_get_categories(self):
     workspace, module = self.make_workspace(
             dict(image=numpy.zeros((20, 10), bool)),
             dict(image=numpy.zeros((20, 10), bool)))
     categories = module.get_categories(workspace.pipeline, "Foo")
     self.assertEqual(len(categories), 0)
     categories = module.get_categories(workspace.pipeline, cellprofiler.measurement.IMAGE)
     self.assertEqual(len(categories), 1)
     self.assertEqual(categories[0], cellprofiler.modules.measureimageoverlap.C_IMAGE_OVERLAP)
 def test_04_02_get_categories(self):
     workspace, module = self.make_workspace(
             dict(image=numpy.zeros((20, 10), bool)),
             dict(image=numpy.zeros((20, 10), bool)))
     categories = module.get_categories(workspace.pipeline, "Foo")
     self.assertEqual(len(categories), 0)
     categories = module.get_categories(workspace.pipeline, cellprofiler.measurement.IMAGE)
     self.assertEqual(len(categories), 1)
     self.assertEqual(categories[0], cellprofiler.modules.measureimageoverlap.C_IMAGE_OVERLAP)
예제 #3
0
def test_get_categories():
    workspace, module = make_workspace(dict(image=numpy.zeros((20, 10), bool)),
                                       dict(image=numpy.zeros((20, 10), bool)))
    categories = module.get_categories(workspace.pipeline, "Foo")
    assert len(categories) == 0
    categories = module.get_categories(workspace.pipeline,
                                       cellprofiler.measurement.IMAGE)
    assert len(categories) == 1
    assert categories[
        0] == cellprofiler.modules.measureimageoverlap.C_IMAGE_OVERLAP
예제 #4
0
    def test_get_categories_other(self):
        module = cellprofiler.module.ImageSegmentation()

        module.x_name.value = "Image"

        actual = module.get_categories(None, "foo")

        expected = []

        assert actual == expected
예제 #5
0
    def test_get_categories_other(self):
        module = cellprofiler.module.ObjectProcessing()

        module.x_name.value = "Objects"

        actual = module.get_categories(None, "foo")

        expected = []

        assert actual == expected
예제 #6
0
    def test_get_categories_other(self):
        module = cellprofiler.module.ImageSegmentation()

        module.x_name.value = "Image"

        actual = module.get_categories(None, "foo")

        expected = []

        assert actual == expected
예제 #7
0
    def test_get_categories_other(self):
        module = cellprofiler.module.ObjectProcessing()

        module.x_name.value = "Objects"

        actual = module.get_categories(None, "foo")

        expected = []

        assert actual == expected
예제 #8
0
    def test_get_categories_image(self):
        module = cellprofiler.module.ObjectProcessing()

        module.x_name.value = "Objects"

        actual = module.get_categories(None, cellprofiler.measurement.IMAGE)

        expected = [cellprofiler.measurement.C_COUNT]

        assert actual == expected
예제 #9
0
    def test_get_categories_image(self):
        module = cellprofiler.module.ImageSegmentation()

        module.x_name.value = "Image"

        actual = module.get_categories(None, cellprofiler.measurement.IMAGE)

        expected = [cellprofiler.measurement.C_COUNT]

        assert actual == expected
예제 #10
0
    def test_get_categories_input_object(self):
        module = cellprofiler.module.ObjectProcessing()

        module.x_name.value = "Objects"

        actual = module.get_categories(None, "Objects")

        expected = [cellprofiler.measurement.C_CHILDREN]

        assert actual == expected
예제 #11
0
    def test_get_categories_image(self):
        module = cellprofiler.module.ImageSegmentation()

        module.x_name.value = "Image"

        actual = module.get_categories(None, cellprofiler.measurement.IMAGE)

        expected = [
            cellprofiler.measurement.C_COUNT
        ]

        assert actual == expected
예제 #12
0
    def test_get_categories_image(self):
        module = cellprofiler.module.ObjectProcessing()

        module.x_name.value = "Objects"

        actual = module.get_categories(None, cellprofiler.measurement.IMAGE)

        expected = [
            cellprofiler.measurement.C_COUNT
        ]

        assert actual == expected
예제 #13
0
    def test_get_categories_input_object(self):
        module = cellprofiler.module.ObjectProcessing()

        module.x_name.value = "Objects"

        actual = module.get_categories(None, "Objects")

        expected = [
            cellprofiler.measurement.C_CHILDREN
        ]

        assert actual == expected
예제 #14
0
    def test_get_categories_output_object(self):
        module = cellprofiler.module.ImageSegmentation()

        module.x_name.value = "Image"

        actual = module.get_categories(None, "ImageSegmentation")

        expected = [
            cellprofiler.measurement.C_LOCATION,
            cellprofiler.measurement.C_NUMBER,
        ]

        assert actual == expected
예제 #15
0
    def test_get_categories_output_object(self):
        module = cellprofiler.module.ImageSegmentation()

        module.x_name.value = "Image"

        actual = module.get_categories(None, "ImageSegmentation")

        expected = [
            cellprofiler.measurement.C_LOCATION,
            cellprofiler.measurement.C_NUMBER
        ]

        assert actual == expected
예제 #16
0
    def test_get_categories_output_object(self):
        module = cellprofiler.module.ObjectProcessing()

        module.x_name.value = "Objects"

        actual = module.get_categories(None, "ObjectProcessing")

        expected = [
            cellprofiler.measurement.C_LOCATION,
            cellprofiler.measurement.C_NUMBER,
            cellprofiler.measurement.C_PARENT,
        ]

        assert actual == expected
예제 #17
0
    def test_get_categories_output_object(self):
        module = cellprofiler.module.ObjectProcessing()

        module.x_name.value = "Objects"

        actual = module.get_categories(None, "ObjectProcessing")

        expected = [
            cellprofiler.measurement.C_LOCATION,
            cellprofiler.measurement.C_NUMBER,
            cellprofiler.measurement.C_PARENT
        ]

        assert actual == expected
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,
                        )