def _ply_header(num_vertices, num_faces, use_vertex_colors=False):
    """
    Return a string representing the PLY format header for the given data properties.
    """
    hdr_top = """ply
format ascii 1.0
comment Generated by Brainload
"""

    hdr_verts = """element vertex %d
property float x
property float y
property float z
""" % num_vertices

    hdr_vertex_colors = """property uchar red
property uchar green
property uchar blue
property uchar alpha
"""

    hdr_face = "element face %d\nproperty list uchar int vertex_indices\n" % num_faces
    hdr_end = "end_header\n"

    if use_vertex_colors:
        hdr_elements = [hdr_top, hdr_verts, hdr_vertex_colors, hdr_face, hdr_end]
    else:
        hdr_elements = [hdr_top, hdr_verts, hdr_face, hdr_end]
    return ''.join(hdr_elements)