本文整理汇总了Python中mne.io.meas_info.create_info函数的典型用法代码示例。如果您正苦于以下问题:Python create_info函数的具体用法?Python create_info怎么用?Python create_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_merge_info
def test_merge_info():
"""Test merging of multiple Info objects."""
info_a = create_info(ch_names=['a', 'b', 'c'], sfreq=1000., ch_types=None)
info_b = create_info(ch_names=['d', 'e', 'f'], sfreq=1000., ch_types=None)
info_merged = _merge_info([info_a, info_b])
assert_equal(info_merged['nchan'], 6)
assert_equal(info_merged['ch_names'], ['a', 'b', 'c', 'd', 'e', 'f'])
assert_raises(ValueError, _merge_info, [info_a, info_a])
# Testing for force updates before merging
info_c = create_info(ch_names=['g', 'h', 'i'], sfreq=500., ch_types=None)
# This will break because sfreq is not equal
assert_raises(RuntimeError, _merge_info, [info_a, info_c])
_force_update_info(info_a, info_c)
assert_true(info_c['sfreq'] == info_a['sfreq'])
assert_true(info_c['ch_names'][0] != info_a['ch_names'][0])
# Make sure it works now
_merge_info([info_a, info_c])
# Check that you must supply Info
assert_raises(ValueError, _force_update_info, info_a,
dict([('sfreq', 1000.)]))
# KIT System-ID
info_a['kit_system_id'] = 50
assert_equal(_merge_info((info_a, info_b))['kit_system_id'], 50)
info_b['kit_system_id'] = 50
assert_equal(_merge_info((info_a, info_b))['kit_system_id'], 50)
info_b['kit_system_id'] = 60
assert_raises(ValueError, _merge_info, (info_a, info_b))
开发者ID:jmontoyam,项目名称:mne-python,代码行数:28,代码来源:test_meas_info.py
示例2: test_make_dig_points
def test_make_dig_points():
"""Test application of Polhemus HSP to info"""
dig_points = _read_dig_points(hsp_fname)
info = create_info(ch_names=['Test Ch'], sfreq=1000., ch_types=None)
assert_false(info['dig'])
info['dig'] = _make_dig_points(dig_points=dig_points)
assert_true(info['dig'])
assert_array_equal(info['dig'][0]['r'], [-106.93, 99.80, 68.81])
dig_points = _read_dig_points(elp_fname)
nasion, lpa, rpa = dig_points[:3]
info = create_info(ch_names=['Test Ch'], sfreq=1000., ch_types=None)
assert_false(info['dig'])
info['dig'] = _make_dig_points(nasion, lpa, rpa, dig_points[3:], None)
assert_true(info['dig'])
idx = [d['ident'] for d in info['dig']].index(FIFF.FIFFV_POINT_NASION)
assert_array_equal(info['dig'][idx]['r'],
np.array([1.3930, 13.1613, -4.6967]))
assert_raises(ValueError, _make_dig_points, nasion[:2])
assert_raises(ValueError, _make_dig_points, None, lpa[:2])
assert_raises(ValueError, _make_dig_points, None, None, rpa[:2])
assert_raises(ValueError, _make_dig_points, None, None, None,
dig_points[:, :2])
assert_raises(ValueError, _make_dig_points, None, None, None, None,
dig_points[:, :2])
开发者ID:esdalmaijer,项目名称:mne-python,代码行数:27,代码来源:test_meas_info.py
示例3: test_merge_info
def test_merge_info():
"""Test merging of multiple Info objects."""
info_a = create_info(ch_names=["a", "b", "c"], sfreq=1000.0, ch_types=None)
info_b = create_info(ch_names=["d", "e", "f"], sfreq=1000.0, ch_types=None)
info_merged = _merge_info([info_a, info_b])
assert_equal(info_merged["nchan"], 6)
assert_equal(info_merged["ch_names"], ["a", "b", "c", "d", "e", "f"])
assert_raises(ValueError, _merge_info, [info_a, info_a])
# Testing for force updates before merging
info_c = create_info(ch_names=["g", "h", "i"], sfreq=500.0, ch_types=None)
# This will break because sfreq is not equal
assert_raises(RuntimeError, _merge_info, [info_a, info_c])
_force_update_info(info_a, info_c)
assert_true(info_c["sfreq"] == info_a["sfreq"])
assert_true(info_c["ch_names"][0] != info_a["ch_names"][0])
# Make sure it works now
_merge_info([info_a, info_c])
# Check that you must supply Info
assert_raises(ValueError, _force_update_info, info_a, dict([("sfreq", 1000.0)]))
# KIT System-ID
info_a["kit_system_id"] = 50
assert_equal(_merge_info((info_a, info_b))["kit_system_id"], 50)
info_b["kit_system_id"] = 50
assert_equal(_merge_info((info_a, info_b))["kit_system_id"], 50)
info_b["kit_system_id"] = 60
assert_raises(ValueError, _merge_info, (info_a, info_b))
开发者ID:mne-tools,项目名称:mne-python,代码行数:27,代码来源:test_meas_info.py
示例4: test_make_dig_points
def test_make_dig_points():
"""Test application of Polhemus HSP to info."""
extra_points = _read_dig_points(hsp_fname)
info = create_info(ch_names=['Test Ch'], sfreq=1000., ch_types=None)
assert info['dig'] is None
info['dig'] = _make_dig_points(extra_points=extra_points)
assert (info['dig'])
assert_allclose(info['dig'][0]['r'], [-.10693, .09980, .06881])
elp_points = _read_dig_points(elp_fname)
nasion, lpa, rpa = elp_points[:3]
info = create_info(ch_names=['Test Ch'], sfreq=1000., ch_types=None)
assert info['dig'] is None
info['dig'] = _make_dig_points(nasion, lpa, rpa, elp_points[3:], None)
assert (info['dig'])
idx = [d['ident'] for d in info['dig']].index(FIFF.FIFFV_POINT_NASION)
assert_array_equal(info['dig'][idx]['r'],
np.array([.0013930, .0131613, -.0046967]))
pytest.raises(ValueError, _make_dig_points, nasion[:2])
pytest.raises(ValueError, _make_dig_points, None, lpa[:2])
pytest.raises(ValueError, _make_dig_points, None, None, rpa[:2])
pytest.raises(ValueError, _make_dig_points, None, None, None,
elp_points[:, :2])
pytest.raises(ValueError, _make_dig_points, None, None, None, None,
elp_points[:, :2])
开发者ID:jhouck,项目名称:mne-python,代码行数:27,代码来源:test_meas_info.py
示例5: test_merge_info
def test_merge_info():
"""Test merging of multiple Info objects"""
info_a = create_info(ch_names=['a', 'b', 'c'], sfreq=1000., ch_types=None)
info_b = create_info(ch_names=['d', 'e', 'f'], sfreq=1000., ch_types=None)
info_merged = _merge_info([info_a, info_b])
assert_equal(info_merged['nchan'], 6)
assert_equal(info_merged['ch_names'], ['a', 'b', 'c', 'd', 'e', 'f'])
assert_raises(ValueError, _merge_info, [info_a, info_a])
开发者ID:Pablo-Arias,项目名称:mne-python,代码行数:8,代码来源:test_meas_info.py
示例6: test_duplicate_name_correction
def test_duplicate_name_correction():
"""Test duplicate channel names with running number."""
# When running number is possible
info = create_info(['A', 'A', 'A'], 1000., verbose='error')
assert info['ch_names'] == ['A-0', 'A-1', 'A-2']
# When running number is not possible
with pytest.raises(ValueError, match='Adding a running number'):
create_info(['A', 'A', 'A-0'], 1000., verbose='error')
开发者ID:kambysese,项目名称:mne-python,代码行数:9,代码来源:test_meas_info.py
示例7: test_check_consistency
def test_check_consistency():
"""Test consistency check of Info objects."""
info = create_info(ch_names=['a', 'b', 'c'], sfreq=1000.)
# This should pass
info._check_consistency()
# Info without any channels
info_empty = create_info(ch_names=[], sfreq=1000.)
info_empty._check_consistency()
# Bad channels that are not in the info object
info2 = info.copy()
info2['bads'] = ['b', 'foo', 'bar']
assert_raises(RuntimeError, info2._check_consistency)
# Bad data types
info2 = info.copy()
info2['sfreq'] = 'foo'
assert_raises(ValueError, info2._check_consistency)
info2 = info.copy()
info2['highpass'] = 'foo'
assert_raises(ValueError, info2._check_consistency)
info2 = info.copy()
info2['lowpass'] = 'foo'
assert_raises(ValueError, info2._check_consistency)
info2 = info.copy()
info2['filename'] = 'foo'
with warnings.catch_warnings(record=True) as w:
info2._check_consistency()
assert_equal(len(w), 1)
assert_true(all('filename' in str(ww.message) for ww in w))
# Silent type conversion to float
info2 = info.copy()
info2['sfreq'] = 1
info2['highpass'] = 2
info2['lowpass'] = 2
info2._check_consistency()
assert_true(isinstance(info2['sfreq'], float))
assert_true(isinstance(info2['highpass'], float))
assert_true(isinstance(info2['lowpass'], float))
# Duplicate channel names
info2 = info.copy()
info2['chs'][2]['ch_name'] = 'b'
assert_raises(RuntimeError, info2._check_consistency)
# Duplicates appended with running numbers
with warnings.catch_warnings(record=True) as w:
info3 = create_info(ch_names=['a', 'b', 'b', 'c', 'b'], sfreq=1000.)
assert_equal(len(w), 1)
assert_true(all('Channel names are not' in '%s' % ww.message for ww in w))
assert_array_equal(info3['ch_names'], ['a', 'b-0', 'b-1', 'c', 'b-2'])
开发者ID:nfoti,项目名称:mne-python,代码行数:57,代码来源:test_meas_info.py
示例8: test_long_names
def test_long_names():
"""Test long name support."""
info = create_info(['a' * 15 + 'b', 'a' * 16], 1000., verbose='error')
data = np.empty((2, 1000))
raw = RawArray(data, info)
assert raw.ch_names == ['a' * 13 + '-0', 'a' * 13 + '-1']
info = create_info(['a' * 16] * 11, 1000., verbose='error')
data = np.empty((11, 1000))
raw = RawArray(data, info)
assert raw.ch_names == ['a' * 12 + '-%s' % ii for ii in range(11)]
开发者ID:jdammers,项目名称:mne-python,代码行数:10,代码来源:test_array.py
示例9: test_merge_info
def test_merge_info():
"""Test merging of multiple Info objects."""
info_a = create_info(ch_names=['a', 'b', 'c'], sfreq=1000., ch_types=None)
info_b = create_info(ch_names=['d', 'e', 'f'], sfreq=1000., ch_types=None)
info_merged = _merge_info([info_a, info_b])
assert info_merged['nchan'], 6
assert info_merged['ch_names'], ['a', 'b', 'c', 'd', 'e', 'f']
pytest.raises(ValueError, _merge_info, [info_a, info_a])
# Testing for force updates before merging
info_c = create_info(ch_names=['g', 'h', 'i'], sfreq=500., ch_types=None)
# This will break because sfreq is not equal
pytest.raises(RuntimeError, _merge_info, [info_a, info_c])
_force_update_info(info_a, info_c)
assert (info_c['sfreq'] == info_a['sfreq'])
assert (info_c['ch_names'][0] != info_a['ch_names'][0])
# Make sure it works now
_merge_info([info_a, info_c])
# Check that you must supply Info
pytest.raises(ValueError, _force_update_info, info_a,
dict([('sfreq', 1000.)]))
# KIT System-ID
info_a['kit_system_id'] = 50
assert _merge_info((info_a, info_b))['kit_system_id'] == 50
info_b['kit_system_id'] = 50
assert _merge_info((info_a, info_b))['kit_system_id'] == 50
info_b['kit_system_id'] = 60
pytest.raises(ValueError, _merge_info, (info_a, info_b))
# hpi infos
info_d = create_info(ch_names=['d', 'e', 'f'], sfreq=1000., ch_types=None)
info_merged = _merge_info([info_a, info_d])
assert not info_merged['hpi_meas']
assert not info_merged['hpi_results']
info_a['hpi_meas'] = [{'f1': 3, 'f2': 4}]
assert _merge_info([info_a, info_d])['hpi_meas'] == info_a['hpi_meas']
info_d['hpi_meas'] = [{'f1': 3, 'f2': 4}]
assert _merge_info([info_a, info_d])['hpi_meas'] == info_d['hpi_meas']
# This will break because of inconsistency
info_d['hpi_meas'] = [{'f1': 3, 'f2': 5}]
pytest.raises(ValueError, _merge_info, [info_a, info_d])
info_0 = read_info(raw_fname)
info_0['bads'] = ['MEG 2443', 'EEG 053']
assert len(info_0['chs']) == 376
assert len(info_0['dig']) == 146
info_1 = create_info(["STI XXX"], info_0['sfreq'], ['stim'])
assert info_1['bads'] == []
info_out = _merge_info([info_0, info_1], force_update_to_first=True)
assert len(info_out['chs']) == 377
assert len(info_out['bads']) == 2
assert len(info_out['dig']) == 146
assert len(info_0['chs']) == 376
assert len(info_0['bads']) == 2
assert len(info_0['dig']) == 146
开发者ID:jhouck,项目名称:mne-python,代码行数:55,代码来源:test_meas_info.py
示例10: test_check_consistency
def test_check_consistency():
"""Test consistency check of Info objects."""
info = create_info(ch_names=['a', 'b', 'c'], sfreq=1000.)
# This should pass
info._check_consistency()
# Info without any channels
info_empty = create_info(ch_names=[], sfreq=1000.)
info_empty._check_consistency()
# Bad channels that are not in the info object
info2 = info.copy()
info2['bads'] = ['b', 'foo', 'bar']
pytest.raises(RuntimeError, info2._check_consistency)
# Bad data types
info2 = info.copy()
info2['sfreq'] = 'foo'
pytest.raises(ValueError, info2._check_consistency)
info2 = info.copy()
info2['highpass'] = 'foo'
pytest.raises(ValueError, info2._check_consistency)
info2 = info.copy()
info2['lowpass'] = 'foo'
pytest.raises(ValueError, info2._check_consistency)
info2 = info.copy()
info2['filename'] = 'foo'
with pytest.warns(RuntimeWarning, match='filename'):
info2._check_consistency()
# Silent type conversion to float
info2 = info.copy()
info2['sfreq'] = 1
info2['highpass'] = 2
info2['lowpass'] = 2
info2._check_consistency()
assert (isinstance(info2['sfreq'], float))
assert (isinstance(info2['highpass'], float))
assert (isinstance(info2['lowpass'], float))
# Duplicate channel names
info2 = info.copy()
info2['chs'][2]['ch_name'] = 'b'
pytest.raises(RuntimeError, info2._check_consistency)
# Duplicates appended with running numbers
with pytest.warns(RuntimeWarning, match='Channel names are not'):
info3 = create_info(ch_names=['a', 'b', 'b', 'c', 'b'], sfreq=1000.)
assert_array_equal(info3['ch_names'], ['a', 'b-0', 'b-1', 'c', 'b-2'])
开发者ID:jhouck,项目名称:mne-python,代码行数:53,代码来源:test_meas_info.py
示例11: test_make_info
def test_make_info():
"""Test some create_info properties
"""
n_ch = 1
info = create_info(n_ch, 1000., 'eeg')
assert_equal(sorted(info.keys()), sorted(RAW_INFO_FIELDS))
coil_types = set([ch['coil_type'] for ch in info['chs']])
assert_true(FIFF.FIFFV_COIL_EEG in coil_types)
assert_raises(TypeError, create_info, ch_names='Test Ch', sfreq=1000)
assert_raises(ValueError, create_info, ch_names=['Test Ch'], sfreq=-1000)
assert_raises(ValueError, create_info, ch_names=['Test Ch'], sfreq=1000,
ch_types=['eeg', 'eeg'])
assert_raises(TypeError, create_info, ch_names=[np.array([1])],
sfreq=1000)
assert_raises(TypeError, create_info, ch_names=['Test Ch'], sfreq=1000,
ch_types=np.array([1]))
assert_raises(KeyError, create_info, ch_names=['Test Ch'], sfreq=1000,
ch_types='awesome')
assert_raises(TypeError, create_info, ['Test Ch'], sfreq=1000,
ch_types=None, montage=np.array([1]))
m = read_montage('biosemi32')
info = create_info(ch_names=m.ch_names, sfreq=1000., ch_types='eeg',
montage=m)
ch_pos = [ch['loc'][:3] for ch in info['chs']]
assert_array_equal(ch_pos, m.pos)
names = ['nasion', 'lpa', 'rpa', '1', '2', '3', '4', '5']
d = read_dig_montage(hsp_fname, None, elp_fname, names, unit='m',
transform=False)
info = create_info(ch_names=m.ch_names, sfreq=1000., ch_types='eeg',
montage=d)
idents = [p['ident'] for p in info['dig']]
assert_true(FIFF.FIFFV_POINT_NASION in idents)
info = create_info(ch_names=m.ch_names, sfreq=1000., ch_types='eeg',
montage=[d, m])
ch_pos = [ch['loc'][:3] for ch in info['chs']]
assert_array_equal(ch_pos, m.pos)
idents = [p['ident'] for p in info['dig']]
assert_true(FIFF.FIFFV_POINT_NASION in idents)
info = create_info(ch_names=m.ch_names, sfreq=1000., ch_types='eeg',
montage=[d, 'biosemi32'])
ch_pos = [ch['loc'][:3] for ch in info['chs']]
assert_array_equal(ch_pos, m.pos)
idents = [p['ident'] for p in info['dig']]
assert_true(FIFF.FIFFV_POINT_NASION in idents)
开发者ID:esdalmaijer,项目名称:mne-python,代码行数:48,代码来源:test_meas_info.py
示例12: load_FieldTrip_data
def load_FieldTrip_data(meg_fname):
from mne.io.meas_info import create_info
from mne.epochs import EpochsArray
"""XXX Here explain what this does"""
# import information from fieldtrip data to get data shape
ft_data = sio.loadmat(meg_fname[:-4] + '.mat', squeeze_me=True,
struct_as_record=True)['data']
# import binary MEG data
bin_data = np.fromfile(meg_fname[:-4] + '.dat', dtype=np.float32)
Xdim = ft_data['Xdim'].item()
bin_data = np.reshape(bin_data, Xdim[[2, 1, 0]]).transpose([2, 1, 0])
# Create an MNE Epoch
n_trial, n_chans, n_time = bin_data.shape
sfreq = ft_data['fsample'].item()
time = ft_data['time'].item()[0]
tmin = min(time)
chan_names = [str(label) for label in ft_data['label'].item()]
chan_types = np.squeeze(np.concatenate(
(np.tile(['grad', 'grad', 'mag'], (1, 102)),
np.tile('misc', (1, n_chans - 306))), axis=1))
info = create_info(chan_names, sfreq, chan_types)
events = np.c_[np.cumsum(np.ones(n_trial)) * 5 * sfreq,
np.zeros(n_trial),
ft_data['trialinfo'].item()]
epochs = EpochsArray(bin_data, info, events=events, tmin=tmin)
return epochs
开发者ID:SherazKhan,项目名称:Paris_orientation-decoding,代码行数:28,代码来源:utils.py
示例13: eeglab2mne
def eeglab2mne(file_name):
""" Loads EEGLab epochs from Matlab and return MNE-python epochs"""
# Convert from eeglab structure to mne Epochs
import scipy.io as sio
from itertools import product
from mne.io.meas_info import create_info
from mne.epochs import EpochsArray
mat = sio.loadmat(file_name, squeeze_me=True, struct_as_record=False)
event_id = dict()
for visible, expect, reward in product('HL', 'EU', 'RP'):
event_id['/'.join((visible, expect, reward))] = (
1 * (visible == 'H') + 10 * (expect == 'U') +
100 * (reward == 'P'))
data = list()
events = list()
for visible, expect, reward in product('HL', 'EU', 'RP'):
struct = visible + expect + reward
eeg_data = mat[struct]
n_chan, n_time, n_trials = eeg_data.shape
data.append(eeg_data.transpose([2, 0, 1]))
event = event_id['/'.join((visible, expect, reward))]
events.append(np.ones(n_trials) * event)
data = np.vstack(data)
events = np.hstack(events)
times = np.linspace(-1.8, 2., data.shape[2])
sfreq = len(times) / np.ptp([times[0], times[-1]])
chan_names = ['eeg_%s' % chan for chan in range(64)]
chan_types = ['eeg' for ii in range(64)]
events = np.c_[np.cumsum(np.ones_like(events)) * 5 * sfreq,
np.zeros_like(events), events]
info = create_info(chan_names, sfreq, chan_types)
epochs = EpochsArray(data, info, events=np.array(events, int), tmin=-1.8,
verbose=False, event_id=event_id)
return epochs
开发者ID:kingjr,项目名称:simon_unconscious_prediction,代码行数:35,代码来源:base.py
示例14: test_array_copy
def test_array_copy():
"""Test copying during construction."""
info = create_info(1, 1000.)
data = np.empty((1, 1000))
# 'auto' (default)
raw = RawArray(data, info)
assert raw._data is data
assert raw.info is not info
raw = RawArray(data.astype(np.float32), info)
assert raw._data is not data
assert raw.info is not info
# 'info' (more restrictive)
raw = RawArray(data, info, copy='info')
assert raw._data is data
assert raw.info is not info
with pytest.raises(ValueError, match="data copying was not .* copy='info"):
RawArray(data.astype(np.float32), info, copy='info')
# 'data'
raw = RawArray(data, info, copy='data')
assert raw._data is not data
assert raw.info is info
# 'both'
raw = RawArray(data, info, copy='both')
assert raw._data is not data
assert raw.info is not info
raw = RawArray(data.astype(np.float32), info, copy='both')
assert raw._data is not data
assert raw.info is not info
# None
raw = RawArray(data, info, copy=None)
assert raw._data is data
assert raw.info is info
with pytest.raises(ValueError, match='data copying was not .* copy=None'):
RawArray(data.astype(np.float32), info, copy=None)
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:34,代码来源:test_array.py
示例15: test_check_consistency
def test_check_consistency():
"""Test consistency check of Info objects."""
info = create_info(ch_names=["a", "b", "c"], sfreq=1000.0)
# This should pass
info._check_consistency()
# Info without any channels
info_empty = create_info(ch_names=[], sfreq=1000.0)
info_empty._check_consistency()
# Bad channels that are not in the info object
info2 = info.copy()
info2["bads"] = ["b", "foo", "bar"]
assert_raises(RuntimeError, info2._check_consistency)
# Bad data types
info2 = info.copy()
info2["sfreq"] = "foo"
assert_raises(ValueError, info2._check_consistency)
info2 = info.copy()
info2["highpass"] = "foo"
assert_raises(ValueError, info2._check_consistency)
info2 = info.copy()
info2["lowpass"] = "foo"
assert_raises(ValueError, info2._check_consistency)
info2 = info.copy()
info2["filename"] = "foo"
assert_raises(KeyError, info2._check_consistency)
# Silent type conversion to float
info2 = info.copy()
info2["sfreq"] = 1
info2["highpass"] = 2
info2["lowpass"] = 2
info2._check_consistency()
assert_true(isinstance(info2["sfreq"], float))
assert_true(isinstance(info2["highpass"], float))
assert_true(isinstance(info2["lowpass"], float))
# Duplicate channel names
info2 = info.copy()
info2["chs"][2]["ch_name"] = "b"
assert_raises(RuntimeError, info2._check_consistency)
开发者ID:mne-tools,项目名称:mne-python,代码行数:47,代码来源:test_meas_info.py
示例16: test_redundant
def test_redundant():
"""Test some of the redundant properties of info."""
# Indexing
info = create_info(ch_names=['a', 'b', 'c'], sfreq=1000., ch_types=None)
assert info['ch_names'][0] == 'a'
assert info['ch_names'][1] == 'b'
assert info['ch_names'][2] == 'c'
# Equality
assert info['ch_names'] == info['ch_names']
assert info['ch_names'] == ['a', 'b', 'c']
# No channels in info
info = create_info(ch_names=[], sfreq=1000., ch_types=None)
assert info['ch_names'] == []
# List should be read-only
info = create_info(ch_names=['a', 'b', 'c'], sfreq=1000., ch_types=None)
开发者ID:jhouck,项目名称:mne-python,代码行数:18,代码来源:test_meas_info.py
示例17: test_redundant
def test_redundant():
"""Test some of the redundant properties of info"""
# Indexing
info = create_info(ch_names=['a', 'b', 'c'], sfreq=1000., ch_types=None)
assert_equal(info['ch_names'][0], 'a')
assert_equal(info['ch_names'][1], 'b')
assert_equal(info['ch_names'][2], 'c')
# Equality
assert_equal(info['ch_names'], info['ch_names'])
assert_equal(info['ch_names'], ['a', 'b', 'c'])
# No channels in info
info = create_info(ch_names=[], sfreq=1000., ch_types=None)
assert_equal(info['ch_names'], [])
# List should be read-only
info = create_info(ch_names=['a', 'b', 'c'], sfreq=1000., ch_types=None)
开发者ID:esdalmaijer,项目名称:mne-python,代码行数:18,代码来源:test_meas_info.py
示例18: test_redundant
def test_redundant():
"""Test some of the redundant properties of info."""
# Indexing
info = create_info(ch_names=["a", "b", "c"], sfreq=1000.0, ch_types=None)
assert_equal(info["ch_names"][0], "a")
assert_equal(info["ch_names"][1], "b")
assert_equal(info["ch_names"][2], "c")
# Equality
assert_equal(info["ch_names"], info["ch_names"])
assert_equal(info["ch_names"], ["a", "b", "c"])
# No channels in info
info = create_info(ch_names=[], sfreq=1000.0, ch_types=None)
assert_equal(info["ch_names"], [])
# List should be read-only
info = create_info(ch_names=["a", "b", "c"], sfreq=1000.0, ch_types=None)
开发者ID:mne-tools,项目名称:mne-python,代码行数:18,代码来源:test_meas_info.py
示例19: test_check_consistency
def test_check_consistency():
"""Test consistency check of Info objects"""
info = create_info(ch_names=['a', 'b', 'c'], sfreq=1000.)
# This should pass
info._check_consistency()
# Info without any channels
info_empty = create_info(ch_names=[], sfreq=1000.)
info_empty._check_consistency()
# Bad channels that are not in the info object
info2 = info.copy()
info2['bads'] = ['b', 'foo', 'bar']
assert_raises(RuntimeError, info2._check_consistency)
# Bad data types
info2 = info.copy()
info2['sfreq'] = 'foo'
assert_raises(ValueError, info2._check_consistency)
info2 = info.copy()
info2['highpass'] = 'foo'
assert_raises(ValueError, info2._check_consistency)
info2 = info.copy()
info2['lowpass'] = 'foo'
assert_raises(ValueError, info2._check_consistency)
# Silent type conversion to float
info2 = info.copy()
info2['sfreq'] = 1
info2['highpass'] = 2
info2['lowpass'] = 2
info2._check_consistency()
assert_true(isinstance(info2['sfreq'], float))
assert_true(isinstance(info2['highpass'], float))
assert_true(isinstance(info2['lowpass'], float))
# Duplicate channel names
info2 = info.copy()
info2['chs'][2]['ch_name'] = 'b'
assert_raises(RuntimeError, info2._check_consistency)
开发者ID:esdalmaijer,项目名称:mne-python,代码行数:43,代码来源:test_meas_info.py
示例20: test_array_epochs
def test_array_epochs():
"""Test creating evoked from array
"""
tempdir = _TempDir()
# creating
rng = np.random.RandomState(42)
data1 = rng.randn(20, 60)
sfreq = 1e3
ch_names = ['EEG %03d' % (i + 1) for i in range(20)]
types = ['eeg'] * 20
info = create_info(ch_names, sfreq, types)
evoked1 = EvokedArray(data1, info, tmin=-0.01)
# save, read, and compare evokeds
tmp_fname = op.join(tempdir, 'evkdary-ave.fif')
evoked1.save(tmp_fname)
evoked2 = read_evokeds(tmp_fname)[0]
data2 = evoked2.data
assert_allclose(data1, data2)
assert_allclose(evoked1.times, evoked2.times)
assert_equal(evoked1.first, evoked2.first)
assert_equal(evoked1.last, evoked2.last)
assert_equal(evoked1.kind, evoked2.kind)
assert_equal(evoked1.nave, evoked2.nave)
# now compare with EpochsArray (with single epoch)
data3 = data1[np.newaxis, :, :]
events = np.c_[10, 0, 1]
evoked3 = EpochsArray(data3, info, events=events, tmin=-0.01).average()
assert_allclose(evoked1.data, evoked3.data)
assert_allclose(evoked1.times, evoked3.times)
assert_equal(evoked1.first, evoked3.first)
assert_equal(evoked1.last, evoked3.last)
assert_equal(evoked1.kind, evoked3.kind)
assert_equal(evoked1.nave, evoked3.nave)
# test match between channels info and data
ch_names = ['EEG %03d' % (i + 1) for i in range(19)]
types = ['eeg'] * 19
info = create_info(ch_names, sfreq, types)
assert_raises(ValueError, EvokedArray, data1, info, tmin=-0.01)
开发者ID:Lem97,项目名称:mne-python,代码行数:42,代码来源:test_evoked.py
注:本文中的mne.io.meas_info.create_info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论