Skip to content

Commit 08e6939

Browse files
committed
more more coverage
1 parent 44ce4cc commit 08e6939

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

mne_bids/tests/test_write.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,6 +3368,22 @@ def test_sidecar_encoding(_bids_validate, tmp_path):
33683368
assert_array_equal(raw.annotations.description, raw_read.annotations.description)
33693369

33703370

3371+
@testing.requires_testing_data
3372+
def test_emg_errors_and_warnings(tmp_path):
3373+
"""Test EMG-specific error/warning raising."""
3374+
bids_root = tmp_path / "EDF"
3375+
raw_fname = data_path / "EDF" / "test_generator_2.edf"
3376+
bids_path = _bids_path.copy().update(root=bids_root, datatype="emg")
3377+
raw = _read_raw_edf(raw_fname)
3378+
raw.set_channel_types({ch: "emg" for ch in raw.ch_names}) # HACK eeg → emg
3379+
raw = raw.pick(["emg"]) # drop misc
3380+
good_kwargs = dict(raw=raw, bids_path=bids_path, verbose=False)
3381+
with pytest.raises(ValueError, match="`emg_placement` must be one of"):
3382+
write_raw_bids(**good_kwargs, emg_placement="Foo")
3383+
with pytest.warns(RuntimeWarning, match="add `coordsystem.json` file manually"):
3384+
write_raw_bids(**good_kwargs, emg_placement="Other")
3385+
3386+
33713387
@pytest.mark.parametrize("dir_name, fmt, fname, reader", test_convertemg_data)
33723388
@pytest.mark.filterwarnings(
33733389
warning_str["edfblocks"],

mne_bids/write.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2008,7 +2008,11 @@ def write_raw_bids(
20082008
datatype=datatype, suffix=datatype, extension=ext
20092009
)
20102010

2011-
if datatype == "emg" and emg_placement is None:
2011+
if datatype == "emg" and emg_placement not in (
2012+
"Measured",
2013+
"ChannelSpecific",
2014+
"Other",
2015+
):
20122016
raise ValueError(
20132017
'`emg_placement` must be one of "Measured", "ChannelSpecific", or "Other" '
20142018
f"(got {emg_placement})"

0 commit comments

Comments
 (0)