Skip to content

Commit 46e7071

Browse files
Improve tests of maxwell_filter_prepare_emptyroom (#13208)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent e0cc99b commit 46e7071

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Handle channels with potential electrode location in :func:`~mne.preprocessing.maxwell_filter_prepare_emptyroom`, by `Mathieu Scheltienne`_.

mne/preprocessing/maxwell.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,17 @@ def maxwell_filter_prepare_emptyroom(
131131
* Set the following properties of the empty-room recording to match the
132132
experimental recording:
133133
134-
* Montage
134+
* Montage (required for the fiducials defining the head coordinate frame)
135135
* ``raw.first_time`` and ``raw.first_samp``
136136
137137
* Adjust annotations according to the ``annotations`` parameter.
138138
* Adjust the measurement date according to the ``meas_date`` parameter.
139139
140+
.. note::
141+
142+
Note that in case of dual MEG/EEG acquisition, EEG channels should not be
143+
included in the empty room recording. If provided, they will be ignored.
144+
140145
.. versionadded:: 1.1
141146
""" # noqa: E501
142147
_validate_type(item=raw_er, types=BaseRaw, item_name="raw_er")

mne/preprocessing/tests/test_maxwell.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ def test_prepare_emptyroom_bads(bads):
18961896
assert raw_er_prepared.info["bads"] == ["MEG0113", "MEG2313"]
18971897
assert raw_er_prepared.info["dev_head_t"] == raw.info["dev_head_t"]
18981898

1899-
montage_expected = raw.copy().pick(picks="meg").get_montage()
1899+
montage_expected = raw.pick(picks="meg").get_montage()
19001900
assert raw_er_prepared.get_montage() == montage_expected
19011901

19021902
# Ensure the originals were not modified
@@ -1906,6 +1906,27 @@ def test_prepare_emptyroom_bads(bads):
19061906
assert raw_er.get_montage() is None
19071907

19081908

1909+
@testing.requires_testing_data
1910+
def test_prepare_empty_room_with_eeg() -> None:
1911+
"""Test preparation of MEG empty-room which was acquired with EEG enabled."""
1912+
raw = read_raw_fif(raw_fname, allow_maxshield="yes", verbose=False)
1913+
raw_er = read_raw_fif(erm_fname, allow_maxshield="yes", verbose=False)
1914+
assert "eeg" in raw
1915+
assert "eeg" in raw_er
1916+
raw_er_prepared = maxwell_filter_prepare_emptyroom(raw_er=raw_er, raw=raw)
1917+
assert raw_er_prepared.info["dev_head_t"] == raw.info["dev_head_t"]
1918+
montage_expected = raw.get_montage()
1919+
assert raw_er_prepared.get_montage() == montage_expected
1920+
1921+
raw_er = raw_er.pick("meg")
1922+
assert "eeg" in raw
1923+
assert "eeg" not in raw_er
1924+
raw_er_prepared = maxwell_filter_prepare_emptyroom(raw_er=raw_er, raw=raw)
1925+
assert raw_er_prepared.info["dev_head_t"] == raw.info["dev_head_t"]
1926+
montage_expected = raw.pick("meg").get_montage()
1927+
assert raw_er_prepared.get_montage() == montage_expected
1928+
1929+
19091930
@testing.requires_testing_data
19101931
@pytest.mark.slowtest # lots of params
19111932
@pytest.mark.parametrize("set_annot_when", ("before", "after"))

0 commit comments

Comments
 (0)