本文整理汇总了Python中mne.io.Raw.info['bads']方法的典型用法代码示例。如果您正苦于以下问题:Python Raw.info['bads']方法的具体用法?Python Raw.info['bads']怎么用?Python Raw.info['bads']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mne.io.Raw
的用法示例。
在下文中一共展示了Raw.info['bads']方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"""
raw = Raw(raw_fname, allow_maxshield='yes').crop(0., 1., 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.)
示例2: _get_data
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info['bads'] [as 别名]
def _get_data():
# Read raw data
raw = Raw(raw_fname)
raw.info['bads'] = ['MEG 2443', 'EEG 053'] # 2 bads channels
# Set picks
picks = mne.pick_types(raw.info, meg=True, eeg=False, eog=False,
stim=False, exclude='bads')
# Read several epochs
event_id, tmin, tmax = 1, -0.2, 0.5
events = mne.read_events(event_fname)[0:100]
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=True,
picks=picks, baseline=(None, 0), preload=True,
reject=dict(grad=4000e-13, mag=4e-12))
# Create an epochs object with one epoch and one channel of artificial data
event_id, tmin, tmax = 1, 0.0, 1.0
epochs_sin = mne.Epochs(raw, events[0:5], event_id, tmin, tmax, proj=True,
picks=[0], baseline=(None, 0), preload=True,
reject=dict(grad=4000e-13))
freq = 10
epochs_sin._data = np.sin(2 * np.pi * freq
* epochs_sin.times)[None, None, :]
return epochs, epochs_sin
示例3: 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"""
raw = Raw(raw_fname, allow_maxshield='yes').crop(0., 1., 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.)
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), '')
raw_ctf = Raw(fname_ctf_raw)
assert_raises(ValueError, maxwell_filter, raw_ctf) # cannot fit headshape
raw_sss = maxwell_filter(raw_ctf, origin=(0., 0., 0.04))
_assert_n_free(raw_sss, 68)
raw_sss = maxwell_filter(raw_ctf, origin=(0., 0., 0.04), ignore_ref=True)
_assert_n_free(raw_sss, 70)
raw_missing = raw.crop(0, 0.1, copy=True).load_data().pick_channels(
[raw.ch_names[pi] for pi in pick_types(raw.info, meg=True,
exclude=())[3:]])
with warnings.catch_warnings(record=True) as w:
maxwell_filter(raw_missing, cross_talk=ctc_fname)
assert_equal(len(w), 1)
assert_true('Not all cross-talk channels in raw' in str(w[0].message))
# MEG channels not in cross-talk
assert_raises(RuntimeError, maxwell_filter, raw_ctf, origin=(0., 0., 0.04),
cross_talk=ctc_fname)
示例4: 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., 1., False)
raw.info['bads'] = bads
raw_sss = maxwell_filter(raw)
_assert_snr(raw_sss, Raw(sss_bad_recon_fname), 300.)
示例5: test_set_channel_types
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info['bads'] [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 type change
raw2 = Raw(raw_fname)
raw2.info['bads'] = ['EEG 059', 'EEG 060', 'EOG 061']
mapping = {'EEG 060': 'eog', 'EEG 059': 'ecg', 'EOG 061': 'seeg'}
raw2.set_channel_types(mapping)
info = raw2.info
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'][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'][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)
示例6: test_set_channel_types
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info['bads'] [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)
示例7: 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
示例8: test_spatiotemporal_only
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info['bads'] [as 别名]
def test_spatiotemporal_only():
"""Test tSSS-only processing"""
# Load raw testing data
raw = Raw(raw_fname,
allow_maxshield='yes').crop(0, 2, copy=False).load_data()
picks = pick_types(raw.info, meg='mag', exclude=())
power = np.sqrt(np.sum(raw[picks][0] ** 2))
# basics
raw_tsss = maxwell_filter(raw, st_duration=1., st_only=True)
assert_equal(raw_tsss.estimate_rank(), 366)
_assert_shielding(raw_tsss, power, 10)
# temporal proj will actually reduce spatial DOF with small windows!
raw_tsss = maxwell_filter(raw, st_duration=0.1, st_only=True)
assert_true(raw_tsss.estimate_rank() < 350)
_assert_shielding(raw_tsss, power, 40)
# with movement
head_pos = read_head_pos(pos_fname)
raw_tsss = maxwell_filter(raw, st_duration=1., st_only=True,
head_pos=head_pos)
assert_equal(raw_tsss.estimate_rank(), 366)
_assert_shielding(raw_tsss, power, 12)
with warnings.catch_warnings(record=True): # st_fixed False
raw_tsss = maxwell_filter(raw, st_duration=1., st_only=True,
head_pos=head_pos, st_fixed=False)
assert_equal(raw_tsss.estimate_rank(), 366)
_assert_shielding(raw_tsss, power, 12)
# should do nothing
raw_tsss = maxwell_filter(raw, st_duration=1., st_correlation=1.,
st_only=True)
assert_allclose(raw[:][0], raw_tsss[:][0])
# degenerate
assert_raises(ValueError, maxwell_filter, raw, st_only=True) # no ST
# two-step process equivalent to single-step process
raw_tsss = maxwell_filter(raw, st_duration=1., st_only=True)
raw_tsss = maxwell_filter(raw_tsss)
raw_tsss_2 = maxwell_filter(raw, st_duration=1.)
assert_meg_snr(raw_tsss, raw_tsss_2, 1e5)
# now also with head movement, and a bad MEG channel
assert_equal(len(raw.info['bads']), 0)
raw.info['bads'] = ['EEG001', 'MEG2623']
raw_tsss = maxwell_filter(raw, st_duration=1., st_only=True,
head_pos=head_pos)
assert_equal(raw.info['bads'], ['EEG001', 'MEG2623'])
assert_equal(raw_tsss.info['bads'], ['EEG001', 'MEG2623']) # don't reset
raw_tsss = maxwell_filter(raw_tsss, head_pos=head_pos)
assert_equal(raw_tsss.info['bads'], ['EEG001']) # do reset MEG bads
raw_tsss_2 = maxwell_filter(raw, st_duration=1., head_pos=head_pos)
assert_equal(raw_tsss_2.info['bads'], ['EEG001'])
assert_meg_snr(raw_tsss, raw_tsss_2, 1e5)
示例9: test_maxwell_filter_cross_talk
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info['bads'] [as 别名]
def test_maxwell_filter_cross_talk():
"""Test Maxwell filter cross-talk cancellation"""
with warnings.catch_warnings(record=True): # maxshield
raw = Raw(raw_fname, allow_maxshield=True).crop(0., 1., False)
raw.info['bads'] = bads
sss_ctc = Raw(sss_ctc_fname)
raw_sss = maxwell_filter(raw, cross_talk=ctc_fname)
_assert_snr(raw_sss, sss_ctc, 275.)
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), '')
示例10: 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)
info = pick_info(raw.info, picks_meg)
info._check_consistency()
info['bads'] += ['EEG 053']
assert_raises(RuntimeError, info._check_consistency)
info = pick_info(raw.info, picks_meg)
info._check_consistency()
info['ch_names'][0] += 'f'
assert_raises(RuntimeError, info._check_consistency)
info = pick_info(raw.info, picks_meg)
info._check_consistency()
info['nchan'] += 1
assert_raises(RuntimeError, info._check_consistency)
示例11: 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'])
示例12: test_bads_reconstruction
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info['bads'] [as 别名]
def test_bads_reconstruction():
"""Test reconstruction of channels marked as bad"""
with warnings.catch_warnings(record=True): # maxshield, naming
sss_bench = Raw(sss_bad_recon_fname, preload=True, proj=False,
allow_maxshield=True)
raw_fname = op.join(data_path, 'SSS', 'test_move_anon_raw.fif')
with warnings.catch_warnings(record=True): # maxshield
raw = Raw(raw_fname, preload=False, proj=False,
allow_maxshield=True).crop(0., 1., False)
raw.load_data()
# Set 30 random bad MEG channels (20 grad, 10 mag)
bads = ['MEG0912', 'MEG1722', 'MEG2213', 'MEG0132', 'MEG1312', 'MEG0432',
'MEG2433', 'MEG1022', 'MEG0442', 'MEG2332', 'MEG0633', 'MEG1043',
'MEG1713', 'MEG0422', 'MEG0932', 'MEG1622', 'MEG1343', 'MEG0943',
'MEG0643', 'MEG0143', 'MEG2142', 'MEG0813', 'MEG2143', 'MEG1323',
'MEG0522', 'MEG1123', 'MEG0423', 'MEG2122', 'MEG2532', 'MEG0812']
raw.info['bads'] = bads
# Compute Maxwell filtered data
raw_sss = maxwell.maxwell_filter(raw)
meg_chs = pick_types(raw_sss.info)
# Some numerical imprecision since save uses 'single' fmt
assert_allclose(raw_sss._data[meg_chs, :], sss_bench._data[meg_chs, :],
rtol=1e-12, atol=1e-4, err_msg='Maxwell filtered data '
'with reconstructed bads is incorrect.')
# Confirm SNR is above 1000
bench_rms = np.sqrt(np.mean(raw_sss._data[meg_chs, :] ** 2, axis=1))
error = raw_sss._data[meg_chs, :] - sss_bench._data[meg_chs, :]
error_rms = np.sqrt(np.mean(error ** 2, axis=1))
assert_true(np.mean(bench_rms / error_rms) >= 1000, 'SNR < 1000')
示例13: print
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info['bads'] [as 别名]
print(__doc__)
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif'
noise_fname = data_path + '/MEG/sample/ernoise_raw.fif'
event_fname = data_path + '/MEG/sample/sample_audvis_raw-eve.fif'
fname_fwd = data_path + '/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif'
subjects_dir = data_path + '/subjects'
label_name = 'Aud-lh'
fname_label = data_path + '/MEG/sample/labels/%s.label' % label_name
###############################################################################
# Read raw data, preload to allow filtering
raw = Raw(raw_fname, preload=True)
raw.info['bads'] = ['MEG 2443'] # 1 bad MEG channel
# Pick a selection of magnetometer channels. A subset of all channels was used
# to speed up the example. For a solution based on all MEG channels use
# meg=True, selection=None and add grad=4000e-13 to the reject dictionary.
left_temporal_channels = mne.read_selection('Left-temporal')
picks = mne.pick_types(raw.info, meg='mag', eeg=False, eog=False,
stim=False, exclude='bads',
selection=left_temporal_channels)
reject = dict(mag=4e-12)
# Setting time limits for reading epochs. Note that tmin and tmax are set so
# that time-frequency beamforming will be performed for a wider range of time
# points than will later be displayed on the final spectrogram. This ensures
# that all time bins displayed represent an average of an equal number of time
# windows.
示例14: Raw
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info['bads'] [as 别名]
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif'
event_fname = data_path + '/MEG/sample/sample_audvis_raw-eve.fif'
fname_fwd = data_path + '/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif'
fname_cov = data_path + '/MEG/sample/sample_audvis-cov.fif'
label_name = 'Aud-lh'
fname_label = data_path + '/MEG/sample/labels/%s.label' % label_name
###############################################################################
# Get epochs
event_id, tmin, tmax = 1, -0.2, 0.5
# Setup for reading the raw data
raw = Raw(raw_fname)
raw.info['bads'] = ['MEG 2443', 'EEG 053'] # 2 bads channels
events = mne.read_events(event_fname)
# Set up pick list: EEG + MEG - bad channels (modify to your needs)
left_temporal_channels = mne.read_selection('Left-temporal')
picks = mne.pick_types(raw.info, meg=True, eeg=False, stim=True, eog=True,
exclude='bads', selection=left_temporal_channels)
# Read epochs
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=True,
picks=picks, baseline=(None, 0), preload=True,
reject=dict(grad=4000e-13, mag=4e-12, eog=150e-6))
evoked = epochs.average()
forward = mne.read_forward_solution(fname_fwd, surf_ori=True)
示例15: print
# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import info['bads'] [as 别名]
from mne.datasets import sample
from mne.time_frequency import compute_epochs_csd
from mne.beamformer import dics_source_power
print(__doc__)
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif'
event_fname = data_path + '/MEG/sample/sample_audvis_raw-eve.fif'
fname_fwd = data_path + '/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif'
subjects_dir = data_path + '/subjects'
###############################################################################
# Read raw data
raw = Raw(raw_fname)
raw.info['bads'] = ['MEG 2443'] # 1 bad MEG channel
# Set picks
picks = mne.pick_types(raw.info, meg=True, eeg=False, eog=False,
stim=False, exclude='bads')
# Read epochs
event_id, tmin, tmax = 1, -0.2, 0.5
events = mne.read_events(event_fname)
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=True,
picks=picks, baseline=(None, 0), preload=True,
reject=dict(grad=4000e-13, mag=4e-12))
evoked = epochs.average()
# Read forward operator
forward = mne.read_forward_solution(fname_fwd, surf_ori=True)