From 4cc5da313b35ba0802b72cef03112693334ebb39 Mon Sep 17 00:00:00 2001 From: Teon L Brooks Date: Wed, 4 Jun 2025 12:32:29 -0400 Subject: [PATCH 1/3] Update path.py --- mne_bids/path.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mne_bids/path.py b/mne_bids/path.py index b3591fac4..e520eff36 100644 --- a/mne_bids/path.py +++ b/mne_bids/path.py @@ -410,8 +410,6 @@ def __init__( ): raise ValueError("At least one parameter must be given.") - self.check = check - self.update( subject=subject, session=session, @@ -427,6 +425,7 @@ def __init__( datatype=datatype, suffix=suffix, extension=extension, + check=check, ) @property From 50cbfd0c14b797fcf2ceb66943093c882b88c8a3 Mon Sep 17 00:00:00 2001 From: Teon L Brooks Date: Sun, 15 Jun 2025 14:54:08 -0400 Subject: [PATCH 2/3] Added test, Fix private function also within `_get_matching_bidspaths_from_filesystem`, the check parameter was being passed so it would not work when trying to generate a fpath Added test to check for the fpath creation with datatype not in VALID_DATATYPES when check=False --- mne_bids/path.py | 8 +++++--- mne_bids/tests/test_path.py | 11 +++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mne_bids/path.py b/mne_bids/path.py index e520eff36..f9998113c 100644 --- a/mne_bids/path.py +++ b/mne_bids/path.py @@ -923,10 +923,10 @@ def fpath(self): return bids_fpath def update(self, *, check=None, **kwargs): - """Update inplace BIDS entity key/value pairs in object. + """Update in-place BIDS entity key/value pairs in object. ``run`` and ``split`` are auto-converted to have two - digits. For example, if ``run=1``, then it will nbecome ``run='01'``. + digits. For example, if ``run=1``, then it will become ``run='01'``. Also performs error checks on various entities to adhere to the BIDS specification. Specifically: @@ -1363,12 +1363,14 @@ def _get_matching_bidspaths_from_filesystem(bids_path): sub, ses = bids_path.subject, bids_path.session datatype = bids_path.datatype basename, bids_root = bids_path.basename, bids_path.root + check = bids_path.check if datatype is None: datatype = _infer_datatype(root=bids_root, sub=sub, ses=ses) data_dir = BIDSPath( - subject=sub, session=ses, datatype=datatype, root=bids_root + subject=sub, session=ses, datatype=datatype, root=bids_root, + check=check ).directory # For BTi data, just return the directory with a '.pdf' extension diff --git a/mne_bids/tests/test_path.py b/mne_bids/tests/test_path.py index 37e642e43..ab87a96d1 100644 --- a/mne_bids/tests/test_path.py +++ b/mne_bids/tests/test_path.py @@ -1611,6 +1611,17 @@ def test_datasetdescription_with_bidspath(return_bids_test_dir): == Path(f"{return_bids_test_dir}/dataset_description.json").as_posix() ) +@testing.requires_testing_data +def test_update_check(return_bids_test_dir): + """Test check argument is passed BIDSPath properly.""" + bids_path = BIDSPath( + root=return_bids_test_dir, + check=False, + ) + bids_path.update(datatype="eyetrack") + assert (bids_path.fpath.as_posix() + == Path(f"{return_bids_test_dir}/eyetrack").as_posix()) + def test_update_fail_check_no_change(): """Test BIDSPath.check works in preventing invalid changes.""" From b2253d35cecce60d2e25a54ea00025c80c6131a4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 15 Jun 2025 18:54:16 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne_bids/path.py | 3 +-- mne_bids/tests/test_path.py | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mne_bids/path.py b/mne_bids/path.py index f9998113c..bea243b8d 100644 --- a/mne_bids/path.py +++ b/mne_bids/path.py @@ -1369,8 +1369,7 @@ def _get_matching_bidspaths_from_filesystem(bids_path): datatype = _infer_datatype(root=bids_root, sub=sub, ses=ses) data_dir = BIDSPath( - subject=sub, session=ses, datatype=datatype, root=bids_root, - check=check + subject=sub, session=ses, datatype=datatype, root=bids_root, check=check ).directory # For BTi data, just return the directory with a '.pdf' extension diff --git a/mne_bids/tests/test_path.py b/mne_bids/tests/test_path.py index ab87a96d1..60434fdf4 100644 --- a/mne_bids/tests/test_path.py +++ b/mne_bids/tests/test_path.py @@ -1611,6 +1611,7 @@ def test_datasetdescription_with_bidspath(return_bids_test_dir): == Path(f"{return_bids_test_dir}/dataset_description.json").as_posix() ) + @testing.requires_testing_data def test_update_check(return_bids_test_dir): """Test check argument is passed BIDSPath properly.""" @@ -1619,8 +1620,10 @@ def test_update_check(return_bids_test_dir): check=False, ) bids_path.update(datatype="eyetrack") - assert (bids_path.fpath.as_posix() - == Path(f"{return_bids_test_dir}/eyetrack").as_posix()) + assert ( + bids_path.fpath.as_posix() + == Path(f"{return_bids_test_dir}/eyetrack").as_posix() + ) def test_update_fail_check_no_change():