'Get data in the given range.
Parameters
picks : array-like of int | None
Indices of channels to get data from. If None, data from all
channels is returned
start : int
The first sample to include. Defaults to 0.
stop : int | None
End sample (first not to include). If None (default), the end of
the data is  used.
reject_by_annotation : None | \'omit\' | \'NaN\'
Whether to reject by annotation. If None (default), no rejection is
done. If \'omit\', segments annotated with description starting with
\'bad\' are omitted. If \'NaN\', the bad samples are filled with NaNs.
return_times : bool
Whether to return times as well. Defaults to False.
Returns
data : ndarray, shape (n_channels, n_times)
Copy of the data in the given range.
times : ndarray, shape (n_times,)
Times associated with the data samples. Only returned if
return_times=True.
Notes
.. versionadded:: 0.14.0'

def get_data(self, picks=None, start=0, stop=None, reject_by_annotation=None, return_times=False):

    if (picks is None):
        picks = np.arange(self.info['nchan'])
    start = (0 if (start is None) else start)
    stop = (self.n_times if (stop is None) else stop)
    if ((self.annotations is None) or (reject_by_annotation is None)):
        (data, times) = self[picks, start:stop]
        if return_times:
            return (data, times)
        return data
    if (reject_by_annotation.lower() not in ['omit', 'nan']):
        raise ValueError(("reject_by_annotation    must    be    None,    'omit'    or    'NaN'.    Got    %s." % reject_by_annotation))
    sfreq = self.info['sfreq']
    bads = [idx for (idx, desc) in enumerate(self.annotations.description) if desc.upper().startswith('BAD')]
    onsets = self.annotations.onset[bads]
    onsets = _sync_onset(self, onsets)
    ends = (onsets + self.annotations.duration[bads])
    omit = np.concatenate([np.where((onsets > (stop / sfreq)))[0], np.where((ends < (start / sfreq)))[0]])
    (onsets, ends) = (np.delete(onsets, omit), np.delete(ends, omit))
    if (len(onsets) == 0):
        (data, times) = self[picks, start:stop]
        if return_times:
            return (data, times)
        return data
    stop = min(stop, self.n_times)
    order = np.argsort(onsets)
    onsets = self.time_as_index(onsets[order])
    ends = self.time_as_index(ends[order])
    np.clip(onsets, start, stop, onsets)
    np.clip(ends, start, stop, ends)
    used = np.ones((stop - start), bool)
    for (onset, end) in zip(onsets, ends):
        if (onset >= end):
            continue
        used[(onset - start):(end - start)] = False
    used = np.concatenate([[False], used, [False]])
    starts = (np.where(((~ used[:(-1)]) & used[1:]))[0] + start)
    stops = (np.where((used[:(-1)] & (~ used[1:])))[0] + start)
    if (reject_by_annotation == 'omit'):
        data = np.zeros((len(picks), (stops - starts).sum()))
        times = np.zeros(data.shape[1])
        idx = 0
        for (start, stop) in zip(starts, stops):
            if (start == stop):
                continue
            end = ((idx + stop) - start)
            (data[:, idx:end], times[idx:end]) = self[picks, start:stop]
            idx = end
    else:
        (data, times) = self[picks, start:stop]
        data[:, (~ used[1:(-1)])] = np.nan
    if return_times:
        return (data, times)
    return data
