From b2b421d8ac95085f40202a3d77bd55d5d23b1b2c Mon Sep 17 00:00:00 2001 From: Scott Huberty Date: Fri, 20 Dec 2024 11:52:32 -0800 Subject: [PATCH 1/3] FIX: don't use "rec" for recording entity. Use the full name Fixes #1348 See: https://bids-specification.readthedocs.io/en/stable/modality-specific-files/physiological-recordings.html --- mne_bids/config.py | 2 +- mne_bids/path.py | 6 ++++-- mne_bids/tests/test_path.py | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mne_bids/config.py b/mne_bids/config.py index d225f02b7..7b6a38e51 100644 --- a/mne_bids/config.py +++ b/mne_bids/config.py @@ -235,7 +235,7 @@ "run": "run", "proc": "processing", "space": "space", - "rec": "recording", + "recording": "recording", "split": "split", "desc": "description", } diff --git a/mne_bids/path.py b/mne_bids/path.py index 63d6d1259..74d659a78 100644 --- a/mne_bids/path.py +++ b/mne_bids/path.py @@ -2088,7 +2088,7 @@ def get_entity_vals( ): continue if ignore_recordings and any( - [f"_rec-{a}_" in filename.stem for a in ignore_recordings] + [f"_recording-{a}_" in filename.stem for a in ignore_recordings] ): continue if ignore_splits and any( @@ -2280,7 +2280,9 @@ def _filter_fnames( r"_proc-(" + "|".join(processing) + ")" if processing else r"(|_proc-([^_]+))" ) space_str = r"_space-(" + "|".join(space) + ")" if space else r"(|_space-([^_]+))" - rec_str = r"_rec-(" + "|".join(recording) + ")" if recording else r"(|_rec-([^_]+))" + rec_str = (r"_recording-(" + "|".join(recording) + ")" + if recording else r"(|_recording-([^_]+))" + ) split_str = r"_split-(" + "|".join(split) + ")" if split else r"(|_split-([^_]+))" desc_str = ( r"_desc-(" + "|".join(description) + ")" if description else r"(|_desc-([^_]+))" diff --git a/mne_bids/tests/test_path.py b/mne_bids/tests/test_path.py index bcf42f682..605050f96 100644 --- a/mne_bids/tests/test_path.py +++ b/mne_bids/tests/test_path.py @@ -857,7 +857,7 @@ def test_make_filenames(): datatype="ieeg", ) expected_str = ( - "sub-one_ses-two_task-three_acq-four_run-1_proc-six_rec-seven_ieeg.json" + "sub-one_ses-two_task-three_acq-four_run-1_proc-six_recording-seven_ieeg.json" ) assert BIDSPath(**prefix_data).basename == expected_str assert ( @@ -896,7 +896,7 @@ def test_make_filenames(): basename = BIDSPath(**prefix_data, check=False) assert ( basename.basename - == "sub-one_ses-two_task-three_acq-four_run-1_proc-six_rec-seven_ieeg.h5" + == "sub-one_ses-two_task-three_acq-four_run-1_proc-six_recording-seven_ieeg.h5" ) # what happens with scans.tsv file From 8d6a5f144c88f702558446242bac69d29c914f9e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 20:07:58 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne_bids/path.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mne_bids/path.py b/mne_bids/path.py index 74d659a78..83c5ebe53 100644 --- a/mne_bids/path.py +++ b/mne_bids/path.py @@ -2280,9 +2280,11 @@ def _filter_fnames( r"_proc-(" + "|".join(processing) + ")" if processing else r"(|_proc-([^_]+))" ) space_str = r"_space-(" + "|".join(space) + ")" if space else r"(|_space-([^_]+))" - rec_str = (r"_recording-(" + "|".join(recording) + ")" - if recording else r"(|_recording-([^_]+))" - ) + rec_str = ( + r"_recording-(" + "|".join(recording) + ")" + if recording + else r"(|_recording-([^_]+))" + ) split_str = r"_split-(" + "|".join(split) + ")" if split else r"(|_split-([^_]+))" desc_str = ( r"_desc-(" + "|".join(description) + ")" if description else r"(|_desc-([^_]+))" From 3cd603ada12b9e7d96f8b2746a4b47533d7a3fe0 Mon Sep 17 00:00:00 2001 From: Scott Huberty Date: Fri, 20 Dec 2024 12:13:20 -0800 Subject: [PATCH 3/3] DOC: update changelog --- doc/whats_new.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/whats_new.rst b/doc/whats_new.rst index b685cd3cd..ade3fe6f9 100644 --- a/doc/whats_new.rst +++ b/doc/whats_new.rst @@ -47,6 +47,7 @@ Detailed list of changes ^^^^^^^^^^^^ - :func:`mne_bids.read_raw_bids` can optionally return an ``event_id`` dictionary suitable for use with :func:`mne.events_from_annotations`, and if a ``values`` column is present in ``events.tsv`` it will be used as the source of the integer event ID codes, by `Daniel McCloy`_ (:gh:`1349`) +- BIDS dictates that the recording entity should be displayed as "_recording-" in the filename. This PR makes :class:`mne_bids.BIDSPath` correctly display "_recording-" (instead of "_rec-") in BIDSPath.fpath. By `Scott Huberty`_ (:gh:`1348`) ⚕️ Code health ^^^^^^^^^^^^^^