当前位置: 首页>>代码示例>>Python>>正文


Python Raw.time_to_index方法代码示例

本文整理汇总了Python中mne.fiff.Raw.time_to_index方法的典型用法代码示例。如果您正苦于以下问题:Python Raw.time_to_index方法的具体用法?Python Raw.time_to_index怎么用?Python Raw.time_to_index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mne.fiff.Raw的用法示例。


在下文中一共展示了Raw.time_to_index方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_io_raw

# 需要导入模块: from mne.fiff import Raw [as 别名]
# 或者: from mne.fiff.Raw import time_to_index [as 别名]
def test_io_raw():
    """Test IO for raw data (Neuromag + CTF)
    """
    for fname in [fif_fname, ctf_fname]:
        raw = Raw(fname)

        nchan = raw.info['nchan']
        ch_names = raw.info['ch_names']
        meg_channels_idx = [k for k in range(nchan)
                                            if ch_names[k][0] == 'M']
        n_channels = 100
        meg_channels_idx = meg_channels_idx[:n_channels]
        start, stop = raw.time_to_index(0, 5)
        data, times = raw[meg_channels_idx, start:(stop + 1)]
        meg_ch_names = [ch_names[k] for k in meg_channels_idx]

        # Set up pick list: MEG + STI 014 - bad channels
        include = ['STI 014']
        include += meg_ch_names
        picks = pick_types(raw.info, meg=True, eeg=False,
                                stim=True, misc=True, include=include,
                                exclude=raw.info['bads'])
        print "Number of picked channels : %d" % len(picks)

        # Writing with drop_small_buffer True
        raw.save('raw.fif', picks, tmin=0, tmax=4, buffer_size_sec=3,
                 drop_small_buffer=True)
        raw2 = Raw('raw.fif')

        sel = pick_channels(raw2.ch_names, meg_ch_names)
        data2, times2 = raw2[sel, :]
        assert_true(times2.max() <= 3)

        # Writing
        raw.save('raw.fif', picks, tmin=0, tmax=5)

        if fname == fif_fname:
            assert_true(len(raw.info['dig']) == 146)

        raw2 = Raw('raw.fif')

        sel = pick_channels(raw2.ch_names, meg_ch_names)
        data2, times2 = raw2[sel, :]

        assert_array_almost_equal(data, data2)
        assert_array_almost_equal(times, times2)
        assert_array_almost_equal(raw.info['dev_head_t']['trans'],
                                  raw2.info['dev_head_t']['trans'])
        assert_array_almost_equal(raw.info['sfreq'], raw2.info['sfreq'])

        if fname == fif_fname:
            assert_array_almost_equal(raw.info['dig'][0]['r'],
                                      raw2.info['dig'][0]['r'])

        fname = op.join(op.dirname(__file__), 'data', 'test_raw.fif')
开发者ID:sudo-nim,项目名称:mne-python,代码行数:57,代码来源:test_raw.py

示例2: test_io_complex

# 需要导入模块: from mne.fiff import Raw [as 别名]
# 或者: from mne.fiff.Raw import time_to_index [as 别名]
def test_io_complex():
    """ Test IO with complex data types """
    dtypes = [np.complex64, np.complex128]

    raw = Raw(fif_fname, preload=True)
    picks = np.arange(5)
    start, stop = raw.time_to_index(0, 5)

    data_orig, _ = raw[picks, start:stop]

    for dtype in dtypes:
        imag_rand = np.array(1j * np.random.randn(data_orig.shape[0],
                            data_orig.shape[1]), dtype)

        raw_cp = deepcopy(raw)
        raw_cp._data = np.array(raw_cp._data, dtype)
        raw_cp._data[picks, start:stop] += imag_rand
        raw_cp.save('raw.fif', picks, tmin=0, tmax=5)

        raw2 = Raw('raw.fif')
        raw2_data, _ = raw2[picks, :]
        n_samp = raw2_data.shape[1]
        assert_array_almost_equal(raw2_data[:, :n_samp],
                                  raw_cp._data[picks, :n_samp])
开发者ID:sudo-nim,项目名称:mne-python,代码行数:26,代码来源:test_raw.py

示例3: Raw

# 需要导入模块: from mne.fiff import Raw [as 别名]
# 或者: from mne.fiff.Raw import time_to_index [as 别名]
data_path = sample.data_path('..')
fname_inv = data_path + '/MEG/sample/sample_audvis-meg-oct-6-meg-inv.fif'
fname_raw = data_path + '/MEG/sample/sample_audvis_raw.fif'
label_name = 'Aud-lh'
fname_label = data_path + '/MEG/sample/labels/%s.label' % label_name

snr = 3.0
lambda2 = 1.0 / snr ** 2
dSPM = True

# Load data
raw = Raw(fname_raw)
inverse_operator = read_inverse_operator(fname_inv)
label = mne.read_label(fname_label)

start, stop = raw.time_to_index(0, 15)  # read the first 15s of data

# Compute inverse solution
stc = apply_inverse_raw(raw, inverse_operator, lambda2, dSPM, label,
                        start, stop, pick_normal=False)

# Save result in stc files
stc.save('mne_dSPM_raw_inverse_%s' % label_name)

###############################################################################
# View activation time-series
pl.plot(1e3 * stc.times, stc.data[::100, :].T)
pl.xlabel('time (ms)')
pl.ylabel('dSPM value')
pl.show()
开发者ID:KuperbergLab,项目名称:mne-python,代码行数:32,代码来源:plot_compute_mne_inverse_raw_in_label.py


注:本文中的mne.fiff.Raw.time_to_index方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。