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

MRG: Drop support for MNE-Python <1.3, add new CI job to cover "previous stable" MNE version #1140

Merged
merged 5 commits into from
May 29, 2023
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
11 changes: 11 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ jobs:
python-version: "3.10"
mne-version: mne-main
bids-validator-version: validator-main
# Test previous MNE stable only on a single system so save CI resources
- os: ubuntu-latest
python-version: "3.8"
mne-version: mne-prev-stable
bids-validator-version: validator-stable

env:
TZ: Europe/Berlin
Expand Down Expand Up @@ -153,6 +158,12 @@ jobs:

- name: Install MNE (stable)
if: "matrix.mne-version == 'mne-stable'"
run: |
git clone --single-branch --branch maint/1.4 https://github.com/mne-tools/mne-python.git
python -m pip install -e ./mne-python

- name: Install MNE (previous stable)
if: "matrix.mne-version == 'mne-prev-stable'"
run: |
git clone --single-branch --branch maint/1.3 https://github.com/mne-tools/mne-python.git
python -m pip install -e ./mne-python
Expand Down
2 changes: 1 addition & 1 deletion doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Dependencies

Required:

* ``mne`` (>=1.2)
* ``mne`` (>=1.3)
* ``numpy`` (>=1.18.1)
* ``scipy`` (>=1.4.1, or >=1.5.0 for certain operations with EEGLAB data)
* ``setuptools`` (>=46.4.0)
Expand Down
2 changes: 1 addition & 1 deletion doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Detailed list of changes
🛠 Requirements
^^^^^^^^^^^^^^^

- ...
- MNE-BIDS now requires MNE-Python 1.3 or newer.

🪲 Bug fixes
^^^^^^^^^^^^
Expand Down
22 changes: 4 additions & 18 deletions mne_bids/commands/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import mne

from mne.datasets import testing
from mne.utils import ArgvSetter, requires_pandas, check_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,
Expand Down Expand Up @@ -148,11 +148,7 @@ def test_mark_bad_channels_single_file(tmp_path):
mne_bids_mark_channels.run()

# Check the data was properly written
if check_version("mne", "1.3"):
raw = read_raw_bids(bids_path=bids_path, verbose=False)
else:
with pytest.warns(RuntimeWarning, match='The unit for chann*'):
raw = read_raw_bids(bids_path=bids_path, verbose=False)
raw = read_raw_bids(bids_path=bids_path, verbose=False)
assert set(old_bads + ch_names) == set(raw.info['bads'])

# Test resetting bad channels.
Expand All @@ -164,11 +160,7 @@ def test_mark_bad_channels_single_file(tmp_path):
print('Finished running the reset...')

# Check the data was properly written
if check_version("mne", "1.3"):
raw = read_raw_bids(bids_path=bids_path)
else:
with pytest.warns(RuntimeWarning, match='The unit for chann*'):
raw = read_raw_bids(bids_path=bids_path)
raw = read_raw_bids(bids_path=bids_path)
assert raw.info['bads'] == []


Expand Down Expand Up @@ -210,13 +202,7 @@ def test_mark_bad_channels_multiple_files(tmp_path):

# Check the data was properly written
for subject in subjects:
if check_version("mne", "1.3"):
raw = read_raw_bids(bids_path=bids_path.copy()
.update(subject=subject))
else:
with pytest.warns(RuntimeWarning, match='The unit for chann*'):
raw = read_raw_bids(bids_path=bids_path.copy()
.update(subject=subject))
raw = read_raw_bids(bids_path=bids_path.copy().update(subject=subject))
assert set(old_bads + ch_names) == set(raw.info['bads'])


Expand Down
70 changes: 19 additions & 51 deletions mne_bids/tests/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
import numpy as np
from numpy.testing import assert_almost_equal

from pkg_resources import parse_version

import mne
from mne.datasets import testing
from mne.io.constants import FIFF
from mne.utils import object_diff, requires_version
from mne.utils import assert_dig_allclose, check_version
from mne.utils import object_diff
from mne.utils import assert_dig_allclose

from mne_bids import BIDSPath
from mne_bids.config import (MNE_STR_TO_FRAME, BIDS_SHARED_COORDINATE_FRAMES,
Expand All @@ -40,7 +38,6 @@
run = '01'
acq = '01'
task = 'testing'
fids_added = check_version('mne', '1.2')

_bids_path = BIDSPath(
subject=subject_id, session=session_id, run=run, acquisition=acq,
Expand Down Expand Up @@ -288,10 +285,7 @@ def test_get_head_mri_trans(tmp_path):
raw_test.set_montage(montage)
raw_test.save(bids_path.fpath, overwrite=True)

if fids_added:
ctx = nullcontext()
else:
ctx = pytest.raises(RuntimeError, match='Could not extract fiducial')
ctx = nullcontext()
with ctx:
get_head_mri_trans(bids_path=bids_path, fs_subject='sample',
fs_subjects_dir=subjects_dir)
Expand Down Expand Up @@ -581,7 +575,6 @@ def test_handle_scans_reading(tmp_path):
assert new_acq_time != raw_01.info['meas_date']


@requires_version('mne', '1.2') # tiny_bids contains GSR & temperature chans
@pytest.mark.filterwarnings(warning_str['channel_unit_changed'])
def test_handle_scans_reading_brainvision(tmp_path):
"""Test stability of BrainVision's different file extensions"""
Expand Down Expand Up @@ -724,26 +717,21 @@ def test_handle_chpi_reading(tmp_path):
meg_json_data = json.load(f)

# cHPI frequency mismatch
if parse_version(mne.__version__) <= parse_version('1.1'):
assert 'ContinuousHeadLocalization' not in meg_json_data
assert 'HeadCoilFrequency' not in meg_json_data
else:
meg_json_data_freq_mismatch = meg_json_data.copy()
meg_json_data_freq_mismatch['HeadCoilFrequency'][0] = 123
_write_json(meg_json_path, meg_json_data_freq_mismatch, overwrite=True)
meg_json_data_freq_mismatch = meg_json_data.copy()
meg_json_data_freq_mismatch['HeadCoilFrequency'][0] = 123
_write_json(meg_json_path, meg_json_data_freq_mismatch, overwrite=True)

with pytest.warns(RuntimeWarning,
match='Defaulting to .* mne.Raw object'):
raw_read = read_raw_bids(bids_path)
with pytest.warns(RuntimeWarning, match='Defaulting to .* mne.Raw object'):
raw_read = read_raw_bids(bids_path)

# cHPI "off" according to sidecar, but present in the data
meg_json_data_chpi_mismatch = meg_json_data.copy()
meg_json_data_chpi_mismatch['ContinuousHeadLocalization'] = False
_write_json(meg_json_path, meg_json_data_chpi_mismatch, overwrite=True)
# cHPI "off" according to sidecar, but present in the data
meg_json_data_chpi_mismatch = meg_json_data.copy()
meg_json_data_chpi_mismatch['ContinuousHeadLocalization'] = False
_write_json(meg_json_path, meg_json_data_chpi_mismatch, overwrite=True)

raw_read = read_raw_bids(bids_path)
assert raw_read.info['hpi_subsystem'] is None
assert raw_read.info['hpi_meas'] == []
raw_read = read_raw_bids(bids_path)
assert raw_read.info['hpi_subsystem'] is None
assert raw_read.info['hpi_meas'] == []


@pytest.mark.filterwarnings(warning_str['nasion_not_found'])
Expand Down Expand Up @@ -772,11 +760,7 @@ def test_handle_eeg_coords_reading(tmp_path):
montage = mne.channels.make_dig_montage(ch_pos=ch_pos,
coord_frame="unknown")
raw.set_montage(montage)
if fids_added:
ctx = nullcontext()
else:
ctx = pytest.raises(
RuntimeError, match="'head' coordinate frame must contain")
ctx = nullcontext()
with ctx:
write_raw_bids(raw, bids_path, overwrite=True)

Expand All @@ -789,33 +773,18 @@ def test_handle_eeg_coords_reading(tmp_path):
suffix='electrodes',
extension='.tsv',
on_error='warn')
if fids_added:
assert coordsystem_fname is not None
assert electrodes_fname is not None
else:
assert coordsystem_fname is None
assert electrodes_fname is None
assert coordsystem_fname is not None
assert electrodes_fname is not None

# create montage in head frame and set should result in
# an error if landmarks are not set
montage = mne.channels.make_dig_montage(ch_pos=ch_pos,
coord_frame="head")
raw.set_montage(montage)
if fids_added:
ctx = nullcontext()
else:
ctx = pytest.raises(
RuntimeError, match="'head' coordinate frame must contain")
ctx = nullcontext()
with ctx:
write_raw_bids(raw, bids_path, overwrite=True)

if not fids_added: # only need to rerun if the last one failed
montage = mne.channels.make_dig_montage(ch_pos=ch_pos,
coord_frame="head",
nasion=[1, 0, 0],
lpa=[0, 1, 0],
rpa=[0, 0, 1])
raw.set_montage(montage)
write_raw_bids(raw, bids_path, overwrite=True)

# obtain the sensor positions and assert ch_coords are same
Expand Down Expand Up @@ -1323,7 +1292,6 @@ def test_file_not_found(tmp_path):
read_raw_bids(bp)


@requires_version('mne', '1.2')
@pytest.mark.filterwarnings(warning_str['channel_unit_changed'])
def test_gsr_and_temp_reading():
"""Test GSR and temperature channels are handled correctly."""
Expand Down
Loading