Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions mne_bids/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,6 @@ def __init__(
):
raise ValueError("At least one parameter must be given.")

self.check = check

self.update(
subject=subject,
session=session,
Expand All @@ -427,6 +425,7 @@ def __init__(
datatype=datatype,
suffix=suffix,
extension=extension,
check=check,
)

@property
Expand Down Expand Up @@ -924,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:
Expand Down Expand Up @@ -1364,12 +1363,13 @@ 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
Expand Down
14 changes: 14 additions & 0 deletions mne_bids/tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,20 @@ def test_datasetdescription_with_bidspath(return_bids_test_dir):
)


@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."""
bids_path = BIDSPath(subject="test")
Expand Down