Exemple #1
0
def test_get_measurement_images():
    workspace, module = make_workspace(dict(image=numpy.zeros((20, 10), bool)),
                                       dict(image=numpy.zeros((20, 10), bool)))

    for feature in cellprofiler.modules.measureimageoverlap.FTR_ALL:
        imnames = module.get_measurement_images(
            workspace.pipeline,
            "Image",
            cellprofiler.modules.measureimageoverlap.C_IMAGE_OVERLAP,
            feature,
        )
        assert len(imnames) == 1
        assert imnames[0] == TEST_IMAGE_NAME
    imnames = module.get_measurement_images(
        workspace.pipeline,
        "Image",
        cellprofiler.modules.measureimageoverlap.C_IMAGE_OVERLAP,
        "Foo",
    )
    assert len(imnames) == 0
    imnames = module.get_measurement_images(
        workspace.pipeline,
        "Image",
        "Foo",
        cellprofiler.modules.measureimageoverlap.FTR_FALSE_NEG_RATE,
    )
    assert len(imnames) == 0
    imnames = module.get_measurement_images(
        workspace.pipeline,
        "Foo",
        cellprofiler.modules.measureimageoverlap.C_IMAGE_OVERLAP,
        cellprofiler.modules.measureimageoverlap.FTR_FALSE_NEG_RATE,
    )
    assert len(imnames) == 0
Exemple #2
0
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

        module.images_list.value = "DNA, Cytoplasm, Actin"
        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
Exemple #3
0
def test_01_get_measurements():
    module = (cellprofiler.modules.measureobjectintensitydistribution.
              MeasureObjectIntensityDistribution())
    module.images_list.value = "DNA, Cytoplasm, Actin"
    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 module.images_list.value:
            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,
                        )