From c1d59eccff860a79f875bfc274d1281921496eb2 Mon Sep 17 00:00:00 2001 From: Simon Kern <14980558+skjerns@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:37:15 +0200 Subject: [PATCH] Add chpi to known channel list (#1325) * add chpi to known channel list * removed some ch types from testing * change chpi to BIDS type HLU * adapt changelog * remove myself from authors again? --- doc/whats_new.rst | 2 ++ mne_bids/tests/test_utils.py | 30 ++++++++++++++++++++++++++++++ mne_bids/utils.py | 1 + 3 files changed, 33 insertions(+) diff --git a/doc/whats_new.rst b/doc/whats_new.rst index 0bc77bb7a..cb0048152 100644 --- a/doc/whats_new.rst +++ b/doc/whats_new.rst @@ -20,6 +20,7 @@ The following authors contributed for the first time. Thank you so much! 🤩 * `Aaron Earle-Richardson`_ * `Amaia Benitez`_ * `Kaare Mikkelsen`_ +* `Simon Kern`_ * `Thomas Hartmann`_ * `William Turner`_ @@ -55,6 +56,7 @@ Detailed list of changes 🪲 Bug fixes ^^^^^^^^^^^^ +- Writing MEGIN data with MNE channel types `chpi` will now map to BIDS type HLU by `Simon Kern`_ (:gh:`1325`) - When anonymizing the date of a recording, MNE-BIDS will no longer error during `~mne_bids.write_raw_bids` if passing a `~mne.io.Raw` instance to ``empty_room``, by `Daniel McCloy`_ (:gh:`1270`) - Dealing with alphanumeric ``sub`` entity labels is now fixed for :func:`~mne_bids.write_raw_bids`, by `Aaron Earle-Richardson`_ (:gh:`1291`) - When processing subject_info data that MNE Python imports as numpy arrays with only one item, MNE-BIDS now unpacks these, resulting in a correct participants.tsv, by `Thomas Hartmann`_ (:gh:`1310`) diff --git a/mne_bids/tests/test_utils.py b/mne_bids/tests/test_utils.py index 0f08454c4..d23b53684 100644 --- a/mne_bids/tests/test_utils.py +++ b/mne_bids/tests/test_utils.py @@ -39,6 +39,36 @@ def test_get_ch_type_mapping(): with pytest.raises(ValueError, match='specified from "bogus" to "mne"'): _get_ch_type_mapping(fro="bogus", to="mne") + # check that all mne types have a corresponding BIDS translation + # last update from mne 0.19.0. + mne_valid_types = [ + "bio", + "chpi", + "dbs", + # "dipole", # currently not converted + "ecg", + "ecog", + "eeg", + "emg", + "eog", + "exci", + # "eyetrack", # currently not converted + # "fnirs", # currently not converted + # "gof", # currently not converted + "gsr", + "ias", + "misc", + # "meg", # inferred in more detail + "resp", + "seeg", + "stim", + "syst", + "temperature", + ] + map_mne_to_bids = _get_ch_type_mapping(fro="mne", to="bids") + for ch_type in mne_valid_types: + assert ch_type in map_mne_to_bids + def test_handle_datatype(): """Test the automatic extraction of datatype from the data.""" diff --git a/mne_bids/utils.py b/mne_bids/utils.py index fe3ad5738..05aac7523 100644 --- a/mne_bids/utils.py +++ b/mne_bids/utils.py @@ -82,6 +82,7 @@ def _get_ch_type_mapping(fro="mne", to="bids"): megrefgradaxial="MEGREFGRADAXIAL", meggradplanar="MEGGRADPLANAR", megrefmag="MEGREFMAG", + chpi="HLU", ias="MEGOTHER", syst="MEGOTHER", exci="MEGOTHER",