'Set self._reject_time and self._channel_type_idx.'

def _reject_setup(self, reject, flat):

    idx = channel_indices_by_type(self.info)
    reject = (deepcopy(reject) if (reject is not None) else dict())
    flat = (deepcopy(flat) if (flat is not None) else dict())
    for (rej, kind) in zip((reject, flat), ('reject', 'flat')):
        if (not isinstance(rej, dict)):
            raise TypeError(('reject    and    flat    must    be    dict    or    None,    not    %s' % type(rej)))
        bads = (set(rej.keys()) - set(idx.keys()))
        if (len(bads) > 0):
            raise KeyError(('Unknown    channel    types    found    in    %s:    %s' % (kind, bads)))
    for key in idx.keys():
        if ((len(idx[key]) == 0) and (np.isfinite(reject.get(key, np.inf)) or (flat.get(key, (-1)) >= 0))):
            raise ValueError(('No    %s    channel    found.    Cannot    reject    based    on    %s.' % (key.upper(), key.upper())))
    for (rej, kind) in zip((reject, flat), ('Rejection', 'Flat')):
        for (key, val) in rej.items():
            if ((val is None) or (val < 0)):
                raise ValueError(('%s    value    must    be    a    number    >=    0,    not    "%s"' % (kind, val)))
    old_reject = (self.reject if (self.reject is not None) else dict())
    old_flat = (self.flat if (self.flat is not None) else dict())
    bad_msg = '{kind}["{key}"]    ==    {new}    {op}    {old}    (old    value),    new    {kind}    values    must    be    at    least    as    stringent    as    previous    ones'
    for key in set(reject.keys()).union(old_reject.keys()):
        old = old_reject.get(key, np.inf)
        new = reject.get(key, np.inf)
        if (new > old):
            raise ValueError(bad_msg.format(kind='reject', key=key, new=new, old=old, op='>'))
    for key in set(flat.keys()).union(old_flat.keys()):
        old = old_flat.get(key, (- np.inf))
        new = flat.get(key, (- np.inf))
        if (new < old):
            raise ValueError(bad_msg.format(kind='flat', key=key, new=new, old=old, op='<'))
    self._bad_dropped = False
    self._channel_type_idx = idx
    self.reject = (reject if (len(reject) > 0) else None)
    self.flat = (flat if (len(flat) > 0) else None)
    if ((self.reject_tmin is None) and (self.reject_tmax is None)):
        self._reject_time = None
    else:
        if (self.reject_tmin is None):
            reject_imin = None
        else:
            idxs = np.nonzero((self.times >= self.reject_tmin))[0]
            reject_imin = idxs[0]
        if (self.reject_tmax is None):
            reject_imax = None
        else:
            idxs = np.nonzero((self.times <= self.reject_tmax))[0]
            reject_imax = idxs[(-1)]
        self._reject_time = slice(reject_imin, reject_imax)
