This is an automated email from the git hooks/post-receive script. yoh pushed a commit to tag 0.4 in repository python-mne.
commit d3c80dc02822df89f720ea05ef20aa08350112c7 Author: Alexandre Gramfort <[email protected]> Date: Fri Aug 3 22:27:21 2012 +0200 pyflakes + pep8 --- mne/artifacts/stim.py | 2 +- mne/artifacts/tests/test_ecg.py | 1 - mne/artifacts/tests/test_peak_finder.py | 1 - mne/cov.py | 2 +- mne/epochs.py | 9 ++++++--- mne/fiff/matrix.py | 2 +- mne/fiff/tests/test_evoked.py | 1 + mne/fiff/tests/test_pick.py | 1 - mne/filter.py | 2 ++ mne/mixed_norm/debiasing.py | 2 +- mne/selection.py | 1 - mne/simulation/evoked.py | 2 +- mne/source_space.py | 1 + mne/stats/tests/test_permutations.py | 2 +- mne/tests/test_epochs.py | 12 ++++++------ mne/tests/test_misc.py | 1 + mne/tests/test_selection.py | 1 - mne/tests/test_utils.py | 1 + mne/time_frequency/tests/test_psd.py | 7 ++++--- mne/time_frequency/tfr.py | 4 ++-- mne/utils.py | 10 +++++----- 21 files changed, 35 insertions(+), 30 deletions(-) diff --git a/mne/artifacts/stim.py b/mne/artifacts/stim.py index 5f65ddd..84717ec 100644 --- a/mne/artifacts/stim.py +++ b/mne/artifacts/stim.py @@ -48,7 +48,7 @@ def eliminate_stim_artifact(raw, events, event_id, tmin=-0.005, picks = pick_types(raw.info, meg=True, eeg=True) if mode == 'window': - window = 1 - np.r_[signal.hann(4)[:2], np.ones(s_end + s_start - 4), \ + window = 1 - np.r_[signal.hann(4)[:2], np.ones(s_end + s_start - 4), signal.hann(4)[-2:]].T for k in range(len(event_start)): diff --git a/mne/artifacts/tests/test_ecg.py b/mne/artifacts/tests/test_ecg.py index 5777136..4c994e0 100644 --- a/mne/artifacts/tests/test_ecg.py +++ b/mne/artifacts/tests/test_ecg.py @@ -1,7 +1,6 @@ import os.path as op from nose.tools import assert_true -from numpy.testing import assert_array_almost_equal from mne.fiff import Raw from mne.artifacts.ecg import find_ecg_events diff --git a/mne/artifacts/tests/test_peak_finder.py b/mne/artifacts/tests/test_peak_finder.py index 276427a..5d60719 100644 --- a/mne/artifacts/tests/test_peak_finder.py +++ b/mne/artifacts/tests/test_peak_finder.py @@ -1,4 +1,3 @@ -import numpy as np from numpy.testing import assert_array_equal from mne.artifacts.peak_finder import peak_finder diff --git a/mne/cov.py b/mne/cov.py index 518a403..ef1872c 100644 --- a/mne/cov.py +++ b/mne/cov.py @@ -94,7 +94,7 @@ class Covariance(dict): """Add Covariance taking into account number of degrees of freedom""" _check_covs_algebra(self, cov) this_cov = copy.deepcopy(cov) - this_cov['data'] = ((this_cov['data'] * this_cov['nfree']) + \ + this_cov['data'] = ((this_cov['data'] * this_cov['nfree']) + (self['data'] * self['nfree'])) / \ (self['nfree'] + this_cov['nfree']) this_cov['nfree'] += self['nfree'] diff --git a/mne/epochs.py b/mne/epochs.py index 944153f..8b6dc75 100644 --- a/mne/epochs.py +++ b/mne/epochs.py @@ -16,6 +16,7 @@ from .fiff.proj import activate_proj, make_eeg_average_ref_proj from .baseline import rescale from .utils import check_random_state + class Epochs(object): """List of Epochs @@ -181,7 +182,8 @@ class Epochs(object): # Select the desired events self.events = events if event_id is not None: - selected = np.logical_and(events[:, 1] == 0, events[:, 2] == event_id) + selected = np.logical_and(events[:, 1] == 0, + events[:, 2] == event_id) self.events = self.events[selected] n_events = len(self.events) @@ -519,8 +521,9 @@ def _is_good(e, ch_names, channel_type_idx, reject, flat): delta = deltas[idx_min_delta] if delta < thresh: ch_name = ch_names[idx[idx_min_delta]] - print (' Rejecting flat epoch based on %s : %s (%s < %s).' - % (name, ch_name, delta, thresh)) + print (' Rejecting flat epoch based on ' + '%s : %s (%s < %s).' % (name, ch_name, delta, + thresh)) return False return True diff --git a/mne/fiff/matrix.py b/mne/fiff/matrix.py index 8f883a2..df01757 100644 --- a/mne/fiff/matrix.py +++ b/mne/fiff/matrix.py @@ -7,7 +7,7 @@ import copy from .constants import FIFF from .tag import find_tag, has_tag from .write import write_int, start_block, end_block, write_float_matrix, \ - write_string, write_name_list + write_name_list def _transpose_named_matrix(mat): diff --git a/mne/fiff/tests/test_evoked.py b/mne/fiff/tests/test_evoked.py index 7feca2c..248526d 100644 --- a/mne/fiff/tests/test_evoked.py +++ b/mne/fiff/tests/test_evoked.py @@ -6,6 +6,7 @@ from mne.fiff import read_evoked, write_evoked fname = op.join(op.dirname(__file__), 'data', 'test-ave.fif') + def test_io_evoked(): """Test IO for evoked data """ diff --git a/mne/fiff/tests/test_pick.py b/mne/fiff/tests/test_pick.py index ce4ef37..d574c34 100644 --- a/mne/fiff/tests/test_pick.py +++ b/mne/fiff/tests/test_pick.py @@ -8,4 +8,3 @@ def test_pick_channels_regexp(): assert_array_equal(pick_channels_regexp(ch_names, 'MEG ...1'), [0]) assert_array_equal(pick_channels_regexp(ch_names, 'MEG ...[2-3]'), [1, 2]) assert_array_equal(pick_channels_regexp(ch_names, 'MEG *'), [0, 1, 2]) - diff --git a/mne/filter.py b/mne/filter.py index 55f82a4..cd68046 100644 --- a/mne/filter.py +++ b/mne/filter.py @@ -5,6 +5,7 @@ from scipy.signal import freqz from .utils import firwin2 # back port for old scipy + def is_power2(num): """Test if number is a power of 2 @@ -148,6 +149,7 @@ def _filter_attenuation(h, freq, gain): return att_db, att_freq + def _filter(x, Fs, freq, gain, filter_length=None): """Filter signal using gain control points in the frequency domain. diff --git a/mne/mixed_norm/debiasing.py b/mne/mixed_norm/debiasing.py index 95d7f47..439af2d 100755 --- a/mne/mixed_norm/debiasing.py +++ b/mne/mixed_norm/debiasing.py @@ -7,7 +7,7 @@ from math import sqrt import numpy as np from scipy import linalg -from ..utils import check_random_state +from ..utils import check_random_state def power_iteration_kron(A, C, max_iter=1000, tol=1e-3, random_state=0): diff --git a/mne/selection.py b/mne/selection.py index ba52262..558e7ca 100644 --- a/mne/selection.py +++ b/mne/selection.py @@ -95,4 +95,3 @@ def read_selection(name, fname=None): sel.sort() return sel - diff --git a/mne/simulation/evoked.py b/mne/simulation/evoked.py index cf127dd..f7b9895 100644 --- a/mne/simulation/evoked.py +++ b/mne/simulation/evoked.py @@ -47,7 +47,7 @@ def generate_evoked(fwd, stc, evoked, cov, snr=3, tmin=None, tmax=None, The simulated evoked data """ evoked = apply_forward(fwd, stc, evoked) - noise = generate_noise_evoked(evoked, cov, fir_filter, random_state) + noise = generate_noise_evoked(evoked, cov, iir_filter, random_state) evoked_noise = add_noise_evoked(evoked, noise, snr, tmin=tmin, tmax=tmax) return evoked_noise diff --git a/mne/source_space.py b/mne/source_space.py index a75df95..e5a8388 100644 --- a/mne/source_space.py +++ b/mne/source_space.py @@ -382,6 +382,7 @@ def _get_vertno(src): vertno.append(s['vertno']) return vertno + ############################################################################### # Write routines diff --git a/mne/stats/tests/test_permutations.py b/mne/stats/tests/test_permutations.py index 1c40457..8ac0bac 100644 --- a/mne/stats/tests/test_permutations.py +++ b/mne/stats/tests/test_permutations.py @@ -12,7 +12,7 @@ def test_permutation_t_test(): np.random.seed(10) n_samples, n_tests = 30, 5 X = np.random.randn(n_samples, n_tests) - X[:,:2] += 1 + X[:, :2] += 1 T_obs, p_values, H0 = permutation_t_test(X, n_permutations=999, tail=0) is_significant = p_values < 0.05 diff --git a/mne/tests/test_epochs.py b/mne/tests/test_epochs.py index 584b8ac..459e27e 100644 --- a/mne/tests/test_epochs.py +++ b/mne/tests/test_epochs.py @@ -85,8 +85,8 @@ def test_reject_epochs(): def test_preload_epochs(): """Test of epochs rejection """ - epochs_preload = Epochs(raw, events[:16], event_id, tmin, tmax, picks=picks, - baseline=(None, 0), preload=True, + epochs_preload = Epochs(raw, events[:16], event_id, tmin, tmax, + picks=picks, baseline=(None, 0), preload=True, reject=reject, flat=flat) data_preload = epochs_preload.get_data() @@ -127,7 +127,7 @@ def test_indexing_slicing(): epochs2_sliced = epochs2[start_index:end_index] data_epochs2_sliced = epochs2_sliced.get_data() - assert_array_equal(data_epochs2_sliced, \ + assert_array_equal(data_epochs2_sliced, data_normal[start_index:end_index]) # using indexing @@ -136,16 +136,16 @@ def test_indexing_slicing(): data = epochs2_sliced[pos].get_data() assert_array_equal(data[0], data_normal[idx]) pos += 1 - + # using indexing with an int data = epochs2[data_epochs2_sliced.shape[0]].get_data() assert_array_equal(data, data_normal[[idx]]) - + # using indexing with an array idx = np.random.randint(0, data_epochs2_sliced.shape[0], 10) data = epochs2[idx].get_data() assert_array_equal(data, data_normal[idx]) - + # using indexing with a list of indices idx = [0] data = epochs2[idx].get_data() diff --git a/mne/tests/test_misc.py b/mne/tests/test_misc.py index d639026..0c1008b 100644 --- a/mne/tests/test_misc.py +++ b/mne/tests/test_misc.py @@ -6,6 +6,7 @@ from mne.misc import parse_config ave_fname = op.join(op.dirname(__file__), '..', 'fiff', 'tests', 'data', 'test.ave') + def test_parse_ave(): """Test parsing of .ave file """ diff --git a/mne/tests/test_selection.py b/mne/tests/test_selection.py index 725f2a3..4272ed0 100644 --- a/mne/tests/test_selection.py +++ b/mne/tests/test_selection.py @@ -25,4 +25,3 @@ def test_read_selection(): frontal = read_selection('frontal') occipital = read_selection('Right-occipital') assert(len(set(frontal).intersection(set(occipital))) == 0) - diff --git a/mne/tests/test_utils.py b/mne/tests/test_utils.py index 6a7cac6..6606d28 100644 --- a/mne/tests/test_utils.py +++ b/mne/tests/test_utils.py @@ -3,6 +3,7 @@ from numpy.testing import assert_equal from mne.utils import _firwin2 as mne_firwin2 + def test_firwin2(): """Test firwin2 backport """ diff --git a/mne/time_frequency/tests/test_psd.py b/mne/time_frequency/tests/test_psd.py index b9b8981..9520b4f 100644 --- a/mne/time_frequency/tests/test_psd.py +++ b/mne/time_frequency/tests/test_psd.py @@ -3,19 +3,20 @@ import os.path as op from numpy.testing import assert_array_almost_equal from nose.tools import assert_true -from mne import fiff, Epochs, read_events +from mne import fiff from mne.time_frequency import compute_raw_psd raw_fname = op.join(op.dirname(__file__), '..', '..', 'fiff', 'tests', 'data', 'test_raw.fif') + def test_psd(): """Test PSD estimation """ raw = fiff.Raw(raw_fname) - exclude = raw.info['bads'] + ['MEG 2443', 'EEG 053'] # bads + 2 more + exclude = raw.info['bads'] + ['MEG 2443', 'EEG 053'] # bads + 2 more # picks MEG gradiometers picks = fiff.pick_types(raw.info, meg='mag', eeg=False, @@ -25,7 +26,7 @@ def test_psd(): tmin, tmax = 0, 10 # use the first 60s of data fmin, fmax = 2, 70 # look at frequencies between 5 and 70Hz - NFFT = 124 # the FFT size (NFFT). Ideally a power of 2 + NFFT = 124 # the FFT size (NFFT). Ideally a power of 2 psds, freqs = compute_raw_psd(raw, tmin=tmin, tmax=tmax, picks=picks, fmin=fmin, fmax=fmax, NFFT=NFFT, n_jobs=1, proj=False) diff --git a/mne/time_frequency/tfr.py b/mne/time_frequency/tfr.py index a0c431e..8b33534 100644 --- a/mne/time_frequency/tfr.py +++ b/mne/time_frequency/tfr.py @@ -142,8 +142,8 @@ def _cwt_convolve(X, Ws, mode='same'): for i, W in enumerate(Ws): ret = np.convolve(x, W, mode=mode) if len(W) > len(x): - raise ValueError('Wavelet is too long for such a short signal. ' - 'Reduce the number of cycles.') + raise ValueError('Wavelet is too long for such a short ' + 'signal. Reduce the number of cycles.') if mode == "valid": sz = abs(W.size - n_times) + 1 offset = (n_times - sz) / 2 diff --git a/mne/utils.py b/mne/utils.py index 187de8e..ec62e83 100644 --- a/mne/utils.py +++ b/mne/utils.py @@ -193,7 +193,7 @@ def _firwin2(numtaps, freq, gain, nfreqs=None, window='hamming', nyq=1.0): if nfreqs is not None and numtaps >= nfreqs: raise ValueError('ntaps must be less than nfreqs, but firwin2 was ' - 'called with ntaps=%d and nfreqs=%s' % (numtaps, nfreqs)) + 'called with ntaps=%d and nfreqs=%s' % (numtaps, nfreqs)) if freq[0] != 0 or freq[-1] != nyq: raise ValueError('freq must start with 0 and end with `nyq`.') @@ -209,14 +209,14 @@ def _firwin2(numtaps, freq, gain, nfreqs=None, window='hamming', nyq=1.0): "have zero gain at the Nyquist rate.") if nfreqs is None: - nfreqs = 1 + 2 ** int(ceil(log(numtaps,2))) + nfreqs = 1 + 2 ** int(ceil(log(numtaps, 2))) # Tweak any repeated values in freq so that interp works. eps = np.finfo(float).eps for k in range(len(freq)): - if k < len(freq)-1 and freq[k] == freq[k+1]: + if k < len(freq) - 1 and freq[k] == freq[k + 1]: freq[k] = freq[k] - eps - freq[k+1] = freq[k+1] + eps + freq[k + 1] = freq[k + 1] + eps # Linearly interpolate the desired response on a uniform mesh `x`. x = np.linspace(0.0, nyq, nfreqs) @@ -224,7 +224,7 @@ def _firwin2(numtaps, freq, gain, nfreqs=None, window='hamming', nyq=1.0): # Adjust the phases of the coefficients so that the first `ntaps` of the # inverse FFT are the desired filter coefficients. - shift = np.exp(-(numtaps-1)/2. * 1.j * np.pi * x / nyq) + shift = np.exp(-(numtaps - 1) / 2. * 1.j * np.pi * x / nyq) fx2 = fx * shift # Use irfft to compute the inverse FFT. -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-mne.git _______________________________________________ debian-med-commit mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit
