• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python test_raw._test_raw_reader函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mne.io.tests.test_raw._test_raw_reader函数的典型用法代码示例。如果您正苦于以下问题:Python _test_raw_reader函数的具体用法?Python _test_raw_reader怎么用?Python _test_raw_reader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_edf_data

def test_edf_data():
    """Test edf files"""
    _test_raw_reader(read_raw_edf, input_fname=edf_path, stim_channel=None)
    raw_py = read_raw_edf(edf_path, preload=True)
    # Test saving and loading when annotations were parsed.
    tempdir = _TempDir()
    raw_file = op.join(tempdir, 'test-raw.fif')
    raw_py.save(raw_file, overwrite=True, buffer_size_sec=1)
    Raw(raw_file, preload=True)

    edf_events = find_events(raw_py, output='step', shortest_event=0,
                             stim_channel='STI 014')

    # onset, duration, id
    events = [[0.1344, 0.2560, 2],
              [0.3904, 1.0000, 2],
              [2.0000, 0.0000, 3],
              [2.5000, 2.5000, 2]]
    events = np.array(events)
    events[:, :2] *= 512  # convert time to samples
    events = np.array(events, dtype=int)
    events[:, 1] -= 1
    events[events[:, 1] <= 0, 1] = 1
    events[:, 1] += events[:, 0]

    onsets = events[:, [0, 2]]
    offsets = events[:, [1, 2]]

    events = np.zeros((2 * events.shape[0], 3), dtype=int)
    events[0::2, [0, 2]] = onsets
    events[1::2, [0, 1]] = offsets

    assert_array_equal(edf_events, events)
开发者ID:EmanuelaLiaci,项目名称:mne-python,代码行数:33,代码来源:test_edf.py


示例2: test_gdf2_data

def test_gdf2_data():
    """Test reading raw GDF 2.x files."""
    raw = read_raw_edf(gdf2_path + '.gdf', eog=None, misc=None, preload=True)

    picks = pick_types(raw.info, meg=False, eeg=True, exclude='bads')
    data, _ = raw[picks]

    # This .mat was generated using the official biosig matlab package
    mat = sio.loadmat(gdf2_path + '_biosig.mat')
    data_biosig = mat['dat'] * 1e-6  # data are stored in microvolts
    data_biosig = data_biosig[picks]

    # Assert data are almost equal
    assert_array_almost_equal(data, data_biosig, 8)

    # Find events
    events = find_events(raw, verbose=1)
    events[:, 2] >>= 8  # last 8 bits are system events in biosemi files
    assert_equal(events.shape[0], 2)  # 2 events in file
    assert_array_equal(events[:, 2], [20, 28])

    # gh-5604
    assert raw.info['meas_date'] == DATE_NONE
    _test_raw_reader(read_raw_edf, input_fname=gdf2_path + '.gdf',
                     eog=None, misc=None)
开发者ID:kambysese,项目名称:mne-python,代码行数:25,代码来源:test_gdf.py


示例3: test_eximia_nxe

def test_eximia_nxe():
    """Test reading Eximia NXE files"""
    fname = op.join(data_path(), 'eximia', 'test_eximia.nxe')
    raw = read_raw_eximia(fname, preload=True)
    assert_true('RawEximia' in repr(raw))
    _test_raw_reader(read_raw_eximia, fname=fname)
    fname_mat = op.join(data_path(), 'eximia', 'test_eximia.mat')
    mc = sio.loadmat(fname_mat)
    m_data = mc['data']
    m_header = mc['header']
    assert_equal(raw._data.shape, m_data.shape)
    assert_equal(m_header['Fs'][0, 0][0, 0], raw.info['sfreq'])
    m_names = [x[0][0] for x in m_header['label'][0, 0]]
    m_names = list(
        map(lambda x: x.replace('GATE', 'GateIn').replace('TRIG', 'Trig'),
            m_names))
    assert_equal(raw.ch_names, m_names)
    m_ch_types = [x[0][0] for x in m_header['chantype'][0, 0]]
    m_ch_types = list(
        map(lambda x: x.replace('unknown', 'stim').replace('trigger', 'stim'),
            m_ch_types))
    types_dict = {2: 'eeg', 3: 'stim', 202: 'eog'}
    ch_types = [types_dict[raw.info['chs'][x]['kind']]
                for x in range(len(raw.ch_names))]
    assert_equal(ch_types, m_ch_types)

    assert_array_equal(m_data, raw._data)
开发者ID:jdammers,项目名称:mne-python,代码行数:27,代码来源:test_eximia.py


示例4: test_bdf_data

def test_bdf_data():
    """Test reading raw bdf files."""
    raw_py = _test_raw_reader(read_raw_edf, input_fname=bdf_path,
                              eog=eog, misc=misc,
                              exclude=['M2', 'IEOG'])
    assert len(raw_py.ch_names) == 71
    raw_py = _test_raw_reader(read_raw_edf, input_fname=bdf_path,
                              montage=montage_path, eog=eog, misc=misc,
                              exclude=['M2', 'IEOG'])
    assert len(raw_py.ch_names) == 71
    assert 'RawEDF' in repr(raw_py)
    picks = pick_types(raw_py.info, meg=False, eeg=True, exclude='bads')
    data_py, _ = raw_py[picks]

    # this .mat was generated using the EEG Lab Biosemi Reader
    raw_eeglab = loadmat(bdf_eeglab_path)
    raw_eeglab = raw_eeglab['data'] * 1e-6  # data are stored in microvolts
    data_eeglab = raw_eeglab[picks]
    # bdf saved as a single, resolution to seven decimal points in matlab
    assert_array_almost_equal(data_py, data_eeglab, 8)

    # Manually checking that float coordinates are imported
    assert (raw_py.info['chs'][0]['loc']).any()
    assert (raw_py.info['chs'][25]['loc']).any()
    assert (raw_py.info['chs'][63]['loc']).any()
开发者ID:kdoelling1919,项目名称:mne-python,代码行数:25,代码来源:test_edf.py


示例5: test_gdf2_data

def test_gdf2_data():
    """Test reading raw GDF 2.x files."""
    raw = read_raw_edf(gdf2_path + '.gdf', eog=None, misc=None, preload=True,
                       stim_channel='STATUS')

    nchan = raw.info['nchan']
    ch_names = raw.ch_names  # Renamed STATUS -> STI 014.
    picks = pick_types(raw.info, meg=False, eeg=True, exclude='bads')
    data, _ = raw[picks]

    # This .mat was generated using the official biosig matlab package
    mat = sio.loadmat(gdf2_path + '_biosig.mat')
    data_biosig = mat['dat'] * 1e-6  # data are stored in microvolts
    data_biosig = data_biosig[picks]

    # Assert data are almost equal
    assert_array_almost_equal(data, data_biosig, 8)

    # Find events
    events = find_events(raw, verbose=1)
    events[:, 2] >>= 8  # last 8 bits are system events in biosemi files
    assert_equal(events.shape[0], 2)  # 2 events in file
    assert_array_equal(events[:, 2], [20, 28])

    with pytest.warns(RuntimeWarning, match='No events found'):
        # header contains no events
        raw = read_raw_edf(gdf2_path + '.gdf', stim_channel='auto')
    assert_equal(nchan, raw.info['nchan'])  # stim channel not constructed
    assert_array_equal(ch_names[1:], raw.ch_names[1:])

    # gh-5604
    assert raw.info['meas_date'] == DATE_NONE
    _test_raw_reader(read_raw_edf, input_fname=gdf2_path + '.gdf',
                     eog=None, misc=None, stim_channel='STATUS')
开发者ID:jhouck,项目名称:mne-python,代码行数:34,代码来源:test_gdf.py


示例6: test_gdf_data

def test_gdf_data():
    """Test reading raw GDF 1.x files."""
    with pytest.warns(RuntimeWarning, match='Overlapping events'):
        raw = read_raw_edf(gdf1_path + '.gdf', eog=None,
                           misc=None, preload=True, stim_channel='auto')
    picks = pick_types(raw.info, meg=False, eeg=True, exclude='bads')
    data, _ = raw[picks]

    # this .npy was generated using the official biosig python package
    raw_biosig = np.load(gdf1_path + '_biosig.npy')
    raw_biosig = raw_biosig * 1e-6  # data are stored in microvolts
    data_biosig = raw_biosig[picks]

    # Assert data are almost equal
    assert_array_almost_equal(data, data_biosig, 8)

    # Test for stim channel
    events = find_events(raw, shortest_event=1)
    # The events are overlapping.
    assert_array_equal(events[:, 0], raw._raw_extras[0]['events'][1][::2])

    # Test events are encoded to stim channel.
    events = find_events(raw)
    evs = raw.find_edf_events()
    assert (all([event in evs[1] for event in events[:, 0]]))

    # gh-5604
    assert raw.info['meas_date'] == DATE_NONE
    with pytest.warns(RuntimeWarning, match='Overlapping events'):
        _test_raw_reader(read_raw_edf, input_fname=gdf1_path + '.gdf',
                         eog=None, misc=None, stim_channel='auto')
开发者ID:jhouck,项目名称:mne-python,代码行数:31,代码来源:test_gdf.py


示例7: test_brainvision_data_highpass_filters

def test_brainvision_data_highpass_filters():
    """Test reading raw Brain Vision files with amplifier filter settings."""
    # Homogeneous highpass in seconds (default measurement unit)
    with warnings.catch_warnings(record=True) as w:  # event parsing
        raw = _test_raw_reader(
            read_raw_brainvision, vhdr_fname=vhdr_highpass_path,
            montage=montage, eog=eog)
    assert_true(all('parse triggers that' in str(ww.message) for ww in w))

    assert_equal(raw.info['highpass'], 0.1)
    assert_equal(raw.info['lowpass'], 250.)

    # Heterogeneous highpass in seconds (default measurement unit)
    with warnings.catch_warnings(record=True) as w:  # event parsing
        raw = _test_raw_reader(
            read_raw_brainvision, vhdr_fname=vhdr_mixed_highpass_path,
            montage=montage, eog=eog, event_id=event_id)

    lowpass_warning = ['different lowpass filters' in str(ww.message)
                       for ww in w]
    highpass_warning = ['different highpass filters' in str(ww.message)
                        for ww in w]

    expected_warnings = zip(lowpass_warning, highpass_warning)

    assert_true(all(any([lp, hp]) for lp, hp in expected_warnings))

    assert_equal(raw.info['highpass'], 0.1)
    assert_equal(raw.info['lowpass'], 250.)

    # Homogeneous highpass in Hertz
    with warnings.catch_warnings(record=True):  # filter settings
        raw = _test_raw_reader(
            read_raw_brainvision, vhdr_fname=vhdr_highpass_hz_path,
            montage=montage, eog=eog, event_id=event_id)

    assert_equal(raw.info['highpass'], 10.)
    assert_equal(raw.info['lowpass'], 250.)

    # Heterogeneous highpass in Hertz
    with warnings.catch_warnings(record=True):  # filter settings
        raw = _test_raw_reader(
            read_raw_brainvision, vhdr_fname=vhdr_mixed_highpass_hz_path,
            montage=montage, eog=eog, event_id=event_id)

    trigger_warning = ['parse triggers that' in str(ww.message)
                       for ww in w]
    lowpass_warning = ['different lowpass filters' in str(ww.message)
                       for ww in w]
    highpass_warning = ['different highpass filters' in str(ww.message)
                        for ww in w]

    expected_warnings = zip(trigger_warning, lowpass_warning, highpass_warning)

    assert_true(all(any([trg, lp, hp]) for trg, lp, hp in expected_warnings))

    assert_equal(raw.info['highpass'], 5.)
    assert_equal(raw.info['lowpass'], 250.)
开发者ID:hoechenberger,项目名称:mne-python,代码行数:58,代码来源:test_brainvision.py


示例8: test_brainvision_data

def test_brainvision_data():
    """Test reading raw Brain Vision files."""
    pytest.raises(IOError, read_raw_brainvision, vmrk_path)
    pytest.raises(ValueError, read_raw_brainvision, vhdr_path, montage,
                  preload=True, scale="foo")

    raw_py = _test_raw_reader(
        read_raw_brainvision, vhdr_fname=vhdr_path, montage=montage,
        eog=eog, misc='auto', event_id=event_id)

    assert ('RawBrainVision' in repr(raw_py))

    assert_equal(raw_py.info['highpass'], 0.)
    assert_equal(raw_py.info['lowpass'], 250.)

    picks = pick_types(raw_py.info, meg=False, eeg=True, exclude='bads')
    data_py, times_py = raw_py[picks]

    # compare with a file that was generated using MNE-C
    raw_bin = read_raw_fif(eeg_bin, preload=True)
    picks = pick_types(raw_py.info, meg=False, eeg=True, exclude='bads')
    data_bin, times_bin = raw_bin[picks]

    assert_array_almost_equal(data_py, data_bin)
    assert_array_almost_equal(times_py, times_bin)

    # Make sure EOG channels are marked correctly
    for ch in raw_py.info['chs']:
        if ch['ch_name'] in eog:
            assert_equal(ch['kind'], FIFF.FIFFV_EOG_CH)
        elif ch['ch_name'] == 'STI 014':
            assert_equal(ch['kind'], FIFF.FIFFV_STIM_CH)
        elif ch['ch_name'] in ('CP5', 'CP6'):
            assert_equal(ch['kind'], FIFF.FIFFV_MISC_CH)
            assert_equal(ch['unit'], FIFF.FIFF_UNIT_NONE)
        elif ch['ch_name'] == 'ReRef':
            assert_equal(ch['kind'], FIFF.FIFFV_MISC_CH)
            assert_equal(ch['unit'], FIFF.FIFF_UNIT_CEL)
        elif ch['ch_name'] in raw_py.info['ch_names']:
            assert_equal(ch['kind'], FIFF.FIFFV_EEG_CH)
            assert_equal(ch['unit'], FIFF.FIFF_UNIT_V)
        else:
            raise RuntimeError("Unknown Channel: %s" % ch['ch_name'])

    # test loading v2
    read_raw_brainvision(vhdr_v2_path, eog=eog, preload=True,
                         event_id=event_id,
                         trig_shift_by_type={'response': 1000},
                         verbose='error')
    # For the nanovolt unit test we use the same data file with a different
    # header file.
    raw_nV = _test_raw_reader(
        read_raw_brainvision, vhdr_fname=vhdr_nV_path, montage=montage,
        eog=eog, misc='auto', event_id=event_id)
    assert_equal(raw_nV.info['chs'][0]['ch_name'], 'FP1')
    assert_equal(raw_nV.info['chs'][0]['kind'], FIFF.FIFFV_EEG_CH)
    data_nanovolt, _ = raw_nV[0]
    assert_array_almost_equal(data_py[0, :], data_nanovolt[0, :])
开发者ID:emilymuller1991,项目名称:mne-python,代码行数:58,代码来源:test_brainvision.py


示例9: test_data

def test_data():
    """Test reading raw Artemis123 files."""
    _test_raw_reader(read_raw_artemis123, input_fname=short_no_HPI_fname)

    # test a random selected point
    raw = read_raw_artemis123(short_no_HPI_fname, preload=True)
    meg_picks = pick_types(raw.info, meg=True, eeg=False)
    # checked against matlab reader.
    assert_allclose(raw[meg_picks[12]][0][0][123], 3.072510659694672e-11)
开发者ID:hoechenberger,项目名称:mne-python,代码行数:9,代码来源:test_artemis123.py


示例10: test_data

def test_data():
    """Test reading raw kit files
    """
    assert_raises(TypeError, read_raw_kit, epochs_path)
    assert_raises(TypeError, read_epochs_kit, sqd_path)
    assert_raises(ValueError, read_raw_kit, sqd_path, mrk_path, elp_path)
    assert_raises(ValueError, read_raw_kit, sqd_path, None, None, None,
                  list(range(200, 190, -1)))
    assert_raises(ValueError, read_raw_kit, sqd_path, None, None, None,
                  list(range(167, 159, -1)), '*', 1, True)
    # check functionality
    raw_mrk = read_raw_kit(sqd_path, [mrk2_path, mrk3_path], elp_path,
                           hsp_path)
    raw_py = _test_raw_reader(read_raw_kit,
                              input_fname=sqd_path, mrk=mrk_path, elp=elp_path,
                              hsp=hsp_path, stim=list(range(167, 159, -1)),
                              slope='+', stimthresh=1)
    assert_true('RawKIT' in repr(raw_py))
    assert_equal(raw_mrk.info['kit_system_id'], KIT.SYSTEM_NYU_2010)
    assert_true(KIT_CONSTANTS[raw_mrk.info['kit_system_id']] is KIT_NY)

    # Test stim channel
    raw_stim = read_raw_kit(sqd_path, mrk_path, elp_path, hsp_path, stim='<',
                            preload=False)
    for raw in [raw_py, raw_stim, raw_mrk]:
        stim_pick = pick_types(raw.info, meg=False, ref_meg=False,
                               stim=True, exclude='bads')
        stim1, _ = raw[stim_pick]
        stim2 = np.array(raw.read_stim_ch(), ndmin=2)
        assert_array_equal(stim1, stim2)

    # Binary file only stores the sensor channels
    py_picks = pick_types(raw_py.info, exclude='bads')
    raw_bin = op.join(data_dir, 'test_bin_raw.fif')
    raw_bin = Raw(raw_bin, preload=True)
    bin_picks = pick_types(raw_bin.info, stim=True, exclude='bads')
    data_bin, _ = raw_bin[bin_picks]
    data_py, _ = raw_py[py_picks]

    # this .mat was generated using the Yokogawa MEG Reader
    data_Ykgw = op.join(data_dir, 'test_Ykgw.mat')
    data_Ykgw = scipy.io.loadmat(data_Ykgw)['data']
    data_Ykgw = data_Ykgw[py_picks]

    assert_array_almost_equal(data_py, data_Ykgw)

    py_picks = pick_types(raw_py.info, stim=True, ref_meg=False,
                          exclude='bads')
    data_py, _ = raw_py[py_picks]
    assert_array_almost_equal(data_py, data_bin)

    # KIT-UMD data
    _test_raw_reader(read_raw_kit, input_fname=sqd_umd_path)
    raw = read_raw_kit(sqd_umd_path)
    assert_equal(raw.info['kit_system_id'], KIT.SYSTEM_UMD_2014_12)
    assert_true(KIT_CONSTANTS[raw.info['kit_system_id']] is KIT_UMD_2014)
开发者ID:EmanuelaLiaci,项目名称:mne-python,代码行数:56,代码来源:test_kit.py


示例11: test_brainvision_data_highpass_filters

def test_brainvision_data_highpass_filters():
    """Test reading raw Brain Vision files with amplifier filter settings."""
    # Homogeneous highpass in seconds (default measurement unit)
    raw = _test_raw_reader(
        read_raw_brainvision, vhdr_fname=vhdr_highpass_path,
        montage=montage, eog=eog)

    assert_equal(raw.info['highpass'], 1. / (2 * np.pi * 10))
    assert_equal(raw.info['lowpass'], 250.)

    # Heterogeneous highpass in seconds (default measurement unit)
    with pytest.warns(RuntimeWarning, match='different .*pass filters') as w:
        raw = _test_raw_reader(
            read_raw_brainvision, vhdr_fname=vhdr_mixed_highpass_path,
            montage=montage, eog=eog)

    lowpass_warning = ['different lowpass filters' in str(ww.message)
                       for ww in w]
    highpass_warning = ['different highpass filters' in str(ww.message)
                        for ww in w]

    expected_warnings = zip(lowpass_warning, highpass_warning)

    assert (all(any([lp, hp]) for lp, hp in expected_warnings))

    assert_equal(raw.info['highpass'], 1. / (2 * np.pi * 10))
    assert_equal(raw.info['lowpass'], 250.)

    # Homogeneous highpass in Hertz
    raw = _test_raw_reader(
        read_raw_brainvision, vhdr_fname=vhdr_highpass_hz_path,
        montage=montage, eog=eog)

    assert_equal(raw.info['highpass'], 10.)
    assert_equal(raw.info['lowpass'], 250.)

    # Heterogeneous highpass in Hertz
    with pytest.warns(RuntimeWarning, match='different .*pass filters') as w:
        raw = _test_raw_reader(
            read_raw_brainvision, vhdr_fname=vhdr_mixed_highpass_hz_path,
            montage=montage, eog=eog)

    trigger_warning = ['will be dropped' in str(ww.message)
                       for ww in w]
    lowpass_warning = ['different lowpass filters' in str(ww.message)
                       for ww in w]
    highpass_warning = ['different highpass filters' in str(ww.message)
                        for ww in w]

    expected_warnings = zip(trigger_warning, lowpass_warning, highpass_warning)

    assert (all(any([trg, lp, hp]) for trg, lp, hp in expected_warnings))

    assert_equal(raw.info['highpass'], 5.)
    assert_equal(raw.info['lowpass'], 250.)
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:55,代码来源:test_brainvision.py


示例12: test_io_set

def test_io_set():
    """Test importing EEGLAB .set files"""
    from scipy import io

    _test_raw_reader(read_raw_eeglab, input_fname=raw_fname, montage=montage)
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter('always')
        _test_raw_reader(read_raw_eeglab, input_fname=raw_fname_onefile,
                         montage=montage)
        raw = read_raw_eeglab(input_fname=raw_fname_onefile, montage=montage)
        raw2 = read_raw_eeglab(input_fname=raw_fname, montage=montage)
        assert_array_equal(raw[:][0], raw2[:][0])
    # one warning per each preload=False or str with raw_fname_onefile
    assert_equal(len(w), 3)

    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter('always')
        epochs = read_epochs_eeglab(epochs_fname)
        epochs2 = read_epochs_eeglab(epochs_fname_onefile)
    # 3 warnings for each read_epochs_eeglab because there are 3 epochs
    # associated with multiple events
    assert_equal(len(w), 6)
    assert_array_equal(epochs.get_data(), epochs2.get_data())

    # test different combinations of events and event_ids
    temp_dir = _TempDir()
    out_fname = op.join(temp_dir, 'test-eve.fif')
    write_events(out_fname, epochs.events)
    event_id = {'S255/S8': 1, 'S8': 2, 'S255/S9': 3}

    epochs = read_epochs_eeglab(epochs_fname, epochs.events, event_id)
    epochs = read_epochs_eeglab(epochs_fname, out_fname, event_id)
    assert_raises(ValueError, read_epochs_eeglab, epochs_fname,
                  None, event_id)
    assert_raises(ValueError, read_epochs_eeglab, epochs_fname,
                  epochs.events, None)

    # test if .dat file raises an error
    eeg = io.loadmat(epochs_fname, struct_as_record=False,
                     squeeze_me=True)['EEG']
    eeg.data = 'epochs_fname.dat'
    bad_epochs_fname = op.join(temp_dir, 'test_epochs.set')
    io.savemat(bad_epochs_fname, {'EEG':
               {'trials': eeg.trials, 'srate': eeg.srate,
                'nbchan': eeg.nbchan, 'data': eeg.data,
                'epoch': eeg.epoch, 'event': eeg.event,
                'chanlocs': eeg.chanlocs}})
    shutil.copyfile(op.join(base_dir, 'test_epochs.fdt'),
                    op.join(temp_dir, 'test_epochs.dat'))
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter('always')
        assert_raises(NotImplementedError, read_epochs_eeglab,
                      bad_epochs_fname)
    assert_equal(len(w), 3)
开发者ID:Famguy,项目名称:mne-python,代码行数:54,代码来源:test_eeglab.py


示例13: test_brainvision_data_lowpass_filters

def test_brainvision_data_lowpass_filters():
    """Test files with amplifier LP filter settings."""
    # Homogeneous lowpass in Hertz (default measurement unit)
    raw = _test_raw_reader(
        read_raw_brainvision, vhdr_fname=vhdr_lowpass_path,
        montage=montage, eog=eog)

    assert_equal(raw.info['highpass'], 1. / (2 * np.pi * 10))
    assert_equal(raw.info['lowpass'], 250.)

    # Heterogeneous lowpass in Hertz (default measurement unit)
    with pytest.warns(RuntimeWarning) as w:  # event parsing
        raw = _test_raw_reader(
            read_raw_brainvision, vhdr_fname=vhdr_mixed_lowpass_path,
            montage=montage, eog=eog)

    lowpass_warning = ['different lowpass filters' in str(ww.message)
                       for ww in w]
    highpass_warning = ['different highpass filters' in str(ww.message)
                        for ww in w]

    expected_warnings = zip(lowpass_warning, highpass_warning)

    assert (all(any([lp, hp]) for lp, hp in expected_warnings))

    assert_equal(raw.info['highpass'], 1. / (2 * np.pi * 10))
    assert_equal(raw.info['lowpass'], 250.)

    # Homogeneous lowpass in seconds
    raw = _test_raw_reader(
        read_raw_brainvision, vhdr_fname=vhdr_lowpass_s_path,
        montage=montage, eog=eog)

    assert_equal(raw.info['highpass'], 1. / (2 * np.pi * 10))
    assert_equal(raw.info['lowpass'], 1. / (2 * np.pi * 0.004))

    # Heterogeneous lowpass in seconds
    with pytest.warns(RuntimeWarning) as w:  # filter settings
        raw = _test_raw_reader(
            read_raw_brainvision, vhdr_fname=vhdr_mixed_lowpass_s_path,
            montage=montage, eog=eog)

    lowpass_warning = ['different lowpass filters' in str(ww.message)
                       for ww in w]
    highpass_warning = ['different highpass filters' in str(ww.message)
                        for ww in w]

    expected_warnings = zip(lowpass_warning, highpass_warning)

    assert (all(any([lp, hp]) for lp, hp in expected_warnings))

    assert_equal(raw.info['highpass'], 1. / (2 * np.pi * 10))
    assert_equal(raw.info['lowpass'], 1. / (2 * np.pi * 0.004))
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:53,代码来源:test_brainvision.py


示例14: test_brainvision_data

def test_brainvision_data():
    """Test reading raw Brain Vision files
    """
    assert_raises(IOError, read_raw_brainvision, vmrk_path)
    assert_raises(ValueError, read_raw_brainvision, vhdr_path, montage,
                  preload=True, scale="foo")
    raw_py = _test_raw_reader(read_raw_brainvision, test_preloading=True,
                              vhdr_fname=vhdr_path, montage=montage, eog=eog)

    assert_true('RawBrainVision' in repr(raw_py))

    assert_equal(raw_py.info['highpass'], 0.)
    assert_equal(raw_py.info['lowpass'], 250.)

    picks = pick_types(raw_py.info, meg=False, eeg=True, exclude='bads')
    data_py, times_py = raw_py[picks]

    # compare with a file that was generated using MNE-C
    raw_bin = Raw(eeg_bin, preload=True)
    picks = pick_types(raw_py.info, meg=False, eeg=True, exclude='bads')
    data_bin, times_bin = raw_bin[picks]

    assert_array_almost_equal(data_py, data_bin)
    assert_array_almost_equal(times_py, times_bin)

    # Make sure EOG channels are marked correctly
    for ch in raw_py.info['chs']:
        if ch['ch_name'] in eog:
            assert_equal(ch['kind'], FIFF.FIFFV_EOG_CH)
        elif ch['ch_name'] == 'STI 014':
            assert_equal(ch['kind'], FIFF.FIFFV_STIM_CH)
        elif ch['ch_name'] in raw_py.info['ch_names']:
            assert_equal(ch['kind'], FIFF.FIFFV_EEG_CH)
        else:
            raise RuntimeError("Unknown Channel: %s" % ch['ch_name'])
开发者ID:orekhova,项目名称:mne-python,代码行数:35,代码来源:test_brainvision.py


示例15: test_data

def test_data():
    """Test reading raw cnt files."""
    raw = _test_raw_reader(read_raw_cnt, montage=None, input_fname=fname,
                           eog='auto', misc=['NA1', 'LEFT_EAR'])
    eog_chs = mne.pick_types(raw.info, eog=True, exclude=[])
    assert_equal(len(eog_chs), 2)  # test eog='auto'
    assert_equal(raw.info['bads'], ['LEFT_EAR', 'VEOGR'])  # test bads
开发者ID:TomDLT,项目名称:mne-python,代码行数:7,代码来源:test_cnt.py


示例16: test_bdf_stim_channel

def test_bdf_stim_channel():
    """Test BDF stim channel."""
    # test if last channel is detected as STIM by default
    raw_py = _test_raw_reader(read_raw_edf, input_fname=bdf_path,
                              stim_channel='auto')
    assert channel_type(raw_py.info, raw_py.info["nchan"] - 1) == 'stim'

    # test BDF file with wrong scaling info in header - this should be ignored
    # for BDF stim channels
    events = [[242, 0, 4],
              [310, 0, 2],
              [952, 0, 1],
              [1606, 0, 1],
              [2249, 0, 1],
              [2900, 0, 1],
              [3537, 0, 1],
              [4162, 0, 1],
              [4790, 0, 1]]
    with pytest.deprecated_call(match='stim_channel'):
        raw = read_raw_edf(bdf_stim_channel_path, preload=True)
    bdf_events = find_events(raw)
    assert_array_equal(events, bdf_events)
    raw = read_raw_edf(bdf_stim_channel_path, preload=False,
                       stim_channel='auto')
    bdf_events = find_events(raw)
    assert_array_equal(events, bdf_events)
开发者ID:jhouck,项目名称:mne-python,代码行数:26,代码来源:test_edf.py


示例17: test_edf_data

def test_edf_data():
    """Test edf files."""
    raw = _test_raw_reader(read_raw_edf, input_fname=edf_path,
                           stim_channel=None, exclude=['Ergo-Left', 'H10'])
    raw_py = read_raw_edf(edf_path, preload=True)
    assert_equal(len(raw.ch_names) + 2, len(raw_py.ch_names))
    # Test saving and loading when annotations were parsed.
    edf_events = find_events(raw_py, output='step', shortest_event=0,
                             stim_channel='STI 014')

    # onset, duration, id
    events = [[0.1344, 0.2560, 2],
              [0.3904, 1.0000, 2],
              [2.0000, 0.0000, 3],
              [2.5000, 2.5000, 2]]
    events = np.array(events)
    events[:, :2] *= 512  # convert time to samples
    events = np.array(events, dtype=int)
    events[:, 1] -= 1
    events[events[:, 1] <= 0, 1] = 1
    events[:, 1] += events[:, 0]

    onsets = events[:, [0, 2]]
    offsets = events[:, [1, 2]]

    events = np.zeros((2 * events.shape[0], 3), dtype=int)
    events[0::2, [0, 2]] = onsets
    events[1::2, [0, 1]] = offsets

    assert_array_equal(edf_events, events)
开发者ID:hoechenberger,项目名称:mne-python,代码行数:30,代码来源:test_edf.py


示例18: test_io_egi_mff

def test_io_egi_mff():
    """Test importing EGI MFF simple binary files."""
    egi_fname_mff = op.join(data_path(), 'EGI', 'test_egi.mff')
    raw = read_raw_egi(egi_fname_mff, include=None)
    assert ('RawMff' in repr(raw))
    include = ['DIN1', 'DIN2', 'DIN3', 'DIN4', 'DIN5', 'DIN7']
    raw = _test_raw_reader(read_raw_egi, input_fname=egi_fname_mff,
                           include=include, channel_naming='EEG %03d')

    assert_equal('eeg' in raw, True)
    eeg_chan = [c for c in raw.ch_names if 'EEG' in c]
    assert_equal(len(eeg_chan), 129)
    picks = pick_types(raw.info, eeg=True)
    assert_equal(len(picks), 129)
    assert_equal('STI 014' in raw.ch_names, True)

    events = find_events(raw, stim_channel='STI 014')
    assert_equal(len(events), 8)
    assert_equal(np.unique(events[:, 1])[0], 0)
    assert (np.unique(events[:, 0])[0] != 0)
    assert (np.unique(events[:, 2])[0] != 0)

    pytest.raises(ValueError, read_raw_egi, egi_fname_mff, include=['Foo'],
                  preload=False)
    pytest.raises(ValueError, read_raw_egi, egi_fname_mff, exclude=['Bar'],
                  preload=False)
    for ii, k in enumerate(include, 1):
        assert (k in raw.event_id)
        assert (raw.event_id[k] == ii)
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:29,代码来源:test_egi.py


示例19: test_data

def test_data():
    """Test reading raw cnt files."""
    with pytest.warns(RuntimeWarning, match='number of bytes'):
        raw = _test_raw_reader(read_raw_cnt, montage=None, input_fname=fname,
                               eog='auto', misc=['NA1', 'LEFT_EAR'])
    eog_chs = pick_types(raw.info, eog=True, exclude=[])
    assert len(eog_chs) == 2  # test eog='auto'
    assert raw.info['bads'] == ['LEFT_EAR', 'VEOGR']  # test bads
开发者ID:SherazKhan,项目名称:mne-python,代码行数:8,代码来源:test_cnt.py


示例20: test_brainvision_data_filters

def test_brainvision_data_filters():
    """Test reading raw Brain Vision files
    """
    raw = _test_raw_reader(read_raw_brainvision,
                           vhdr_fname=vhdr_highpass_path, montage=montage,
                           eog=eog)

    assert_equal(raw.info['highpass'], 0.1)
    assert_equal(raw.info['lowpass'], 250.)
开发者ID:Tavpritesh,项目名称:mne-python,代码行数:9,代码来源:test_brainvision.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python label.label_sign_flip函数代码示例发布时间:2022-05-27
下一篇:
Python proj.make_projector函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap