コード例 #1
0
def get_features(data, peaks):
    """ Uses peaks from DO only
    """
    DO_masks = peaks_to_DO_masks(peaks)

    arr = []
    # loop over peak sources
    for source, mask in DO_masks.items():
        # peak object features
        objects = feature_table(mask, mask, object_features)
        # DO/sequencing features
        table = build_feature_table(data, mask, peak_features, all_index)
        table = objects.join(table)
        table['source'] = source
        arr += [table]
    return pd.concat(arr)
コード例 #2
0
def test_build_feature_table():
    features = {
        'mean': lambda region: region.intensity_image[region.image].mean(),
        'median':
        lambda region: np.median(region.intensity_image[region.image]),
        'max': lambda region: region.intensity_image[region.image].max()
    }

    index = (('round', range(1,
                             4)), ('channel', ('DAPI', 'Cy3', 'A594', 'Cy5')))

    data = read_stack(stack)
    mask = read_stack(nuclei)

    df = build_feature_table(data, mask, features, index)
    df.index.name = 'cell'

    df = df.set_index(['round', 'channel'],
                      append=True).stack().unstack('cell').T

    df_ = pd.read_pickle(home('build_feature_table.pkl'))

    assert (df == df_).all().all()