From aac48a081fb61ecc48ff6c2205ab4047c521e62b Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Mon, 16 Dec 2024 16:36:15 -0600 Subject: [PATCH 1/4] assume less about a column named "value" --- mne_bids/read.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/mne_bids/read.py b/mne_bids/read.py index 8b1a6ead4..b0eb596e2 100644 --- a/mne_bids/read.py +++ b/mne_bids/read.py @@ -574,12 +574,23 @@ def _handle_events_reading(events_fname, raw): new_name = f"{trial_type}/{value}" logger.info(f" Renaming event: {trial_type} -> {new_name}") trial_types[ii] = new_name - # drop rows where `value` is `n/a` & convert remaining `value` to int (only - # when making our `event_id` dict; `value = n/a` doesn't prevent annotation) + # make a copy with rows dropped where `value` is `n/a` (only for making our + # `event_id` dict; `value = n/a` doesn't prevent making annotations). culled = _drop(events_dict, "n/a", "value") - event_id = dict( - zip(culled[trial_type_col_name], np.asarray(culled["value"], dtype=int)) - ) + # Often (but not always!) the `value` column was written by MNE-BIDS and + # represents integer event IDs (as would be found in MNE-Python events + # arrays / event_id dicts). But in case not, let's be defensive: + culled_vals = culled["value"] + try: + culled_vals = np.asarray(culled_vals, dtype=float) + except ValueError: + pass + else: + try: + culled_vals = culled_vals.astype(int) + except ValueError: + pass + event_id = dict(zip(culled[trial_type_col_name], culled_vals)) else: event_id = dict(zip(trial_types, np.arange(len(trial_types)))) descrs = np.asarray(trial_types, dtype=str) From 19ff29a62a5f056404d57b7f1767a9ed25884a7e Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Mon, 16 Dec 2024 17:45:31 -0600 Subject: [PATCH 2/4] improve comment --- mne_bids/read.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mne_bids/read.py b/mne_bids/read.py index b0eb596e2..f53813400 100644 --- a/mne_bids/read.py +++ b/mne_bids/read.py @@ -531,7 +531,8 @@ def _handle_events_reading(events_fname, raw): logger.info(f"Reading events from {events_fname}.") events_dict = _from_tsv(events_fname) - # drop events where onset is n/a + # drop events where onset is n/a; we can't annotate them and thus don't need entries + # for them in event_id either events_dict = _drop(events_dict, "n/a", "onset") # Get event descriptions. Use `trial_type` column if available. From 653dcc41115dc3499ef7672794706131555a071d Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Tue, 17 Dec 2024 17:09:46 -0600 Subject: [PATCH 3/4] ignore xref warning --- doc/conf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index e61a693d7..d4cdaa000 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -114,6 +114,11 @@ # This patterns also effect to html_static_path and html_extra_path exclude_patterns = ["auto_examples/index.rst", "_build", "Thumbs.db", ".DS_Store"] +nitpick_ignore_regex = [ + # needs https://github.com/sphinx-doc/sphinx/issues/13178 + ("py:class", r".*pathlib\._local\.Path"), +] + # HTML options (e.g., theme) html_show_sourcelink = False html_copy_source = False From 9b395b413fad8d82e26cf8ee9bdb5f12e9a67b3c Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Tue, 17 Dec 2024 17:25:50 -0600 Subject: [PATCH 4/4] fix twine check --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b30bf0be3..a44165931 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] build-backend = "hatchling.build" -requires = ["hatch-vcs", "hatchling"] +requires = ["hatch-vcs", "hatchling==1.26.3"] [project] authors = [{name = "The MNE-BIDS developers"}]