'Check if data segment is bad.
If the slice is good, returns the data in desired range.
If rejected based on annotation, returns description of the
bad segment as a string.
Parameters
start : int
First sample of the slice.
stop : int
End of the slice.
picks : array of int
Channel picks.
reject_by_annotation : bool
Whether to perform rejection based on annotations.
False by default.
Returns
data : array | str
Data in the desired range (good segment) or description of the bad
segment.'

def _check_bad_segment(self, start, stop, picks, reject_by_annotation=False):

    if (start < 0):
        return None
    if (reject_by_annotation and (self.annotations is not None)):
        annot = self.annotations
        sfreq = self.info['sfreq']
        onset = _sync_onset(self, annot.onset)
        overlaps = np.where((onset < (stop / sfreq)))
        overlaps = np.where(((onset[overlaps] + annot.duration[overlaps]) > (start / sfreq)))
        for descr in annot.description[overlaps]:
            if descr.lower().startswith('bad'):
                return descr
    return self[picks, start:stop][0]
