def test_read_write_info(): """Test IO of info """ info = fiff.read_info(raw_fname) temp_file = op.join(tempdir, "info.fif") fiff.write_info(temp_file, info) info2 = fiff.read_info(temp_file) assert_true(len(info["chs"]) == len(info2["chs"]))
def test_read_write_info(): """Test IO of info """ info = fiff.read_info(raw_fname) temp_file = op.join(tempdir, 'info.fif') fiff.write_info(temp_file, info) info2 = fiff.read_info(temp_file) assert_true(len(info['chs']) == len(info2['chs']))
def test_read_write_info(): """Test IO of info """ info = fiff.read_info(raw_fname) temp_file = op.join(tempdir, 'info.fif') # check for bug `#1198` info['dev_head_t']['trans'] = np.eye(4) t1 = info['dev_head_t']['trans'] fiff.write_info(temp_file, info) info2 = fiff.read_info(temp_file) t2 = info2['dev_head_t']['trans'] assert_true(len(info['chs']) == len(info2['chs'])) assert_array_equal(t1, t2)
def test_eeg_field_interpolation(): """Test interpolation of EEG field onto head """ trans = read_trans(trans_fname) info = read_info(evoked_fname) surf = get_head_surface('sample', subjects_dir=subjects_dir) # we must have trans if surface is in MRI coords assert_raises(ValueError, make_surface_mapping, info, surf, 'eeg') data = make_surface_mapping(info, surf, 'eeg', trans, mode='accurate') assert_array_equal(data.shape, (2562, 60)) # maps data onto surf
def test_rename_channels(): """Test rename channels """ info = fiff.read_info(raw_fname) # Error Tests # Test channel name exists in ch_names mapping = {'EEG 160': 'EEG060'} assert_raises(ValueError, rename_channels, info, mapping) # Test change to EEG channel mapping = {'EOG 061': ('EEG 061', 'eeg')} assert_raises(ValueError, rename_channels, info, mapping) # Test change to illegal channel type mapping = {'EOG 061': ('MEG 061', 'meg')} assert_raises(ValueError, rename_channels, info, mapping) # Test channel type which you are changing from e.g. MEG mapping = {'MEG 2641': ('MEG2641', 'eeg')} assert_raises(ValueError, rename_channels, info, mapping) # Test improper mapping configuration mapping = {'MEG 2641': 1.0} assert_raises(ValueError, rename_channels, info, mapping) # Test duplicate named channels mapping = {'EEG 060': 'EOG 061'} assert_raises(ValueError, rename_channels, info, mapping) # Test successful changes # Test ch_name and ch_names are changed info2 = deepcopy(info) # for consistency at the start of each test info2['bads'] = ['EEG 060', 'EOG 061'] mapping = {'EEG 060': 'EEG060', 'EOG 061': 'EOG061'} rename_channels(info2, mapping) assert_true(info2['chs'][374]['ch_name'] == 'EEG060') assert_true(info2['ch_names'][374] == 'EEG060') assert_true('EEG060' in info2['bads']) assert_true(info2['chs'][375]['ch_name'] == 'EOG061') assert_true(info2['ch_names'][375] == 'EOG061') assert_true('EOG061' in info2['bads']) # Test type change info2 = deepcopy(info) info2['bads'] = ['EEG 060', 'EEG 059'] mapping = {'EEG 060': ('EOG 060', 'eog'), 'EEG 059': ('EOG 059', 'eog')} rename_channels(info2, mapping) assert_true(info2['chs'][374]['ch_name'] == 'EOG 060') assert_true(info2['ch_names'][374] == 'EOG 060') assert_true('EOG 060' in info2['bads']) assert_true(info2['chs'][374]['kind'] is FIFF.FIFFV_EOG_CH) assert_true(info2['chs'][373]['ch_name'] == 'EOG 059') assert_true(info2['ch_names'][373] == 'EOG 059') assert_true('EOG 059' in info2['bads']) assert_true(info2['chs'][373]['kind'] is FIFF.FIFFV_EOG_CH)
def test_helmet(): """Test loading helmet surfaces """ base_dir = op.join(op.dirname(__file__), '..', 'fiff') fname_raw = op.join(base_dir, 'tests', 'data', 'test_raw.fif') fname_kit_raw = op.join(base_dir, 'kit', 'tests', 'data', 'test_bin.fif') fname_bti_raw = op.join(base_dir, 'bti', 'tests', 'data', 'exported4D_linux.fif') fname_ctf_raw = op.join(base_dir, 'tests', 'data', 'test_ctf_raw.fif') fname_trans = op.join(base_dir, 'tests', 'data', 'sample-audvis-raw-trans.txt') trans = _get_mri_head_t_from_trans_file(fname_trans) for fname in [fname_raw, fname_kit_raw, fname_bti_raw, fname_ctf_raw]: helmet = get_meg_helmet_surf(read_info(fname), trans) assert_equal(len(helmet['rr']), 304) # they all have 304 verts assert_equal(len(helmet['rr']), len(helmet['nn']))