def test_xdawn_apply_transform():
 (raw, events, picks) = _get_data()
 raw.pick_types(eeg=True, meg=False)
 epochs = Epochs(raw, events, event_id, tmin, tmax, proj=False, preload=True, baseline=None, verbose=False)
 n_components = 2
 xd = Xdawn(n_components=n_components, correct_overlap=False)
 xd.fit(epochs)
 for inst in [raw, epochs.average(), epochs]:
  denoise = xd.apply(inst)
 assert_raises(ValueError, xd.apply, 42)
 xd.transform(epochs)
 xd.transform(epochs._data)
 assert_raises(ValueError, xd.transform, 42)
 np.random.seed(0)
 idx = np.arange(len(epochs))
 np.random.shuffle(idx)
 xd.fit(epochs[idx])
 denoise_shfl = xd.apply(epochs)
 assert_array_almost_equal(denoise['cond2']._data, denoise_shfl['cond2']._data)

def test_xdawn_apply_transform ( ) : ( raw , events , picks ) = _get_data ( ) raw . pick_types ( eeg = True , meg = False ) epochs = Epochs ( raw , events , event_id , tmin , tmax , proj = False , preload = True , baseline = None , verbose = False ) n_components = 2 xd = Xdawn ( n_components = n_components , correct_overlap = False ) xd . fit ( epochs ) for inst in [ raw , epochs . average ( ) , epochs ] : denoise = xd . apply ( inst ) assert_raises ( ValueError , xd . apply , 42 ) xd . transform ( epochs ) xd . transform ( epochs . _data ) assert_raises ( ValueError , xd . transform , 42 ) np . random . seed ( 0 ) idx = np . arange ( len ( epochs ) ) np . random . shuffle ( idx ) xd . fit ( epochs [ idx ] ) denoise_shfl = xd . apply ( epochs ) assert_array_almost_equal ( denoise [ 'cond2' ] . _data , denoise_shfl [ 'cond2' ] . _data )
test xdawn apply and transform .