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 6acb9de84922fbeb7f3cc60c0b47232d0f74b2e7 Author: Daniel Strohmeier <[email protected]> Date: Thu Jul 12 21:50:32 2012 +0200 added Alex's comments --- mne/artifacts/stim.py | 26 ++++++++++++++------------ mne/artifacts/tests/test_stim.py | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/mne/artifacts/stim.py b/mne/artifacts/stim.py index 0bdabcb..9e4c2c5 100644 --- a/mne/artifacts/stim.py +++ b/mne/artifacts/stim.py @@ -1,6 +1,8 @@ import numpy as np from scipy import signal, interpolate +from ..fiff import pick_types + def eliminate_stim_artifact(raw, events, event_id, tmin=-0.005, tmax=0.01, mode='linear'): @@ -34,23 +36,23 @@ def eliminate_stim_artifact(raw, events, event_id, tmin=-0.005, event_start = events[events_sel, 0] s_start = np.ceil(raw.info['sfreq'] * np.abs(tmin))[0] s_end = np.ceil(raw.info['sfreq'] * tmax)[0] + picks = pick_types(raw.info, meg=True, eeg=True) if mode == 'linear': for k in range(len(event_start)): - x = np.array([event_start[k] - raw.first_samp - s_start, \ - event_start[k] - raw.first_samp + s_end]) - data = raw._data[:, [event_start[k] - raw.first_samp - s_start, \ - event_start[k] - raw.first_samp + s_end]] - f = interpolate.interp1d(x, data) - xnew = np.arange(event_start[k] - raw.first_samp - s_start, \ - event_start[k] - raw.first_samp + s_end) + first_samp = event_start[k] - raw.first_samp - s_start + last_samp = event_start[k] - raw.first_samp + s_end + x = np.array([first_samp, last_samp]) + data = raw[picks, first_samp:last_samp] + f = interpolate.interp1d(x, data[0][:, [0, -1]]) + xnew = np.arange(first_samp, last_samp) interp_data = f(xnew) - raw._data[:, event_start[k] - raw.first_samp - s_start:\ - event_start[k] - raw.first_samp + s_end] = interp_data + raw[picks, first_samp:last_samp] = interp_data if mode == 'window': 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)): - raw._data[:, event_start[k] - raw.first_samp - s_start:\ - event_start[k] - raw.first_samp + s_end] *= \ - window[np.newaxis, :] + first_samp = event_start[k] - raw.first_samp - s_start + last_samp = event_start[k] - raw.first_samp + s_end + data = raw[picks, first_samp:last_samp] + raw[picks, first_samp:last_samp] = data[0] * window[np.newaxis, :] return raw diff --git a/mne/artifacts/tests/test_stim.py b/mne/artifacts/tests/test_stim.py index 3a6827d..45be159 100644 --- a/mne/artifacts/tests/test_stim.py +++ b/mne/artifacts/tests/test_stim.py @@ -13,7 +13,7 @@ raw_fname = op.join(data_path, 'test_raw.fif') event_fname = op.join(data_path, 'test-eve.fif') -def test_find_ecg(): +def test_stim_elim(): """Test eliminate stim artifact""" raw = Raw(raw_fname, preload=True) events = read_events(event_fname) -- 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
