コード例 #1
0
def test_raw_to_bids(tmpdir):
    """Test mne_bids raw_to_bids."""
    output_path = str(tmpdir)
    data_path = testing.data_path()
    raw_fname = op.join(data_path, 'MEG', 'sample',
                        'sample_audvis_trunc_raw.fif')
    # Check that help is printed
    check_usage(mne_bids_raw_to_bids)

    # Should work
    with ArgvSetter(
        ('--subject_id', subject_id, '--task', task, '--raw', raw_fname,
         '--bids_root', output_path, '--line_freq', 60)):
        mne_bids_raw_to_bids.run()

    # Test EDF files as well
    edf_data_path = op.join(base_path, 'edf', 'tests', 'data')
    edf_fname = op.join(edf_data_path, 'test.edf')
    with ArgvSetter(
        ('--subject_id', subject_id, '--task', task, '--raw', edf_fname,
         '--bids_root', output_path, '--line_freq', 60)):
        mne_bids_raw_to_bids.run()

    # Too few input args
    with pytest.raises(SystemExit):
        with ArgvSetter(('--subject_id', subject_id)):
            mne_bids_cp.run()
コード例 #2
0
ファイル: test_commands.py プロジェクト: romquentin/mne-bids
def test_raw_to_bids():
    """Test mne_bids raw_to_bids."""
    output_path = _TempDir()
    data_path = testing.data_path()
    raw_fname = op.join(data_path, 'MEG', 'sample',
                        'sample_audvis_trunc_raw.fif')
    # check_usage(mne_bids_raw_to_bids)
    with ArgvSetter(('--subject_id', subject_id, '--task', task, '--raw',
                     raw_fname, '--output_path', output_path)):
        mne_bids_raw_to_bids.run()
コード例 #3
0
def test_mark_bad_chanels_single_file(tmpdir):
    """Test mne_bids mark_channels."""

    # Check that help is printed
    check_usage(mne_bids_mark_channels)

    # Create test dataset.
    output_path = str(tmpdir)
    data_path = testing.data_path()
    raw_fname = op.join(data_path, 'MEG', 'sample',
                        'sample_audvis_trunc_raw.fif')
    old_bads = mne.io.read_raw_fif(raw_fname).info['bads']
    bids_path = BIDSPath(subject=subject_id,
                         task=task,
                         root=output_path,
                         datatype=datatype)

    with ArgvSetter(
        ('--subject_id', subject_id, '--task', task, '--raw', raw_fname,
         '--bids_root', output_path, '--line_freq', 60)):
        mne_bids_raw_to_bids.run()

    # Update the dataset.
    ch_names = ['MEG 0112', 'MEG 0131']
    descriptions = ['Really bad!', 'Even worse.']

    args = [
        '--subject_id', subject_id, '--task', task, '--bids_root', output_path,
        '--type', datatype
    ]
    for ch_name, description in zip(ch_names, descriptions):
        args.extend(['--ch_name', ch_name])
        args.extend(['--description', description])

    args = tuple(args)
    with ArgvSetter(args):
        mne_bids_mark_channels.run()

    # Check the data was properly written
    with pytest.warns(RuntimeWarning, match='The unit for chann*'):
        raw = read_raw_bids(bids_path=bids_path, verbose=False)
    assert set(old_bads + ch_names) == set(raw.info['bads'])

    # Test resetting bad channels.
    args = ('--subject_id', subject_id, '--task', task, '--bids_root',
            output_path, '--type', datatype, '--status', 'good', '--ch_name',
            '')
    with ArgvSetter(args):
        mne_bids_mark_channels.run()
    print('Finished running the reset...')

    # Check the data was properly written
    with pytest.warns(RuntimeWarning, match='The unit for chann*'):
        raw = read_raw_bids(bids_path=bids_path)
    assert raw.info['bads'] == []
コード例 #4
0
ファイル: test_cli.py プロジェクト: zuxfoucault/mne-bids
def test_raw_to_bids(tmpdir):
    """Test mne_bids raw_to_bids."""
    output_path = str(tmpdir)
    data_path = testing.data_path()
    raw_fname = op.join(data_path, 'MEG', 'sample',
                        'sample_audvis_trunc_raw.fif')
    # Check that help is printed
    check_usage(mne_bids_raw_to_bids)

    # Should work
    with ArgvSetter(('--subject_id', subject_id, '--task', task, '--raw',
                     raw_fname, '--output_path', output_path)):
        mne_bids_raw_to_bids.run()

    # Too few input args
    with pytest.raises(SystemExit):
        with ArgvSetter(('--subject_id', subject_id)):
            mne_bids_cp.run()
コード例 #5
0
def test_mark_bad_chanels_multiple_files(tmp_path):
    """Test mne_bids mark_channels."""

    # Check that help is printed
    check_usage(mne_bids_mark_channels)

    # Create test dataset.
    output_path = str(tmp_path)
    data_path = testing.data_path()
    raw_fname = op.join(data_path, 'MEG', 'sample',
                        'sample_audvis_trunc_raw.fif')
    old_bads = mne.io.read_raw_fif(raw_fname).info['bads']
    bids_path = BIDSPath(task=task, root=output_path, datatype=datatype)

    subjects = ['01', '02', '03']
    for subject in subjects:
        with ArgvSetter(('--subject_id', subject, '--task', task,
                         '--raw', raw_fname, '--bids_root', output_path,
                         '--line_freq', 60)):
            mne_bids_raw_to_bids.run()

    # Update the dataset.
    ch_names = ['MEG 0112', 'MEG 0131']
    descriptions = ['Really bad!', 'Even worse.']

    args = ['--task', task, '--bids_root', output_path, '--type', datatype]
    for ch_name, description in zip(ch_names, descriptions):
        args.extend(['--ch_name', ch_name])
        args.extend(['--description', description])

    args = tuple(args)
    with ArgvSetter(args):
        mne_bids_mark_channels.run()

    # Check the data was properly written
    for subject in subjects:
        with pytest.warns(RuntimeWarning, match='The unit for chann*'):
            raw = read_raw_bids(bids_path=bids_path.copy()
                                .update(subject=subject))
        assert set(old_bads + ch_names) == set(raw.info['bads'])