From 6624276a2f6ac710681b31c3ed40b2addee4cb79 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 29 Sep 2022 15:53:54 -0400 Subject: [PATCH] MAINT: Ensure we dont download without permission (#1073) * MAINT: Ensure we dont download without permission * MAINT: Fix data_path usage * FIX: macOS login bug * FIX: One more * FIX: Generic * FIX: Name * FIX: Needs shell * FIX: Conditional * FIX: Simplify * FIX: Recomplicate, but better * FIX: No data in doctests * FIX: Flake --- .github/workflows/unit_tests.yml | 25 ++- mne_bids/commands/tests/test_cli.py | 20 +- mne_bids/conftest.py | 16 ++ .../tiny_bids/code/make_tiny_bids_dataset.py | 3 +- mne_bids/tests/test_copyfiles.py | 6 +- mne_bids/tests/test_dig.py | 8 +- mne_bids/tests/test_inspect.py | 21 +- mne_bids/tests/test_path.py | 17 +- mne_bids/tests/test_pick.py | 4 +- mne_bids/tests/test_read.py | 43 ++-- mne_bids/tests/test_report.py | 4 +- mne_bids/tests/test_stats.py | 16 +- mne_bids/tests/test_update.py | 7 +- mne_bids/tests/test_write.py | 209 +++++++++--------- mne_bids/write.py | 20 +- setup.cfg | 4 +- 16 files changed, 251 insertions(+), 172 deletions(-) create mode 100644 mne_bids/conftest.py diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 49264531a..b06b16df6 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -158,13 +158,13 @@ jobs: - name: Install MNE (stable) if: "matrix.mne-version == 'mne-stable'" run: | - git clone --depth 1 https://github.com/mne-tools/mne-python.git -b maint/1.0 + git clone --depth 1 --single-branch --branch maint/1.0 https://github.com/mne-tools/mne-python.git -b maint/1.0 python -m pip install -e ./mne-python - name: Install MNE (main) if: "matrix.mne-version == 'mne-main'" run: | - git clone --depth 1 https://github.com/mne-tools/mne-python.git -b main + git clone --depth 1 --single-branch --branch main https://github.com/mne-tools/mne-python.git -b main python -m pip install -e ./mne-python - name: Install BIDS validator (stable) @@ -210,6 +210,27 @@ jobs: - name: Install MNE-BIDS run: python -m pip install -e . + # Only run on a limited set of jobs + - name: Run pytest without testing data + run: make test + if: ${{ matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' && matrix.mne-version == 'mne-main' }} + + # Get testing data + - run: ./tools/get_testing_version.sh + working-directory: mne-python + shell: bash + name: 'Get testing version' + + - uses: actions/cache@v3 + with: + key: ${{ env.TESTING_VERSION }} + path: ~/mne_data + name: 'Cache testing data' + + - run: ./tools/github_actions_download.sh + shell: bash + working-directory: mne-python + - name: Run pytest shell: bash run: make test diff --git a/mne_bids/commands/tests/test_cli.py b/mne_bids/commands/tests/test_cli.py index ee16b6e90..2fb01c3ec 100644 --- a/mne_bids/commands/tests/test_cli.py +++ b/mne_bids/commands/tests/test_cli.py @@ -18,7 +18,7 @@ import mne from mne.datasets import testing -from mne.utils import ArgvSetter, requires_pandas, requires_version +from mne.utils import ArgvSetter, requires_pandas from mne.utils._testing import requires_module from mne_bids.commands import (mne_bids_raw_to_bids, @@ -34,7 +34,7 @@ requires_matplotlib = partial(requires_module, name='matplotlib', call='import matplotlib') - +data_path = testing.data_path(download=False) base_path = op.join(op.dirname(mne.__file__), 'io') subject_id = '01' task = 'testing' @@ -52,10 +52,10 @@ def check_usage(module, force_help=False): assert 'Usage: ' in out.stdout.getvalue() +@testing.requires_testing_data def test_raw_to_bids(tmp_path): """Test mne_bids raw_to_bids.""" output_path = str(tmp_path) - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') # Check that help is printed @@ -87,6 +87,7 @@ def test_raw_to_bids(tmp_path): mne_bids_cp.run() +@testing.requires_testing_data def test_cp(tmp_path): """Test mne_bids cp.""" output_path = str(tmp_path) @@ -107,6 +108,7 @@ def test_cp(tmp_path): mne_bids_cp.run() +@testing.requires_testing_data def test_mark_bad_chanels_single_file(tmp_path): """Test mne_bids mark_channels.""" # Check that help is printed @@ -114,7 +116,6 @@ def test_mark_bad_chanels_single_file(tmp_path): # 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'] @@ -159,6 +160,7 @@ def test_mark_bad_chanels_single_file(tmp_path): assert raw.info['bads'] == [] +@testing.requires_testing_data def test_mark_bad_chanels_multiple_files(tmp_path): """Test mne_bids mark_channels.""" # Check that help is printed @@ -166,7 +168,6 @@ def test_mark_bad_chanels_multiple_files(tmp_path): # 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'] @@ -200,13 +201,13 @@ def test_mark_bad_chanels_multiple_files(tmp_path): assert set(old_bads + ch_names) == set(raw.info['bads']) +@testing.requires_testing_data def test_calibration_to_bids(tmp_path): """Test mne_bids calibration_to_bids.""" # Check that help is printed check_usage(mne_bids_calibration_to_bids) output_path = str(tmp_path) - data_path = Path(testing.data_path()) fine_cal_fname = data_path / 'SSS' / 'sss_cal_mgh.dat' bids_path = BIDSPath(subject=subject_id, root=output_path) @@ -219,13 +220,13 @@ def test_calibration_to_bids(tmp_path): assert bids_path.meg_calibration_fpath.exists() +@testing.requires_testing_data def test_crosstalk_to_bids(tmp_path): """Test mne_bids crosstalk_to_bids.""" # Check that help is printed check_usage(mne_bids_crosstalk_to_bids) output_path = str(tmp_path) - data_path = Path(testing.data_path()) crosstalk_fname = data_path / 'SSS' / 'ct_sparse.fif' bids_path = BIDSPath(subject=subject_id, root=output_path) @@ -239,6 +240,7 @@ def test_crosstalk_to_bids(tmp_path): @requires_pandas +@testing.requires_testing_data def test_count_events(tmp_path): """Test mne_bids count_events.""" # Check that help is printed @@ -246,7 +248,6 @@ def test_count_events(tmp_path): # 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') @@ -282,7 +283,7 @@ def test_count_events(tmp_path): @requires_matplotlib -@requires_version('mne', '0.22') +@testing.requires_testing_data def test_inspect(tmp_path): """Test mne_bids inspect.""" # Check that help is printed @@ -290,7 +291,6 @@ def test_inspect(tmp_path): # Create test dataset. bids_root = str(tmp_path) - data_path = testing.data_path() subject = '01' task = 'test' datatype = 'meg' diff --git a/mne_bids/conftest.py b/mne_bids/conftest.py new file mode 100644 index 000000000..d6e524330 --- /dev/null +++ b/mne_bids/conftest.py @@ -0,0 +1,16 @@ +"""Configure all tests.""" +import mne +import pytest + + +def pytest_configure(config): + """Configure pytest options.""" + # Fixtures + config.addinivalue_line('usefixtures', 'monkeypatch_mne') + + +@pytest.fixture(scope='session') +def monkeypatch_mne(): + """Monkeypatch MNE to ensure we have download=False everywhere in tests.""" + mne.datasets.utils._MODULES_TO_ENSURE_DOWNLOAD_IS_FALSE_IN_TESTS = \ + ('mne', 'mne_bids') diff --git a/mne_bids/tests/data/tiny_bids/code/make_tiny_bids_dataset.py b/mne_bids/tests/data/tiny_bids/code/make_tiny_bids_dataset.py index b88b32930..7d529e360 100644 --- a/mne_bids/tests/data/tiny_bids/code/make_tiny_bids_dataset.py +++ b/mne_bids/tests/data/tiny_bids/code/make_tiny_bids_dataset.py @@ -10,7 +10,8 @@ import mne_bids from mne_bids import BIDSPath, write_raw_bids -data_path = mne.datasets.testing.data_path() +data_path = mne.datasets.testing.data_path(download=False) +assert mne.datasets.has_dataset('testing'), 'Download testing data' vhdr_path = data_path / "montage" / "bv_dig_test.vhdr" captrak_path = data_path / "montage" / "captrak_coords.bvct" diff --git a/mne_bids/tests/test_copyfiles.py b/mne_bids/tests/test_copyfiles.py index 197b192a3..5a8192d7c 100644 --- a/mne_bids/tests/test_copyfiles.py +++ b/mne_bids/tests/test_copyfiles.py @@ -21,10 +21,11 @@ copyfile_eeglab, copyfile_kit) - +testing_path = testing.data_path(download=False) base_path = op.join(op.dirname(mne.__file__), 'io') +@testing.requires_testing_data def test_get_brainvision_encoding(): """Test getting the file-encoding from a BrainVision header.""" data_path = op.join(base_path, 'brainvision', 'tests', 'data') @@ -195,10 +196,11 @@ def test_copyfile_edfbdf_uppercase(tmp_path): @pytest.mark.parametrize('fname', ('test_raw.set', 'test_raw_chanloc.set', 'test_raw_2021.set')) +@testing.requires_testing_data def test_copyfile_eeglab(tmp_path, fname): """Test the copying of EEGlab set and fdt files.""" bids_root = str(tmp_path) - data_path = op.join(testing.data_path(), 'EEGLAB') + data_path = op.join(testing_path, 'EEGLAB') raw_fname = op.join(data_path, fname) new_name = op.join(bids_root, f'CONVERTED_{fname}.set') diff --git a/mne_bids/tests/test_dig.py b/mne_bids/tests/test_dig.py index 63d3b1001..6eaf8549c 100644 --- a/mne_bids/tests/test_dig.py +++ b/mne_bids/tests/test_dig.py @@ -34,7 +34,7 @@ subject=subject_id, session=session_id, run=run, acquisition=acq, task=task) -data_path = testing.data_path() +data_path = testing.data_path(download=False) def _load_raw(): @@ -47,6 +47,7 @@ def _load_raw(): return raw +@testing.requires_testing_data def test_dig_io(tmp_path): """Test passing different coordinate frames give proper warnings.""" bids_root = tmp_path / 'bids1' @@ -83,6 +84,7 @@ def test_dig_io(tmp_path): write_raw_bids(raw, bids_path) +@testing.requires_testing_data def test_dig_pixels(tmp_path): """Test dig stored correctly for the Pixels coordinate frame.""" bids_root = tmp_path / 'bids1' @@ -118,6 +120,7 @@ def test_dig_pixels(tmp_path): @pytest.mark.filterwarnings('ignore:The unit for chann*.:RuntimeWarning:mne') +@testing.requires_testing_data def test_dig_template(tmp_path): """Test that eeg and ieeg dig are stored properly.""" bids_root = tmp_path / 'bids1' @@ -203,6 +206,7 @@ def _test_montage_trans(raw, montage, pos_test, space='fsaverage', np.array(list(montage_test.get_positions()['ch_pos'].values()))) +@testing.requires_testing_data def test_template_to_head(): """Test transforming a template montage to head.""" # test no montage @@ -295,6 +299,7 @@ def test_template_to_head(): coord_frame='ras', unit='auto') +@testing.requires_testing_data def test_convert_montage(): """Test the montage RAS conversion.""" raw = _load_raw() @@ -327,6 +332,7 @@ def test_convert_montage(): [-0.0313669, 0.0540269, 0.0949191]) +@testing.requires_testing_data def test_electrodes_io(tmp_path): """Ensure only electrodes end up in *_electrodes.json.""" raw = _load_raw() diff --git a/mne_bids/tests/test_inspect.py b/mne_bids/tests/test_inspect.py index 3a1b7c53a..b0537cda5 100644 --- a/mne_bids/tests/test_inspect.py +++ b/mne_bids/tests/test_inspect.py @@ -9,7 +9,6 @@ import mne from mne.datasets import testing -from mne.utils import requires_version from mne.utils._testing import requires_module from mne.viz.utils import _fake_click @@ -25,11 +24,11 @@ _bids_path = BIDSPath(subject='01', session='01', run='01', task='testing', datatype='meg') +data_path = testing.data_path(download=False) def setup_bids_test_dir(bids_root): """Return path to a written test BIDS dir.""" - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') @@ -57,7 +56,7 @@ def setup_bids_test_dir(bids_root): @requires_matplotlib -@requires_version('mne', '0.22') +@testing.requires_testing_data @pytest.mark.parametrize('save_changes', (True, False)) @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) def test_inspect_single_file(tmp_path, save_changes): @@ -105,7 +104,7 @@ def test_inspect_single_file(tmp_path, save_changes): @requires_matplotlib -@requires_version('mne', '0.22') +@testing.requires_testing_data @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) def test_inspect_multiple_files(tmp_path): """Test inspecting a dataset consisting of more than one file.""" @@ -134,7 +133,7 @@ def test_inspect_multiple_files(tmp_path): @requires_matplotlib -@requires_version('mne', '0.22') +@testing.requires_testing_data @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) def test_inspect_set_and_unset_bads(tmp_path): """Test marking channels as bad and later marking them as good again.""" @@ -216,7 +215,7 @@ def _add_annotation(raw_fig): @requires_matplotlib -@requires_version('mne', '0.22') +@testing.requires_testing_data @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) def test_inspect_annotations(tmp_path): """Test inspection of Annotations.""" @@ -277,7 +276,7 @@ def test_inspect_annotations(tmp_path): @requires_matplotlib -@requires_version('mne', '0.22') +@testing.requires_testing_data @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) def test_inspect_annotations_remove_all(tmp_path): """Test behavior if all Annotations are removed by the user.""" @@ -346,7 +345,7 @@ def test_inspect_annotations_remove_all(tmp_path): @requires_matplotlib -@requires_version('mne', '0.22') +@testing.requires_testing_data @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) def test_inspect_dont_show_annotations(tmp_path): """Test if show_annotations=False works.""" @@ -363,7 +362,7 @@ def test_inspect_dont_show_annotations(tmp_path): @requires_matplotlib -@requires_version('mne', '0.22') +@testing.requires_testing_data @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) def test_inspect_bads_and_annotations(tmp_path): """Test adding bads and Annotations in one go.""" @@ -406,7 +405,7 @@ def test_inspect_bads_and_annotations(tmp_path): @requires_matplotlib -@requires_version('mne', '0.22') +@testing.requires_testing_data @pytest.mark.parametrize('save_changes', (True, False)) @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) def test_inspect_auto_flats(tmp_path, save_changes): @@ -466,7 +465,7 @@ def test_inspect_auto_flats(tmp_path, save_changes): @requires_matplotlib -@requires_version('mne', '0.22') +@testing.requires_testing_data @pytest.mark.parametrize(('l_freq', 'h_freq'), [(None, None), (1, None), diff --git a/mne_bids/tests/test_path.py b/mne_bids/tests/test_path.py index b4d71f09a..429852358 100644 --- a/mne_bids/tests/test_path.py +++ b/mne_bids/tests/test_path.py @@ -33,6 +33,7 @@ acq = None task = 'testing' +data_path = testing.data_path(download=False) _bids_path = BIDSPath( subject=subject_id, session=session_id, run=run, acquisition=acq, task=task) @@ -42,7 +43,6 @@ def return_bids_test_dir(tmp_path_factory): """Return path to a written test BIDS dir.""" bids_root = str(tmp_path_factory.mktemp('mnebids_utils_test_bids_ds')) - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') @@ -72,6 +72,7 @@ def return_bids_test_dir(tmp_path_factory): return bids_root +@testing.requires_testing_data def test_get_keys(return_bids_test_dir): """Test getting the datatypes (=modalities) of a dir.""" modalities = get_datatypes(return_bids_test_dir) @@ -95,6 +96,7 @@ def test_get_keys(return_bids_test_dir): ('task', [], dict(ignore_tasks=task)), ('run', [run, '02'], dict(ignore_runs=['bogus'])), ('run', [], dict(ignore_datatypes=['meg']))]) +@testing.requires_testing_data def test_get_entity_vals(entity, expected_vals, kwargs, return_bids_test_dir): """Test getting a list of entities.""" bids_root = return_bids_test_dir @@ -360,6 +362,7 @@ def test_find_best_candidates(candidate_list, best_candidates): assert _find_best_candidates(params, candidate_list) == best_candidates +@testing.requires_testing_data def test_find_matching_sidecar(return_bids_test_dir, tmp_path): """Test finding a sidecar file from a BIDS dir.""" bids_root = return_bids_test_dir @@ -445,6 +448,7 @@ def test_find_matching_sidecar(return_bids_test_dir, tmp_path): assert Path(s).name == 'sub-test_task-task_events.tsv' +@testing.requires_testing_data def test_bids_path_inference(return_bids_test_dir): """Test usage of BIDSPath object and fpath.""" bids_root = return_bids_test_dir @@ -482,6 +486,7 @@ def test_bids_path_inference(return_bids_test_dir): shutil.rmtree(Path(extra_file).parent) +@testing.requires_testing_data def test_bids_path(return_bids_test_dir): """Test usage of BIDSPath object.""" bids_root = return_bids_test_dir @@ -758,6 +763,7 @@ def test_filter_fnames(entities, expected_n_matches): assert len(output) == expected_n_matches +@testing.requires_testing_data def test_match(return_bids_test_dir): """Test retrieval of matching basenames.""" bids_root = Path(return_bids_test_dir) @@ -850,9 +856,9 @@ def test_match(return_bids_test_dir): @pytest.mark.filterwarnings(warning_str['meas_date_set_to_none']) @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_find_empty_room(return_bids_test_dir, tmp_path): """Test reading of empty room data.""" - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') bids_root = tmp_path / "bids" @@ -970,9 +976,9 @@ def test_find_empty_room(return_bids_test_dir, tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_find_emptyroom_ties(tmp_path): """Test that we receive a warning on a date tie.""" - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') @@ -1008,9 +1014,9 @@ def test_find_emptyroom_ties(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_find_emptyroom_no_meas_date(tmp_path): """Test that we warn if measurement date can be read or inferred.""" - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') @@ -1056,6 +1062,7 @@ def test_bids_path_label_vs_index_entity(): BIDSPath(subject='01', split=1) # ok as entity +@testing.requires_testing_data def test_meg_calibration_fpath(return_bids_test_dir): bids_root = return_bids_test_dir @@ -1087,6 +1094,7 @@ def test_meg_calibration_fpath(return_bids_test_dir): assert bids_path_.meg_calibration_fpath is None +@testing.requires_testing_data def test_meg_crosstalk_fpath(return_bids_test_dir): bids_root = return_bids_test_dir @@ -1118,6 +1126,7 @@ def test_meg_crosstalk_fpath(return_bids_test_dir): assert bids_path.meg_crosstalk_fpath is None +@testing.requires_testing_data def test_datasetdescription_with_bidspath(return_bids_test_dir): with pytest.raises(ValueError, match='Unallowed'): bids_path = BIDSPath( diff --git a/mne_bids/tests/test_pick.py b/mne_bids/tests/test_pick.py index 213f33a1b..ad11d88db 100644 --- a/mne_bids/tests/test_pick.py +++ b/mne_bids/tests/test_pick.py @@ -10,10 +10,12 @@ from mne_bids.pick import coil_type +data_path = testing.data_path(download=False) + +@testing.requires_testing_data def test_coil_type(): """Test the correct coil type is retrieved.""" - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') raw = read_raw_fif(raw_fname) diff --git a/mne_bids/tests/test_read.py b/mne_bids/tests/test_read.py index 54507e9a9..a59a46aa6 100644 --- a/mne_bids/tests/test_read.py +++ b/mne_bids/tests/test_read.py @@ -17,10 +17,10 @@ from pkg_resources import parse_version import mne +from mne.datasets import testing from mne.io.constants import FIFF from mne.utils import requires_nibabel, object_diff, requires_version from mne.utils import assert_dig_allclose -from mne.datasets import testing, somato from mne_bids import BIDSPath from mne_bids.config import (MNE_STR_TO_FRAME, BIDS_SHARED_COORDINATE_FRAMES, @@ -47,15 +47,10 @@ _bids_path_minimal = BIDSPath(subject=subject_id, task=task) # Get the MNE testing sample data - USA -data_path = testing.data_path() +data_path = testing.data_path(download=False) raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') -# Get the MNE somato data - EU -somato_path = somato.data_path() -somato_raw_fname = op.join(somato_path, 'sub-01', 'meg', - 'sub-01_task-somato_meg.fif') - # Data with cHPI info raw_fname_chpi = op.join(data_path, 'SSS', 'test_move_anon_raw.fif') @@ -117,6 +112,7 @@ def test_read_correct_inputs(): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_read_participants_data(tmp_path): """Test reading information from a BIDS sidecar.json file.""" bids_path = _bids_path.copy().update(root=tmp_path, datatype='meg') @@ -188,6 +184,7 @@ def test_read_participants_data(tmp_path): ('l', 2, 'm', 1)] ) @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_read_participants_handedness_and_sex_mapping(hand_bids, hand_mne, sex_bids, sex_mne, tmp_path): @@ -212,6 +209,7 @@ def test_read_participants_handedness_and_sex_mapping(hand_bids, hand_mne, @requires_nibabel() @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_get_head_mri_trans(tmp_path): """Test getting a trans object from BIDS data.""" import nibabel as nib @@ -447,6 +445,7 @@ def test_get_head_mri_trans(tmp_path): write_raw_bids(raw=raw, bids_path=bids_path, verbose=False) +@testing.requires_testing_data def test_handle_events_reading(tmp_path): """Test reading events from a BIDS events.tsv file.""" # We can use any `raw` for this @@ -512,6 +511,7 @@ def test_handle_events_reading(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_keep_essential_annotations(tmp_path): """Test that essential Annotations are not omitted during I/O roundtrip.""" raw = _read_raw_fif(raw_fname) @@ -534,6 +534,7 @@ def test_keep_essential_annotations(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_handle_scans_reading(tmp_path): """Test reading data from a BIDS scans.tsv file.""" raw = _read_raw_fif(raw_fname) @@ -609,6 +610,7 @@ def test_handle_scans_reading_brainvision(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_handle_info_reading(tmp_path): """Test reading information from a BIDS sidecar JSON file.""" # read in USA dataset, so it should find 50 Hz @@ -696,6 +698,7 @@ def test_handle_info_reading(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) @pytest.mark.filterwarnings(warning_str['maxshield']) +@testing.requires_testing_data def test_handle_chpi_reading(tmp_path): """Test reading of cHPI information.""" raw = _read_raw_fif(raw_fname_chpi, allow_maxshield='yes') @@ -739,14 +742,14 @@ def test_handle_chpi_reading(tmp_path): @pytest.mark.filterwarnings(warning_str['nasion_not_found']) @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_handle_eeg_coords_reading(tmp_path): """Test reading iEEG coordinates from BIDS files.""" bids_path = BIDSPath( subject=subject_id, session=session_id, run=run, acquisition=acq, task=task, root=tmp_path) - data_path = op.join(testing.data_path(), 'EDF') - raw_fname = op.join(data_path, 'test_reduced.edf') + raw_fname = op.join(data_path, 'EDF', 'test_reduced.edf') raw = _read_raw_edf(raw_fname) # ensure we are writing 'eeg' data @@ -755,7 +758,7 @@ def test_handle_eeg_coords_reading(tmp_path): # set a `random` montage ch_names = raw.ch_names - elec_locs = np.random.random((len(ch_names), 3)).astype(float) + elec_locs = np.random.RandomState(0).randn(len(ch_names), 3) ch_pos = dict(zip(ch_names, elec_locs)) # # create montage in 'unknown' coordinate frame @@ -815,10 +818,10 @@ def test_handle_eeg_coords_reading(tmp_path): [_bids_path, _bids_path_minimal]) @pytest.mark.filterwarnings(warning_str['nasion_not_found']) @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_handle_ieeg_coords_reading(bids_path, tmp_path): """Test reading iEEG coordinates from BIDS files.""" - data_path = op.join(testing.data_path(), 'EDF') - raw_fname = op.join(data_path, 'test_reduced.edf') + raw_fname = op.join(data_path, 'EDF', 'test_reduced.edf') bids_fname = bids_path.copy().update(datatype='ieeg', suffix='ieeg', extension='.edf', @@ -832,7 +835,7 @@ def test_handle_ieeg_coords_reading(bids_path, tmp_path): # coordinate frames in mne-python should all map correctly # set a `random` montage ch_names = raw.ch_names - elec_locs = np.random.random((len(ch_names), 3)).astype(float) + elec_locs = np.random.RandomState(0).randn(len(ch_names), 3) ch_pos = dict(zip(ch_names, elec_locs)) coordinate_frames = ['mni_tal'] for coord_frame in coordinate_frames: @@ -990,11 +993,12 @@ def test_handle_ieeg_coords_reading(bids_path, tmp_path): @requires_nibabel() @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) @pytest.mark.parametrize('fname', ['testdata_ctf.ds', 'catch-alp-good-f.ds']) +@testing.requires_testing_data def test_get_head_mri_trans_ctf(fname, tmp_path): """Test getting a trans object from BIDS data in CTF.""" import nibabel as nib - ctf_data_path = op.join(testing.data_path(), 'CTF') + ctf_data_path = op.join(data_path, 'CTF') raw_ctf_fname = op.join(ctf_data_path, fname) raw_ctf = _read_raw_ctf(raw_ctf_fname, clean_names=True) bids_path = _bids_path.copy().update( @@ -1026,6 +1030,7 @@ def test_get_head_mri_trans_ctf(fname, tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_read_raw_bids_pathlike(tmp_path): """Test that read_raw_bids() can handle a Path-like bids_root.""" bids_path = _bids_path.copy().update(root=tmp_path, datatype='meg') @@ -1035,6 +1040,7 @@ def test_read_raw_bids_pathlike(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_read_raw_datatype(tmp_path): """Test that read_raw_bids() can infer the str_suffix if need be.""" bids_path = _bids_path.copy().update(root=tmp_path, datatype='meg') @@ -1054,6 +1060,7 @@ def test_read_raw_datatype(tmp_path): assert raw_1 == raw_3 +@testing.requires_testing_data def test_handle_channel_type_casing(tmp_path): """Test that non-uppercase entries in the `type` column are accepted.""" bids_path = _bids_path.copy().update(root=tmp_path) @@ -1078,6 +1085,7 @@ def test_handle_channel_type_casing(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_handle_non_mne_channel_type(tmp_path): """Test that channel types not known to MNE will be read as 'misc'.""" bids_path = _bids_path.copy().update(root=tmp_path) @@ -1108,6 +1116,7 @@ def test_handle_non_mne_channel_type(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_bads_reading(tmp_path): bids_path = _bids_path.copy().update(root=tmp_path, datatype='meg') bads_raw = ['MEG 0112', 'MEG 0113'] @@ -1130,6 +1139,7 @@ def test_bads_reading(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_write_read_fif_split_file(tmp_path, monkeypatch): """Test split files are read correctly.""" # load raw test file, extend it to be larger than 2gb, and save it @@ -1144,7 +1154,8 @@ def test_write_read_fif_split_file(tmp_path, monkeypatch): bids_path.update(acquisition='01') n_channels = len(raw.ch_names) n_times = int(2.5e6 / n_channels) # enough to produce a 10MB split - data = np.empty((n_channels, n_times), dtype=np.float32) + data = np.random.RandomState(0).randn( + n_channels, n_times).astype(np.float32) raw = mne.io.RawArray(data, raw.info) big_fif_fname = Path(tmp_dir) / 'test_raw.fif' @@ -1196,6 +1207,7 @@ def test_write_read_fif_split_file(tmp_path, monkeypatch): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_ignore_exclude_param(tmp_path): """Test that extra_params=dict(exclude=...) is being ignored.""" bids_path = _bids_path.copy().update(root=tmp_path) @@ -1209,6 +1221,7 @@ def test_ignore_exclude_param(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_channels_tsv_raw_mismatch(tmp_path): """Test behavior when channels.tsv contains channels not found in raw.""" bids_path = _bids_path.copy().update(root=tmp_path, datatype='meg', diff --git a/mne_bids/tests/test_report.py b/mne_bids/tests/test_report.py index b03bbbcc7..d919cc6b2 100644 --- a/mne_bids/tests/test_report.py +++ b/mne_bids/tests/test_report.py @@ -27,7 +27,7 @@ ) # Get the MNE testing sample data -data_path = testing.data_path() +data_path = testing.data_path(download=False) raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') @@ -37,6 +37,7 @@ @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_report(tmp_path): """Test that report generated works as intended.""" bids_root = str(tmp_path) @@ -65,6 +66,7 @@ def test_report(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_report_no_participant_information(tmp_path): """Test report with participants.tsv with participant_id column only.""" bids_root = tmp_path diff --git a/mne_bids/tests/test_stats.py b/mne_bids/tests/test_stats.py index d6a3dc577..a89be6cbf 100644 --- a/mne_bids/tests/test_stats.py +++ b/mne_bids/tests/test_stats.py @@ -3,8 +3,6 @@ # # License: BSD-3-Clause - -from pathlib import Path import itertools import pytest @@ -19,12 +17,12 @@ from mne_bids.read import _from_tsv from mne_bids.write import _write_tsv +data_path = testing.data_path(download=False) + def _make_dataset(root, subjects, tasks=(None,), runs=(None,), sessions=(None,)): - data_path = testing.data_path() - raw_fname = \ - Path(data_path) / 'MEG' / 'sample' / 'sample_audvis_trunc_raw.fif' + raw_fname = data_path / 'MEG' / 'sample' / 'sample_audvis_trunc_raw.fif' raw = mne.io.read_raw(raw_fname) raw.info['line_freq'] = 60. events = mne.find_events(raw) @@ -85,6 +83,7 @@ def _check_counts(counts, events, event_id, subjects, ] ) @requires_pandas +@testing.requires_testing_data def test_count_events(tmp_path, subjects, tasks, runs, sessions): """Test the event counts.""" root, events, event_id = _make_dataset(tmp_path, subjects, tasks, runs, @@ -96,6 +95,7 @@ def test_count_events(tmp_path, subjects, tasks, runs, sessions): @requires_pandas +@testing.requires_testing_data def test_count_events_bids_path(tmp_path): """Test the event counts passing a BIDSPath.""" root, events, event_id = \ @@ -112,11 +112,10 @@ def test_count_events_bids_path(tmp_path): @requires_pandas +@testing.requires_testing_data def test_count_no_events_file(tmp_path): """Test count_events with no event present.""" - data_path = testing.data_path() - raw_fname = \ - Path(data_path) / 'MEG' / 'sample' / 'sample_audvis_trunc_raw.fif' + raw_fname = data_path / 'MEG' / 'sample' / 'sample_audvis_trunc_raw.fif' raw = mne.io.read_raw(raw_fname) raw.info['line_freq'] = 60. root = str(tmp_path) @@ -131,6 +130,7 @@ def test_count_no_events_file(tmp_path): @requires_pandas +@testing.requires_testing_data def test_count_no_events_column(tmp_path): """Test case where events.tsv doesn't contain [stim,trial]_type column.""" subject, task, run, session, datatype = '01', 'task1', '01', '01', 'meg' diff --git a/mne_bids/tests/test_update.py b/mne_bids/tests/test_update.py index 5e424c34b..49c082084 100644 --- a/mne_bids/tests/test_update.py +++ b/mne_bids/tests/test_update.py @@ -27,6 +27,7 @@ acq = None task = 'testing' +data_path = testing.data_path(download=False) bids_path = BIDSPath( subject=subject_id, session=session_id, run=run, acquisition=acq, task=task) @@ -36,7 +37,6 @@ def _get_bids_test_dir(tmp_path_factory): """Return path to a written test BIDS dir.""" bids_root = str(tmp_path_factory.mktemp('mnebids_utils_test_bids_ds')) - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') @@ -86,8 +86,7 @@ def _get_sidecar_json_update_file(_get_bids_test_dir): return sidecar_fpath -@pytest.mark.usefixtures('_get_bids_test_dir', '_bids_validate', - '_get_sidecar_json_update_file') +@testing.requires_testing_data def test_update_sidecar_jsons(_get_bids_test_dir, _bids_validate, _get_sidecar_json_update_file): """Test updating sidecar JSON files.""" @@ -138,9 +137,9 @@ def test_update_sidecar_jsons(_get_bids_test_dir, _bids_validate, @requires_nibabel() +@testing.requires_testing_data def test_update_anat_landmarks(tmp_path): """Test updating the anatomical landmarks of an MRI scan.""" - data_path = Path(testing.data_path()) raw_path = data_path / 'MEG' / 'sample' / 'sample_audvis_trunc_raw.fif' trans_path = Path(str(raw_path).replace('_raw.fif', '-trans.fif')) t1_path = data_path / 'subjects' / 'sample' / 'mri' / 'T1.mgz' diff --git a/mne_bids/tests/test_write.py b/mne_bids/tests/test_write.py index 924e31ea9..baca47530 100644 --- a/mne_bids/tests/test_write.py +++ b/mne_bids/tests/test_write.py @@ -139,6 +139,11 @@ def fn(fname, *args, **kwargs): ('CNT', 'EDF', 'scan41_short.cnt', _read_raw_cnt) ] +data_path = testing.data_path(download=False) + +bad_frame_xfail = pytest.mark.xfail( + check_version('mne', '1.2'), reason='Coordinate frame bug in MNE 1.2') + def _test_anonymize(root, raw, bids_path, events_fname=None, event_id=None): """Write data to `root` for testing anonymization.""" @@ -162,6 +167,7 @@ def _test_anonymize(root, raw, bids_path, events_fname=None, event_id=None): return root +@testing.requires_testing_data def test_write_participants(_bids_validate, tmp_path): """Test participants.tsv/.json file writing. @@ -169,7 +175,6 @@ def test_write_participants(_bids_validate, tmp_path): files are kept, and mne-bids correctly writes all the subject info it can using ``raw.info['subject_info']``. """ - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') raw = _read_raw_fif(raw_fname) @@ -265,9 +270,9 @@ def test_write_participants(_bids_validate, tmp_path): assert participants_tsv['age'][idx] == 'n/a' +@testing.requires_testing_data def test_write_correct_inputs(): """Test that inputs of write_raw_bids is correct.""" - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') raw = _read_raw_fif(raw_fname) @@ -380,9 +385,9 @@ def test_stamp_to_dt(): tzinfo=timezone.utc)) +@testing.requires_testing_data def test_get_anonymization_daysback(): """Test daysback querying for anonymization.""" - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') raw = _read_raw_fif(raw_fname) @@ -462,13 +467,13 @@ def test_line_freq(line_freq, _bids_validate, tmp_path): @requires_version('pybv', PYBV_VERSION) +@testing.requires_testing_data @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) @pytest.mark.filterwarnings(warning_str['maxshield']) def test_fif(_bids_validate, tmp_path): """Test functionality of the write_raw_bids conversion for fif.""" bids_root = tmp_path / 'bids1' bids_path = _bids_path.copy().update(root=bids_root, datatype='meg') - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') @@ -728,10 +733,9 @@ def test_fif(_bids_validate, tmp_path): @pytest.mark.parametrize('format', ('fif_no_chpi', 'fif', 'ctf', 'kit')) @pytest.mark.filterwarnings(warning_str['maxshield']) +@testing.requires_testing_data def test_chpi(_bids_validate, tmp_path, format): """Test writing of cHPI information.""" - data_path = testing.data_path() - if format == 'fif_no_chpi': fif_raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') @@ -785,10 +789,10 @@ def test_chpi(_bids_validate, tmp_path, format): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_fif_dtype(_bids_validate, tmp_path): """Test functionality of the write_raw_bids conversion for fif.""" bids_path = _bids_path.copy().update(root=tmp_path, datatype='meg') - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') desired_fmt = 'int' @@ -805,11 +809,11 @@ def test_fif_dtype(_bids_validate, tmp_path): assert raw.orig_format == desired_fmt +@testing.requires_testing_data def test_fif_anonymize(_bids_validate, tmp_path): """Test write_raw_bids() with anonymization fif.""" bids_root = tmp_path / 'bids1' bids_path = _bids_path.copy().update(root=bids_root) - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') @@ -863,49 +867,50 @@ def test_fif_anonymize(_bids_validate, tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_fif_ias(tmp_path): """Test writing FIF files with internal active shielding.""" - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') raw = _read_raw_fif(raw_fname) raw.set_channel_types({raw.ch_names[0]: 'ias'}) - data_path = BIDSPath(subject='sample', task='task', root=tmp_path) + this_path = BIDSPath(subject='sample', task='task', root=tmp_path) - write_raw_bids(raw, data_path) - raw = read_raw_bids(data_path) + write_raw_bids(raw, this_path) + raw = read_raw_bids(this_path) assert raw.info['chs'][0]['kind'] == FIFF.FIFFV_IAS_CH @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_fif_exci(tmp_path): """Test writing FIF files with excitation channel.""" - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') raw = _read_raw_fif(raw_fname) raw.set_channel_types({raw.ch_names[0]: 'exci'}) - data_path = BIDSPath(subject='sample', task='task', root=tmp_path) + this_path = BIDSPath(subject='sample', task='task', root=tmp_path) - write_raw_bids(raw, data_path) - raw = read_raw_bids(data_path) + write_raw_bids(raw, this_path) + raw = read_raw_bids(this_path) assert raw.info['chs'][0]['kind'] == FIFF.FIFFV_EXCI_CH +@testing.requires_testing_data def test_kit(_bids_validate, tmp_path): """Test functionality of the write_raw_bids conversion for KIT data.""" bids_root = tmp_path / 'bids' - data_path = op.join(base_path, 'kit', 'tests', 'data') - raw_fname = op.join(data_path, 'test.sqd') - events_fname = op.join(data_path, 'test-eve.txt') - hpi_fname = op.join(data_path, 'test_mrk.sqd') - hpi_pre_fname = op.join(data_path, 'test_mrk_pre.sqd') - hpi_post_fname = op.join(data_path, 'test_mrk_post.sqd') - electrode_fname = op.join(data_path, 'test.elp') - headshape_fname = op.join(data_path, 'test.hsp') + kit_path = op.join(base_path, 'kit', 'tests', 'data') + raw_fname = op.join(kit_path, 'test.sqd') + events_fname = op.join(kit_path, 'test-eve.txt') + hpi_fname = op.join(kit_path, 'test_mrk.sqd') + hpi_pre_fname = op.join(kit_path, 'test_mrk_pre.sqd') + hpi_post_fname = op.join(kit_path, 'test_mrk_post.sqd') + electrode_fname = op.join(kit_path, 'test.elp') + headshape_fname = op.join(kit_path, 'test.hsp') event_id = dict(cond=128) kit_bids_path = _bids_path.copy().update(acquisition=None, @@ -989,11 +994,11 @@ def test_kit(_bids_validate, tmp_path): overwrite=True) # check that everything works with MRK markers, and CON files - data_path = op.join(testing.data_path(download=False), 'KIT') - raw_fname = op.join(data_path, 'data_berlin.con') - hpi_fname = op.join(data_path, 'MQKIT_125.mrk') - electrode_fname = op.join(data_path, 'MQKIT_125.elp') - headshape_fname = op.join(data_path, 'MQKIT_125.hsp') + kit_path = op.join(data_path, 'KIT') + raw_fname = op.join(kit_path, 'data_berlin.con') + hpi_fname = op.join(kit_path, 'MQKIT_125.mrk') + electrode_fname = op.join(kit_path, 'MQKIT_125.elp') + headshape_fname = op.join(kit_path, 'MQKIT_125.hsp') bids_root = tmp_path / 'bids_kit_mrk' kit_bids_path = _bids_path.copy().update(acquisition=None, root=bids_root, @@ -1017,10 +1022,10 @@ def test_kit(_bids_validate, tmp_path): @pytest.mark.filterwarnings(warning_str['meas_date_set_to_none']) +@testing.requires_testing_data def test_ctf(_bids_validate, tmp_path): """Test functionality of the write_raw_bids conversion for CTF data.""" - data_path = op.join(testing.data_path(download=False), 'CTF') - raw_fname = op.join(data_path, 'testdata_ctf.ds') + raw_fname = data_path / 'CTF' / 'testdata_ctf.ds' bids_path = _bids_path.copy().update(root=tmp_path, datatype='meg') raw = _read_raw_ctf(raw_fname) @@ -1055,10 +1060,10 @@ def test_ctf(_bids_validate, tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) def test_bti(_bids_validate, tmp_path): """Test functionality of the write_raw_bids conversion for BTi data.""" - data_path = op.join(base_path, 'bti', 'tests', 'data') - raw_fname = op.join(data_path, 'test_pdf_linux') - config_fname = op.join(data_path, 'test_config_linux') - headshape_fname = op.join(data_path, 'test_hs_linux') + bti_path = op.join(base_path, 'bti', 'tests', 'data') + raw_fname = op.join(bti_path, 'test_pdf_linux') + config_fname = op.join(bti_path, 'test_config_linux') + headshape_fname = op.join(bti_path, 'test_hs_linux') raw = _read_raw_bti(raw_fname, config_fname=config_fname, head_shape_fname=headshape_fname) @@ -1092,11 +1097,12 @@ def test_bti(_bids_validate, tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed'], warning_str['unraisable_exception']) +@testing.requires_testing_data def test_vhdr(_bids_validate, tmp_path): """Test write_raw_bids conversion for BrainVision data.""" bids_root = tmp_path / 'bids1' - data_path = op.join(base_path, 'brainvision', 'tests', 'data') - raw_fname = op.join(data_path, 'test.vhdr') + bv_path = op.join(base_path, 'brainvision', 'tests', 'data') + raw_fname = op.join(bv_path, 'test.vhdr') raw = _read_raw_brainvision(raw_fname) @@ -1167,11 +1173,11 @@ def test_vhdr(_bids_validate, tmp_path): # Test coords and impedance writing # first read the data and set a montage - data_path = op.join(testing.data_path(), 'montage') - fname_vhdr = op.join(data_path, 'bv_dig_test.vhdr') + mon_path = op.join(data_path, 'montage') + fname_vhdr = op.join(mon_path, 'bv_dig_test.vhdr') raw = _read_raw_brainvision(fname_vhdr, preload=False) raw.set_channel_types({'HEOG': 'eog', 'VEOG': 'eog', 'ECG': 'ecg'}) - fname_bvct = op.join(data_path, 'captrak_coords.bvct') + fname_bvct = op.join(mon_path, 'captrak_coords.bvct') montage = mne.channels.read_dig_captrak(fname_bvct) raw.set_montage(montage) @@ -1216,11 +1222,12 @@ def test_vhdr(_bids_validate, tmp_path): warning_str['no_hand'], warning_str['no_montage'], ) +@testing.requires_testing_data +@bad_frame_xfail def test_eegieeg(dir_name, fname, reader, _bids_validate, tmp_path): """Test write_raw_bids conversion for EEG/iEEG data formats.""" bids_root = tmp_path / 'bids1' - data_path = op.join(testing.data_path(), dir_name) - raw_fname = op.join(data_path, fname) + raw_fname = data_path / dir_name / fname # the BIDSPath for test datasets to get written to bids_path = _bids_path.copy().update(root=bids_root, datatype='eeg') @@ -1726,9 +1733,10 @@ def test_eegieeg(dir_name, fname, reader, _bids_validate, tmp_path): _bids_validate(output_path) +@testing.requires_testing_data def test_snirf(_bids_validate, tmp_path): """Test write_raw_bids conversion for SNIRF data.""" - raw_fname = op.join(testing.data_path(), 'SNIRF', 'MNE-NIRS', '20220217', + raw_fname = op.join(data_path, 'SNIRF', 'MNE-NIRS', '20220217', '20220217_nirx_15_3_recording.snirf') bids_path = _bids_path.copy().update(root=tmp_path, datatype='nirs') @@ -1772,8 +1780,7 @@ def test_snirf(_bids_validate, tmp_path): def test_bdf(_bids_validate, tmp_path): """Test write_raw_bids conversion for Biosemi data.""" - data_path = op.join(base_path, 'edf', 'tests', 'data') - raw_fname = op.join(data_path, 'test.bdf') + raw_fname = op.join(base_path, 'edf', 'tests', 'data', 'test.bdf') bids_path = _bids_path.copy().update(root=tmp_path, datatype='eeg') @@ -1844,12 +1851,12 @@ def test_bdf(_bids_validate, tmp_path): @pytest.mark.filterwarnings(warning_str['meas_date_set_to_none']) +@testing.requires_testing_data def test_set(_bids_validate, tmp_path): """Test write_raw_bids conversion for EEGLAB data.""" # standalone .set file with associated .fdt bids_root = tmp_path / 'bids1' - data_path = op.join(testing.data_path(), 'EEGLAB') - raw_fname = op.join(data_path, 'test_raw.set') + raw_fname = data_path / 'EEGLAB' / 'test_raw.set' raw = _read_raw_eeglab(raw_fname) bids_path = _bids_path.copy().update(root=bids_root, datatype='eeg') @@ -1911,9 +1918,9 @@ def _check_anat_json(bids_path): point) +@testing.requires_testing_data def test_get_anat_landmarks(): """Test getting anatomical landmarks in image space.""" - data_path = testing.data_path() # Get the T1 weighted MRI data file # Needs to be converted to Nifti because we only have mgh in our test base t1w_mgh = op.join(data_path, 'subjects', 'sample', 'mri', 'T1.mgz') @@ -1999,12 +2006,12 @@ def test_get_anat_landmarks(): @requires_nibabel() +@testing.requires_testing_data def test_write_anat(_bids_validate, tmp_path): """Test writing anatomical data.""" # Get the MNE testing sample data import nibabel as nib bids_root = tmp_path / 'bids1' - data_path = testing.data_path() # Get the T1 weighted MRI data file # Needs to be converted to Nifti because we only have mgh in our test base @@ -2169,9 +2176,9 @@ def test_write_anat(_bids_validate, tmp_path): 'sample', op.join(data_path, 'subjects')) +@testing.requires_testing_data def test_write_raw_pathlike(tmp_path): """Ensure writing pathlib.Path works.""" - data_path = Path(testing.data_path()) raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') event_id = {'Auditory/Left': 1, 'Auditory/Right': 2, 'Visual/Left': 3, @@ -2192,9 +2199,9 @@ def test_write_raw_pathlike(tmp_path): assert bids_path_.root == bids_root +@testing.requires_testing_data def test_write_raw_no_dig(tmp_path): """Test writing without dig.""" - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') raw = _read_raw_fif(raw_fname) @@ -2215,9 +2222,9 @@ def test_write_raw_no_dig(tmp_path): @requires_nibabel() +@testing.requires_testing_data def test_write_anat_pathlike(tmp_path): """Test writing anatomical data with pathlib.Paths.""" - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') trans_fname = raw_fname.replace('_raw.fif', '-trans.fif') @@ -2239,9 +2246,9 @@ def test_write_anat_pathlike(tmp_path): assert isinstance(bids_path, BIDSPath) +@testing.requires_testing_data def test_write_does_not_alter_events_inplace(tmp_path): """Test that writing does not modify the passed events array.""" - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') events_fname = op.join(data_path, 'MEG', 'sample', @@ -2294,6 +2301,7 @@ def _ensure_list(x): ('MEG 0112', 'Really bad!', True, True, [], []), ]) @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_mark_channels(_bids_validate, ch_names, descriptions, drop_status_col, drop_description_col, @@ -2304,7 +2312,6 @@ def test_mark_channels(_bids_validate, bids_root = tmp_path / 'bids1' bids_path = _bids_path.copy().update(root=bids_root, datatype='meg', suffix='meg') - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') event_id = {'Auditory/Left': 1, 'Auditory/Right': 2, 'Visual/Left': 3, @@ -2391,13 +2398,13 @@ def test_mark_channels(_bids_validate, @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_mark_channel_roundtrip(tmp_path): """Test marking channels fulfills roundtrip.""" # Setup: Create a fresh BIDS dataset. bids_root = tmp_path / 'bids1' bids_path = _bids_path.copy().update(root=bids_root, datatype='meg', suffix='meg') - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') event_id = {'Auditory/Left': 1, 'Auditory/Right': 2, 'Visual/Left': 3, @@ -2437,13 +2444,13 @@ def test_mark_channel_roundtrip(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_error_mark_channels(tmp_path): """Test errors when marking channels.""" # Setup: Create a fresh BIDS dataset. bids_root = tmp_path / 'bids1' bids_path = _bids_path.copy().update(root=bids_root, datatype='meg', suffix='meg') - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') event_id = {'Auditory/Left': 1, 'Auditory/Right': 2, 'Visual/Left': 3, @@ -2467,12 +2474,12 @@ def test_error_mark_channels(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_mark_channels_files(tmp_path): """Test validity of bad channel writing.""" # BV bids_root = tmp_path / 'bids1' - data_path = op.join(testing.data_path(), 'montage') - raw_fname = op.join(data_path, 'bv_dig_test.vhdr') + raw_fname = data_path / 'montage' / 'bv_dig_test.vhdr' raw = _read_raw_brainvision(raw_fname) raw.set_channel_types({'HEOG': 'eog', 'VEOG': 'eog', 'ECG': 'ecg'}) @@ -2503,21 +2510,19 @@ def test_mark_channels_files(tmp_path): fname = 'test_reduced.edf' bids_root = tmp_path / 'bids2' bids_path = _bids_path.copy().update(root=bids_root) - data_path = op.join(testing.data_path(), dir_name) - raw_fname = op.join(data_path, fname) + raw_fname = data_path / dir_name / fname raw = _read_raw_edf(raw_fname) write_raw_bids(raw, bids_path, overwrite=True) mark_channels(bids_path=bids_path, ch_names=raw.ch_names[0], status='bad') +@testing.requires_testing_data def test_write_meg_calibration(_bids_validate, tmp_path): """Test writing of the Elekta/Neuromag fine-calibration file.""" bids_root = tmp_path / 'bids1' bids_path = _bids_path.copy().update(root=bids_root) - data_path = Path(testing.data_path()) - raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') raw = _read_raw_fif(raw_fname, verbose=False) @@ -2560,11 +2565,11 @@ def test_write_meg_calibration(_bids_validate, tmp_path): write_meg_calibration(fine_cal_fname, bids_path) +@testing.requires_testing_data def test_write_meg_crosstalk(_bids_validate, tmp_path): """Test writing of the Elekta/Neuromag fine-calibration file.""" bids_root = tmp_path / 'bids1' bids_path = _bids_path.copy().update(root=bids_root) - data_path = Path(testing.data_path()) raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') @@ -2598,11 +2603,11 @@ def test_write_meg_crosstalk(_bids_validate, tmp_path): [False, 'add', 'only'] ) @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_annotations(_bids_validate, bad_segments, tmp_path): """Test that Annotations are stored as events.""" bids_root = tmp_path / 'bids1' bids_path = _bids_path.copy().update(root=bids_root, datatype='meg') - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') events_fname = op.join(data_path, 'MEG', 'sample', @@ -2653,11 +2658,11 @@ def test_annotations(_bids_validate, bad_segments, tmp_path): [True, False] ) @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_undescribed_events(_bids_validate, drop_undescribed_events, tmp_path): """Test we're behaving correctly if event descriptions are missing.""" bids_root = tmp_path / 'bids1' bids_path = _bids_path.copy().update(root=bids_root, datatype='meg') - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') events_fname = op.join(data_path, 'MEG', 'sample', @@ -2696,11 +2701,11 @@ def test_undescribed_events(_bids_validate, drop_undescribed_events, tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_event_storage(tmp_path): """Test we're retaining the original event IDs when storing events.""" bids_root = tmp_path / 'bids1' bids_path = _bids_path.copy().update(root=bids_root, datatype='meg') - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') events_fname = op.join(data_path, 'MEG', 'sample', @@ -2739,6 +2744,7 @@ def test_event_storage(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) @pytest.mark.filterwarnings(warning_str['encountered_data_in']) @pytest.mark.filterwarnings(warning_str['nasion_not_found']) +@testing.requires_testing_data def test_coordsystem_json_compliance( dir_name, fname, reader, datatype, coord_frame, tmp_path): """Tests that coordsystem.json contents are written correctly. @@ -2746,8 +2752,7 @@ def test_coordsystem_json_compliance( Tests multiple manufacturer data formats and MEG, EEG, and iEEG. """ bids_root = tmp_path / 'bids1' - data_path = op.join(testing.data_path(), dir_name) - raw_fname = op.join(data_path, fname) + raw_fname = data_path / dir_name / fname # the BIDSPath for test datasets to get written to bids_path = _bids_path.copy().update(root=bids_root, @@ -2875,10 +2880,9 @@ def test_coordsystem_json_compliance( warning_str['edf_warning'], warning_str['brainvision_unit'] ) +@testing.requires_testing_data def test_anonymize(subject, dir_name, fname, reader, tmp_path, _bids_validate): """Test writing anonymized EDF data.""" - data_path = testing.data_path() - raw_fname = op.join(data_path, dir_name, fname) bids_root = tmp_path / 'bids1' @@ -2963,6 +2967,7 @@ def test_anonymize(subject, dir_name, fname, reader, tmp_path, _bids_validate): ['EDF', 'test_reduced.edf'], ['BDF', 'test_bdf_stim_channel.bdf'] ]) +@testing.requires_testing_data def test_write_uppercase_edfbdf(tmp_path, dir_name, fname): """Test writing uppercase EDF/BDF ext results in lowercase.""" subject = 'cap' @@ -2971,7 +2976,6 @@ def test_write_uppercase_edfbdf(tmp_path, dir_name, fname): elif dir_name == 'BDF': read_func = _read_raw_bdf - data_path = testing.data_path() raw_fname = op.join(data_path, dir_name, fname) # capitalize the extension file @@ -2994,11 +2998,11 @@ def test_write_uppercase_edfbdf(tmp_path, dir_name, fname): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_sidecar_encoding(_bids_validate, tmp_path): """Test we're properly encoding text as UTF8.""" bids_root = tmp_path / 'bids1' bids_path = _bids_path.copy().update(root=bids_root, datatype='meg') - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') events_fname = op.join(data_path, 'MEG', 'sample', @@ -3059,11 +3063,12 @@ def test_sidecar_encoding(_bids_validate, tmp_path): warning_str['cnt_warning2'], warning_str['no_hand'], ) +@testing.requires_testing_data +@bad_frame_xfail def test_convert_eeg_formats(dir_name, format, fname, reader, tmp_path): """Test conversion of EEG/iEEG manufacturer fmt to BrainVision/EDF.""" bids_root = tmp_path / format - data_path = op.join(testing.data_path(), dir_name) - raw_fname = op.join(data_path, fname) + raw_fname = data_path / dir_name / fname # the BIDSPath for test datasets to get written to bids_path = _bids_path.copy().update(root=bids_root, datatype='eeg') @@ -3135,12 +3140,13 @@ def test_convert_eeg_formats(dir_name, format, fname, reader, tmp_path): warning_str['cnt_warning2'], warning_str['no_hand'], ) +@testing.requires_testing_data +@bad_frame_xfail def test_format_conversion_overwrite(dir_name, format, fname, reader, tmp_path): """Test that overwrite works when format is passed to write_raw_bids.""" bids_root = tmp_path / format - data_path = op.join(testing.data_path(), dir_name) - raw_fname = op.join(data_path, fname) + raw_fname = data_path / dir_name / fname # the BIDSPath for test datasets to get written to bids_path = _bids_path.copy().update(root=bids_root, datatype='eeg') @@ -3170,11 +3176,11 @@ def test_format_conversion_overwrite(dir_name, format, fname, reader, warning_str['cnt_warning2'], warning_str['no_hand'], ) +@testing.requires_testing_data def test_error_write_meg_as_eeg(dir_name, format, fname, reader, tmp_path): """Test error writing as BrainVision EEG data for MEG.""" bids_root = tmp_path / 'bids1' - data_path = op.join(testing.data_path(), dir_name) - raw_fname = op.join(data_path, fname) + raw_fname = data_path / dir_name / fname bids_path = _bids_path.copy().update(root=bids_root, datatype='eeg', extension='.vhdr') @@ -3192,11 +3198,11 @@ def test_error_write_meg_as_eeg(dir_name, format, fname, reader, tmp_path): @pytest.mark.parametrize( 'dir_name, format, fname, reader', test_convertmeg_data) @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_convert_meg_formats(dir_name, format, fname, reader, tmp_path): """Test conversion of MEG manufacturer format to FIF.""" bids_root = tmp_path / format - data_path = op.join(testing.data_path(), dir_name) - raw_fname = op.join(data_path, fname) + raw_fname = data_path / dir_name / fname # the BIDSPath for test datasets to get written to bids_path = _bids_path.copy().update(root=bids_root, datatype='meg') @@ -3230,12 +3236,13 @@ def test_convert_meg_formats(dir_name, format, fname, reader, tmp_path): warning_str['cnt_warning2'], warning_str['no_hand'], ) +@testing.requires_testing_data +@bad_frame_xfail def test_convert_raw_errors(dir_name, fname, reader, tmp_path): """Test errors when converting raw file formats.""" bids_root = tmp_path / 'bids_1' - data_path = op.join(testing.data_path(), dir_name) - raw_fname = op.join(data_path, fname) + raw_fname = data_path / dir_name / fname # the BIDSPath for test datasets to get written to bids_path = _bids_path.copy().update(root=bids_root, datatype='eeg') @@ -3264,9 +3271,9 @@ def test_convert_raw_errors(dir_name, fname, reader, tmp_path): write_raw_bids(**kwargs) +@testing.requires_testing_data def test_write_fif_triux(tmp_path): """Test writing Triux files.""" - data_path = testing.data_path() triux_path = op.join(data_path, 'SSS', 'TRIUX') tri_fname = op.join(triux_path, 'triux_bmlhus_erm_raw.fif') raw = mne.io.read_raw_fif(tri_fname) @@ -3279,23 +3286,24 @@ def test_write_fif_triux(tmp_path): @pytest.mark.filterwarnings(warning_str['nasion_not_found']) @pytest.mark.parametrize('datatype', ['eeg', 'ieeg']) +@testing.requires_testing_data def test_write_extension_case_insensitive(_bids_validate, tmp_path, datatype): """Test writing files is case insensitive.""" dir_name, fname, reader = 'EDF', 'test_reduced.edf', _read_raw_edf bids_root = tmp_path / 'bids1' source_path = Path(bids_root) / 'sourcedata' - data_path = op.join(testing.data_path(), dir_name) - sh.copytree(data_path, source_path) - data_path = source_path + dir_path = data_path / dir_name + sh.copytree(dir_path, source_path) + dir_path = source_path # rename extension to upper-case _fname, ext = _parse_ext(fname) new_fname = _fname + ext.upper() # rename the file's extension - raw_fname = op.join(data_path, fname) - new_raw_fname = op.join(data_path, new_fname) + raw_fname = op.join(dir_path, fname) + new_raw_fname = op.join(dir_path, new_fname) os.rename(raw_fname, new_raw_fname) # the BIDSPath for test datasets to get written to @@ -3309,11 +3317,13 @@ def test_write_extension_case_insensitive(_bids_validate, tmp_path, datatype): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) +@testing.requires_testing_data def test_symlink(tmp_path): """Test creation of symbolic links.""" - testing_data_path = Path(testing.data_path()) - raw_trunc_path = (testing_data_path / 'MEG' / 'sample' / + raw_trunc_path = (data_path / 'MEG' / 'sample' / 'sample_audvis_trunc_raw.fif') + # in case there are symlinks in the path, we need to .resolve() for later + raw_trunc_path = raw_trunc_path.resolve(strict=True) raw = _read_raw_fif(raw_trunc_path) root = tmp_path / 'symlink' bids_path = _bids_path.copy().update(root=root, datatype='meg') @@ -3330,7 +3340,7 @@ def test_symlink(tmp_path): write_raw_bids(anonymize=dict(daysback=123), **kwargs) # We currently only support FIFF - raw_eeglab_path = testing_data_path / 'EEGLAB' / 'test_raw.set' + raw_eeglab_path = data_path / 'EEGLAB' / 'test_raw.set' raw_eeglab = _read_raw_eeglab(raw_eeglab_path) bids_path_eeglab = _bids_path.copy().update(root=root, datatype='eeg') with pytest.raises(NotImplementedError, match='only.*for FIFF'): @@ -3344,10 +3354,6 @@ def test_symlink(tmp_path): # test with split files # prepare the split files - sample_data_path = Path(mne.datasets.sample.data_path()) - raw_path = sample_data_path / 'MEG' / 'sample' / 'sample_audvis_raw.fif' - raw = _read_raw_fif(raw_path).crop(0, 10) - split_raw_path = tmp_path / 'raw' / 'sample_audivis_raw.fif' split_raw_path.parent.mkdir() raw.save(split_raw_path, split_size='10MB', split_naming='neuromag') @@ -3364,12 +3370,12 @@ def test_symlink(tmp_path): @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) @pytest.mark.parametrize('empty_room_dtype', ['BIDSPath', 'raw']) +@testing.requires_testing_data def test_write_associated_emptyroom( _bids_validate, tmp_path, empty_room_dtype ): """Test functionality of the write_raw_bids conversion for fif.""" bids_root = tmp_path / 'bids1' - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') raw = _read_raw_fif(raw_fname) @@ -3447,9 +3453,9 @@ def test_preload(_bids_validate, tmp_path): @pytest.mark.parametrize( 'dir_name', ('tsv_test', 'json_test') ) +@testing.requires_testing_data def test_write_raw_special_paths(tmp_path, dir_name): """Test writing to locations containing strings with special meaning.""" - data_path = testing.data_path() raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif') raw = _read_raw_fif(raw_fname) @@ -3460,6 +3466,7 @@ def test_write_raw_special_paths(tmp_path, dir_name): @requires_nibabel() +@testing.requires_testing_data def test_anonymize_dataset(_bids_validate, tmpdir): """Test creating an anonymized copy of a dataset.""" # Create a non-anonymized dataset @@ -3476,7 +3483,6 @@ def test_anonymize_dataset(_bids_validate, tmpdir): datatype='anat', suffix='T1w', extension='.nii.gz' ) - data_path = Path(testing.data_path()) raw_path = data_path / 'MEG' / 'sample' / 'sample_audvis_trunc_raw.fif' raw_er_path = data_path / 'MEG' / 'sample' / 'ernoise_raw.fif' fine_cal_path = data_path / 'SSS' / 'sss_cal_mgh.dat' @@ -3716,6 +3722,7 @@ def test_anonymize_dataset(_bids_validate, tmpdir): assert 'UnknownKey' not in meg_json +@testing.requires_testing_data def test_anonymize_dataset_daysback(tmpdir): """Test some bits of _get_daysback, which doesn't have a public API.""" # Check progress bar output @@ -3725,7 +3732,6 @@ def test_anonymize_dataset_daysback(tmpdir): bids_path = _bids_path.copy().update( root=bids_root, subject='testparticipant', datatype='meg' ) - data_path = Path(testing.data_path()) raw_path = data_path / 'MEG' / 'sample' / 'sample_audvis_trunc_raw.fif' raw = _read_raw_fif(raw_path, verbose=False) write_raw_bids(raw, bids_path=bids_path) @@ -3764,10 +3770,11 @@ def test_anonymize_dataset_daysback(tmpdir): ) +@testing.requires_testing_data def test_repeat_write_location(tmpdir): """Test error writing BIDS dataset to the same location.""" # Get test data - raw_fname = testing.data_path() / "EDF" / "test_reduced.edf" + raw_fname = data_path / "EDF" / "test_reduced.edf" raw = _read_raw_edf(raw_fname) # Write as BIDS @@ -3783,11 +3790,11 @@ def test_repeat_write_location(tmpdir): write_raw_bids(raw, bids_path, overwrite=True, verbose=False) +@testing.requires_testing_data def test_events_data_deprecation(tmp_path): """Test that passing events_data raises a FutureWarning.""" bids_root = tmp_path / 'bids' bids_path = _bids_path.copy().update(root=bids_root) - data_path = testing.data_path() raw_path = data_path / 'MEG' / 'sample' / 'sample_audvis_trunc_raw.fif' events_path = (data_path / 'MEG' / 'sample' / 'sample_audvis_trunc_raw-eve.fif') diff --git a/mne_bids/write.py b/mne_bids/write.py index 33f8a9d04..21dc05251 100644 --- a/mne_bids/write.py +++ b/mne_bids/write.py @@ -2379,7 +2379,7 @@ def mark_channels(bids_path, *, ch_names, status, descriptions=None, @verbose -def write_meg_calibration(calibration, bids_path, verbose=None): +def write_meg_calibration(calibration, bids_path, *, verbose=None): """Write the Elekta/Neuromag/MEGIN fine-calibration matrix to disk. Parameters @@ -2396,11 +2396,11 @@ def write_meg_calibration(calibration, bids_path, verbose=None): Examples -------- - >>> data_path = mne.datasets.testing.data_path(download=False) - >>> calibration_fname = op.join(data_path, 'SSS', 'sss_cal_3053.dat') + >>> data_path = mne.datasets.testing.data_path(download=False) # doctest: +SKIP + >>> calibration_fname = op.join(data_path, 'SSS', 'sss_cal_3053.dat') # doctest: +SKIP >>> bids_path = BIDSPath(subject='01', session='test', - ... root=op.join(data_path, 'mne_bids')) - >>> write_meg_calibration(calibration_fname, bids_path) # doctest: +ELLIPSIS + ... root=op.join(data_path, 'mne_bids')) # doctest: +SKIP + >>> write_meg_calibration(calibration_fname, bids_path) # doctest: +SKIP Writing fine-calibration file to ...sub-01_ses-test_acq-calibration_meg.dat... """ # noqa: E501 if bids_path.root is None or bids_path.subject is None: @@ -2452,13 +2452,13 @@ def write_meg_crosstalk(fname, bids_path, verbose=None): Examples -------- - >>> data_path = mne.datasets.testing.data_path(download=False) - >>> crosstalk_fname = op.join(data_path, 'SSS', 'ct_sparse.fif') + >>> data_path = mne.datasets.testing.data_path(download=False) # doctest: +SKIP + >>> crosstalk_fname = op.join(data_path, 'SSS', 'ct_sparse.fif') # doctest: +SKIP >>> bids_path = BIDSPath(subject='01', session='test', - ... root=op.join(data_path, 'mne_bids')) - >>> write_meg_crosstalk(crosstalk_fname, bids_path) # doctest: +ELLIPSIS + ... root=op.join(data_path, 'mne_bids')) # doctest: +SKIP + >>> write_meg_crosstalk(crosstalk_fname, bids_path) # doctest: +SKIP Writing crosstalk file to ...sub-01_ses-test_acq-crosstalk_meg.fif - """ + """ # noqa: E501 if bids_path.root is None or bids_path.subject is None: raise ValueError('bids_path must have root and subject set.') if bids_path.datatype not in (None, 'meg'): diff --git a/setup.cfg b/setup.cfg index 667b17639..561ed3ef6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -67,7 +67,7 @@ per-file-ignores = [tool:pytest] addopts = - --showlocals --durations=20 -ra --junit-xml=junit-results.xml + --durations=20 -ra --junit-xml=junit-results.xml --tb=short --ignore=doc --ignore=examples --ignore=mne_bids/tests/data filterwarnings = error @@ -89,6 +89,8 @@ filterwarnings = ignore:.*distutils\.sysconfig module is deprecated.*:DeprecationWarning # numba with NumPy dev ignore:`np.MachAr` is deprecated.*:DeprecationWarning + # old MNE _fake_click + ignore:The .*_event function was deprecated in Matplotlib.*: [pydocstyle] convention = pep257