def test_volume(image, measurements, module, workspace):
    image.set_image(skimage.morphology.ball(3), convert=False)

    image.dimensions = 3

    module.run(workspace)

    expected = {
        "Intensity_TotalIntensity_image": 123.0,
        "Intensity_MeanIntensity_image": 0.358600583090379,
        "Intensity_MedianIntensity_image": 0.0,
        "Intensity_StdIntensity_image": 0.47958962134059907,
        "Intensity_MADIntensity_image": 0.0,
        "Intensity_MaxIntensity_image": 1.0,
        "Intensity_MinIntensity_image": 0.0,
        "Intensity_TotalArea_image": 343.0,
        "Intensity_PercentMaximal_image": 35.8600583090379,
        "Intensity_UpperQuartileIntensity_image": 1.0,
        "Intensity_LowerQuartileIntensity_image": 0.0
    }

    for feature, value in expected.iteritems():
        actual = measurements.get_current_measurement(
            cellprofiler.measurement.IMAGE, feature)

        assert actual == value, "{} expected {}, got {}".format(
            feature, value, actual)
def test_volume_and_objects(image, measurements, module, objects, workspace):
    object_data = skimage.morphology.ball(3, dtype=numpy.uint8)

    image.set_image(numpy.ones_like(object_data, dtype=numpy.uint8),
                    convert=False)

    image.dimensions = 3

    objects.segmented = object_data

    module.images[0].wants_objects.value = True

    module.run(workspace)

    expected = {
        "Intensity_TotalIntensity_image_objects": 123.0,
        "Intensity_MeanIntensity_image_objects": 1.0,
        "Intensity_MedianIntensity_image_objects": 1.0,
        "Intensity_StdIntensity_image_objects": 0.0,
        "Intensity_MADIntensity_image_objects": 0.0,
        "Intensity_MaxIntensity_image_objects": 1.0,
        "Intensity_MinIntensity_image_objects": 1.0,
        "Intensity_TotalArea_image_objects": 123.0,
        "Intensity_PercentMaximal_image_objects": 100.0,
        "Intensity_UpperQuartileIntensity_image_objects": 1.0,
        "Intensity_LowerQuartileIntensity_image_objects": 1.0
    }

    for feature, value in expected.iteritems():
        actual = measurements.get_current_measurement(
            cellprofiler.measurement.IMAGE, feature)

        assert actual == value, "{} expected {}, got {}".format(
            feature, value, actual)
Beispiel #3
0
def test_volume_and_mask(image, measurements, module, workspace):
    mask = skimage.morphology.ball(3, dtype=numpy.bool)

    image.set_image(numpy.ones_like(mask, dtype=numpy.uint8), convert=False)

    image.mask = mask

    image.dimensions = 3

    module.run(workspace)

    expected = {
        "Intensity_TotalIntensity_image": 123.0,
        "Intensity_MeanIntensity_image": 1.0,
        "Intensity_MedianIntensity_image": 1.0,
        "Intensity_StdIntensity_image": 0.0,
        "Intensity_MADIntensity_image": 0.0,
        "Intensity_MaxIntensity_image": 1.0,
        "Intensity_MinIntensity_image": 1.0,
        "Intensity_TotalArea_image": 123.0,
        "Intensity_PercentMaximal_image": 100.0,
        "Intensity_UpperQuartileIntensity_image": 1.0,
        "Intensity_LowerQuartileIntensity_image": 1.0,
    }

    for feature, value in expected.items():
        actual = measurements.get_current_measurement(
            cellprofiler.measurement.IMAGE, feature)

        assert actual == value, "{} expected {}, got {}".format(
            feature, value, actual)
def test_volume_and_objects(image, measurements, module, objects, workspace):
    object_data = skimage.morphology.ball(3, dtype=numpy.uint8)

    image.set_image(numpy.ones_like(object_data, dtype=numpy.uint8), convert=False)

    image.dimensions = 3

    objects.segmented = object_data

    module.images[0].wants_objects.value = True

    module.run(workspace)

    expected = {
        "Intensity_TotalIntensity_image_objects": 123.0,
        "Intensity_MeanIntensity_image_objects": 1.0,
        "Intensity_MedianIntensity_image_objects": 1.0,
        "Intensity_StdIntensity_image_objects": 0.0,
        "Intensity_MADIntensity_image_objects": 0.0,
        "Intensity_MaxIntensity_image_objects": 1.0,
        "Intensity_MinIntensity_image_objects": 1.0,
        "Intensity_TotalArea_image_objects": 123.0,
        "Intensity_PercentMaximal_image_objects": 100.0,
        "Intensity_UpperQuartileIntensity_image_objects": 1.0,
        "Intensity_LowerQuartileIntensity_image_objects": 1.0
    }

    for feature, value in expected.iteritems():
        actual = measurements.get_current_measurement(
            cellprofiler.measurement.IMAGE,
            feature
        )

        assert actual == value, "{} expected {}, got {}".format(feature, value, actual)
def test_volume(image, measurements, module, workspace):
    image.set_image(skimage.morphology.ball(3), convert=False)

    image.dimensions = 3

    module.run(workspace)

    expected = {
        "Intensity_TotalIntensity_image": 123.0,
        "Intensity_MeanIntensity_image": 0.358600583090379,
        "Intensity_MedianIntensity_image": 0.0,
        "Intensity_StdIntensity_image": 0.47958962134059907,
        "Intensity_MADIntensity_image": 0.0,
        "Intensity_MaxIntensity_image": 1.0,
        "Intensity_MinIntensity_image": 0.0,
        "Intensity_TotalArea_image": 343.0,
        "Intensity_PercentMaximal_image": 35.8600583090379,
        "Intensity_UpperQuartileIntensity_image": 1.0,
        "Intensity_LowerQuartileIntensity_image": 0.0
    }

    for feature, value in expected.iteritems():
        actual = measurements.get_current_measurement(
            cellprofiler.measurement.IMAGE,
            feature
        )

        assert actual == value, "{} expected {}, got {}".format(feature, value, actual)
def volume(image):
    data = numpy.zeros((11, 11, 20))

    k, i, j = numpy.mgrid[-5:6, -5:6, -5:15]
    data[k**2 + i**2 + j**2 <= 25] = 0.5
    data[k**2 + i**2 + j**2 <= 16] = 0.25
    data[k**2 + i**2 + j**2 == 0] = 1

    k, i, j = numpy.mgrid[-5:6, -5:6, -15:5]
    data[k**2 + i**2 + j**2 <= 9] = 0.5
    data[k**2 + i**2 + j**2 <= 4] = 0.75
    data[k**2 + i**2 + j**2 == 0] = 1

    image.set_image(data, convert=False)

    image.dimensions = 3

    return image