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 dd42b2dda379825bd3a88c1844a606c4ea55fb1a Author: Alexandre Gramfort <[email protected]> Date: Tue Jul 17 11:06:15 2012 +0200 fix tests + pep8 --- mne/simulation/tests/test_source.py | 34 ++++++++++------------------------ mne/tests/test_label.py | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/mne/simulation/tests/test_source.py b/mne/simulation/tests/test_source.py index f0f5266..bae2dd4 100644 --- a/mne/simulation/tests/test_source.py +++ b/mne/simulation/tests/test_source.py @@ -1,37 +1,24 @@ -import os import os.path as op import copy import numpy as np from numpy.testing import assert_array_almost_equal +from nose.tools import assert_true from ...datasets import sample from ... import read_label from ... import read_forward_solution -from ..source import circular_source_labels, generate_stc +from ..source import generate_stc examples_folder = op.join(op.dirname(__file__), '..', '..', '..' '/examples') data_path = sample.data_path(examples_folder) -fname_fwd = op.join(data_path, 'MEG', 'sample', 'sample_audvis-meg-oct-6-fwd.fif') +fname_fwd = op.join(data_path, 'MEG', 'sample', + 'sample_audvis-meg-oct-6-fwd.fif') fwd = read_forward_solution(fname_fwd, force_fixed=True) label_names = ['Aud-lh', 'Aud-rh'] -labels = [read_label(op.join(data_path, 'MEG', 'sample', 'labels', '%s.label' % label)) - for label in label_names] - -def test_circular_source_labels(): - """ Test generation of circular source labels """ - - seeds = [0, 50000] - hemis = [0, 1] - labels = circular_source_labels('sample', seeds, 3, hemis) - - for label, seed, hemi in zip(labels, seeds, hemis): - assert(np.any(label['vertices'] == seed)) - if hemi == 0: - assert(label['hemi'] == 'lh') - else: - assert(label['hemi'] == 'rh') +labels = [read_label(op.join(data_path, 'MEG', 'sample', 'labels', + '%s.label' % label)) for label in label_names] def test_generate_stc(): @@ -46,17 +33,16 @@ def test_generate_stc(): tstep = 1e-3 stc_data = np.ones((len(labels), n_times)) - stc = generate_stc(fwd, mylabels, stc_data, tmin, tstep) + stc = generate_stc(fwd['src'], mylabels, stc_data, tmin, tstep) - assert(np.all(stc.data == 1.0)) - assert(stc.data.shape[1] == n_times) + assert_true(np.all(stc.data == 1.0)) + assert_true(stc.data.shape[1] == n_times) # test with function fun = lambda x: x ** 2 - stc = generate_stc(fwd, mylabels, stc_data, tmin, tstep, fun) + stc = generate_stc(fwd['src'], mylabels, stc_data, tmin, tstep, fun) print stc.data # the first label has value 0, the second value 2 assert_array_almost_equal(stc.data[0], np.zeros(n_times)) assert_array_almost_equal(stc.data[-1], 4 * np.ones(n_times)) - diff --git a/mne/tests/test_label.py b/mne/tests/test_label.py index bd4af93..51df0fc 100644 --- a/mne/tests/test_label.py +++ b/mne/tests/test_label.py @@ -1,11 +1,12 @@ import os import os.path as op +import numpy as np from numpy.testing import assert_array_almost_equal from nose.tools import assert_true from ..datasets import sample from .. import label_time_courses, read_label, write_label, stc_to_label, \ - SourceEstimate, read_source_spaces + SourceEstimate, read_source_spaces, grow_labels examples_folder = op.join(op.dirname(__file__), '..', '..', 'examples') @@ -56,3 +57,17 @@ def test_stc_to_label(): assert_true(l1[key] == l1[key]) else: assert_array_almost_equal(l1[key], l2[key], 4) + + +def test_grow_labels(): + """Test generation of circular source labels""" + seeds = [0, 50000] + hemis = [0, 1] + labels = grow_labels('sample', seeds, 3, hemis) + + for label, seed, hemi in zip(labels, seeds, hemis): + assert(np.any(label['vertices'] == seed)) + if hemi == 0: + assert(label['hemi'] == 'lh') + else: + assert(label['hemi'] == 'rh') -- 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
