예제 #1
0
 def features_and_columns_match(self, workspace):
     module = workspace.module
     pipeline = workspace.pipeline
     measurements = workspace.measurements
     object_names = [
         x
         for x in measurements.get_object_names()
         if x != cellprofiler_core.measurement.IMAGE
     ]
     features = [
         [
         feature
         for feature in measurements.get_feature_names(object_name)
         if feature not in (MEASUREMENT, IGNORED_MEASUREMENT)
     ]
         for object_name in object_names
     ]
     columns = [
         x
         for x in module.get_measurement_columns(pipeline)
         if x[0] != cellprofiler_core.measurement.IMAGE
     ]
     self.assertEqual(sum([len(f) for f in features]), len(columns))
     for column in columns:
         index = object_names.index(column[0])
         self.assertTrue(column[1] in features[index])
    def test_means_of_distances(self):
        #
        # Regression test of issue #1409
        #
        # Make sure means of minimum and mean distances of children
        # are recorded properly
        #
        i, j = numpy.mgrid[0:14, 0:30]
        #
        # Make the objects different sizes to exercise more code
        #
        parent_labels = (i >= 7) * 1 + (j >= 15) * 2 + 1
        child_labels = numpy.zeros(i.shape)
        numpy.random.seed(0)
        # Take 12 random points and label them
        child_centers = numpy.random.permutation(numpy.prod(i.shape))[:12]
        child_centers = numpy.vstack(
            (i.flatten()[child_centers], j.flatten()[child_centers]))
        child_labels[child_centers[0], child_centers[1]] = numpy.arange(1, 13)
        parent_centers = numpy.array([[3, 7], [10, 7], [3, 22], [10, 22]],
                                     float)
        parent_indexes = parent_labels[child_centers[0], child_centers[1]] - 1
        expected = numpy.sqrt(
            numpy.sum((parent_centers[parent_indexes, :] -
                       child_centers.transpose())**2, 1))

        workspace, module = self.make_workspace(parent_labels, child_labels)
        assert isinstance(module, cellprofiler.modules.relateobjects.Relate)
        module.find_parent_child_distances.value = (
            cellprofiler.modules.relateobjects.D_CENTROID)
        module.wants_per_parent_means.value = True
        mnames = module.get_measurements(
            workspace.pipeline,
            PARENT_OBJECTS,
            "_".join(
                (cellprofiler.modules.relateobjects.C_MEAN, CHILD_OBJECTS)),
        )
        assert cellprofiler.modules.relateobjects.FF_CENTROID % PARENT_OBJECTS in mnames
        feat_mean = cellprofiler.modules.relateobjects.FF_MEAN % (
            CHILD_OBJECTS,
            cellprofiler.modules.relateobjects.FF_CENTROID % PARENT_OBJECTS,
        )
        mcolumns = module.get_measurement_columns(workspace.pipeline)
        assert any(
            [c[0] == PARENT_OBJECTS and c[1] == feat_mean for c in mcolumns])
        m = workspace.measurements
        m[CHILD_OBJECTS, M_LOCATION_CENTER_X, 1] = child_centers[1]
        m[CHILD_OBJECTS, M_LOCATION_CENTER_Y, 1] = child_centers[0]
        module.run(workspace)

        v = m[PARENT_OBJECTS, feat_mean, 1]

        plabel = m[CHILD_OBJECTS, "_".join((C_PARENT, PARENT_OBJECTS)), 1, ]

        assert len(v) == 4
        for idx in range(4):
            if numpy.any(plabel == idx + 1):
                assert (round(
                    abs(v[idx] - numpy.mean(expected[plabel == idx + 1])),
                    4) == 0)
def test_zeros(image, measurements, module, workspace):
    """Test operation on a completely-masked image"""
    image.pixel_data = numpy.zeros((10, 10))

    image.mask = numpy.zeros((10, 10), bool)

    module.run(workspace)

    assert (
        measurements.get_current_measurement(
            cellprofiler_core.measurement.IMAGE, "Intensity_TotalArea_image"
        )
        == 0
    )

    assert len(measurements.get_object_names()) == 1

    assert measurements.get_object_names()[0] == cellprofiler_core.measurement.IMAGE

    columns = module.get_measurement_columns(workspace.pipeline)

    features = measurements.get_feature_names(cellprofiler_core.measurement.IMAGE)

    assert len(columns) == len(features)

    for column in columns:
        assert column[1] in features
def test_image_and_objects(image, measurements, module, objects, workspace):
    """Test operation on an image masked by objects"""
    numpy.random.seed(0)

    pixels = numpy.random.uniform(size=(10, 10)).astype(numpy.float32) * 0.99

    pixels[1:3, 1:3] = 1

    image.pixel_data = pixels

    labels = numpy.zeros((10, 10), int)

    labels[1:9, 1:5] = 1

    labels[1:9, 5:9] = 2

    objects.segmented = labels

    module.wants_objects.value = True

    module.run(workspace)

    assert (
        measurements.get_current_measurement(
            "Image", "Intensity_TotalArea_image_objects"
        )
        == 64
    )

    assert measurements.get_current_measurement(
        "Image", "Intensity_TotalIntensity_image_objects"
    ) == numpy.sum(pixels[1:9, 1:9])

    assert (
        measurements.get_current_measurement(
            "Image", "Intensity_MeanIntensity_image_objects"
        )
        == numpy.sum(pixels[1:9, 1:9]) / 64.0
    )

    numpy.testing.assert_almost_equal(
        measurements.get_current_measurement(
            "Image",
            "Intensity_PercentMaximal_image_objects",
        ),
        400.0 / 64.0,
    )

    assert len(measurements.get_object_names()) == 1

    assert measurements.get_object_names()[0] == "Image"

    columns = module.get_measurement_columns(workspace.pipeline)

    features = measurements.get_feature_names("Image")

    assert len(columns) == len(features)

    for column in columns:
        assert column[1] in features
예제 #5
0
def test_long_integer_column():
    """This is a regression test of IMG-644 where a 13-digit number got turned into an int"""
    colnames = ("Long_Integer_Measurement", "Float_Measurement",
                "String_Measurement")
    coltypes = [
        cellprofiler_core.measurement.COLTYPE_VARCHAR_FORMAT % 13,
        cellprofiler_core.measurement.COLTYPE_FLOAT,
        cellprofiler_core.measurement.COLTYPE_VARCHAR_FORMAT % 9,
    ]
    csv_text = (""""%s","%s","%s"
                1,1,1
                2,1.5,"Hi"
                3,1,"Hello"
                4,1.7,"Hola"
                5,1.2,"Bonjour"
                6,1.5,"Gutentag"
                7,1.1,"Hej"
                1234567890123,2.3,"Bevakasha"
                """ % colnames)
    pipeline, module, filename = make_pipeline(csv_text)
    columns = module.get_measurement_columns(pipeline)
    fmt = "%15s %30s %20s"
    print((fmt % ("Object", "Feature", "Type")))
    for object_name, feature, coltype in columns:
        print((fmt % (object_name, feature, coltype)))
    for colname, coltype in zip(colnames, coltypes):
        assert any([(column[0] == cellprofiler_core.measurement.IMAGE
                     and column[1] == colname and column[2] == coltype)
                    for column in columns]), ("Failed to find %s" % colname)
    os.remove(filename)
예제 #6
0
def test_get_measurement_columns():
    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)),
    )

    columns = module.get_measurement_columns(workspace.pipeline)
    # All columns should be unique
    assert len(columns) == len(set([x[1] for x in columns]))
    # All columns should be floats and done on images
    x = columns[-1]
    assert all([x[0] == "Image"])
    assert all([x[2] == COLTYPE_FLOAT])
    for feature in cellprofiler.modules.measureobjectoverlap.FTR_ALL:
        field = "_".join(
            (
                cellprofiler.modules.measureobjectoverlap.C_IMAGE_OVERLAP,
                feature,
                GROUND_TRUTH_OBJ,
                ID_OBJ,
            )
        )
        assert field in [x[1] for x in columns]
예제 #7
0
def test_get_measurement_columns():
    """Test the get_measurement_columns method"""
    colnames = ("Integer_Measurement", "Float_Measurement", "String_Measurement")
    coltypes = [
        cellprofiler_core.measurement.COLTYPE_INTEGER,
        cellprofiler_core.measurement.COLTYPE_FLOAT,
        cellprofiler_core.measurement.COLTYPE_VARCHAR_FORMAT % 9,
    ]
    csv_text = (
        """"%s","%s","%s"
                1,1,1
                2,1.5,"Hi"
                3,1,"Hello"
                4,1.7,"Hola"
                5,1.2,"Bonjour"
                6,1.5,"Gutentag"
                7,1.1,"Hej"
                8,2.3,"Bevakasha"
                """
        % colnames
    )
    pipeline, module, filename = make_pipeline(csv_text)
    columns = module.get_measurement_columns(pipeline)
    for colname, coltype in zip(colnames, coltypes):
        assert any(
            [
                (
                    column[0] == cellprofiler_core.measurement.IMAGE
                    and column[1] == colname
                    and column[2] == coltype
                )
                for column in columns
            ]
        ), ("Failed to find %s" % colname)
    os.remove(filename)
예제 #8
0
def test_metadata_row_and_column_and_well():
    csv_text = """"Metadata_Row","Metadata_Column","Metadata_Well"
"C","03","B14"
"""
    pipeline, module, filename = make_pipeline(csv_text)
    columns = module.get_measurement_columns(pipeline)
    assert any([
        c[0] == cellprofiler_core.measurement.IMAGE and c[1] == "Metadata_Row"
        and c[2] == "varchar(1)" for c in columns
    ])
    assert any([
        c[0] == cellprofiler_core.measurement.IMAGE
        and c[1] == "Metadata_Column" and c[2] == "varchar(2)" for c in columns
    ])
    assert any([
        c[0] == cellprofiler_core.measurement.IMAGE and c[1] == "Metadata_Well"
        and c[2] == "varchar(3)" for c in columns
    ])
    m = pipeline.run()
    features = module.get_measurements(
        pipeline,
        cellprofiler_core.measurement.IMAGE,
        cellprofiler_core.measurement.C_METADATA,
    )
    for feature, expected in (("Row", "C"), ("Column", "03"), ("Well", "B14")):
        assert feature in features
        value = m.get_current_image_measurement("_".join(
            (cellprofiler_core.measurement.C_METADATA, feature)))
        assert value == expected
예제 #9
0
def test_01_get_measurement_columns():
    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 enumerate((4, 5, 6)):
        if i:
            module.add_bin_count()
        module.bin_counts[i].bin_count.value = bin_count
    module.bin_counts[2].wants_scaled.value = False

    columns = module.get_measurement_columns(None)
    column_dictionary = {}
    for object_name, feature, coltype in columns:
        key = (object_name, feature)
        assert not (key in column_dictionary)
        assert coltype == cellprofiler_core.measurement.COLTYPE_FLOAT
        column_dictionary[key] = (object_name, feature, coltype)

    for object_name in [x.object_name.value for x in module.objects]:
        for image_name in module.images_list.value:
            for bin_count, wants_scaled in [
                (x.bin_count.value, x.wants_scaled.value) for x in module.bin_counts
            ]:
                for bin in range(1, bin_count + (1 if wants_scaled else 2)):
                    for feature_fn in (
                        feature_frac_at_d,
                        feature_mean_frac,
                        feature_radial_cv,
                    ):
                        measurement = feature_fn(bin, bin_count, image_name)
                        key = (object_name, measurement)
                        assert key in column_dictionary
                        del column_dictionary[key]
    assert len(column_dictionary) == 0
예제 #10
0
def test_02_get_zernike_columns():
    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
        columns = module.get_measurement_columns(None)
        for image_name in "DNA", "Cytoplasm", "Actin":
            for object_name in "Nucleii", "Cells", "Cytoplasm":
                for n, m in ((0, 0), (1, 1), (2, 0), (2, 2)):
                    for ftr in ftrs:
                        name = "_".join((
                            cellprofiler.modules.
                            measureobjectintensitydistribution.M_CATEGORY,
                            ftr,
                            image_name,
                            str(n),
                            str(m),
                        ))
                        col = (
                            object_name,
                            name,
                            cellprofiler_core.measurement.COLTYPE_FLOAT,
                        )
                        assert col in columns
예제 #11
0
    def find_measurements(self, modules, pipeline):
        """Scan the modules for features

        modules - modules to scan for features
        pipeline - the pipeline they came from

        returns a two tuple of
            Java types, e.g., "java.lang.Integer"
            A dictionary whose key is the object name and whose
            value is a list of two-tuples of feature name and index into
            the java types array.
        """
        jtypes = ["java.lang.Integer"]
        features = {}
        for module in modules:
            assert isinstance(module, cellprofiler_core.module.Module)
            for column in module.get_measurement_columns(pipeline):
                objects, name, dbtype = column[:3]
                qualifiers = {} if len(column) < 4 else column[3]
                if (objects == cellprofiler_core.measurement.EXPERIMENT
                        and qualifiers.get(
                            cellprofiler_core.measurement.
                            MCA_AVAILABLE_POST_RUN, False) == True):
                    continue
                if dbtype == cellprofiler_core.measurement.COLTYPE_FLOAT:
                    jtype = "java.lang.Double"
                elif dbtype == cellprofiler_core.measurement.COLTYPE_INTEGER:
                    jtype = "java.lang.Integer"
                elif dbtype.startswith(
                        cellprofiler_core.measurement.COLTYPE_VARCHAR):
                    jtype = "java.lang.String"
                else:
                    continue
                if jtype in jtypes:
                    type_idx = jtypes.index(jtype)
                else:
                    type_idx = len(jtypes)
                    jtypes.append(jtype)
                if objects not in features:
                    ofeatures = features[objects] = {}
                else:
                    ofeatures = features[objects]
                if name not in ofeatures:
                    ofeatures[name] = type_idx
        for key in features:
            features[key][cellprofiler_core.measurement.IMAGE_NUMBER] = 0
        features_out = dict([(k, list(v.items()))
                             for k, v in list(features.items())])
        return jtypes, features_out
예제 #12
0
    def test_get_measurement_columns(self):
        module = (cellprofiler_core.module.image_segmentation.
                  _object_processing.ObjectProcessing())

        module.x_name.value = "Objects"

        actual = module.get_measurement_columns(None)

        expected = [
            (
                "ObjectProcessing",
                cellprofiler_core.constants.measurement.M_LOCATION_CENTER_X,
                cellprofiler_core.constants.measurement.COLTYPE_FLOAT,
            ),
            (
                "ObjectProcessing",
                cellprofiler_core.constants.measurement.M_LOCATION_CENTER_Y,
                cellprofiler_core.constants.measurement.COLTYPE_FLOAT,
            ),
            (
                "ObjectProcessing",
                cellprofiler_core.constants.measurement.M_LOCATION_CENTER_Z,
                cellprofiler_core.constants.measurement.COLTYPE_FLOAT,
            ),
            (
                "ObjectProcessing",
                cellprofiler_core.constants.measurement.M_NUMBER_OBJECT_NUMBER,
                cellprofiler_core.constants.measurement.COLTYPE_INTEGER,
            ),
            (
                cellprofiler_core.constants.measurement.IMAGE,
                cellprofiler_core.constants.measurement.FF_COUNT %
                "ObjectProcessing",
                cellprofiler_core.constants.measurement.COLTYPE_INTEGER,
            ),
            (
                "Objects",
                cellprofiler_core.constants.measurement.FF_CHILDREN_COUNT %
                "ObjectProcessing",
                cellprofiler_core.constants.measurement.COLTYPE_INTEGER,
            ),
            (
                "ObjectProcessing",
                cellprofiler_core.constants.measurement.FF_PARENT % "Objects",
                cellprofiler_core.constants.measurement.COLTYPE_INTEGER,
            ),
        ]

        assert actual == expected
예제 #13
0
def test_objects_measurement_columns():
    csv_text = """%s_%s,%s_%s
Channel1-01-A-01.tif,/imaging/analysis/trunk/ExampleImages/ExampleSBSImages
""" % (
        cellprofiler_core.measurement.C_OBJECTS_FILE_NAME,
        OBJECTS_NAME,
        cellprofiler_core.measurement.C_OBJECTS_PATH_NAME,
        OBJECTS_NAME,
    )
    pipeline, module, filename = make_pipeline(csv_text)
    columns = module.get_measurement_columns(pipeline)
    expected_columns = (
        (
            cellprofiler_core.measurement.IMAGE,
            cellprofiler_core.measurement.C_OBJECTS_URL + "_" + OBJECTS_NAME,
        ),
        (
            cellprofiler_core.measurement.IMAGE,
            cellprofiler_core.measurement.C_OBJECTS_FILE_NAME + "_" + OBJECTS_NAME,
        ),
        (
            cellprofiler_core.measurement.IMAGE,
            cellprofiler_core.measurement.C_OBJECTS_PATH_NAME + "_" + OBJECTS_NAME,
        ),
        (
            cellprofiler_core.measurement.IMAGE,
            cellprofiler_core.measurement.C_COUNT + "_" + OBJECTS_NAME,
        ),
        (OBJECTS_NAME, cellprofiler_core.measurement.M_LOCATION_CENTER_X),
        (OBJECTS_NAME, cellprofiler_core.measurement.M_LOCATION_CENTER_Y),
        (OBJECTS_NAME, cellprofiler_core.measurement.M_NUMBER_OBJECT_NUMBER),
    )
    for column in columns:
        assert any(
            [
                True
                for object_name, feature in expected_columns
                if object_name == column[0] and feature == column[1]
            ]
        )
    for object_name, feature in expected_columns:
        assert any(
            [
                True
                for column in columns
                if object_name == column[0] and feature == column[1]
            ]
        )
예제 #14
0
def test_file_name_measurement_columns():
    """Regression test bug IMG-315

    A csv header of Image_FileName_Foo or Image_PathName_Foo should
    yield column names of FileName_Foo and PathName_Foo
    """
    colnames = ("Image_FileName_Foo", "Image_PathName_Foo")
    csv_text = (""""%s","%s"
                "Channel1-01.tif","/imaging/analysis/2500_01_01_Jones"
                "Channel1-02.tif","/imaging/analysis/2500_01_01_Jones"
                """ % colnames)
    pipeline, module, filename = make_pipeline(csv_text)
    try:
        columns = module.get_measurement_columns(pipeline)
        assert "FileName_Foo" in [c[1] for c in columns]
        assert "PathName_Foo" in [c[1] for c in columns]
    finally:
        os.remove(filename)
예제 #15
0
def test_get_measurement_columns():
    workspace, module = make_workspace(dict(image=numpy.zeros((20, 10), bool)),
                                       dict(image=numpy.zeros((20, 10), bool)))

    assert isinstance(
        module, cellprofiler.modules.measureimageoverlap.MeasureImageOverlap)
    name = TEST_IMAGE_NAME

    columns = module.get_measurement_columns(workspace.pipeline)
    # All columns should be unique
    assert len(columns) == len(set([x[1] for x in columns]))
    # All columns should be floats and done on images
    x = columns[-1]
    assert all([x[0] == "Image"])
    assert all([x[2] == COLTYPE_FLOAT])
    for feature in cellprofiler.modules.measureimageoverlap.FTR_ALL:
        field = "_".join(
            (cellprofiler.modules.measureimageoverlap.C_IMAGE_OVERLAP, feature,
             name))
        assert field in [x[1] for x in columns]
    def test_get_measurement_columns(self):
        module = (cellprofiler_core.module.image_segmentation.
                  _image_segmentation.ImageSegmentation())

        module.x_name.value = "Image"

        actual = module.get_measurement_columns(None)

        expected = [
            (
                "ImageSegmentation",
                cellprofiler_core.constants.measurement.M_LOCATION_CENTER_X,
                cellprofiler_core.constants.measurement.COLTYPE_FLOAT,
            ),
            (
                "ImageSegmentation",
                cellprofiler_core.constants.measurement.M_LOCATION_CENTER_Y,
                cellprofiler_core.constants.measurement.COLTYPE_FLOAT,
            ),
            (
                "ImageSegmentation",
                cellprofiler_core.constants.measurement.M_LOCATION_CENTER_Z,
                cellprofiler_core.constants.measurement.COLTYPE_FLOAT,
            ),
            (
                "ImageSegmentation",
                cellprofiler_core.constants.measurement.M_NUMBER_OBJECT_NUMBER,
                cellprofiler_core.constants.measurement.COLTYPE_INTEGER,
            ),
            (
                cellprofiler_core.constants.measurement.IMAGE,
                cellprofiler_core.constants.measurement.FF_COUNT %
                "ImageSegmentation",
                cellprofiler_core.constants.measurement.COLTYPE_INTEGER,
            ),
        ]

        assert actual == expected
def test_get_measurement_columns(module):
    image_names = ["image%d" % i for i in range(3)]

    object_names = ["object%d" % i for i in range(3)]

    first = True

    expected_suffixes = []

    for image_name in image_names:
        if first:
            first = False
        else:
            module.add_image_measurement()

        im = module.images[-1]

        im.image_name.value = image_name

        im.wants_objects.value = False

        expected_suffixes.append(image_name)

        for object_name in object_names:
            module.add_image_measurement()

            im = module.images[-1]

            im.image_name.value = image_name

            im.wants_objects.value = True

            im.object_name.value = object_name

            expected_suffixes.append("%s_%s" % (image_name, object_name))

    columns = module.get_measurement_columns(None)

    assert all([column[0] == cellprofiler_core.measurement.IMAGE for column in columns])

    for expected_suffix in expected_suffixes:
        for feature, coltype in (
            (
                    cellprofiler.modules.measureimageintensity.F_TOTAL_INTENSITY,
                    cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
            (
                    cellprofiler.modules.measureimageintensity.F_MEAN_INTENSITY,
                    cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
            (
                    cellprofiler.modules.measureimageintensity.F_MIN_INTENSITY,
                    cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
            (
                    cellprofiler.modules.measureimageintensity.F_MAX_INTENSITY,
                    cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
            (
                    cellprofiler.modules.measureimageintensity.F_TOTAL_AREA,
                    cellprofiler_core.measurement.COLTYPE_INTEGER,
            ),
            (
                    cellprofiler.modules.measureimageintensity.F_PERCENT_MAXIMAL,
                    cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
            (
                    cellprofiler.modules.measureimageintensity.F_MAD_INTENSITY,
                    cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
            (
                    cellprofiler.modules.measureimageintensity.F_LOWER_QUARTILE,
                    cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
            (
                    cellprofiler.modules.measureimageintensity.F_UPPER_QUARTILE,
                    cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
        ):
            # feature names are now formatting strings
            feature_name = feature % expected_suffix

            assert any(
                [
                    (column[1] == feature_name and column[2] == coltype)
                    for column in columns
                ]
            )
예제 #18
0
def test_get_measurement_columns_whole_image_mode(module):
    image_names = ["image%d" % i for i in range(3)]

    module.wants_objects.value = False

    expected_suffixes = []

    for image_name in image_names:
        im = module.images_list.value[-1]

        module.images_list.value.append(image_name)

        expected_suffixes.append(image_name)

    columns = module.get_measurement_columns(None)

    assert all([
        column[0] == cellprofiler_core.measurement.IMAGE for column in columns
    ])

    for expected_suffix in expected_suffixes:
        for feature, coltype in (
            (
                cellprofiler.modules.measureimageintensity.F_TOTAL_INTENSITY,
                cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
            (
                cellprofiler.modules.measureimageintensity.F_MEAN_INTENSITY,
                cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
            (
                cellprofiler.modules.measureimageintensity.F_MIN_INTENSITY,
                cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
            (
                cellprofiler.modules.measureimageintensity.F_MAX_INTENSITY,
                cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
            (
                cellprofiler.modules.measureimageintensity.F_TOTAL_AREA,
                cellprofiler_core.measurement.COLTYPE_INTEGER,
            ),
            (
                cellprofiler.modules.measureimageintensity.F_PERCENT_MAXIMAL,
                cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
            (
                cellprofiler.modules.measureimageintensity.F_MAD_INTENSITY,
                cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
            (
                cellprofiler.modules.measureimageintensity.F_LOWER_QUARTILE,
                cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
            (
                cellprofiler.modules.measureimageintensity.F_UPPER_QUARTILE,
                cellprofiler_core.measurement.COLTYPE_FLOAT,
            ),
        ):
            # feature names are now formatting strings
            feature_name = feature % expected_suffix

            assert any([(column[1] == feature_name and column[2] == coltype)
                        for column in columns])