@requires_mne
def test_compensation_raw_mne():
 tempdir = _TempDir()
 def compensate_mne(fname, grad):
  tmp_fname = op.join(tempdir, 'mne_ctf_test_raw.fif')
  cmd = ['mne_process_raw', '--raw', fname, '--save', tmp_fname, '--grad', str(grad), '--projoff', '--filteroff']
  run_subprocess(cmd)
  return read_raw_fif(tmp_fname, preload=True)
 for grad in [0, 2, 3]:
  raw_py = read_raw_fif(ctf_comp_fname, preload=True)
  raw_py.apply_gradient_compensation(grad)
  raw_c = compensate_mne(ctf_comp_fname, grad)
  assert_allclose(raw_py._data, raw_c._data, rtol=1e-06, atol=1e-17)
  assert_equal(raw_py.info['nchan'], raw_c.info['nchan'])
  for (ch_py, ch_c) in zip(raw_py.info['chs'], raw_c.info['chs']):
   for key in ('ch_name', 'coil_type', 'scanno', 'logno', 'unit', 'coord_frame', 'kind'):
    assert_equal(ch_py[key], ch_c[key])
   for key in ('loc', 'unit_mul', 'range', 'cal'):
    assert_allclose(ch_py[key], ch_c[key])

@ requires_mne def test_compensation_raw_mne ( ) : tempdir = _TempDir ( ) def compensate_mne ( fname , grad ) : tmp_fname = op . join ( tempdir , 'mne_ctf_test_raw.fif' ) cmd = [ 'mne_process_raw' , '--raw' , fname , '--save' , tmp_fname , '--grad' , str ( grad ) , '--projoff' , '--filteroff' ] run_subprocess ( cmd ) return read_raw_fif ( tmp_fname , preload = True ) for grad in [ 0 , 2 , 3 ] : raw_py = read_raw_fif ( ctf_comp_fname , preload = True ) raw_py . apply_gradient_compensation ( grad ) raw_c = compensate_mne ( ctf_comp_fname , grad ) assert_allclose ( raw_py . _data , raw_c . _data , rtol = 1e-06 , atol = 1e-17 ) assert_equal ( raw_py . info [ 'nchan' ] , raw_c . info [ 'nchan' ] ) for ( ch_py , ch_c ) in zip ( raw_py . info [ 'chs' ] , raw_c . info [ 'chs' ] ) : for key in ( 'ch_name' , 'coil_type' , 'scanno' , 'logno' , 'unit' , 'coord_frame' , 'kind' ) : assert_equal ( ch_py [ key ] , ch_c [ key ] ) for key in ( 'loc' , 'unit_mul' , 'range' , 'cal' ) : assert_allclose ( ch_py [ key ] , ch_c [ key ] )
test raw compensation by comparing with mne-c .