Skip to content

Commit

Permalink
Refactor of NoisyChannels tests and split into separate methods (#84)
Browse files Browse the repository at this point in the history
* Major refactor of NoisyChannels tests

* Fix pylint no-member warning

* Remove outdated comments in MATLAB tests

* Try a different fix for the pylint warning

* Explicitly add montage for Reference tests

* Change raw_clean test file to a totally clean one

* Made RNGs constants
  • Loading branch information
a-hurst authored May 11, 2021
1 parent bc46978 commit 47976eb
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 166 deletions.
50 changes: 45 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,55 @@ def montage():

@pytest.fixture(scope="session")
def raw():
"""Fixture for physionet EEG subject 4, dataset 1."""
"""Return an `mne.io.Raw` object for use with unit tests.
This fixture downloads and reads in subject 4, run 1 from the Physionet
BCI2000 (eegbci) open dataset. This recording is quite noisy and is thus a
good candidate for testing the PREP pipeline.
File attributes:
- Channels: 64 EEG
- Sample rate: 160 Hz
- Duration: 61 seconds
This is only run once per session to save time downloading.
"""
mne.set_log_level("WARNING")
# load in subject 1, run 1 dataset

# Download and read S004R01.edf from the BCI2000 dataset
edf_fpath = eegbci.load_data(4, 1, update_path=True)[0]
raw = mne.io.read_raw_edf(edf_fpath, preload=True)
eegbci.standardize(raw) # Fix non-standard channel names

return raw


@pytest.fixture(scope="session")
def raw_clean(montage):
"""Return an `mne.io.Raw` object with no bad channels for use with tests.
This fixture downloads and reads in subject 30, run 2 from the Physionet
BCI2000 (eegbci) open dataset, which contains no bad channels on an initial
pass of :class:`pyprep.NoisyChannels`. Intended for use with tests where
channels are made artifically bad.
File attributes:
- Channels: 64 EEG
- Sample rate: 160 Hz
- Duration: 61 seconds
This is only run once per session to save time downloading.
"""
mne.set_log_level("WARNING")

# using sample EEG data (https://physionet.org/content/eegmmidb/1.0.0/)
# Download and read S030R02.edf from the BCI2000 dataset
edf_fpath = eegbci.load_data(30, 2, update_path=True)[0]
raw = mne.io.read_raw_edf(edf_fpath, preload=True)
eegbci.standardize(raw) # Fix non-standard channel names

# The eegbci data has non-standard channel names. We need to rename them:
eegbci.standardize(raw)
# Set a montage for use with RANSAC
raw.set_montage(montage)

return raw
Loading

0 comments on commit 47976eb

Please sign in to comment.