def stream_name_mapping(stream, exclude_params=['name'], reverse=False):
    """
    Return a complete dictionary mapping between stream parameter names
    to their applicable renames, excluding parameters listed in
    exclude_params.

    If reverse is True, the mapping is from the renamed strings to the
    original stream parameter names.
    """
    filtered = [k for k in stream.param if k not in exclude_params]
    mapping = {k:stream._rename.get(k,k) for k in filtered}
    if reverse:
        return {v:k for k,v in mapping.items()}
    else:
        return mapping