Skip to content

Commit

Permalink
Add regression test for EEGLAB data with a chanlocs struct (mne-tools…
Browse files Browse the repository at this point in the history
…#8647)

* Use testing data release 0.112

* Add regression test for EEGLAB data with chanlocs struct

* Reduce code duplication
  • Loading branch information
hoechenberger authored Dec 11, 2020
1 parent e2357ad commit 76b64ff
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
4 changes: 2 additions & 2 deletions mne/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def _data_path(path=None, force_update=False, update_path=True, download=True,
path = _get_path(path, key, name)
# To update the testing or misc dataset, push commits, then make a new
# release on GitHub. Then update the "releases" variable:
releases = dict(testing='0.110', misc='0.7')
releases = dict(testing='0.112', misc='0.7')
# And also update the "md5_hashes['testing']" variable below.
# To update any other dataset, update the data archive itself (upload
# an updated version) and update the md5 hash.
Expand Down Expand Up @@ -331,7 +331,7 @@ def _data_path(path=None, force_update=False, update_path=True, download=True,
sample='12b75d1cb7df9dfb4ad73ed82f61094f',
somato='32fd2f6c8c7eb0784a1de6435273c48b',
spm='9f43f67150e3b694b523a21eb929ea75',
testing='c4cd3385f321cd1151ed9de34fc4ce5a',
testing='8eabd73532dd7df7c155983962c5b1fd',
multimodal='26ec847ae9ab80f58f204d09e2c08367',
fnirs_motor='c4935d19ddab35422a69f3326a01fef8',
opm='370ad1dcfd5c47e029e692c85358a374',
Expand Down
42 changes: 33 additions & 9 deletions mne/io/eeglab/tests/test_eeglab.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
epochs_fname_onefile_mat = op.join(base_dir, 'test_epochs_onefile.set')
raw_mat_fnames = [raw_fname_mat, raw_fname_onefile_mat]
epochs_mat_fnames = [epochs_fname_mat, epochs_fname_onefile_mat]
raw_fname_chanloc = op.join(base_dir, 'test_raw_chanloc.set')

raw_fname_h5 = op.join(base_dir, 'test_raw_h5.set')
raw_fname_onefile_h5 = op.join(base_dir, 'test_raw_onefile_h5.set')
Expand All @@ -58,7 +59,7 @@ def _check_h5(fname):
@testing.requires_testing_data
@pytest.mark.slowtest
@pytest.mark.parametrize(
'fname', [raw_fname_mat, raw_fname_h5], ids=op.basename
'fname', [raw_fname_mat, raw_fname_h5, raw_fname_chanloc], ids=op.basename
)
def test_io_set_raw(fname):
"""Test importing EEGLAB .set files."""
Expand All @@ -67,17 +68,40 @@ def test_io_set_raw(fname):
'EEG {0:03d}'.format(ii) for ii in range(len(montage.ch_names))
]

_test_raw_reader(read_raw_eeglab, input_fname=fname)
kws = dict(reader=read_raw_eeglab, input_fname=fname)
if fname.endswith('test_raw_chanloc.set'):
with pytest.warns(RuntimeWarning,
match="The data contains 'boundary' events"):
_test_raw_reader(**kws)
else:
_test_raw_reader(**kws)

# test that preloading works
raw0 = read_raw_eeglab(input_fname=fname, preload=True)
raw0.set_montage(montage)
raw0.filter(1, None, l_trans_bandwidth='auto', filter_length='auto',
phase='zero')
read_raw_kws = dict(input_fname=fname, preload=True)
if fname.endswith('test_raw_chanloc.set'):
with pytest.warns(RuntimeWarning,
match="The data contains 'boundary' events"):
raw0 = read_raw_eeglab(**read_raw_kws)
raw0.set_montage(montage, on_missing='ignore')
# crop to check if the data has been properly preloaded; we cannot
# filter as the snippet of raw data is very short
raw0.crop(0, 1)
else:
raw0 = read_raw_eeglab(**read_raw_kws)
raw0.set_montage(montage)
raw0.filter(1, None, l_trans_bandwidth='auto', filter_length='auto',
phase='zero')

# test that using uint16_codec does not break stuff
raw0 = read_raw_eeglab(input_fname=fname,
preload=False, uint16_codec='ascii')
raw0.set_montage(montage)
read_raw_kws = dict(input_fname=fname, preload=False, uint16_codec='ascii')
if fname.endswith('test_raw_chanloc.set'):
with pytest.warns(RuntimeWarning,
match="The data contains 'boundary' events"):
raw0 = read_raw_eeglab(**read_raw_kws)
raw0.set_montage(montage, on_missing='ignore')
else:
raw0 = read_raw_eeglab(**read_raw_kws)
raw0.set_montage(montage)


@testing.requires_testing_data
Expand Down

0 comments on commit 76b64ff

Please sign in to comment.