def read_phantom_head(fname):
    """
    Given filename, read and parse phantom header file

    return voxels and dimensions
    """

    lines = None
    with open(fname) as f:
        lines = f.readlines()

    vx = 0.0
    vy = 0.0
    vz = 0.0

    nx = 0
    ny = 0
    nz = 0

    for line in lines:
        s = line.split(" ")
        s = [x for x in s if x]  # remove empty lines

        if s[0] == "VOXELSIZE":
            vx = float(s[2])
            vy = float(s[3])
            vz = float(s[4])
            continue

        if s[0] == "DIMENSION":
            nx = int(s[2])
            ny = int(s[3])
            nz = int(s[4])
            continue

        if s[0] == "END-INPUT":
            break

    return (vx, vy, vz, nx, ny, nz)