Create measurement configurations out of a pool of current
        injections.  Use only the provided dipoles for potential dipole
        selection. This means that we have always reciprocal measurements.

        Remove quadpoles where electrodes are used both as current and voltage
        dipoles.

        Parameters
        ----------
        injections_raw : Nx2 array
            current injections
        only_same_dipole_length : bool, optional
            if True, only generate permutations for the same dipole length
        ignore_crossed_dipoles : bool, optional
            If True, potential dipoles will be ignored that lie between current
            dipoles,  e.g. 1-4 3-5. In this case it is possible to not have
            full normal-reciprocal coverage.
        silent: bool, optional
            if True, do not print information on ignored configs (default:
            False)

        Returns
        -------
        configs : Nx4 array
            quadrupoles generated out of the current injections

def gen_configs_permutate(self,
                              injections_raw,
                              only_same_dipole_length=False,
                              ignore_crossed_dipoles=False,
                              silent=False):
        """ Create measurement configurations out of a pool of current
        injections.  Use only the provided dipoles for potential dipole
        selection. This means that we have always reciprocal measurements.

        Remove quadpoles where electrodes are used both as current and voltage
        dipoles.

        Parameters
        ----------
        injections_raw : Nx2 array
            current injections
        only_same_dipole_length : bool, optional
            if True, only generate permutations for the same dipole length
        ignore_crossed_dipoles : bool, optional
            If True, potential dipoles will be ignored that lie between current
            dipoles,  e.g. 1-4 3-5. In this case it is possible to not have
            full normal-reciprocal coverage.
        silent: bool, optional
            if True, do not print information on ignored configs (default:
            False)

        Returns
        -------
        configs : Nx4 array
            quadrupoles generated out of the current injections

        """
        injections = np.atleast_2d(injections_raw).astype(int)
        N = injections.shape[0]

        measurements = []

        for injection in range(0, N):
            dipole_length = np.abs(injections[injection][1] -
                                   injections[injection][0])

            # select all dipole EXCEPT for the injection dipole
            for i in set(range(0, N)) - set([injection]):
                test_dipole_length = np.abs(injections[i, :][1] -
                                            injections[i, :][0])
                if (only_same_dipole_length
                        and test_dipole_length != dipole_length):
                    continue
                quadpole = np.array(
                    [injections[injection, :], injections[i, :]]).flatten()
                if ignore_crossed_dipoles is True:
                    # check if we need to ignore this dipole
                    # Note: this could be wrong if electrode number are not
                    # ascending!
                    if (quadpole[2] > quadpole[0]
                            and quadpole[2] < quadpole[1]):
                        if not silent:
                            print('A - ignoring', quadpole)
                    elif (quadpole[3] > quadpole[0]
                          and quadpole[3] < quadpole[1]):
                        if not silent:
                            print('B - ignoring', quadpole)
                    else:
                        measurements.append(quadpole)
                else:
                    # add very quadpole
                    measurements.append(quadpole)

        # check and remove double use of electrodes
        filtered = []
        for quadpole in measurements:
            if (not set(quadpole[0:2]).isdisjoint(set(quadpole[2:4]))):
                if not silent:
                    print('Ignoring quadrupole because of ',
                          'repeated electrode use:', quadpole)
            else:
                filtered.append(quadpole)
        self.add_to_configs(filtered)
        return np.array(filtered)