Example #1
0
def test_img_to_metadata_extra_list():
    # make some example data
    colnames = ['Correlation_Correlation_W2_W3',
                'Correlation_Costes_W2_W3',
                'Correlation_Costes_W3_W2',
                'Correlation_K_W2_W3',
                'Correlation_K_W3_W2',
                'Correlation_Manders_W2_W3',
                'Correlation_Manders_W3_W2',
                'Correlation_Overlap_W2_W3',
                'Correlation_RWC_W2_W3',
                'Correlation_RWC_W3_W2',
                'Correlation_Slope_W2_W3',
                'Count_Cells',
                'Count_Nuclei',
                'ExecutionTime_01LoadData',
                'ExecutionTime_02IdentifyPrimaryObjects',
                'ExecutionTime_03ImageMath',
                'ExecutionTime_04IdentifySecondaryObjects',
                'ExecutionTime_05MeasureObjectSizeShape',
                'ExecutionTime_06MeasureImageQuality',
                'ExecutionTime_07MeasureObjectIntensity',
                'ExecutionTime_08MeasureObjectIntensity',
                'ExecutionTime_09MeasureObjectIntensityDistribution',
                'ExecutionTime_10MeasureObjectNeighbors',
                'ExecutionTime_11MeasureTexture',
                'ExecutionTime_12MeasureTexture',
                'ExecutionTime_13MeasureCorrelation',
                'ExecutionTime_14MeasureGranularity',
                'ExecutionTime_15MeasureGranularity',
                'FileName_W1',
                'FileName_W2',
                'FileName_W3',
                'FileName_W4',
                'FileName_W5',
                'Granularity_10_W1',
                'Granularity_10_W4',
                'Granularity_10_W5',
                'Granularity_11_W1',
                'Metadata_well',
                'Cells_AreaShape_Area',
                "Nuclei_AreaShape_Area"]
    dat = np.random.randn(10, len(colnames))
    test_df = pd.DataFrame(dat, columns=colnames)
    ans = utils.img_to_metadata(test_df, prefix="Metadata_", extra=["Cells", "Nuclei"])
    expected = ['Correlation_Correlation_W2_W3',
                'Correlation_Costes_W2_W3',
                'Correlation_Costes_W3_W2',
                'Correlation_K_W2_W3',
                'Correlation_K_W3_W2',
                'Correlation_Manders_W2_W3',
                'Correlation_Manders_W3_W2',
                'Correlation_Overlap_W2_W3',
                'Correlation_RWC_W2_W3',
                'Correlation_RWC_W3_W2',
                'Correlation_Slope_W2_W3',
                'Count_Cells',
                'Count_Nuclei',
                'Metadata_ExecutionTime_01LoadData',
                'Metadata_ExecutionTime_02IdentifyPrimaryObjects',
                'Metadata_ExecutionTime_03ImageMath',
                'Metadata_ExecutionTime_04IdentifySecondaryObjects',
                'Metadata_ExecutionTime_05MeasureObjectSizeShape',
                'Metadata_ExecutionTime_06MeasureImageQuality',
                'Metadata_ExecutionTime_07MeasureObjectIntensity',
                'Metadata_ExecutionTime_08MeasureObjectIntensity',
                'Metadata_ExecutionTime_09MeasureObjectIntensityDistribution',
                'Metadata_ExecutionTime_10MeasureObjectNeighbors',
                'Metadata_ExecutionTime_11MeasureTexture',
                'Metadata_ExecutionTime_12MeasureTexture',
                'Metadata_ExecutionTime_13MeasureCorrelation',
                'Metadata_ExecutionTime_14MeasureGranularity',
                'Metadata_ExecutionTime_15MeasureGranularity',
                'Metadata_FileName_W1',
                'Metadata_FileName_W2',
                'Metadata_FileName_W3',
                'Metadata_FileName_W4',
                'Metadata_FileName_W5',
                'Granularity_10_W1',
                'Granularity_10_W4',
                'Granularity_10_W5',
                'Granularity_11_W1',
                "Metadata_well",
                "Cells_AreaShape_Area",
                "Nuclei_AreaShape_Area"]
    assert ans == expected
Example #2
0
def test_img_to_metadata():
    # make some example data
    colnames = [
        "Correlation_Correlation_W2_W3",
        "Correlation_Costes_W2_W3",
        "Correlation_Costes_W3_W2",
        "Correlation_K_W2_W3",
        "Correlation_K_W3_W2",
        "Correlation_Manders_W2_W3",
        "Correlation_Manders_W3_W2",
        "Correlation_Overlap_W2_W3",
        "Correlation_RWC_W2_W3",
        "Correlation_RWC_W3_W2",
        "Correlation_Slope_W2_W3",
        "Count_Cells",
        "Count_Nuclei",
        "ExecutionTime_01LoadData",
        "ExecutionTime_02IdentifyPrimaryObjects",
        "ExecutionTime_03ImageMath",
        "ExecutionTime_04IdentifySecondaryObjects",
        "ExecutionTime_05MeasureObjectSizeShape",
        "ExecutionTime_06MeasureImageQuality",
        "ExecutionTime_07MeasureObjectIntensity",
        "ExecutionTime_08MeasureObjectIntensity",
        "ExecutionTime_09MeasureObjectIntensityDistribution",
        "ExecutionTime_10MeasureObjectNeighbors",
        "ExecutionTime_11MeasureTexture",
        "ExecutionTime_12MeasureTexture",
        "ExecutionTime_13MeasureCorrelation",
        "ExecutionTime_14MeasureGranularity",
        "ExecutionTime_15MeasureGranularity",
        "FileName_W1",
        "FileName_W2",
        "FileName_W3",
        "FileName_W4",
        "FileName_W5",
        "Granularity_10_W1",
        "Granularity_10_W4",
        "Granularity_10_W5",
        "Granularity_11_W1",
        "Metadata_well",
    ]
    dat = np.random.randn(10, len(colnames))
    test_df = pd.DataFrame(dat, columns=colnames)
    ans = utils.img_to_metadata(test_df, prefix="Metadata_")
    expected = [
        "Correlation_Correlation_W2_W3",
        "Correlation_Costes_W2_W3",
        "Correlation_Costes_W3_W2",
        "Correlation_K_W2_W3",
        "Correlation_K_W3_W2",
        "Correlation_Manders_W2_W3",
        "Correlation_Manders_W3_W2",
        "Correlation_Overlap_W2_W3",
        "Correlation_RWC_W2_W3",
        "Correlation_RWC_W3_W2",
        "Correlation_Slope_W2_W3",
        "Count_Cells",
        "Count_Nuclei",
        "Metadata_ExecutionTime_01LoadData",
        "Metadata_ExecutionTime_02IdentifyPrimaryObjects",
        "Metadata_ExecutionTime_03ImageMath",
        "Metadata_ExecutionTime_04IdentifySecondaryObjects",
        "Metadata_ExecutionTime_05MeasureObjectSizeShape",
        "Metadata_ExecutionTime_06MeasureImageQuality",
        "Metadata_ExecutionTime_07MeasureObjectIntensity",
        "Metadata_ExecutionTime_08MeasureObjectIntensity",
        "Metadata_ExecutionTime_09MeasureObjectIntensityDistribution",
        "Metadata_ExecutionTime_10MeasureObjectNeighbors",
        "Metadata_ExecutionTime_11MeasureTexture",
        "Metadata_ExecutionTime_12MeasureTexture",
        "Metadata_ExecutionTime_13MeasureCorrelation",
        "Metadata_ExecutionTime_14MeasureGranularity",
        "Metadata_ExecutionTime_15MeasureGranularity",
        "Metadata_FileName_W1",
        "Metadata_FileName_W2",
        "Metadata_FileName_W3",
        "Metadata_FileName_W4",
        "Metadata_FileName_W5",
        "Granularity_10_W1",
        "Granularity_10_W4",
        "Granularity_10_W5",
        "Granularity_11_W1",
        "Metadata_well",
    ]
    assert ans == expected