[med-svn] [python-mne] 78/353: COSMIT: polish test_forward.py

Yaroslav Halchenko debian at onerussian.com
Fri Nov 27 17:24:34 UTC 2015


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 f3f71d81c8c61cac17cca4974d565c67b207476c
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date:   Wed Feb 8 21:06:59 2012 +0100

    COSMIT: polish test_forward.py
---
 mne/forward.py            |  4 ++--
 mne/tests/test_forward.py | 43 +++++++++++++------------------------------
 2 files changed, 15 insertions(+), 32 deletions(-)

diff --git a/mne/forward.py b/mne/forward.py
index ea178cd..88b8f62 100644
--- a/mne/forward.py
+++ b/mne/forward.py
@@ -473,8 +473,8 @@ def _fill_measurement_info(info, fwd, sfreq):
     info['bads'] = []
 
     info['filename'] = None
-    info['meas_id'] = None  #XXX is this the right thing to do?
-    info['file_id'] = None  #XXX is this the right thing to do?
+    info['meas_id'] = None  # XXX is this the right thing to do?
+    info['file_id'] = None  # XXX is this the right thing to do?
 
     now = time()
     sec = np.floor(now)
diff --git a/mne/tests/test_forward.py b/mne/tests/test_forward.py
index e28d66d..c235a51 100644
--- a/mne/tests/test_forward.py
+++ b/mne/tests/test_forward.py
@@ -4,11 +4,9 @@ import numpy as np
 from numpy.testing import assert_array_almost_equal, assert_equal
 
 from ..datasets import sample
-from ..fiff import Raw, Evoked, pick_types, pick_types_forward, \
-                   pick_channels_forward
+from ..fiff import Raw, Evoked, pick_types_forward
 from ..minimum_norm.inverse import _make_stc
-from .. import read_forward_solution, apply_forward, apply_forward_raw,\
-               SourceEstimate
+from .. import read_forward_solution, apply_forward, apply_forward_raw
 
 
 examples_folder = op.join(op.dirname(__file__), '..', '..', 'examples')
@@ -26,10 +24,15 @@ def test_io_forward():
     """Test IO for forward solutions
     """
     fwd = read_forward_solution(fname)
-    fwd = read_forward_solution(fname, force_fixed=True)
     fwd = read_forward_solution(fname, surf_ori=True)
     leadfield = fwd['sol']['data']
-    # XXX : test something
+    assert_equal(leadfield.shape, (306, 22494))
+    assert_equal(len(fwd['sol']['row_names']), 306)
+
+    fwd = read_forward_solution(fname, force_fixed=True)
+    leadfield = fwd['sol']['data']
+    assert_equal(leadfield.shape, (306, 22494 / 3))
+    assert_equal(len(fwd['sol']['row_names']), 306)
 
 
 def test_apply_forward():
@@ -48,46 +51,26 @@ def test_apply_forward():
     stc_data = np.ones((len(vertno[0]) + len(vertno[1]), n_times))
     stc = _make_stc(stc_data, t_start, 1.0 / sfreq, vertno)
 
-    evoked = Evoked(fname_evoked, setno=0)
+    gain_sum = np.sum(fwd['sol']['data'], axis=1)
 
+    # Evoked
+    evoked = Evoked(fname_evoked, setno=0)
     evoked = apply_forward(fwd, stc, evoked, start=start, stop=stop)
 
     data = evoked.data
     times = evoked.times
 
-    gain_sum = np.sum(fwd['sol']['data'], axis=1)
-
     # do some tests
     assert_array_almost_equal(evoked.info['sfreq'], sfreq)
     assert_array_almost_equal(np.sum(data, axis=1), n_times * gain_sum)
     assert_array_almost_equal(times[0], t_start)
     assert_array_almost_equal(times[-1], t_start + (n_times - 1) / sfreq)
 
-
-def test_apply_forward_raw():
-    """Test projection of source space data to sensor space (Raw)
-    """
-    start = 0
-    stop = 5
-    n_times = stop - start - 1
-    sfreq = 10.0
-    t_start = 0.123
-
-    fwd = read_forward_solution(fname, force_fixed=True)
-    fwd = pick_types_forward(fwd, meg=True)
-
-    vertno = [fwd['src'][0]['vertno'], fwd['src'][1]['vertno']]
-    stc_data = np.ones((len(vertno[0]) + len(vertno[1]), n_times))
-    stc = _make_stc(stc_data, t_start, 1.0 / sfreq, vertno)
-
+    # Raw
     raw = Raw(fname_raw)
-
     raw_proj = apply_forward_raw(fwd, stc, raw, start=start, stop=stop)
-
     data, times = raw_proj[:, :]
 
-    gain_sum = np.sum(fwd['sol']['data'], axis=1)
-
     # do some tests
     assert_array_almost_equal(raw_proj.info['sfreq'], sfreq)
     assert_array_almost_equal(np.sum(data, axis=1), n_times * gain_sum)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-mne.git



More information about the debian-med-commit mailing list