本文整理汇总了Python中mne.io.Raw.info['chs'][0]['unit']方法的典型用法代码示例。如果您正苦于以下问题:Python Raw.info['chs'][0]['unit']方法的具体用法?Python Raw.info['chs'][0]['unit']怎么用?Python Raw.info['chs'][0]['unit']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mne.io.Raw
的用法示例。
在下文中一共展示了Raw.info['chs'][0]['unit']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_channel_types
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info['chs'][0]['unit'] [as 别名]
def test_set_channel_types():
"""Test set_channel_types
"""
raw = Raw(raw_fname)
# Error Tests
# Test channel name exists in ch_names
mapping = {'EEG 160': 'EEG060'}
assert_raises(ValueError, raw.set_channel_types, mapping)
# Test change to illegal channel type
mapping = {'EOG 061': 'xxx'}
assert_raises(ValueError, raw.set_channel_types, mapping)
# Test changing type if in proj (avg eeg ref here)
mapping = {'EEG 058': 'ecog', 'EEG 059': 'ecg', 'EEG 060': 'eog',
'EOG 061': 'seeg', 'MEG 2441': 'eeg', 'MEG 2443': 'eeg'}
assert_raises(RuntimeError, raw.set_channel_types, mapping)
# Test type change
raw2 = Raw(raw_fname, add_eeg_ref=False)
raw2.info['bads'] = ['EEG 059', 'EEG 060', 'EOG 061']
with warnings.catch_warnings(record=True): # MEG channel change
assert_raises(RuntimeError, raw2.set_channel_types, mapping) # has prj
raw2.add_proj([], remove_existing=True)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
raw2.set_channel_types(mapping)
assert_true(len(w) >= 1, msg=[str(ww.message) for ww in w])
assert_true(all('The unit for channel' in str(ww.message) for ww in w))
info = raw2.info
assert_true(info['chs'][372]['ch_name'] == 'EEG 058')
assert_true(info['chs'][372]['kind'] == FIFF.FIFFV_ECOG_CH)
assert_true(info['chs'][372]['unit'] == FIFF.FIFF_UNIT_V)
assert_true(info['chs'][372]['coil_type'] == FIFF.FIFFV_COIL_EEG)
assert_true(info['chs'][373]['ch_name'] == 'EEG 059')
assert_true(info['chs'][373]['kind'] == FIFF.FIFFV_ECG_CH)
assert_true(info['chs'][373]['unit'] == FIFF.FIFF_UNIT_V)
assert_true(info['chs'][373]['coil_type'] == FIFF.FIFFV_COIL_NONE)
assert_true(info['chs'][374]['ch_name'] == 'EEG 060')
assert_true(info['chs'][374]['kind'] == FIFF.FIFFV_EOG_CH)
assert_true(info['chs'][374]['unit'] == FIFF.FIFF_UNIT_V)
assert_true(info['chs'][374]['coil_type'] == FIFF.FIFFV_COIL_NONE)
assert_true(info['chs'][375]['ch_name'] == 'EOG 061')
assert_true(info['chs'][375]['kind'] == FIFF.FIFFV_SEEG_CH)
assert_true(info['chs'][375]['unit'] == FIFF.FIFF_UNIT_V)
assert_true(info['chs'][375]['coil_type'] == FIFF.FIFFV_COIL_EEG)
for idx in pick_channels(raw.ch_names, ['MEG 2441', 'MEG 2443']):
assert_true(info['chs'][idx]['kind'] == FIFF.FIFFV_EEG_CH)
assert_true(info['chs'][idx]['unit'] == FIFF.FIFF_UNIT_V)
assert_true(info['chs'][idx]['coil_type'] == FIFF.FIFFV_COIL_EEG)
# Test meaningful error when setting channel type with unknown unit
raw.info['chs'][0]['unit'] = 0.
ch_types = {raw.ch_names[0]: 'misc'}
assert_raises(ValueError, raw.set_channel_types, ch_types)