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


Python Raw.append方法代码示例

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


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

示例1: test_copy_append

# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import append [as 别名]
def test_copy_append():
    """Test raw copying and appending combinations
    """
    raw = Raw(fif_fname, preload=True).copy()
    raw_full = Raw(fif_fname)
    raw_full.append(raw)
    data = raw_full[:, :][0]
    assert_equal(data.shape[1], 2 * raw._data.shape[1])
开发者ID:Pablo-Arias,项目名称:mne-python,代码行数:10,代码来源:test_raw_fiff.py

示例2: merge_fif_from_eo_ec

# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import append [as 别名]
def merge_fif_from_eo_ec(Subj_ID):
  from mne.io import Raw
  import pandas as pd
  from table_handling import get_eo_ec_by_name
  from params import main_path
  Subj_ID_ec = Subj_ID + ' CLOSED'
  Subj_ID_eo = Subj_ID + ' OPEN'
  eo_ec_table_fname = main_path + 'Aut_gamma_EO_EC_Timing.xls'
  suffix_open = '_rest_open_raw_tsss_mc_trans.fif'
  suffix_closed = '_rest_closed_raw_tsss_mc_trans.fif'
  suffix_merged = '_rest_raw_tsss_mc_trans.fif'
  filename_ec = main_path + 'MEG/' + Subj_ID + '/' + Subj_ID + suffix_closed
  filename_eo = main_path + 'MEG/' + Subj_ID + '/' + Subj_ID + suffix_open
  filename_merged = main_path + 'MEG/' + Subj_ID + '/' + Subj_ID + suffix_merged

  if Subj_ID[0] == 'K':
    sheetname = 'Control'
  elif Subj_ID[0] == 'R':
    sheetname = 'ASD'

  eo_ec_table = pd.read_excel(eo_ec_table_fname, skiprows=[1], sheetname=sheetname)
  idx_Subj_ID_ec = eo_ec_table.Subj_ID == Subj_ID_ec
  idx_Subj_ID_eo = eo_ec_table.Subj_ID == Subj_ID_eo
  first_samp_ec = eo_ec_table[idx_Subj_ID_ec]['#f'].get_values()[0]
  first_samp_eo = eo_ec_table[idx_Subj_ID_eo]['#f'].get_values()[0]

  raw_eo = Raw(filename_eo)
  raw_ec = Raw(filename_ec)
  ec_length = round(raw_ec.times[-1], 0)
  raw_ec.append(raw_eo)

  raw_ec.save(filename_merged, overwrite=True)
  # lCondStart, lCondEnd, first_samp, cond = \
  #   get_eo_ec_by_name(Subj_ID_ec, 'ec')
  lCondStart_eo, lCondEnd_eo, _, _ = \
    get_eo_ec_by_name(Subj_ID_eo, 'eo')

  lCondStart_eo = [time + ec_length - first_samp_eo + first_samp_ec for time in lCondStart_eo]
  lCondEnd_eo = [time + ec_length - first_samp_eo + first_samp_ec for time in lCondEnd_eo]
  print 'EO start times : {}'.format(lCondStart_eo)
  print 'EO end times : {}'.format(lCondEnd_eo)
  print 'Merged file length: {} seconds'.format(round(raw_ec.times[-1], 0))

  return
开发者ID:dmalt,项目名称:ICA_clean_pipeline,代码行数:46,代码来源:split_data.py

示例3: test_multiple_files

# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import append [as 别名]
def test_multiple_files():
    """Test loading multiple files simultaneously
    """
    # split file
    tempdir = _TempDir()
    raw = Raw(fif_fname).crop(0, 10, False)
    raw.load_data()
    raw.load_data()  # test no operation
    split_size = 3.  # in seconds
    sfreq = raw.info['sfreq']
    nsamp = (raw.last_samp - raw.first_samp)
    tmins = np.round(np.arange(0., nsamp, split_size * sfreq))
    tmaxs = np.concatenate((tmins[1:] - 1, [nsamp]))
    tmaxs /= sfreq
    tmins /= sfreq
    assert_equal(raw.n_times, len(raw.times))

    # going in reverse order so the last fname is the first file (need later)
    raws = [None] * len(tmins)
    for ri in range(len(tmins) - 1, -1, -1):
        fname = op.join(tempdir, 'test_raw_split-%d_raw.fif' % ri)
        raw.save(fname, tmin=tmins[ri], tmax=tmaxs[ri])
        raws[ri] = Raw(fname)
    events = [find_events(r, stim_channel='STI 014') for r in raws]
    last_samps = [r.last_samp for r in raws]
    first_samps = [r.first_samp for r in raws]

    # test concatenation of split file
    assert_raises(ValueError, concatenate_raws, raws, True, events[1:])
    all_raw_1, events1 = concatenate_raws(raws, preload=False,
                                          events_list=events)
    assert_equal(raw.first_samp, all_raw_1.first_samp)
    assert_equal(raw.last_samp, all_raw_1.last_samp)
    assert_allclose(raw[:, :][0], all_raw_1[:, :][0])
    raws[0] = Raw(fname)
    all_raw_2 = concatenate_raws(raws, preload=True)
    assert_allclose(raw[:, :][0], all_raw_2[:, :][0])

    # test proper event treatment for split files
    events2 = concatenate_events(events, first_samps, last_samps)
    events3 = find_events(all_raw_2, stim_channel='STI 014')
    assert_array_equal(events1, events2)
    assert_array_equal(events1, events3)

    # test various methods of combining files
    raw = Raw(fif_fname, preload=True)
    n_times = raw.n_times
    # make sure that all our data match
    times = list(range(0, 2 * n_times, 999))
    # add potentially problematic points
    times.extend([n_times - 1, n_times, 2 * n_times - 1])

    raw_combo0 = Raw([fif_fname, fif_fname], preload=True)
    _compare_combo(raw, raw_combo0, times, n_times)
    raw_combo = Raw([fif_fname, fif_fname], preload=False)
    _compare_combo(raw, raw_combo, times, n_times)
    raw_combo = Raw([fif_fname, fif_fname], preload='memmap8.dat')
    _compare_combo(raw, raw_combo, times, n_times)
    assert_raises(ValueError, Raw, [fif_fname, ctf_fname])
    assert_raises(ValueError, Raw, [fif_fname, fif_bad_marked_fname])
    assert_equal(raw[:, :][0].shape[1] * 2, raw_combo0[:, :][0].shape[1])
    assert_equal(raw_combo0[:, :][0].shape[1], raw_combo0.n_times)

    # with all data preloaded, result should be preloaded
    raw_combo = Raw(fif_fname, preload=True)
    raw_combo.append(Raw(fif_fname, preload=True))
    assert_true(raw_combo.preload is True)
    assert_equal(raw_combo.n_times, raw_combo._data.shape[1])
    _compare_combo(raw, raw_combo, times, n_times)

    # with any data not preloaded, don't set result as preloaded
    raw_combo = concatenate_raws([Raw(fif_fname, preload=True),
                                  Raw(fif_fname, preload=False)])
    assert_true(raw_combo.preload is False)
    assert_array_equal(find_events(raw_combo, stim_channel='STI 014'),
                       find_events(raw_combo0, stim_channel='STI 014'))
    _compare_combo(raw, raw_combo, times, n_times)

    # user should be able to force data to be preloaded upon concat
    raw_combo = concatenate_raws([Raw(fif_fname, preload=False),
                                  Raw(fif_fname, preload=True)],
                                 preload=True)
    assert_true(raw_combo.preload is True)
    _compare_combo(raw, raw_combo, times, n_times)

    raw_combo = concatenate_raws([Raw(fif_fname, preload=False),
                                  Raw(fif_fname, preload=True)],
                                 preload='memmap3.dat')
    _compare_combo(raw, raw_combo, times, n_times)

    raw_combo = concatenate_raws([Raw(fif_fname, preload=True),
                                  Raw(fif_fname, preload=True)],
                                 preload='memmap4.dat')
    _compare_combo(raw, raw_combo, times, n_times)

    raw_combo = concatenate_raws([Raw(fif_fname, preload=False),
                                  Raw(fif_fname, preload=False)],
                                 preload='memmap5.dat')
    _compare_combo(raw, raw_combo, times, n_times)

#.........这里部分代码省略.........
开发者ID:Pablo-Arias,项目名称:mne-python,代码行数:103,代码来源:test_raw_fiff.py


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