'Aux function.'

def _pre_whiten(self, data, info, picks):

    has_pre_whitener = hasattr(self, '_pre_whitener')
    if ((not has_pre_whitener) and (self.noise_cov is None)):
        info = pick_info(info, picks)
        pre_whitener = np.empty([len(data), 1])
        for ch_type in (_DATA_CH_TYPES_SPLIT + ['eog']):
            if _contains_ch_type(info, ch_type):
                if (ch_type == 'seeg'):
                    this_picks = pick_types(info, meg=False, seeg=True)
                elif (ch_type == 'ecog'):
                    this_picks = pick_types(info, meg=False, ecog=True)
                elif (ch_type == 'eeg'):
                    this_picks = pick_types(info, meg=False, eeg=True)
                elif (ch_type in ('mag', 'grad')):
                    this_picks = pick_types(info, meg=ch_type)
                elif (ch_type == 'eog'):
                    this_picks = pick_types(info, meg=False, eog=True)
                elif (ch_type in ('hbo', 'hbr')):
                    this_picks = pick_types(info, meg=False, fnirs=ch_type)
                else:
                    raise RuntimeError('Should    not    be    reached.Unsupported    channel    {0}'.format(ch_type))
                pre_whitener[this_picks] = np.std(data[this_picks])
        data /= pre_whitener
    elif ((not has_pre_whitener) and (self.noise_cov is not None)):
        (pre_whitener, _) = compute_whitener(self.noise_cov, info, picks)
        assert (data.shape[0] == pre_whitener.shape[1])
        data = np.dot(pre_whitener, data)
    elif (has_pre_whitener and (self.noise_cov is None)):
        data /= self._pre_whitener
        pre_whitener = self._pre_whitener
    else:
        data = np.dot(self._pre_whitener, data)
        pre_whitener = self._pre_whitener
    return (data, pre_whitener)
