This is an automated email from the git hooks/post-receive script. yoh pushed a commit to annotated tag v0.1 in repository python-mne.
commit 87c0dffa0521a91ed400829f017779bc79657280 Author: Alexandre Gramfort <[email protected]> Date: Fri Sep 16 17:22:57 2011 -0400 prettify example + adding test for source_induced_power --- .../plot_source_label_time_frequency.py | 4 ++-- mne/baseline.py | 7 +++++-- mne/minimum_norm/tests/test_time_frequency.py | 20 +++++++++++++++++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/examples/time_frequency/plot_source_label_time_frequency.py b/examples/time_frequency/plot_source_label_time_frequency.py index 5c53aef..17621d4 100644 --- a/examples/time_frequency/plot_source_label_time_frequency.py +++ b/examples/time_frequency/plot_source_label_time_frequency.py @@ -49,10 +49,10 @@ epochs = mne.Epochs(raw, events, event_id, tmin, tmax, picks=picks, preload=True) # Compute a source estimate per frequency band -frequencies = np.arange(7, 30, 3) # define frequencies of interest +frequencies = np.arange(7, 30, 2) # define frequencies of interest label = mne.read_label(fname_label) power, phase_lock = source_induced_power(epochs, inverse_operator, frequencies, - label, baseline=(None, 0), baseline_mode='logratio', + label, baseline=(-0.1, 0), baseline_mode='percent', n_cycles=2, n_jobs=1) power = np.mean(power, axis=0) # average over sources diff --git a/mne/baseline.py b/mne/baseline.py index 6cb7c11..16435d4 100644 --- a/mne/baseline.py +++ b/mne/baseline.py @@ -29,7 +29,7 @@ def rescale(data, times, baseline, mode, verbose=True, copy=True): If baseline is equal ot (None, None) all the time interval is used. - mode: 'logratio' | 'ratio' | 'zscore' | 'mean' + mode: 'logratio' | 'ratio' | 'zscore' | 'mean' | 'percent' Do baseline correction with ratio (power is divided by mean power during baseline) or zscore (power is divided by standard deviatio of power during baseline after substracting the mean, @@ -44,7 +44,7 @@ def rescale(data, times, baseline, mode, verbose=True, copy=True): if copy: data = data.copy() - valid_modes = ['logratio', 'ratio', 'zscore', 'mean'] + valid_modes = ['logratio', 'ratio', 'zscore', 'mean', 'percent'] if mode not in valid_modes: raise Exception('mode should be any of : %s' % valid_modes) @@ -73,6 +73,9 @@ def rescale(data, times, baseline, mode, verbose=True, copy=True): std = np.std(data[..., imin:imax], axis=-1)[..., None] data -= mean data /= std + elif mode == 'percent': + data -= mean + data /= mean elif verbose: print "No baseline correction applied..." diff --git a/mne/minimum_norm/tests/test_time_frequency.py b/mne/minimum_norm/tests/test_time_frequency.py index 6423e67..c231db0 100644 --- a/mne/minimum_norm/tests/test_time_frequency.py +++ b/mne/minimum_norm/tests/test_time_frequency.py @@ -8,7 +8,7 @@ from ...datasets import sample from ... import fiff, find_events, Epochs from ...label import read_label from ..inverse import read_inverse_operator -from ..time_frequency import source_band_induced_power +from ..time_frequency import source_band_induced_power, source_induced_power examples_folder = op.join(op.dirname(__file__), '..', '..', '..', 'examples') @@ -39,8 +39,8 @@ def test_tfr_with_inverse_operator(): # Load condition 1 event_id = 1 - events = events[:3] # take 3 events to keep the computation time low - epochs = Epochs(raw, events, event_id, tmin, tmax, picks=picks, + events3 = events[:3] # take 3 events to keep the computation time low + epochs = Epochs(raw, events3, event_id, tmin, tmax, picks=picks, baseline=(None, 0), reject=dict(grad=4000e-13, eog=150e-6), preload=True) @@ -60,3 +60,17 @@ def test_tfr_with_inverse_operator(): n_cycles=2, use_fft=False, pca=False, label=label) assert_array_almost_equal(stcs['alpha'].data, stcs_no_pca['alpha'].data) + + # Compute a source estimate per frequency band + events = find_events(raw) + epochs = Epochs(raw, events[:10], event_id, tmin, tmax, picks=picks, + baseline=(None, 0), reject=dict(grad=4000e-13, eog=150e-6), + preload=True) + + frequencies = np.arange(7, 30, 2) # define frequencies of interest + power, phase_lock = source_induced_power(epochs, inverse_operator, + frequencies, label, baseline=(-0.1, 0), + baseline_mode='percent', n_cycles=2, n_jobs=1) + assert_true(np.all(phase_lock > 0)) + assert_true(np.all(phase_lock < 1)) + assert_true(np.max(power) > 10) -- 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
