def process_image_features(features, verbose=False, inplace=False,
        blank_thresh=DEFAULT_BLANK_THRESH, blank_handler=DEFAULT_BLANK_HANDLER,
        do_pca=True, pca=None,
            pca_k=None, pca_varfrac=DEFAULT_VARFRAC, pca_random=False,
            pca_whiten=False,
        add_x=True, add_y=True,
        standardize_feats=True, scaler=None,
        ret_pca=False, ret_scaler=False):
    '''
    Does the full image processing stack:
        - blank handling with handle_blanks()
        - dimensionality reduction with features.pca()
        - adds spatial information with add_spatial_info()
        - standardizes the features with features.standardize()
    '''
    # TODO: use sklearn.Pipeline instead?
    pr = partial(print, file=sys.stderr) if verbose else _do_nothing

    if blank_handler not in (None, "none"):
        pr("Handling blanks...")
        ret = handle_blanks(features, blank_thresh=blank_thresh,
                            blank_handler=blank_handler, inplace=inplace)
        if not inplace:
            features = ret

    if do_pca:
        pr("Running PCA...")
        old_dim = features.dim

        ret = features.pca(
            pca=pca, ret_pca=True, k=pca_k, varfrac=pca_varfrac,
            randomize=pca_random, whiten=pca_whiten, inplace=inplace)
        if inplace:
            pca = ret
        else:
            features, pca = ret

        new_dim = features.dim
        pr("Reduced dimensionality from {} to {}.".format(old_dim, new_dim))

    if add_x or add_y:
        pr("Adding spatial info...")
        ret = add_spatial_info(features, add_x, add_y, inplace=inplace)
        if not inplace:
            features = ret

    if standardize_feats:
        pr("Standardizing features...")
        ret = features.standardize(scaler=scaler, ret_scaler=True,
                                   inplace=inplace)
        if inplace:
            scaler = ret
        else:
            features, scaler = ret

    if not ret_pca and not ret_scaler:
        return features
    ret = [features]
    if ret_pca:
        ret.append(pca)
    if ret_scaler:
        ret.append(scaler)
    return ret
dataset/ETHPy150Open dougalsutherland/py-sdm/sdm/proc_image_features.py/process_image_features/original