#NEWLINE# @ requires_version ( 'scipy' , '0.14' ) #NEWLINE# def test_savgol_filter( ) : #NEWLINE# #INDENT# 'Test savgol filtering\n    ' #NEWLINE# h_freq = 10.0 #NEWLINE# evoked = read_evokeds ( fname , 0 ) #NEWLINE# freqs = fftpack . fftfreq ( len ( evoked . times ) , ( 1.0 / evoked . info [ 'sfreq' ] ) ) #NEWLINE# data = np . abs ( fftpack . fft ( evoked . data ) ) #NEWLINE# match_mask = np . logical_and ( ( freqs >= 0 ) , ( data_filt <= ( h_freq / 2.0 ) ) ) #NEWLINE# mismatch_mask = np . logical_and ( ( freqs >= ( h_freq * 2 ) ) , ( freqs < 50.0 ) ) #NEWLINE# assert_raises ( ValueError , evoked . savgol_filter , evoked . info [ 'sfreq' ] ) #NEWLINE# evoked_sg = evoked . copy ( ) . savgol_filter ( h_freq ) #NEWLINE# data_filt = np . abs ( fftpack . fft ( evoked_sg . data ) ) #NEWLINE# assert_allclose ( np . mean ( data [ : , match_mask ] , 0 ) , np . mean ( data_filt [ : , match_mask ] , 0 ) , rtol = 0.0001 , atol = 0.01 ) #NEWLINE# assert_true ( ( np . mean ( data [ : , mismatch_mask ] ) > ( np . mean ( data_filt [ : , mismatch_mask ] ) * 5 ) ) ) #NEWLINE# assert_allclose ( data , np . abs ( fftpack . fft ( evoked . data ) ) , atol = 1e-16 )