def B2IQUV_TMS(B, sign_uv=1, sign_q=1):
    """Convert sky brightness matrix to I, Q, U, V"""
    B11 = B[0, 0, :, :]
    B12 = B[0, 1, :, :]
    B21 = B[1, 0, :, :]
    B22 = B[1, 1, :, :]

    stokes = {}
    stokes['I'] = (B11 + B22) / 2.
    stokes['Q'] = sign_q * sign_uv * (B11 - B22) / 2.
    stokes['U'] = sign_uv * (B12 + B21) / 2.
    stokes['V'] = sign_uv * 1j * (B21 - B12) / 2.
    return stokes