<s> import os <EOL> import warnings <EOL> import numpy as np <EOL> from numpy . testing import assert_allclose , assert_array_equal <EOL> from nose . tools import assert_true , assert_false , assert_equal <EOL> import mne <EOL> from mne . io . kit . tests import data_dir as kit_data_dir <EOL> from mne . io import Raw <EOL> from mne . utils import _TempDir , requires_traits , run_tests_if_main <EOL> mrk_pre_path = os . path . join ( kit_data_dir , '<STR_LIT>' ) <EOL> mrk_post_path = os . path . join ( kit_data_dir , '<STR_LIT>' ) <EOL> sqd_path = os . path . join ( kit_data_dir , '<STR_LIT>' ) <EOL> hsp_path = os . path . join ( kit_data_dir , '<STR_LIT>' ) <EOL> fid_path = os . path . join ( kit_data_dir , '<STR_LIT>' ) <EOL> fif_path = os . path . join ( kit_data_dir , '<STR_LIT>' ) <EOL> warnings . simplefilter ( '<STR_LIT>' ) <EOL> @ requires_traits <EOL> def test_kit2fiff_model ( ) : <EOL> """<STR_LIT>""" <EOL> from mne . gui . _kit2fiff_gui import Kit2FiffModel , Kit2FiffPanel <EOL> tempdir = _TempDir ( ) <EOL> tgt_fname = os . path . join ( tempdir , '<STR_LIT>' ) <EOL> model = Kit2FiffModel ( ) <EOL> assert_false ( model . can_save ) <EOL> model . markers . mrk1 . file = mrk_pre_path <EOL> model . markers . mrk2 . file = mrk_post_path <EOL> model . sqd_file = sqd_path <EOL> model . hsp_file = hsp_path <EOL> assert_false ( model . can_save ) <EOL> model . fid_file = fid_path <EOL> assert_true ( model . can_save ) <EOL> model . stim_chs = "<STR_LIT>" <EOL> assert_array_equal ( model . stim_chs_array , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert_true ( model . stim_chs_ok ) <EOL> model . stim_chs = "<STR_LIT>" <EOL> assert_false ( model . stim_chs_ok ) <EOL> assert_false ( model . can_save ) <EOL> model . stim_chs = "<STR_LIT>" <EOL> assert_true ( model . can_save ) <EOL> raw_out = model . get_raw ( ) <EOL> raw_out . save ( tgt_fname ) <EOL> raw = Raw ( tgt_fname ) <EOL> raw_bin = Raw ( fif_path ) <EOL> trans_bin = raw . info [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> want_keys = list ( raw_bin . info . keys ( ) ) <EOL> assert_equal ( sorted ( want_keys ) , sorted ( list ( raw . info . keys ( ) ) ) ) <EOL> trans_transform = raw_bin . info [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> assert_allclose ( trans_transform , trans_bin , <NUM_LIT:0.1> ) <EOL> model . markers . mrk3 . method = "<STR_LIT>" <EOL> trans_avg = model . dev_head_trans <EOL> assert_false ( np . all ( trans_avg == trans_transform ) ) <EOL> assert_allclose ( trans_avg , trans_bin , <NUM_LIT:0.1> ) <EOL> model . markers . mrk3 . method = "<STR_LIT>" <EOL> model . use_mrk = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] <EOL> assert_false ( np . all ( model . dev_head_trans == trans_transform ) ) <EOL> assert_false ( np . all ( model . dev_head_trans == trans_avg ) ) <EOL> assert_false ( np . all ( model . dev_head_trans == np . eye ( <NUM_LIT:4> ) ) ) <EOL> model . stim_slope = '<STR_LIT:+>' <EOL> events_bin = mne . find_events ( raw_bin , stim_channel = '<STR_LIT>' ) <EOL> model . stim_coding = '<STR_LIT:<>' <EOL> raw = model . get_raw ( ) <EOL> events = mne . find_events ( raw , stim_channel = '<STR_LIT>' ) <EOL> assert_array_equal ( events , events_bin ) <EOL> events_rev = events_bin . copy ( ) <EOL> events_rev [ : , <NUM_LIT:2> ] = <NUM_LIT:1> <EOL> model . stim_coding = '<STR_LIT:>>' <EOL> raw = model . get_raw ( ) <EOL> events = mne . find_events ( raw , stim_channel = '<STR_LIT>' ) <EOL> assert_array_equal ( events , events_rev ) <EOL> model . stim_coding = '<STR_LIT>' <EOL> model . stim_chs = "<STR_LIT>" <EOL> raw = model . get_raw ( ) <EOL> events = mne . find_events ( raw , stim_channel = '<STR_LIT>' ) <EOL> assert_array_equal ( events , events_bin + [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:32> ] ) <EOL> model . clear_all ( ) <EOL> assert_equal ( model . use_mrk , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) <EOL> assert_equal ( model . sqd_file , "<STR_LIT>" ) <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT:true>' <EOL> try : <EOL> with warnings . catch_warnings ( record = True ) : <EOL> warnings . simplefilter ( '<STR_LIT>' ) <EOL> Kit2FiffPanel ( ) <EOL> finally : <EOL> del os . environ [ '<STR_LIT>' ] <EOL> run_tests_if_main ( ) </s>
