Exemplo n.º 1
0
def test_copyfile_eeglab(tmpdir, fname):
    """Test the copying of EEGlab set and fdt files."""
    if (fname == 'test_raw_chanloc.set' and
            LooseVersion(testing.get_version()) < LooseVersion('0.112')):
        return

    bids_root = str(tmpdir)
    data_path = op.join(testing.data_path(), 'EEGLAB')
    raw_fname = op.join(data_path, fname)
    new_name = op.join(bids_root, 'tested_conversion.set')

    # IO error testing
    with pytest.raises(ValueError, match="Need to move data with same ext"):
        copyfile_eeglab(raw_fname, new_name + '.wrong')

    # Bad .set file testing
    with pytest.raises(ValueError, match='Could not find "EEG" field'):
        fake_set = op.join(bids_root, 'fake.set')
        savemat(fake_set, {'arr': [1, 2, 3]}, appendmat=False)
        copyfile_eeglab(fake_set, new_name)

    # Test copying and reading a combined set+fdt
    copyfile_eeglab(raw_fname, new_name)
    if fname == 'test_raw_chanloc.set':
        with pytest.warns(RuntimeWarning,
                          match="The data contains 'boundary' events"):
            raw = mne.io.read_raw_eeglab(new_name)
            assert 'Fp1' in raw.ch_names
    else:
        raw = mne.io.read_raw_eeglab(new_name)
        assert 'EEG 001' in raw.ch_names
    assert isinstance(raw, mne.io.BaseRaw)
Exemplo n.º 2
0
def test_copyfile_eeglab(tmp_path, fname):
    """Test the copying of EEGlab set and fdt files."""
    if (fname == 'test_raw_chanloc.set'
            and _compare_version(testing.get_version(), '<', '0.112')):
        return

    bids_root = str(tmp_path)
    data_path = op.join(testing.data_path(), 'EEGLAB')
    raw_fname = op.join(data_path, fname)
    new_name = op.join(bids_root, 'tested_conversion.set')

    # IO error testing
    with pytest.raises(ValueError, match="Need to move data with same ext"):
        copyfile_eeglab(raw_fname, new_name + '.wrong')

    # Test copying and reading
    copyfile_eeglab(raw_fname, new_name)
    if fname == 'test_raw_chanloc.set':  # combined set+fdt
        with pytest.warns(RuntimeWarning,
                          match="The data contains 'boundary' events"):
            raw = mne.io.read_raw_eeglab(new_name)
            assert 'Fp1' in raw.ch_names
    else:  # combined set+fdt and single set (new EEGLAB format)
        raw = mne.io.read_raw_eeglab(new_name, preload=True)
        assert 'EEG 001' in raw.ch_names
    assert isinstance(raw, mne.io.BaseRaw)