import re


def filename_to_tzc(filename, identifiers=None):
    """ Find ocurrences of z/t/c + number (e.g. t001, z06, c2)
    in a filename and returns a list of [t, z, c] coordinates

    Parameters
    ----------
    filename : string
        filename to be searched for t, z, c indices
    identifiers : list of string, optional
        3 strings preceding t, z, c indices, in that order

    Returns
    ---------
    list of int
        t, z, c indices. Elements default to 0 when index was not found.

    """
    if identifiers is None:
        identifiers = tzc = ['t', 'z', 'c']
    else:
        tzc = [re.escape(a) for a in identifiers]
    dimensions = re.findall(r'({0}|{1}|{2})(\d+)'.format(*tzc),
                            filename)
    if len(dimensions) > 3:
        dimensions = dimensions[-3:]
    order = [a[0] for a in dimensions]
    result = [0, 0, 0]
    for (i, col) in enumerate(identifiers):
        try:
            result[i] = int(dimensions[order.index(col)][1])
        except ValueError:
            result[i] = 0
    return result