def _decimate_chpi(raw, decim=4):
 raw_dec = RawArray(raw._data[:, ::decim], raw.info, first_samp=(raw.first_samp // decim))
 raw_dec.info['sfreq'] /= decim
 for coil in raw_dec.info['hpi_meas'][0]['hpi_coils']:
  if (coil['coil_freq'] > raw_dec.info['sfreq']):
   coil['coil_freq'] = np.mod(coil['coil_freq'], raw_dec.info['sfreq'])
   if (coil['coil_freq'] > (raw_dec.info['sfreq'] / 2.0)):
    coil['coil_freq'] = (raw_dec.info['sfreq'] - coil['coil_freq'])
 return raw_dec

def _decimate_chpi ( raw , decim = 4 ) : raw_dec = RawArray ( raw . _data [ : , : : decim ] , raw . info , first_samp = ( raw . first_samp // decim ) ) raw_dec . info [ 'sfreq' ] /= decim for coil in raw_dec . info [ 'hpi_meas' ] [ 0 ] [ 'hpi_coils' ] : if ( coil [ 'coil_freq' ] > raw_dec . info [ 'sfreq' ] ) : coil [ 'coil_freq' ] = np . mod ( coil [ 'coil_freq' ] , raw_dec . info [ 'sfreq' ] ) if ( coil [ 'coil_freq' ] > ( raw_dec . info [ 'sfreq' ] / 2.0 ) ) : coil [ 'coil_freq' ] = ( raw_dec . info [ 'sfreq' ] - coil [ 'coil_freq' ] ) return raw_dec
decimate raw data in chpi-fitting compatible way .