本文整理汇总了Python中mne.io.Raw.info["bads"]方法的典型用法代码示例。如果您正苦于以下问题:Python Raw.info["bads"]方法的具体用法?Python Raw.info["bads"]怎么用?Python Raw.info["bads"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mne.io.Raw
的用法示例。
在下文中一共展示了Raw.info["bads"]方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bads_reconstruction
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info["bads"] [as 别名]
def test_bads_reconstruction():
"""Test Maxwell filter reconstruction of bad channels"""
with warnings.catch_warnings(record=True): # maxshield
raw = Raw(raw_fname, allow_maxshield=True).crop(0.0, 1.0, False)
raw.info["bads"] = bads
raw_sss = maxwell_filter(raw, origin=mf_head_origin, regularize=None, bad_condition="ignore")
assert_meg_snr(raw_sss, Raw(sss_bad_recon_fname), 300.0)
示例2: test_clean_info_bads
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info["bads"] [as 别名]
def test_clean_info_bads():
"""Test cleaning info['bads'] when bad_channels are excluded """
raw_file = op.join(op.dirname(__file__), "io", "tests", "data", "test_raw.fif")
raw = Raw(raw_file)
# select eeg channels
picks_eeg = pick_types(raw.info, meg=False, eeg=True)
# select 3 eeg channels as bads
idx_eeg_bad_ch = picks_eeg[[1, 5, 14]]
eeg_bad_ch = [raw.info["ch_names"][k] for k in idx_eeg_bad_ch]
# select meg channels
picks_meg = pick_types(raw.info, meg=True, eeg=False)
# select randomly 3 meg channels as bads
idx_meg_bad_ch = picks_meg[[0, 15, 34]]
meg_bad_ch = [raw.info["ch_names"][k] for k in idx_meg_bad_ch]
# simulate the bad channels
raw.info["bads"] = eeg_bad_ch + meg_bad_ch
# simulate the call to pick_info excluding the bad eeg channels
info_eeg = pick_info(raw.info, picks_eeg)
# simulate the call to pick_info excluding the bad meg channels
info_meg = pick_info(raw.info, picks_meg)
assert_equal(info_eeg["bads"], eeg_bad_ch)
assert_equal(info_meg["bads"], meg_bad_ch)
示例3: test_clean_eog_ecg
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info["bads"] [as 别名]
def test_clean_eog_ecg():
"""Test mne clean_eog_ecg"""
check_usage(mne_clean_eog_ecg)
tempdir = _TempDir()
raw = Raw([raw_fname, raw_fname, raw_fname])
raw.info["bads"] = ["MEG 2443"]
use_fname = op.join(tempdir, op.basename(raw_fname))
raw.save(use_fname)
with ArgvSetter(("-i", use_fname, "--quiet")):
mne_clean_eog_ecg.run()
fnames = glob.glob(op.join(tempdir, "*proj.fif"))
assert_true(len(fnames) == 2) # two projs
fnames = glob.glob(op.join(tempdir, "*-eve.fif"))
assert_true(len(fnames) == 3) # raw plus two projs
示例4: test_cross_talk
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info["bads"] [as 别名]
def test_cross_talk():
"""Test Maxwell filter cross-talk cancellation"""
with warnings.catch_warnings(record=True): # maxshield
raw = Raw(raw_fname, allow_maxshield=True).crop(0.0, 1.0, False)
raw.info["bads"] = bads
sss_ctc = Raw(sss_ctc_fname)
raw_sss = maxwell_filter(raw, cross_talk=ctc_fname, origin=mf_head_origin, regularize=None, bad_condition="ignore")
assert_meg_snr(raw_sss, sss_ctc, 275.0)
py_ctc = raw_sss.info["proc_history"][0]["max_info"]["sss_ctc"]
assert_true(len(py_ctc) > 0)
assert_raises(ValueError, maxwell_filter, raw, cross_talk=raw)
assert_raises(ValueError, maxwell_filter, raw, cross_talk=raw_fname)
mf_ctc = sss_ctc.info["proc_history"][0]["max_info"]["sss_ctc"]
del mf_ctc["block_id"] # we don't write this
assert_equal(object_diff(py_ctc, mf_ctc), "")
示例5: test_load_bad_channels
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info["bads"] [as 别名]
def test_load_bad_channels():
"""Test reading/writing of bad channels
"""
tempdir = _TempDir()
# Load correctly marked file (manually done in mne_process_raw)
raw_marked = Raw(fif_bad_marked_fname)
correct_bads = raw_marked.info["bads"]
raw = Raw(test_fif_fname)
# Make sure it starts clean
assert_array_equal(raw.info["bads"], [])
# Test normal case
raw.load_bad_channels(bad_file_works)
# Write it out, read it in, and check
raw.save(op.join(tempdir, "foo_raw.fif"))
raw_new = Raw(op.join(tempdir, "foo_raw.fif"))
assert_equal(correct_bads, raw_new.info["bads"])
# Reset it
raw.info["bads"] = []
# Test bad case
assert_raises(ValueError, raw.load_bad_channels, bad_file_wrong)
# Test forcing the bad case
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
raw.load_bad_channels(bad_file_wrong, force=True)
n_found = sum(["1 bad channel" in str(ww.message) for ww in w])
assert_equal(n_found, 1) # there could be other irrelevant errors
# write it out, read it in, and check
raw.save(op.join(tempdir, "foo_raw.fif"), overwrite=True)
raw_new = Raw(op.join(tempdir, "foo_raw.fif"))
assert_equal(correct_bads, raw_new.info["bads"])
# Check that bad channels are cleared
raw.load_bad_channels(None)
raw.save(op.join(tempdir, "foo_raw.fif"), overwrite=True)
raw_new = Raw(op.join(tempdir, "foo_raw.fif"))
assert_equal([], raw_new.info["bads"])
示例6: print
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info["bads"] [as 别名]
from mne.io import Raw, read_info
from mne.datasets import sample
from mne.time_frequency import fit_iir_model_raw
from mne.viz import plot_sparse_source_estimates
from mne.simulation import simulate_sparse_stc, simulate_evoked
print(__doc__)
###############################################################################
# Load real data as templates
data_path = sample.data_path()
raw = Raw(data_path + "/MEG/sample/sample_audvis_raw.fif")
proj = read_proj(data_path + "/MEG/sample/sample_audvis_ecg_proj.fif")
raw.info["projs"] += proj
raw.info["bads"] = ["MEG 2443", "EEG 053"] # mark bad channels
fwd_fname = data_path + "/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif"
ave_fname = data_path + "/MEG/sample/sample_audvis-no-filter-ave.fif"
cov_fname = data_path + "/MEG/sample/sample_audvis-cov.fif"
fwd = read_forward_solution(fwd_fname, force_fixed=True, surf_ori=True)
fwd = pick_types_forward(fwd, meg=True, eeg=True, exclude=raw.info["bads"])
cov = read_cov(cov_fname)
info = read_info(ave_fname)
label_names = ["Aud-lh", "Aud-rh"]
labels = [read_label(data_path + "/MEG/sample/labels/%s.label" % ln) for ln in label_names]
###############################################################################
# Generate source time courses from 2 dipoles and the correspond evoked data