Skip to content
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 @@ def _index_file(self, abs_fn, entities):
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
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_file(self, abs_fn, entities):
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