Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Add function to enable smart path search #1098 #1103

Merged
merged 22 commits into from
Nov 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions mne_bids/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,7 @@ def _filter_fnames(fnames, *, subject=None, session=None, task=None,
recording = _ensure_tuple(recording)
split = _ensure_tuple(split)
description = _ensure_tuple(description)
suffixe = _ensure_tuple(suffix)
suffix = _ensure_tuple(suffix)
extension = _ensure_tuple(extension)

leading_path_str = r'.*\/?' # nothing or something ending with a `/`
Expand All @@ -1951,8 +1951,8 @@ def _filter_fnames(fnames, *, subject=None, session=None, task=None,
if split else r'(|_split-([^_]+))')
desc_str = (r'_desc-(' + '|'.join(description) + ')'
if description else r'(|_desc-([^_]+))')
suffix_str = (r'_(' + '|'.join(suffixe) + ')' if suffix
else (r'_(' + '|'.join(ALLOWED_FILENAME_SUFFIX) + ')'))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the function _filter_fnames() only returns paths with valid BIDS suffixes even if the two mother functions find_matching_paths() and BIDSPath.match() have the keyword argument check=False.

In theory, one could add the argument check=False to _filter_fnames(check=False) and then code

    if suffix:
        suffix_str = r'_(' + '|'.join(suffix) + ')'
    elif suffix is None and check:
        # only return files with suffixes that are valid in BIDS
        suffix_str = (r'_(' + '|'.join(ALLOWED_FILENAME_SUFFIX) + ')'))
    elif suffix is None and not check:
        suffix_str = r'_([^_]+)'

However, this seems overkill to me since the BIDS conformity is checked afterwards using _fnames_to_bidspaths(check=check).

suffix_str = (r'_(' + '|'.join(suffix) + ')' if suffix
else r'_([^_]+)')
ext_str = r'(' + '|'.join(extension) + ')' if extension else r'.([^_]+)'

regexp = (
Expand Down