def image_filename(im_num=0, pos_num=0, channel_num=0, z_num=0):
    """ create a filename based on the image number, position, channel and z

    Micro-manager format:
        img_channel000_position001_time000000002_z000.tif
    """
    filename = "img_channel{0:03d}_position{1:03d}_time{2:09d}_z{3:03d}.tif"
    return filename.format(channel_num, pos_num, im_num, z_num)