本文整理汇总了Python中mne.datasets.testing.data_path函数的典型用法代码示例。如果您正苦于以下问题:Python data_path函数的具体用法?Python data_path怎么用?Python data_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了data_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_eximia_nxe
def test_eximia_nxe():
"""Test reading Eximia NXE files"""
fname = op.join(data_path(), 'eximia', 'test_eximia.nxe')
raw = read_raw_eximia(fname, preload=True)
assert_true('RawEximia' in repr(raw))
_test_raw_reader(read_raw_eximia, fname=fname)
fname_mat = op.join(data_path(), 'eximia', 'test_eximia.mat')
mc = sio.loadmat(fname_mat)
m_data = mc['data']
m_header = mc['header']
assert_equal(raw._data.shape, m_data.shape)
assert_equal(m_header['Fs'][0, 0][0, 0], raw.info['sfreq'])
m_names = [x[0][0] for x in m_header['label'][0, 0]]
m_names = list(
map(lambda x: x.replace('GATE', 'GateIn').replace('TRIG', 'Trig'),
m_names))
assert_equal(raw.ch_names, m_names)
m_ch_types = [x[0][0] for x in m_header['chantype'][0, 0]]
m_ch_types = list(
map(lambda x: x.replace('unknown', 'stim').replace('trigger', 'stim'),
m_ch_types))
types_dict = {2: 'eeg', 3: 'stim', 202: 'eog'}
ch_types = [types_dict[raw.info['chs'][x]['kind']]
for x in range(len(raw.ch_names))]
assert_equal(ch_types, m_ch_types)
assert_array_equal(m_data, raw._data)
开发者ID:jdammers,项目名称:mne-python,代码行数:27,代码来源:test_eximia.py
示例2: test_io_egi_pns_mff_bug
def test_io_egi_pns_mff_bug():
"""Test importing EGI MFF with PNS data (BUG)."""
egi_fname_mff = op.join(data_path(), 'EGI', 'test_egi_pns_bug.mff')
with pytest.warns(RuntimeWarning, match='EGI PSG sample bug'):
raw = read_raw_egi(egi_fname_mff, include=None, preload=True,
verbose='warning')
egi_fname_mat = op.join(data_path(), 'EGI', 'test_egi_pns.mat')
mc = sio.loadmat(egi_fname_mat)
pns_chans = pick_types(raw.info, ecg=True, bio=True, emg=True)
pns_names = ['Resp. Temperature'[:15],
'Resp. Pressure',
'ECG',
'Body Position',
'Resp. Effort Chest'[:15],
'Resp. Effort Abdomen'[:15],
'EMG-Leg']
mat_names = [
'Resp_Temperature'[:15],
'Resp_Pressure',
'ECG',
'Body_Position',
'Resp_Effort_Chest'[:15],
'Resp_Effort_Abdomen'[:15],
'EMGLeg'
]
for ch_name, ch_idx, mat_name in zip(pns_names, pns_chans, mat_names):
print('Testing {}'.format(ch_name))
mc_key = [x for x in mc.keys() if mat_name in x][0]
cal = raw.info['chs'][ch_idx]['cal']
mat_data = mc[mc_key] * cal
mat_data[:, -1] = 0 # The MFF has one less sample, the last one
raw_data = raw[ch_idx][0]
assert_array_equal(mat_data, raw_data)
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:34,代码来源:test_egi.py
示例3: test_io_egi_mff
def test_io_egi_mff():
"""Test importing EGI MFF simple binary files."""
egi_fname_mff = op.join(data_path(), 'EGI', 'test_egi.mff')
raw = read_raw_egi(egi_fname_mff, include=None)
assert ('RawMff' in repr(raw))
include = ['DIN1', 'DIN2', 'DIN3', 'DIN4', 'DIN5', 'DIN7']
raw = _test_raw_reader(read_raw_egi, input_fname=egi_fname_mff,
include=include, channel_naming='EEG %03d')
assert_equal('eeg' in raw, True)
eeg_chan = [c for c in raw.ch_names if 'EEG' in c]
assert_equal(len(eeg_chan), 129)
picks = pick_types(raw.info, eeg=True)
assert_equal(len(picks), 129)
assert_equal('STI 014' in raw.ch_names, True)
events = find_events(raw, stim_channel='STI 014')
assert_equal(len(events), 8)
assert_equal(np.unique(events[:, 1])[0], 0)
assert (np.unique(events[:, 0])[0] != 0)
assert (np.unique(events[:, 2])[0] != 0)
pytest.raises(ValueError, read_raw_egi, egi_fname_mff, include=['Foo'],
preload=False)
pytest.raises(ValueError, read_raw_egi, egi_fname_mff, exclude=['Bar'],
preload=False)
for ii, k in enumerate(include, 1):
assert (k in raw.event_id)
assert (raw.event_id[k] == ii)
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:29,代码来源:test_egi.py
示例4: test_maxwell_filter_additional
def test_maxwell_filter_additional():
"""Test processing of Maxwell filtered data"""
# TODO: Future tests integrate with mne/io/tests/test_proc_history
# Load testing data (raw, SSS std origin, SSS non-standard origin)
data_path = op.join(testing.data_path(download=False))
file_name = 'test_move_anon'
raw_fname = op.join(data_path, 'SSS', file_name + '_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_sss = maxwell.maxwell_filter(raw)
# Test io on processed data
tempdir = _TempDir()
test_outname = op.join(tempdir, 'test_raw_sss.fif')
raw_sss.save(test_outname)
raw_sss_loaded = Raw(test_outname, preload=True, proj=False,
allow_maxshield=True)
# Some numerical imprecision since save uses 'single' fmt
assert_allclose(raw_sss_loaded._data[:, :], raw_sss._data[:, :],
rtol=1e-6, atol=1e-20)
开发者ID:emmanuelkalunga,项目名称:mne-python,代码行数:25,代码来源:test_maxwell.py
示例5: test_find_ch_connectivity
def test_find_ch_connectivity():
"""Test computing the connectivity matrix."""
data_path = testing.data_path()
raw = read_raw_fif(raw_fname, preload=True)
sizes = {'mag': 828, 'grad': 1700, 'eeg': 386}
nchans = {'mag': 102, 'grad': 204, 'eeg': 60}
for ch_type in ['mag', 'grad', 'eeg']:
conn, ch_names = find_ch_connectivity(raw.info, ch_type)
# Silly test for checking the number of neighbors.
assert_equal(conn.getnnz(), sizes[ch_type])
assert_equal(len(ch_names), nchans[ch_type])
pytest.raises(ValueError, find_ch_connectivity, raw.info, None)
# Test computing the conn matrix with gradiometers.
conn, ch_names = _compute_ch_connectivity(raw.info, 'grad')
assert_equal(conn.getnnz(), 2680)
# Test ch_type=None.
raw.pick_types(meg='mag')
find_ch_connectivity(raw.info, None)
bti_fname = op.join(data_path, 'BTi', 'erm_HFH', 'c,rfDC')
bti_config_name = op.join(data_path, 'BTi', 'erm_HFH', 'config')
raw = read_raw_bti(bti_fname, bti_config_name, None)
_, ch_names = find_ch_connectivity(raw.info, 'mag')
assert 'A1' in ch_names
ctf_fname = op.join(data_path, 'CTF', 'testdata_ctf_short.ds')
raw = read_raw_ctf(ctf_fname)
_, ch_names = find_ch_connectivity(raw.info, 'mag')
assert 'MLC11' in ch_names
pytest.raises(ValueError, find_ch_connectivity, raw.info, 'eog')
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:34,代码来源:test_channels.py
示例6: test_events_long
def test_events_long():
"""Test events."""
data_path = testing.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_trunc_raw.fif'
raw = read_raw_fif(raw_fname, preload=True)
raw_tmin, raw_tmax = 0, 90
tmin, tmax = -0.2, 0.5
event_id = dict(aud_l=1, vis_l=3)
# select gradiometers
picks = pick_types(raw.info, meg='grad', eeg=False, eog=True,
stim=True, exclude=raw.info['bads'])
# load data with usual Epochs for later verification
raw = concatenate_raws([raw, raw.copy(), raw.copy(), raw.copy(),
raw.copy(), raw.copy()])
assert 110 < raw.times[-1] < 130
raw_cropped = raw.copy().crop(raw_tmin, raw_tmax)
events_offline = find_events(raw_cropped)
epochs_offline = Epochs(raw_cropped, events_offline, event_id=event_id,
tmin=tmin, tmax=tmax, picks=picks, decim=1,
reject=dict(grad=4000e-13, eog=150e-6),
baseline=None)
epochs_offline.drop_bad()
# create the mock-client object
rt_client = MockRtClient(raw)
rt_epochs = RtEpochs(rt_client, event_id, tmin, tmax, picks=picks, decim=1,
reject=dict(grad=4000e-13, eog=150e-6), baseline=None,
isi_max=1.)
rt_epochs.start()
rt_client.send_data(rt_epochs, picks, tmin=raw_tmin, tmax=raw_tmax,
buffer_size=1000)
expected_events = epochs_offline.events.copy()
expected_events[:, 0] = expected_events[:, 0] - raw_cropped.first_samp
assert np.all(expected_events[:, 0] <=
(raw_tmax - tmax) * raw.info['sfreq'])
assert_array_equal(rt_epochs.events, expected_events)
assert len(rt_epochs) == len(epochs_offline)
data_picks = pick_types(epochs_offline.info, meg='grad', eeg=False,
eog=True,
stim=False, exclude=raw.info['bads'])
for ev_num, ev in enumerate(rt_epochs.iter_evoked()):
if ev_num == 0:
X_rt = ev.data[None, data_picks, :]
y_rt = int(ev.comment) # comment attribute contains the event_id
else:
X_rt = np.concatenate((X_rt, ev.data[None, data_picks, :]), axis=0)
y_rt = np.append(y_rt, int(ev.comment))
X_offline = epochs_offline.get_data()[:, data_picks, :]
y_offline = epochs_offline.events[:, 2]
assert_array_equal(X_rt, X_offline)
assert_array_equal(y_rt, y_offline)
开发者ID:SherazKhan,项目名称:mne-python,代码行数:59,代码来源:test_mockclient.py
示例7: test_interpolation_ctf_comp
def test_interpolation_ctf_comp():
"""Test interpolation with compensated CTF data."""
ctf_dir = op.join(testing.data_path(download=False), 'CTF')
raw_fname = op.join(ctf_dir, 'somMDYO-18av.ds')
raw = io.read_raw_ctf(raw_fname, preload=True)
raw.info['bads'] = [raw.ch_names[5], raw.ch_names[-5]]
raw.interpolate_bads(mode='fast')
assert raw.info['bads'] == []
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:8,代码来源:test_interpolation.py
示例8: test_io_egi_crop_no_preload
def test_io_egi_crop_no_preload():
"""Test crop non-preloaded EGI MFF data (BUG)."""
egi_fname_mff = op.join(data_path(), 'EGI', 'test_egi.mff')
raw = read_raw_egi(egi_fname_mff, preload=False)
raw.crop(17.5, 20.5)
raw.load_data()
raw_preload = read_raw_egi(egi_fname_mff, preload=True)
raw_preload.crop(17.5, 20.5)
raw_preload.load_data()
assert_allclose(raw._data, raw_preload._data)
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:10,代码来源:test_egi.py
示例9: test_inverse_ctf_comp
def test_inverse_ctf_comp():
"""Test interpolation with compensated CTF data."""
ctf_dir = op.join(testing.data_path(download=False), 'CTF')
raw_fname = op.join(ctf_dir, 'somMDYO-18av.ds')
raw = mne.io.read_raw_ctf(raw_fname)
raw.apply_gradient_compensation(1)
sphere = make_sphere_model()
cov = make_ad_hoc_cov(raw.info)
src = mne.setup_volume_source_space(
pos=dict(rr=[[0., 0., 0.01]], nn=[[0., 1., 0.]]))
fwd = make_forward_solution(raw.info, None, src, sphere, eeg=False)
inv = make_inverse_operator(raw.info, fwd, cov, loose=1.)
apply_inverse_raw(raw, inv, 1. / 9.)
开发者ID:teonbrooks,项目名称:mne-python,代码行数:13,代码来源:test_inverse.py
示例10: test_io_egi_pns_mff
def test_io_egi_pns_mff():
"""Test importing EGI MFF with PNS data."""
egi_fname_mff = op.join(data_path(), 'EGI', 'test_egi_pns.mff')
raw = read_raw_egi(egi_fname_mff, include=None, preload=True,
verbose='error')
assert ('RawMff' in repr(raw))
pns_chans = pick_types(raw.info, ecg=True, bio=True, emg=True)
assert_equal(len(pns_chans), 7)
names = [raw.ch_names[x] for x in pns_chans]
pns_names = ['Resp. Temperature'[:15],
'Resp. Pressure',
'ECG',
'Body Position',
'Resp. Effort Chest'[:15],
'Resp. Effort Abdomen'[:15],
'EMG-Leg']
_test_raw_reader(read_raw_egi, input_fname=egi_fname_mff,
channel_naming='EEG %03d', verbose='error')
assert_equal(names, pns_names)
mat_names = [
'Resp_Temperature'[:15],
'Resp_Pressure',
'ECG',
'Body_Position',
'Resp_Effort_Chest'[:15],
'Resp_Effort_Abdomen'[:15],
'EMGLeg'
]
egi_fname_mat = op.join(data_path(), 'EGI', 'test_egi_pns.mat')
mc = sio.loadmat(egi_fname_mat)
for ch_name, ch_idx, mat_name in zip(pns_names, pns_chans, mat_names):
print('Testing {}'.format(ch_name))
mc_key = [x for x in mc.keys() if mat_name in x][0]
cal = raw.info['chs'][ch_idx]['cal']
mat_data = mc[mc_key] * cal
raw_data = raw[ch_idx][0]
assert_array_equal(mat_data, raw_data)
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:38,代码来源:test_egi.py
示例11: test_eeglab_event_from_annot
def test_eeglab_event_from_annot():
"""Test all forms of obtaining annotations."""
base_dir = op.join(testing.data_path(download=False), 'EEGLAB')
raw_fname_mat = op.join(base_dir, 'test_raw.set')
raw_fname = raw_fname_mat
montage = op.join(base_dir, 'test_chans.locs')
event_id = {'rt': 1, 'square': 2}
raw1 = read_raw_eeglab(input_fname=raw_fname, montage=montage,
preload=False)
annotations = read_annotations(raw_fname)
assert len(raw1.annotations) == 154
raw1.set_annotations(annotations)
events_b, _ = events_from_annotations(raw1, event_id=event_id)
assert len(events_b) == 154
开发者ID:palday,项目名称:mne-python,代码行数:15,代码来源:test_eeglab.py
示例12: test_plot_ctf
def test_plot_ctf():
"""Test plotting of CTF evoked."""
ctf_dir = op.join(testing.data_path(download=False), 'CTF')
raw_fname = op.join(ctf_dir, 'testdata_ctf.ds')
raw = mne.io.read_raw_ctf(raw_fname, preload=True)
events = np.array([[200, 0, 1]])
event_id = 1
tmin, tmax = -0.1, 0.5 # start and end of an epoch in sec.
picks = mne.pick_types(raw.info, meg=True, stim=True, eog=True,
ref_meg=True, exclude='bads')[::20]
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=True,
picks=picks, preload=True, decim=10, verbose='error')
evoked = epochs.average()
evoked.plot_joint(times=[0.1])
mne.viz.plot_compare_evokeds([evoked, evoked])
开发者ID:jhouck,项目名称:mne-python,代码行数:16,代码来源:test_evoked.py
示例13: test_maxwell_filter_additional
def test_maxwell_filter_additional():
"""Test processing of Maxwell filtered data"""
# TODO: Future tests integrate with mne/io/tests/test_proc_history
# Load testing data (raw, SSS std origin, SSS non-standard origin)
data_path = op.join(testing.data_path(download=False))
file_name = 'test_move_anon'
raw_fname = op.join(data_path, 'SSS', file_name + '_raw.fif')
with warnings.catch_warnings(record=True): # maxshield
# Use 2.0 seconds of data to get stable cov. estimate
raw = Raw(raw_fname, preload=False, proj=False,
allow_maxshield=True).crop(0., 2., False)
# Get MEG channels, compute Maxwell filtered data
raw.load_data()
raw.pick_types(meg=True, eeg=False)
int_order, ext_order = 8, 3
raw_sss = maxwell.maxwell_filter(raw, int_order=int_order,
ext_order=ext_order)
# Test io on processed data
tempdir = _TempDir()
test_outname = op.join(tempdir, 'test_raw_sss.fif')
raw_sss.save(test_outname)
raw_sss_loaded = Raw(test_outname, preload=True, proj=False,
allow_maxshield=True)
# Some numerical imprecision since save uses 'single' fmt
assert_allclose(raw_sss_loaded._data[:, :], raw_sss._data[:, :],
rtol=1e-6, atol=1e-20)
# Test rank of covariance matrices for raw and SSS processed data
cov_raw = compute_raw_covariance(raw)
cov_sss = compute_raw_covariance(raw_sss)
scalings = None
cov_raw_rank = _estimate_rank_meeg_cov(cov_raw['data'], raw.info, scalings)
cov_sss_rank = _estimate_rank_meeg_cov(cov_sss['data'], raw_sss.info,
scalings)
assert_equal(cov_raw_rank, raw.info['nchan'])
assert_equal(cov_sss_rank, maxwell.get_num_moments(int_order, 0))
开发者ID:leggitta,项目名称:mne-python,代码行数:46,代码来源:test_maxwell.py
示例14: test_add_noise
def test_add_noise():
"""Test noise addition."""
rng = np.random.RandomState(0)
data_path = testing.data_path()
raw = read_raw_fif(data_path + '/MEG/sample/sample_audvis_trunc_raw.fif')
raw.del_proj()
picks = pick_types(raw.info, eeg=True, exclude=())
cov = compute_raw_covariance(raw, picks=picks)
with pytest.raises(RuntimeError, match='to be loaded'):
add_noise(raw, cov)
raw.crop(0, 1).load_data()
with pytest.raises(TypeError, match='Raw, Epochs, or Evoked'):
add_noise(0., cov)
with pytest.raises(TypeError, match='Covariance'):
add_noise(raw, 0.)
# test a no-op (data preserved)
orig_data = raw[:][0]
zero_cov = cov.copy()
zero_cov['data'].fill(0)
add_noise(raw, zero_cov)
new_data = raw[:][0]
assert_allclose(orig_data, new_data, atol=1e-30)
# set to zero to make comparisons easier
raw._data[:] = 0.
epochs = EpochsArray(np.zeros((1, len(raw.ch_names), 100)),
raw.info.copy())
epochs.info['bads'] = []
evoked = epochs.average(picks=np.arange(len(raw.ch_names)))
for inst in (raw, epochs, evoked):
with catch_logging() as log:
add_noise(inst, cov, random_state=rng, verbose=True)
log = log.getvalue()
want = ('to {0}/{1} channels ({0}'
.format(len(cov['names']), len(raw.ch_names)))
assert want in log
if inst is evoked:
inst = EpochsArray(inst.data[np.newaxis], inst.info)
if inst is raw:
cov_new = compute_raw_covariance(inst, picks=picks,
verbose='error') # samples
else:
cov_new = compute_covariance(inst, verbose='error') # avg ref
assert cov['names'] == cov_new['names']
r = np.corrcoef(cov['data'].ravel(), cov_new['data'].ravel())[0, 1]
assert r > 0.99
开发者ID:kambysese,项目名称:mne-python,代码行数:45,代码来源:test_evoked.py
示例15: test_lcmv_ctf_comp
def test_lcmv_ctf_comp():
"""Test interpolation with compensated CTF data."""
ctf_dir = op.join(testing.data_path(download=False), 'CTF')
raw_fname = op.join(ctf_dir, 'somMDYO-18av.ds')
raw = mne.io.read_raw_ctf(raw_fname, preload=True)
events = mne.make_fixed_length_events(raw, duration=0.2)[:2]
epochs = mne.Epochs(raw, events, tmin=0., tmax=0.2)
evoked = epochs.average()
with pytest.warns(RuntimeWarning,
match='Too few samples .* estimate may be unreliable'):
data_cov = mne.compute_covariance(epochs)
fwd = mne.make_forward_solution(evoked.info, None,
mne.setup_volume_source_space(pos=15.0),
mne.make_sphere_model())
filters = mne.beamformer.make_lcmv(evoked.info, fwd, data_cov)
assert 'weights' in filters
开发者ID:SherazKhan,项目名称:mne-python,代码行数:18,代码来源:test_lcmv.py
示例16: generate_data_for_comparing_against_eeglab_infomax
def generate_data_for_comparing_against_eeglab_infomax(ch_type, random_state):
"""Generate data."""
data_dir = op.join(testing.data_path(download=False), 'MEG', 'sample')
raw_fname = op.join(data_dir, 'sample_audvis_trunc_raw.fif')
raw = read_raw_fif(raw_fname, preload=True, add_eeg_ref=False)
if ch_type == 'eeg':
picks = pick_types(raw.info, meg=False, eeg=True, exclude='bads')
else:
picks = pick_types(raw.info, meg=ch_type,
eeg=False, exclude='bads')
# select a small number of channels for the test
number_of_channels_to_use = 5
idx_perm = random_permutation(picks.shape[0], random_state)
picks = picks[idx_perm[:number_of_channels_to_use]]
with warnings.catch_warnings(record=True): # deprecated params
raw.filter(1, 45, picks=picks)
# Eventually we will need to add these, but for now having none of
# them is a nice deprecation sanity check.
# filter_length='10s',
# l_trans_bandwidth=0.5, h_trans_bandwidth=0.5,
# phase='zero-double', fir_window='hann') # use the old way
X = raw[picks, :][0][:, ::20]
# Subtract the mean
mean_X = X.mean(axis=1)
X -= mean_X[:, None]
# pre_whitening: z-score
X /= np.std(X)
T = X.shape[1]
cov_X = np.dot(X, X.T) / T
# Let's whiten the data
U, D, _ = svd(cov_X)
W = np.dot(U, U.T / np.sqrt(D)[:, None])
Y = np.dot(W, X)
return Y
开发者ID:jmontoyam,项目名称:mne-python,代码行数:44,代码来源:test_eeglab_infomax.py
示例17: test_eeglab_event_from_annot
def test_eeglab_event_from_annot(recwarn):
"""Test all forms of obtaining annotations."""
base_dir = op.join(testing.data_path(download=False), 'EEGLAB')
raw_fname_mat = op.join(base_dir, 'test_raw.set')
raw_fname = raw_fname_mat
montage = op.join(base_dir, 'test_chans.locs')
event_id = {'rt': 1, 'square': 2}
raw1 = read_raw_eeglab(input_fname=raw_fname, montage=montage,
event_id=event_id, preload=False)
events_a = find_events(raw1)
events_b = read_events_eeglab(raw_fname, event_id=event_id)
annotations = read_annotations_eeglab(raw_fname)
assert raw1.annotations is None
raw1.set_annotations(annotations)
events_c, _ = events_from_annotations(raw1, event_id=event_id)
assert_array_equal(events_a, events_b)
assert_array_equal(events_a, events_c)
开发者ID:cjayb,项目名称:mne-python,代码行数:19,代码来源:test_eeglab.py
示例18: test_min_distance_fit_dipole
def test_min_distance_fit_dipole():
"""Test dipole min_dist to inner_skull"""
data_path = testing.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_trunc_raw.fif'
subjects_dir = op.join(data_path, 'subjects')
fname_cov = op.join(data_path, 'MEG', 'sample', 'sample_audvis-cov.fif')
fname_trans = op.join(data_path, 'MEG', 'sample',
'sample_audvis_trunc-trans.fif')
fname_bem = op.join(subjects_dir, 'sample', 'bem',
'sample-1280-1280-1280-bem-sol.fif')
subject = 'sample'
raw = Raw(raw_fname, preload=True)
# select eeg data
picks = pick_types(raw.info, meg=False, eeg=True, exclude='bads')
info = pick_info(raw.info, picks)
# Let's use cov = Identity
cov = read_cov(fname_cov)
cov['data'] = np.eye(cov['data'].shape[0])
# Simulated scal map
simulated_scalp_map = np.zeros(picks.shape[0])
simulated_scalp_map[27:34] = 1
simulated_scalp_map = simulated_scalp_map[:, None]
evoked = EvokedArray(simulated_scalp_map, info, tmin=0)
min_dist = 5. # distance in mm
dip, residual = fit_dipole(evoked, cov, fname_bem, fname_trans,
min_dist=min_dist)
dist = _compute_depth(dip, fname_bem, fname_trans, subject, subjects_dir)
assert_true(min_dist < (dist[0] * 1000.) < (min_dist + 1.))
assert_raises(ValueError, fit_dipole, evoked, cov, fname_bem, fname_trans,
-1.)
开发者ID:matthew-tucker,项目名称:mne-python,代码行数:43,代码来源:test_dipole.py
示例19: test_maxwell_filter_additional
def test_maxwell_filter_additional():
"""Test processing of Maxwell filtered data."""
# TODO: Future tests integrate with mne/io/tests/test_proc_history
# Load testing data (raw, SSS std origin, SSS non-standard origin)
data_path = op.join(testing.data_path(download=False))
file_name = 'test_move_anon'
raw_fname = op.join(data_path, 'SSS', file_name + '_raw.fif')
# Use 2.0 seconds of data to get stable cov. estimate
raw = read_crop(raw_fname, (0., 2.))
# Get MEG channels, compute Maxwell filtered data
raw.load_data()
raw.pick_types(meg=True, eeg=False)
int_order = 8
raw_sss = maxwell_filter(raw, origin=mf_head_origin, regularize=None,
bad_condition='ignore')
# Test io on processed data
tempdir = _TempDir()
test_outname = op.join(tempdir, 'test_raw_sss.fif')
raw_sss.save(test_outname)
raw_sss_loaded = read_crop(test_outname).load_data()
# Some numerical imprecision since save uses 'single' fmt
assert_allclose(raw_sss_loaded[:][0], raw_sss[:][0],
rtol=1e-6, atol=1e-20)
# Test rank of covariance matrices for raw and SSS processed data
cov_raw = compute_raw_covariance(raw)
cov_sss = compute_raw_covariance(raw_sss)
scalings = None
cov_raw_rank = _estimate_rank_meeg_cov(cov_raw['data'], raw.info, scalings)
cov_sss_rank = _estimate_rank_meeg_cov(cov_sss['data'], raw_sss.info,
scalings)
assert_equal(cov_raw_rank, raw.info['nchan'])
assert_equal(cov_sss_rank, _get_n_moments(int_order))
开发者ID:Lx37,项目名称:mne-python,代码行数:43,代码来源:test_maxwell.py
示例20: test_plot_ctf
def test_plot_ctf():
"""Test plotting of CTF evoked."""
ctf_dir = op.join(testing.data_path(download=False), 'CTF')
raw_fname = op.join(ctf_dir, 'testdata_ctf.ds')
raw = mne.io.read_raw_ctf(raw_fname, preload=True)
events = np.array([[200, 0, 1]])
event_id = 1
tmin, tmax = -0.1, 0.5 # start and end of an epoch in sec.
picks = mne.pick_types(raw.info, meg=True, stim=True, eog=True,
ref_meg=True, exclude='bads')[::20]
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=True,
picks=picks, preload=True, decim=10, verbose='error')
evoked = epochs.average()
evoked.plot_joint(times=[0.1])
mne.viz.plot_compare_evokeds([evoked, evoked])
# make sure axes position is "almost" unchanged
# when axes were passed to plot_joint by the user
times = [0.1, 0.2, 0.3]
fig = plt.figure()
# create custom axes for topomaps, colorbar and the timeseries
gs = gridspec.GridSpec(3, 7, hspace=0.5, top=0.8)
topo_axes = [fig.add_subplot(gs[0, idx * 2:(idx + 1) * 2])
for idx in range(len(times))]
topo_axes.append(fig.add_subplot(gs[0, -1]))
ts_axis = fig.add_subplot(gs[1:, 1:-1])
def get_axes_midpoints(axes):
midpoints = list()
for ax in axes[:-1]:
pos = ax.get_position()
midpoints.append([pos.x0 + (pos.width * 0.5),
pos.y0 + (pos.height * 0.5)])
return np.array(midpoints)
midpoints_before = get_axes_midpoints(topo_axes)
evoked.plot_joint(times=times, ts_args={'axes': ts_axis},
topomap_args={'axes': topo_axes}, title=None)
midpoints_after = get_axes_midpoints(topo_axes)
assert (np.linalg.norm(midpoints_before - midpoints_after) < 0.1).all()
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:42,代码来源:test_evoked.py
注:本文中的mne.datasets.testing.data_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论