'Compute the mean or std over epochs and return Evoked.'

def _compute_mean_or_stderr(self, picks, mode='ave'):

    _do_std = (True if (mode == 'stderr') else False)
    if (picks is None):
        check_ICA = [x.startswith('ICA') for x in self.ch_names]
        if np.all(check_ICA):
            raise TypeError('picks    must    be    specified    (i.e.    not    None)    for    ICA    channel    data')
        elif np.any(check_ICA):
            warn('ICA    channels    will    not    be    included    unless    explicitly    selected    in    picks')
    n_channels = len(self.ch_names)
    n_times = len(self.times)
    if self.preload:
        n_events = len(self.events)
        fun = (np.std if _do_std else np.mean)
        data = fun(self._data, axis=0)
        assert (len(self.events) == len(self._data))
    else:
        data = np.zeros((n_channels, n_times))
        n_events = 0
        for e in self:
            data += e
            n_events += 1
        if (n_events > 0):
            data /= n_events
        else:
            data.fill(np.nan)
        if _do_std:
            data_mean = data.copy()
            data.fill(0.0)
            for e in self:
                data += ((e - data_mean) ** 2)
            data = np.sqrt((data / n_events))
    if (not _do_std):
        kind = 'average'
    else:
        kind = 'standard_error'
        data /= np.sqrt(n_events)
    return self._evoked_from_epoch_data(data, self.info, picks, n_events, kind, self._name)
