当前位置: 首页>>代码示例>>Python>>正文


Python Epochs.drop_channels方法代码示例

本文整理汇总了Python中mne.Epochs.drop_channels方法的典型用法代码示例。如果您正苦于以下问题:Python Epochs.drop_channels方法的具体用法?Python Epochs.drop_channels怎么用?Python Epochs.drop_channels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mne.Epochs的用法示例。


在下文中一共展示了Epochs.drop_channels方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_drop_channels_mixin

# 需要导入模块: from mne import Epochs [as 别名]
# 或者: from mne.Epochs import drop_channels [as 别名]
def test_drop_channels_mixin():
    """Test channels-dropping functionality
    """
    epochs = Epochs(raw, events, event_id, tmin, tmax, picks=picks, baseline=(None, 0))
    drop_ch = epochs.ch_names[:3]
    ch_names = epochs.ch_names[3:]
    epochs.drop_channels(drop_ch)
    assert_equal(ch_names, epochs.ch_names)
    assert_equal(len(ch_names), epochs.get_data().shape[1])
开发者ID:NeedlessToSay,项目名称:mne-python,代码行数:11,代码来源:test_epochs.py

示例2: test_equalize_channels

# 需要导入模块: from mne import Epochs [as 别名]
# 或者: from mne.Epochs import drop_channels [as 别名]
def test_equalize_channels():
    """Test equalization of channels
    """
    epochs1 = Epochs(raw, events, event_id, tmin, tmax, picks=picks, baseline=(None, 0), proj=False)
    epochs2 = epochs1.copy()
    ch_names = epochs1.ch_names[2:]
    epochs1.drop_channels(epochs1.ch_names[:1])
    epochs2.drop_channels(epochs2.ch_names[1:2])
    my_comparison = [epochs1, epochs2]
    equalize_channels(my_comparison)
    for e in my_comparison:
        assert_equal(ch_names, e.ch_names)
开发者ID:rgoj,项目名称:mne-python,代码行数:14,代码来源:test_epochs.py

示例3: test_drop_channels_mixin

# 需要导入模块: from mne import Epochs [as 别名]
# 或者: from mne.Epochs import drop_channels [as 别名]
def test_drop_channels_mixin():
    """Test channels-dropping functionality
    """
    # here without picks to get additional coverage
    epochs = Epochs(raw, events, event_id, tmin, tmax, picks=None, baseline=(None, 0))
    drop_ch = epochs.ch_names[:3]
    ch_names = epochs.ch_names[3:]

    ch_names_orig = epochs.ch_names
    dummy = epochs.drop_channels(drop_ch, copy=True)
    assert_equal(ch_names, dummy.ch_names)
    assert_equal(ch_names_orig, epochs.ch_names)
    assert_equal(len(ch_names_orig), epochs.get_data().shape[1])

    epochs.drop_channels(drop_ch)
    assert_equal(ch_names, epochs.ch_names)
    assert_equal(len(ch_names), epochs.get_data().shape[1])
开发者ID:rgoj,项目名称:mne-python,代码行数:19,代码来源:test_epochs.py

示例4: test_read_write_epochs

# 需要导入模块: from mne import Epochs [as 别名]
# 或者: from mne.Epochs import drop_channels [as 别名]
def test_read_write_epochs():
    """Test epochs from raw files with IO as fif file
    """
    epochs = Epochs(raw, events, event_id, tmin, tmax, picks=picks, baseline=(None, 0))
    evoked = epochs.average()
    data = epochs.get_data()

    epochs_no_id = Epochs(raw, pick_events(events, include=event_id), None, tmin, tmax, picks=picks, baseline=(None, 0))
    assert_array_equal(data, epochs_no_id.get_data())

    eog_picks = pick_types(raw.info, meg=False, eeg=False, stim=False, eog=True, exclude="bads")
    eog_ch_names = [raw.ch_names[k] for k in eog_picks]
    epochs.drop_channels(eog_ch_names)
    assert_true(len(epochs.info["chs"]) == len(epochs.ch_names) == epochs.get_data().shape[1])
    data_no_eog = epochs.get_data()
    assert_true(data.shape[1] == (data_no_eog.shape[1] + len(eog_picks)))

    # test decim kwarg
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter("always")
        epochs_dec = Epochs(raw, events, event_id, tmin, tmax, picks=picks, baseline=(None, 0), decim=4)
        assert_equal(len(w), 1)

    data_dec = epochs_dec.get_data()
    assert_array_equal(data[:, :, epochs_dec._decim_idx], data_dec)

    evoked_dec = epochs_dec.average()
    assert_array_equal(evoked.data[:, epochs_dec._decim_idx], evoked_dec.data)

    n = evoked.data.shape[1]
    n_dec = evoked_dec.data.shape[1]
    n_dec_min = n // 4
    assert_true(n_dec_min <= n_dec <= n_dec_min + 1)
    assert_true(evoked_dec.info["sfreq"] == evoked.info["sfreq"] / 4)

    # test IO
    epochs.save(op.join(tempdir, "test-epo.fif"))
    epochs_read = read_epochs(op.join(tempdir, "test-epo.fif"))

    assert_array_almost_equal(epochs_read.get_data(), epochs.get_data())
    assert_array_equal(epochs_read.times, epochs.times)
    assert_array_almost_equal(epochs_read.average().data, evoked.data)
    assert_equal(epochs_read.proj, epochs.proj)
    bmin, bmax = epochs.baseline
    if bmin is None:
        bmin = epochs.times[0]
    if bmax is None:
        bmax = epochs.times[-1]
    baseline = (bmin, bmax)
    assert_array_almost_equal(epochs_read.baseline, baseline)
    assert_array_almost_equal(epochs_read.tmin, epochs.tmin, 2)
    assert_array_almost_equal(epochs_read.tmax, epochs.tmax, 2)
    assert_equal(epochs_read.event_id, epochs.event_id)

    epochs.event_id.pop("1")
    epochs.event_id.update({"a:a": 1})  # test allow for ':' in key
    epochs.save(op.join(tempdir, "foo-epo.fif"))
    epochs_read2 = read_epochs(op.join(tempdir, "foo-epo.fif"))
    assert_equal(epochs_read2.event_id, epochs.event_id)

    # add reject here so some of the epochs get dropped
    epochs = Epochs(raw, events, event_id, tmin, tmax, picks=picks, baseline=(None, 0), reject=reject)
    epochs.save(op.join(tempdir, "test-epo.fif"))
    # ensure bad events are not saved
    epochs_read3 = read_epochs(op.join(tempdir, "test-epo.fif"))
    assert_array_equal(epochs_read3.events, epochs.events)
    data = epochs.get_data()
    assert_true(epochs_read3.events.shape[0] == data.shape[0])

    # test copying loaded one (raw property)
    epochs_read4 = epochs_read3.copy()
    assert_array_almost_equal(epochs_read4.get_data(), data)
    # test equalizing loaded one (drop_log property)
    epochs_read4.equalize_event_counts(epochs.event_id)

    epochs.drop_epochs([1, 2], reason="can we recover orig ID?")
    epochs.save("test-epo.fif")
    epochs_read5 = read_epochs("test-epo.fif")
    assert_array_equal(epochs_read5.selection, epochs.selection)
    assert_array_equal(epochs_read5.drop_log, epochs.drop_log)

    # Test that one can drop channels on read file
    epochs_read5.drop_channels(epochs_read5.ch_names[:1])

    # test warnings on bad filenames
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter("always")
        epochs_badname = op.join(tempdir, "test-bad-name.fif.gz")
        epochs.save(epochs_badname)
        read_epochs(epochs_badname)
    assert_true(len(w) == 2)
开发者ID:rgoj,项目名称:mne-python,代码行数:93,代码来源:test_epochs.py


注:本文中的mne.Epochs.drop_channels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。