本文整理汇总了Python中mne.io.read_raw_ctf函数的典型用法代码示例。如果您正苦于以下问题:Python read_raw_ctf函数的具体用法?Python read_raw_ctf怎么用?Python read_raw_ctf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_raw_ctf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_rawctf_clean_names
def test_rawctf_clean_names():
"""Test RawCTF _clean_names method."""
# read test data
with pytest.warns(RuntimeWarning, match='ref channel RMSP did not'):
raw = read_raw_ctf(op.join(ctf_dir, ctf_fname_catch))
raw_cleaned = read_raw_ctf(op.join(ctf_dir, ctf_fname_catch),
clean_names=True)
test_channel_names = _clean_names(raw.ch_names)
test_info_comps = copy.deepcopy(raw.info['comps'])
# channel names should not be cleaned by default
assert raw.ch_names != test_channel_names
chs_ch_names = [ch['ch_name'] for ch in raw.info['chs']]
assert chs_ch_names != test_channel_names
for test_comp, comp in zip(test_info_comps, raw.info['comps']):
for key in ('row_names', 'col_names'):
assert not array_equal(_clean_names(test_comp['data'][key]),
comp['data'][key])
# channel names should be cleaned if clean_names=True
assert raw_cleaned.ch_names == test_channel_names
for ch, test_ch_name in zip(raw_cleaned.info['chs'], test_channel_names):
assert ch['ch_name'] == test_ch_name
for test_comp, comp in zip(test_info_comps, raw_cleaned.info['comps']):
for key in ('row_names', 'col_names'):
assert _clean_names(test_comp['data'][key]) == comp['data'][key]
开发者ID:jhouck,项目名称:mne-python,代码行数:31,代码来源:test_ctf.py
示例2: convert_ds_to_raw_fif
def convert_ds_to_raw_fif(ds_file):
import os
import os.path as op
from nipype.utils.filemanip import split_filename as split_f
from mne.io import read_raw_ctf
subj_path,basename,ext = split_f(ds_file)
print subj_path,basename,ext
raw = read_raw_ctf(ds_file)
#raw_fif_file = os.path.abspath(basename + "_raw.fif")
#raw.save(raw_fif_file)
#return raw_fif_file
raw_fif_file = os.path.join(subj_path,basename + "_raw.fif")
if not op.isfile(raw_fif_file):
raw = read_raw_ctf(ds_file)
raw.save(raw_fif_file)
else:
print '*** RAW FIF file %s exists!!!' % raw_fif_file
return raw_fif_file
开发者ID:davidmeunier79,项目名称:neuropype_ephy,代码行数:25,代码来源:import_ctf.py
示例3: test_plot_ref_meg
def test_plot_ref_meg():
"""Test plotting ref_meg."""
import matplotlib.pyplot as plt
raw_ctf = read_raw_ctf(ctf_fname_continuous).crop(0, 1).load_data()
raw_ctf.plot()
plt.close('all')
assert_raises(ValueError, raw_ctf.plot, group_by='selection')
开发者ID:HSMin,项目名称:mne-python,代码行数:7,代码来源:test_raw.py
示例4: 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
示例5: test_plot_trans
def test_plot_trans():
"""Test plotting of -trans.fif files and MEG sensor layouts
"""
evoked = read_evokeds(evoked_fname)[0]
with warnings.catch_warnings(record=True): # 4D weight tables
bti = read_raw_bti(pdf_fname, config_fname, hs_fname, convert=True,
preload=False).info
infos = dict(
Neuromag=evoked.info,
CTF=read_raw_ctf(ctf_fname).info,
BTi=bti,
KIT=read_raw_kit(sqd_fname).info,
)
for system, info in infos.items():
ref_meg = False if system == 'KIT' else True
plot_trans(info, trans_fname, subject='sample', meg_sensors=True,
subjects_dir=subjects_dir, ref_meg=ref_meg)
# KIT ref sensor coil def not defined
assert_raises(RuntimeError, plot_trans, infos['KIT'], None,
meg_sensors=True, ref_meg=True)
info = infos['Neuromag']
assert_raises(ValueError, plot_trans, info, trans_fname,
subject='sample', subjects_dir=subjects_dir,
ch_type='bad-chtype')
assert_raises(TypeError, plot_trans, 'foo', trans_fname,
subject='sample', subjects_dir=subjects_dir)
# no-head version
plot_trans(info, None, meg_sensors=True, dig=True, coord_frame='head')
# EEG only with strange options
with warnings.catch_warnings(record=True) as w:
plot_trans(evoked.copy().pick_types(meg=False, eeg=True).info,
trans=trans_fname, meg_sensors=True)
assert_true(['Cannot plot MEG' in str(ww.message) for ww in w])
开发者ID:MartinBaBer,项目名称:mne-python,代码行数:33,代码来源:test_3d.py
示例6: test_check_compensation_consistency
def test_check_compensation_consistency():
"""Test check picks compensation."""
raw = read_raw_ctf(ctf_fname, preload=False)
events = make_fixed_length_events(raw, 99999)
picks = pick_types(raw.info, meg=True, exclude=[], ref_meg=True)
pick_ch_names = [raw.info['ch_names'][idx] for idx in picks]
for (comp, expected_result) in zip([0, 1], [False, False]):
raw.apply_gradient_compensation(comp)
ret, missing = _bad_chans_comp(raw.info, pick_ch_names)
assert ret == expected_result
assert len(missing) == 0
Epochs(raw, events, None, -0.2, 0.2, preload=False, picks=picks)
picks = pick_types(raw.info, meg=True, exclude=[], ref_meg=False)
pick_ch_names = [raw.info['ch_names'][idx] for idx in picks]
for (comp, expected_result) in zip([0, 1], [False, True]):
raw.apply_gradient_compensation(comp)
ret, missing = _bad_chans_comp(raw.info, pick_ch_names)
assert ret == expected_result
assert len(missing) == 17
with catch_logging() as log:
Epochs(raw, events, None, -0.2, 0.2, preload=False,
picks=picks, verbose=True)
assert'Removing 5 compensators' in log.getvalue()
开发者ID:jhouck,项目名称:mne-python,代码行数:25,代码来源:test_meas_info.py
示例7: test_ica_ctf
def test_ica_ctf():
"""Test run ICA computation on ctf data with/without compensation."""
method = 'fastica'
raw = read_raw_ctf(ctf_fname, preload=True)
events = make_fixed_length_events(raw, 99999)
for comp in [0, 1]:
raw.apply_gradient_compensation(comp)
epochs = Epochs(raw, events, None, -0.2, 0.2, preload=True)
evoked = epochs.average()
# test fit
for inst in [raw, epochs]:
ica = ICA(n_components=2, random_state=0, max_iter=2,
method=method)
with pytest.warns(UserWarning, match='did not converge'):
ica.fit(inst)
# test apply and get_sources
for inst in [raw, epochs, evoked]:
ica.apply(inst)
ica.get_sources(inst)
# test mixed compensation case
raw.apply_gradient_compensation(0)
ica = ICA(n_components=2, random_state=0, max_iter=2, method=method)
with pytest.warns(UserWarning, match='did not converge'):
ica.fit(raw)
raw.apply_gradient_compensation(1)
epochs = Epochs(raw, events, None, -0.2, 0.2, preload=True)
evoked = epochs.average()
for inst in [raw, epochs, evoked]:
with pytest.raises(RuntimeError, match='Compensation grade of ICA'):
ica.apply(inst)
with pytest.raises(RuntimeError, match='Compensation grade of ICA'):
ica.get_sources(inst)
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:35,代码来源:test_ica.py
示例8: test_saving_picked
def test_saving_picked():
"""Test saving picked CTF instances."""
temp_dir = _TempDir()
out_fname = op.join(temp_dir, 'test_py_raw.fif')
raw = read_raw_ctf(op.join(ctf_dir, ctf_fname_1_trial))
raw.crop(0, 1).load_data()
assert raw.compensation_grade == get_current_comp(raw.info) == 0
assert len(raw.info['comps']) == 5
pick_kwargs = dict(meg=True, ref_meg=False, verbose=True)
for comp_grade in [0, 1]:
raw.apply_gradient_compensation(comp_grade)
with catch_logging() as log:
raw_pick = raw.copy().pick_types(**pick_kwargs)
assert len(raw.info['comps']) == 5
assert len(raw_pick.info['comps']) == 0
log = log.getvalue()
assert 'Removing 5 compensators' in log
raw_pick.save(out_fname, overwrite=True) # should work
raw2 = read_raw_fif(out_fname)
assert (raw_pick.ch_names == raw2.ch_names)
assert_array_equal(raw_pick.times, raw2.times)
assert_allclose(raw2[0:20][0], raw_pick[0:20][0], rtol=1e-6,
atol=1e-20) # atol is very small but > 0
raw2 = read_raw_fif(out_fname, preload=True)
assert (raw_pick.ch_names == raw2.ch_names)
assert_array_equal(raw_pick.times, raw2.times)
assert_allclose(raw2[0:20][0], raw_pick[0:20][0], rtol=1e-6,
atol=1e-20) # atol is very small but > 0
开发者ID:jhouck,项目名称:mne-python,代码行数:29,代码来源:test_ctf.py
示例9: test_check_compensation_consistency
def test_check_compensation_consistency():
"""Test check picks compensation."""
raw = read_raw_ctf(ctf_fname, preload=False)
events = make_fixed_length_events(raw, 99999)
picks = pick_types(raw.info, meg=True, exclude=[], ref_meg=True)
pick_ch_names = [raw.info['ch_names'][idx] for idx in picks]
for (comp, expected_result) in zip([0, 1], [False, False]):
raw.apply_gradient_compensation(comp)
ret, missing = _bad_chans_comp(raw.info, pick_ch_names)
assert ret == expected_result
assert len(missing) == 0
Epochs(raw, events, None, -0.2, 0.2, preload=False, picks=picks)
picks = pick_types(raw.info, meg=True, exclude=[], ref_meg=False)
pick_ch_names = [raw.info['ch_names'][idx] for idx in picks]
for (comp, expected_result) in zip([0, 1], [False, True]):
raw.apply_gradient_compensation(comp)
ret, missing = _bad_chans_comp(raw.info, pick_ch_names)
assert ret == expected_result
assert len(missing) == 17
if comp != 0:
with pytest.raises(RuntimeError,
match='Compensation grade 1 has been applied'):
Epochs(raw, events, None, -0.2, 0.2, preload=False,
picks=picks)
else:
Epochs(raw, events, None, -0.2, 0.2, preload=False, picks=picks)
开发者ID:emilymuller1991,项目名称:mne-python,代码行数:28,代码来源:test_meas_info.py
示例10: test_cov_ctf
def test_cov_ctf():
"""Test basic cov computation on ctf data with/without compensation."""
raw = read_raw_ctf(ctf_fname).crop(0., 2.).load_data()
events = make_fixed_length_events(raw, 99999)
assert len(events) == 2
ch_names = [raw.info['ch_names'][pick]
for pick in pick_types(raw.info, meg=True, eeg=False,
ref_meg=False)]
for comp in [0, 1]:
raw.apply_gradient_compensation(comp)
epochs = Epochs(raw, events, None, -0.2, 0.2, preload=True)
with pytest.warns(RuntimeWarning, match='Too few samples'):
noise_cov = compute_covariance(epochs, tmax=0.,
method=['empirical'])
prepare_noise_cov(noise_cov, raw.info, ch_names)
raw.apply_gradient_compensation(0)
epochs = Epochs(raw, events, None, -0.2, 0.2, preload=True)
with pytest.warns(RuntimeWarning, match='Too few samples'):
noise_cov = compute_covariance(epochs, tmax=0., method=['empirical'])
raw.apply_gradient_compensation(1)
# TODO This next call in principle should fail.
prepare_noise_cov(noise_cov, raw.info, ch_names)
# make sure comps matrices was not removed from raw
assert raw.info['comps'], 'Comps matrices removed'
开发者ID:jhouck,项目名称:mne-python,代码行数:28,代码来源:test_cov.py
示例11: test_ica_eeg
def test_ica_eeg():
"""Test ICA on EEG."""
method = 'fastica'
raw_fif = read_raw_fif(fif_fname, preload=True)
with pytest.warns(RuntimeWarning, match='events'):
raw_eeglab = read_raw_eeglab(input_fname=eeglab_fname,
montage=eeglab_montage, preload=True)
for raw in [raw_fif, raw_eeglab]:
events = make_fixed_length_events(raw, 99999, start=0, stop=0.3,
duration=0.1)
picks_meg = pick_types(raw.info, meg=True, eeg=False)[:2]
picks_eeg = pick_types(raw.info, meg=False, eeg=True)[:2]
picks_all = []
picks_all.extend(picks_meg)
picks_all.extend(picks_eeg)
epochs = Epochs(raw, events, None, -0.1, 0.1, preload=True)
evoked = epochs.average()
for picks in [picks_meg, picks_eeg, picks_all]:
if len(picks) == 0:
continue
# test fit
for inst in [raw, epochs]:
ica = ICA(n_components=2, random_state=0, max_iter=2,
method=method)
with pytest.warns(None):
ica.fit(inst, picks=picks)
# test apply and get_sources
for inst in [raw, epochs, evoked]:
ica.apply(inst)
ica.get_sources(inst)
with pytest.warns(RuntimeWarning, match='MISC channel'):
raw = read_raw_ctf(ctf_fname2, preload=True)
events = make_fixed_length_events(raw, 99999, start=0, stop=0.2,
duration=0.1)
picks_meg = pick_types(raw.info, meg=True, eeg=False)[:2]
picks_eeg = pick_types(raw.info, meg=False, eeg=True)[:2]
picks_all = picks_meg + picks_eeg
for comp in [0, 1]:
raw.apply_gradient_compensation(comp)
epochs = Epochs(raw, events, None, -0.1, 0.1, preload=True)
evoked = epochs.average()
for picks in [picks_meg, picks_eeg, picks_all]:
if len(picks) == 0:
continue
# test fit
for inst in [raw, epochs]:
ica = ICA(n_components=2, random_state=0, max_iter=2,
method=method)
with pytest.warns(None):
ica.fit(inst)
# test apply and get_sources
for inst in [raw, epochs, evoked]:
ica.apply(inst)
ica.get_sources(inst)
开发者ID:SherazKhan,项目名称:mne-python,代码行数:59,代码来源:test_ica.py
示例12: 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
示例13: test_read_spm_ctf
def test_read_spm_ctf():
"""Test CTF reader with omitted samples."""
data_path = spm_face.data_path()
raw_fname = op.join(data_path, 'MEG', 'spm',
'SPM_CTF_MEG_example_faces1_3D.ds')
raw = read_raw_ctf(raw_fname)
extras = raw._raw_extras[0]
assert_equal(extras['n_samp'], raw.n_times)
assert_false(extras['n_samp'] == extras['n_samp_tot'])
开发者ID:deep-introspection,项目名称:mne-python,代码行数:9,代码来源:test_ctf.py
示例14: test_calculate_head_pos_ctf
def test_calculate_head_pos_ctf():
"""Test extracting of cHPI positions from ctf data."""
raw = read_raw_ctf(ctf_chpi_fname)
quats = _calculate_head_pos_ctf(raw)
mc_quats = read_head_pos(ctf_chpi_pos_fname)
_assert_quats(quats, mc_quats, dist_tol=0.004, angle_tol=2.5)
raw = read_raw_fif(ctf_fname)
pytest.raises(RuntimeError, _calculate_head_pos_ctf, raw)
开发者ID:SherazKhan,项目名称:mne-python,代码行数:9,代码来源:test_chpi.py
示例15: test_dipole_fitting_ctf
def test_dipole_fitting_ctf():
"""Test dipole fitting with CTF data."""
raw_ctf = read_raw_ctf(fname_ctf).set_eeg_reference()
events = make_fixed_length_events(raw_ctf, 1)
evoked = Epochs(raw_ctf, events, 1, 0, 0, baseline=None).average()
cov = make_ad_hoc_cov(evoked.info)
sphere = make_sphere_model((0., 0., 0.))
# XXX Eventually we should do some better checks about accuracy, but
# for now our CTF phantom fitting tutorials will have to do
# (otherwise we need to add that to the testing dataset, which is
# a bit too big)
fit_dipole(evoked, cov, sphere)
开发者ID:mvdoc,项目名称:mne-python,代码行数:12,代码来源:test_dipole.py
示例16: test_ica_labels
def test_ica_labels():
"""Test ICA labels."""
# The CTF data are uniquely well suited to testing the ICA.find_bads_
# methods
raw = read_raw_ctf(ctf_fname, preload=True)
# derive reference ICA components and append them to raw
icarf = ICA(n_components=2, random_state=0, max_iter=2, allow_ref_meg=True)
with pytest.warns(UserWarning, match='did not converge'):
icarf.fit(raw.copy().pick_types(meg=False, ref_meg=True))
icacomps = icarf.get_sources(raw)
# rename components so they are auto-detected by find_bads_ref
icacomps.rename_channels({c: 'REF_' + c for c in icacomps.ch_names})
# and add them to raw
raw.add_channels([icacomps])
# set the appropriate EEG channels to EOG and ECG
raw.set_channel_types({'EEG057': 'eog', 'EEG058': 'eog', 'EEG059': 'ecg'})
ica = ICA(n_components=4, random_state=0, max_iter=2, method='fastica')
with pytest.warns(UserWarning, match='did not converge'):
ica.fit(raw)
ica.find_bads_eog(raw, l_freq=None, h_freq=None)
picks = list(pick_types(raw.info, meg=False, eog=True))
for idx, ch in enumerate(picks):
assert '{}/{}/{}'.format('eog', idx, raw.ch_names[ch]) in ica.labels_
assert 'eog' in ica.labels_
for key in ('ecg', 'ref_meg', 'ecg/ECG-MAG'):
assert key not in ica.labels_
ica.find_bads_ecg(raw, l_freq=None, h_freq=None, method='correlation')
picks = list(pick_types(raw.info, meg=False, ecg=True))
for idx, ch in enumerate(picks):
assert '{}/{}/{}'.format('ecg', idx, raw.ch_names[ch]) in ica.labels_
for key in ('ecg', 'eog'):
assert key in ica.labels_
for key in ('ref_meg', 'ecg/ECG-MAG'):
assert key not in ica.labels_
ica.find_bads_ref(raw, l_freq=None, h_freq=None)
picks = pick_channels_regexp(raw.ch_names, 'REF_ICA*')
for idx, ch in enumerate(picks):
assert '{}/{}/{}'.format('ref_meg', idx,
raw.ch_names[ch]) in ica.labels_
for key in ('ecg', 'eog', 'ref_meg'):
assert key in ica.labels_
assert 'ecg/ECG-MAG' not in ica.labels_
ica.find_bads_ecg(raw, l_freq=None, h_freq=None)
for key in ('ecg', 'eog', 'ref_meg', 'ecg/ECG-MAG'):
assert key in ica.labels_
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:49,代码来源:test_ica.py
示例17: test_plot_trans
def test_plot_trans():
"""Test plotting of -trans.fif files and MEG sensor layouts."""
from mayavi import mlab
evoked = read_evokeds(evoked_fname)[0]
with warnings.catch_warnings(record=True): # 4D weight tables
bti = read_raw_bti(pdf_fname, config_fname, hs_fname, convert=True,
preload=False).info
infos = dict(
Neuromag=evoked.info,
CTF=read_raw_ctf(ctf_fname).info,
BTi=bti,
KIT=read_raw_kit(sqd_fname).info,
)
for system, info in infos.items():
ref_meg = False if system == 'KIT' else True
plot_trans(info, trans_fname, subject='sample', meg_sensors=True,
subjects_dir=subjects_dir, ref_meg=ref_meg)
mlab.close(all=True)
# KIT ref sensor coil def is defined
plot_trans(infos['KIT'], None, meg_sensors=True, ref_meg=True)
mlab.close(all=True)
info = infos['Neuromag']
assert_raises(ValueError, plot_trans, info, trans_fname,
subject='sample', subjects_dir=subjects_dir,
ch_type='bad-chtype')
assert_raises(TypeError, plot_trans, 'foo', trans_fname,
subject='sample', subjects_dir=subjects_dir)
# no-head version
plot_trans(info, None, meg_sensors=True, dig=True, coord_frame='head')
mlab.close(all=True)
# all coord frames
for coord_frame in ('meg', 'head', 'mri'):
plot_trans(info, meg_sensors=True, dig=True, coord_frame=coord_frame,
trans=trans_fname, subject='sample',
subjects_dir=subjects_dir)
mlab.close(all=True)
# EEG only with strange options
evoked_eeg_ecog = evoked.copy().pick_types(meg=False, eeg=True)
evoked_eeg_ecog.info['projs'] = [] # "remove" avg proj
evoked_eeg_ecog.set_channel_types({'EEG 001': 'ecog'})
with warnings.catch_warnings(record=True) as w:
plot_trans(evoked_eeg_ecog.info, subject='sample', trans=trans_fname,
source='outer_skin', meg_sensors=True, skull=True,
eeg_sensors=['original', 'projected'], ecog_sensors=True,
brain='white', head=True, subjects_dir=subjects_dir)
mlab.close(all=True)
assert_true(['Cannot plot MEG' in str(ww.message) for ww in w])
开发者ID:hoechenberger,项目名称:mne-python,代码行数:47,代码来源:test_3d.py
示例18: test_read_spm_ctf
def test_read_spm_ctf():
"""Test CTF reader with omitted samples."""
data_path = spm_face.data_path()
raw_fname = op.join(data_path, 'MEG', 'spm',
'SPM_CTF_MEG_example_faces1_3D.ds')
raw = read_raw_ctf(raw_fname)
extras = raw._raw_extras[0]
assert_equal(extras['n_samp'], raw.n_times)
assert extras['n_samp'] != extras['n_samp_tot']
# Test that LPA, nasion and RPA are correct.
coord_frames = np.array([d['coord_frame'] for d in raw.info['dig']])
assert np.all(coord_frames == FIFF.FIFFV_COORD_HEAD)
cardinals = {d['ident']: d['r'] for d in raw.info['dig']}
assert cardinals[1][0] < cardinals[2][0] < cardinals[3][0] # x coord
assert cardinals[1][1] < cardinals[2][1] # y coord
assert cardinals[3][1] < cardinals[2][1] # y coord
for key in cardinals.keys():
assert_allclose(cardinals[key][2], 0, atol=1e-6) # z coord
开发者ID:jhouck,项目名称:mne-python,代码行数:19,代码来源:test_ctf.py
示例19: test_saving_picked
def test_saving_picked():
"""Test saving picked CTF instances."""
temp_dir = _TempDir()
out_fname = op.join(temp_dir, 'test_py_raw.fif')
raw = read_raw_ctf(op.join(ctf_dir, ctf_fname_1_trial))
raw.crop(0, 1).load_data()
assert raw.compensation_grade == get_current_comp(raw.info) == 0
assert len(raw.info['comps']) == 5
pick_kwargs = dict(meg=True, ref_meg=False, verbose=True)
with catch_logging() as log:
raw_pick = raw.copy().pick_types(**pick_kwargs)
assert len(raw.info['comps']) == 5
assert len(raw_pick.info['comps']) == 0
log = log.getvalue()
assert 'Removing 5 compensators' in log
raw_pick.save(out_fname) # should work
read_raw_fif(out_fname)
read_raw_fif(out_fname, preload=True)
# If comp is applied, picking should error
raw.apply_gradient_compensation(1)
assert raw.compensation_grade == get_current_comp(raw.info) == 1
with pytest.raises(RuntimeError, match='Compensation grade 1 has been'):
raw.copy().pick_types(**pick_kwargs)
开发者ID:jdammers,项目名称:mne-python,代码行数:23,代码来源:test_ctf.py
示例20: test_compute_proj_ctf
def test_compute_proj_ctf():
"""Test to show that projector code completes on CTF data."""
raw = read_raw_ctf(ctf_fname)
raw.load_data()
# expected channels per projector type
n_mags = len(pick_types(raw.info, meg='mag', ref_meg=False,
exclude='bads'))
n_grads = len(pick_types(raw.info, meg='grad', ref_meg=False,
exclude='bads'))
n_eegs = len(pick_types(raw.info, meg=False, eeg=True, ref_meg=False,
exclude='bads'))
# Test with and without gradient compensation
for c in [0, 1]:
raw.apply_gradient_compensation(c)
for average in [False, True]:
n_projs_init = len(raw.info['projs'])
projs, events = compute_proj_eog(raw, n_mag=2, n_grad=2, n_eeg=2,
average=average,
ch_name='EEG059',
avg_ref=True, no_proj=False,
l_freq=None, h_freq=None,
reject=None, tmax=dur_use,
filter_length=6000)
_check_projs_for_expected_channels(projs, n_mags, n_grads, n_eegs)
assert len(projs) == (5 + n_projs_init)
projs, events = compute_proj_ecg(raw, n_mag=1, n_grad=1, n_eeg=2,
average=average,
ch_name='EEG059',
avg_ref=True, no_proj=False,
l_freq=None, h_freq=None,
reject=None, tmax=dur_use,
filter_length=6000)
_check_projs_for_expected_channels(projs, n_mags, n_grads, n_eegs)
assert len(projs) == (4 + n_projs_init)
开发者ID:SherazKhan,项目名称:mne-python,代码行数:37,代码来源:test_ssp.py
注:本文中的mne.io.read_raw_ctf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论