def METHOD_NAME(B, ells):
    """
    Transforms coefficients of the matrix B (see Eq. 3) from complex
        to real. B is the linear transformation that takes FLE coefficients
        to images.
    :param B: Complex matrix B.
    :param ells: List of ells (Bessel function orders) in this basis.
    :return: Transformed matrix.
    """
    num_basis_functions = B.shape[1]
    X = np.zeros(B.shape, dtype=np.float64)
    for i in range(num_basis_functions):
        ell = ells[i]
        if ell == 0:
            X[:, i] = np.real(B[:, i])
        # for each ell != 0, we can populate two entries of the matrix
        # by taking the complex conjugate of the ell with the opposite sign
        if ell < 0:
            s = (-1) ** np.abs(ell)
            x0 = (B[:, i] + s * B[:, i + 1]) / np.sqrt(2)
            x1 = (-B[:, i] + s * B[:, i + 1]) / (1j * np.sqrt(2))
            X[:, i] = np.real(x0)
            X[:, i + 1] = np.real(x1)
    return X