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

FIX: Filtering in BIDSLayoutIndexer #1063

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion bids/layout/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@
m = e.match_file(bf)
if m is None and e.mandatory:
break
# Skip entities that don't match the filter
if self.filters and e.name and e.name in self.filters and m and m not in self.filters[e.name]:
continue

Check warning on line 255 in bids/layout/index.py

View check run for this annotation

Codecov / codecov/patch

bids/layout/index.py#L255

Added line #L255 was not covered by tests
if m is not None:
Comment on lines +253 to 256
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the equivalent of

Suggested change
# Skip entities that don't match the filter
if self.filters and e.name and e.name in self.filters and m and m not in self.filters[e.name]:
continue
if m is not None:
if m is not None and (e.name not in self.filters or m in listify(self.filters[e.name])):

match_vals[e.name] = (e, m)

Expand All @@ -264,7 +267,7 @@
def _index_metadata(self):
"""Index metadata for all files in the BIDS dataset.
"""
filters = self.filters
filters = self.filters.copy()

if filters:
# ensure we are returning objects
Expand Down
Loading