Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor of NoisyChannels tests and split into separate methods #84

Merged
merged 7 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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