def shapeFromHdr(hdr, verbose=0):
    """
    return "smart" shape
    considering numTimes, numWavelenth and hdr.ImgSequence
    if verbose:
        print somthing like: w,t,z,y,x  ot z,y,x
    """
    zOrder = hdr.ImgSequence
    nt, nw = hdr.NumTimes, hdr.NumWaves
    nx, ny, nsecs = hdr.Num
    if nt == 0:
        nt = 1
    if nw == 0:
        nw = 1
    nz = int(nsecs / nt / nw)
    if nt == nw == 1:
        shape = nz, ny, nx
        orderLetters = 'zyx'
    elif nz == 1 == nw:
        shape = nt, ny, nx
        orderLetters = 'tyx'
    elif nt == 1 or nw == 1:
        if zOrder == 0 or zOrder == 2:
            nn = nt
            if nt == 1:
                nn = nw
                orderLetters = 'wyx'
            else:
                orderLetters = 'tyx'
            shape = nn, nz, ny, nx
        elif nt == 1:
            shape = nz, nw, ny, nx
            orderLetters = 'zwyx'
        else:
            shape = nt, nz, ny, nx
            orderLetters = 'tzyx'
    elif zOrder == 0:
        shape = nw, nt, nz, ny, nx
        orderLetters = 'wtzyx'
    elif zOrder == 1:
        shape = nt, nz, nw, ny, nx
        orderLetters = 'tzwyx'
    else:
        shape = nt, nw, nz, ny, nx
        orderLetters = 'twzyx'
    if verbose:
        print(','.join(orderLetters))
    return shape
