1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
# Authors: Christian Brodbeck <christianbrodbeck@nyu.edu>
#
# License: BSD (3-clause)
import os
import sys
from unittest import SkipTest
import numpy as np
from numpy.testing import assert_array_equal
from mne.io.kit.tests import data_dir as kit_data_dir
from mne.io.kit import read_mrk
from mne.utils import (_TempDir, requires_mayavi, run_tests_if_main,
traits_test)
mrk_pre_path = os.path.join(kit_data_dir, 'test_mrk_pre.sqd')
mrk_post_path = os.path.join(kit_data_dir, 'test_mrk_post.sqd')
mrk_avg_path = os.path.join(kit_data_dir, 'test_mrk.sqd')
def _check_ci():
if os.getenv('TRAVIS', 'false').lower() == 'true' and \
sys.platform == 'darwin':
raise SkipTest('Skipping GUI tests on Travis OSX')
@requires_mayavi
@traits_test
def test_combine_markers_model():
"""Test CombineMarkersModel Traits Model."""
from mne.gui._marker_gui import CombineMarkersModel, CombineMarkersPanel
tempdir = _TempDir()
tgt_fname = os.path.join(tempdir, 'test.txt')
model = CombineMarkersModel()
# set one marker file
assert not model.mrk3.can_save
model.mrk1.file = mrk_pre_path
assert model.mrk3.can_save
assert_array_equal(model.mrk3.points, model.mrk1.points)
# setting second marker file
model.mrk2.file = mrk_pre_path
assert_array_equal(model.mrk3.points, model.mrk1.points)
# set second marker
model.mrk2.clear = True
model.mrk2.file = mrk_post_path
assert np.any(model.mrk3.points)
points_interpolate_mrk1_mrk2 = model.mrk3.points
# change interpolation method
model.mrk3.method = 'Average'
mrk_avg = read_mrk(mrk_avg_path)
assert_array_equal(model.mrk3.points, mrk_avg)
# clear second marker
model.mrk2.clear = True
assert_array_equal(model.mrk1.points, model.mrk3.points)
# I/O
model.mrk2.file = mrk_post_path
model.mrk3.save(tgt_fname)
mrk_io = read_mrk(tgt_fname)
assert_array_equal(mrk_io, model.mrk3.points)
# exclude an individual marker
model.mrk1.use = [1, 2, 3, 4]
assert_array_equal(model.mrk3.points[0], model.mrk2.points[0])
assert_array_equal(model.mrk3.points[1:], mrk_avg[1:])
# reset model
model.clear = True
model.mrk1.file = mrk_pre_path
model.mrk2.file = mrk_post_path
assert_array_equal(model.mrk3.points, points_interpolate_mrk1_mrk2)
_check_ci()
os.environ['_MNE_GUI_TESTING_MODE'] = 'true'
try:
CombineMarkersPanel()
finally:
del os.environ['_MNE_GUI_TESTING_MODE']
run_tests_if_main()
|