本文整理汇总了Python中mne.fiff.Raw.resample方法的典型用法代码示例。如果您正苦于以下问题:Python Raw.resample方法的具体用法?Python Raw.resample怎么用?Python Raw.resample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mne.fiff.Raw
的用法示例。
在下文中一共展示了Raw.resample方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_resample
# 需要导入模块: from mne.fiff import Raw [as 别名]
# 或者: from mne.fiff.Raw import resample [as 别名]
def test_resample():
"""Test resample (with I/O and multiple files)
"""
raw = Raw(fif_fname, preload=True).crop(0, 3, False)
raw_resamp = raw.copy()
sfreq = raw.info['sfreq']
# test parallel on upsample
raw_resamp.resample(sfreq * 2, n_jobs=2)
assert_true(raw_resamp.n_times == len(raw_resamp._times))
raw_resamp.save(op.join(tempdir, 'raw_resamp.fif'))
raw_resamp = Raw(op.join(tempdir, 'raw_resamp.fif'), preload=True)
assert_true(sfreq == raw_resamp.info['sfreq'] / 2)
assert_true(raw.n_times == raw_resamp.n_times / 2)
assert_true(raw_resamp._data.shape[1] == raw_resamp.n_times)
assert_true(raw._data.shape[0] == raw_resamp._data.shape[0])
# test non-parallel on downsample
raw_resamp.resample(sfreq, n_jobs=1)
assert_true(raw_resamp.info['sfreq'] == sfreq)
assert_true(raw._data.shape == raw_resamp._data.shape)
assert_true(raw.first_samp == raw_resamp.first_samp)
assert_true(raw.last_samp == raw.last_samp)
# upsampling then downsampling doubles resampling error, but this still
# works (hooray). Note that the stim channels had to be sub-sampled
# without filtering to be accurately preserved
# note we have to treat MEG and EEG+STIM channels differently (tols)
assert_allclose(raw._data[:306, 200:-200],
raw_resamp._data[:306, 200:-200],
rtol=1e-2, atol=1e-12)
assert_allclose(raw._data[306:, 200:-200],
raw_resamp._data[306:, 200:-200],
rtol=1e-2, atol=1e-7)
# now check multiple file support w/resampling, as order of operations
# (concat, resample) should not affect our data
raw1 = raw.copy()
raw2 = raw.copy()
raw3 = raw.copy()
raw4 = raw.copy()
raw1 = concatenate_raws([raw1, raw2])
raw1.resample(10)
raw3.resample(10)
raw4.resample(10)
raw3 = concatenate_raws([raw3, raw4])
assert_array_equal(raw1._data, raw3._data)
assert_array_equal(raw1._first_samps, raw3._first_samps)
assert_array_equal(raw1._last_samps, raw3._last_samps)
assert_array_equal(raw1._raw_lengths, raw3._raw_lengths)
assert_equal(raw1.first_samp, raw3.first_samp)
assert_equal(raw1.last_samp, raw3.last_samp)
assert_equal(raw1.info['sfreq'], raw3.info['sfreq'])