本文整理汇总了Python中mne.Epochs.anonymize方法的典型用法代码示例。如果您正苦于以下问题:Python Epochs.anonymize方法的具体用法?Python Epochs.anonymize怎么用?Python Epochs.anonymize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mne.Epochs
的用法示例。
在下文中一共展示了Epochs.anonymize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_anonymize
# 需要导入模块: from mne import Epochs [as 别名]
# 或者: from mne.Epochs import anonymize [as 别名]
def test_anonymize():
"""Test that sensitive information can be anonymized."""
pytest.raises(TypeError, anonymize_info, 'foo')
# Fake some subject data
raw = read_raw_fif(raw_fname)
raw.set_annotations(Annotations(onset=[0, 1],
duration=[1, 1],
description='dummy',
orig_time=None))
raw.info['subject_info'] = dict(id=1, his_id='foobar', last_name='bar',
first_name='bar', birthday=(1987, 4, 8),
sex=0, hand=1)
# Test no error for incomplete info
info = raw.info.copy()
info.pop('file_id')
anonymize_info(info)
# Test instance method
events = read_events(event_name)
epochs = Epochs(raw, events[:1], 2, 0., 0.1)
assert not any(_is_anonymous(raw))
raw.anonymize()
assert all(_is_anonymous(raw))
assert not any(_is_anonymous(epochs)[:-1]) # epochs has no annotations
epochs.anonymize()
assert all(_is_anonymous(epochs)[:-1])
# When we write out with raw.save, these get overwritten with the
# new save time
tempdir = _TempDir()
out_fname = op.join(tempdir, 'test_subj_info_raw.fif')
raw.save(out_fname, overwrite=True)
assert all(_is_anonymous(read_raw_fif(out_fname)))