def test_detrend():
 (raw, events, picks) = _get_data()
 epochs_1 = Epochs(raw, events[:4], event_id, tmin, tmax, picks=picks, baseline=None, detrend=1)
 epochs_2 = Epochs(raw, events[:4], event_id, tmin, tmax, picks=picks, baseline=None, detrend=None)
 data_picks = pick_types(epochs_1.info, meg=True, eeg=True, exclude='bads')
 evoked_1 = epochs_1.average()
 evoked_2 = epochs_2.average()
 evoked_2.detrend(1)
 assert_true(np.allclose(evoked_1.data, evoked_2.data, rtol=1e-08, atol=1e-20))
 for preload in [True, False]:
  epochs_1 = Epochs(raw, events[:4], event_id, tmin, tmax, picks=picks, baseline=(None, None), preload=preload)
  epochs_2 = Epochs(raw, events[:4], event_id, tmin, tmax, picks=picks, baseline=None, preload=preload, detrend=0)
  a = epochs_1.get_data()
  b = epochs_2.get_data()
  assert_true(np.allclose(a[:, data_picks, :], b[:, data_picks, :], rtol=1e-16, atol=1e-20))
  assert_true((not np.allclose(a, b)))
 for value in ['foo', 2, False, True]:
  assert_raises(ValueError, Epochs, raw, events[:4], event_id, tmin, tmax, detrend=value)

def test_detrend ( ) : ( raw , events , picks ) = _get_data ( ) epochs_1 = Epochs ( raw , events [ : 4 ] , event_id , tmin , tmax , picks = picks , baseline = None , detrend = 1 ) epochs_2 = Epochs ( raw , events [ : 4 ] , event_id , tmin , tmax , picks = picks , baseline = None , detrend = None ) data_picks = pick_types ( epochs_1 . info , meg = True , eeg = True , exclude = 'bads' ) evoked_1 = epochs_1 . average ( ) evoked_2 = epochs_2 . average ( ) evoked_2 . detrend ( 1 ) assert_true ( np . allclose ( evoked_1 . data , evoked_2 . data , rtol = 1e-08 , atol = 1e-20 ) ) for preload in [ True , False ] : epochs_1 = Epochs ( raw , events [ : 4 ] , event_id , tmin , tmax , picks = picks , baseline = ( None , None ) , preload = preload ) epochs_2 = Epochs ( raw , events [ : 4 ] , event_id , tmin , tmax , picks = picks , baseline = None , preload = preload , detrend = 0 ) a = epochs_1 . get_data ( ) b = epochs_2 . get_data ( ) assert_true ( np . allclose ( a [ : , data_picks , : ] , b [ : , data_picks , : ] , rtol = 1e-16 , atol = 1e-20 ) ) assert_true ( ( not np . allclose ( a , b ) ) ) for value in [ 'foo' , 2 , False , True ] : assert_raises ( ValueError , Epochs , raw , events [ : 4 ] , event_id , tmin , tmax , detrend = value )
test zeroth and first order detrending .