Skip to content

Commit

Permalink
Ignore unselected subjects in BIDSLayoutIndexer (#3236)
Browse files Browse the repository at this point in the history
Closes #3235.

## Changes proposed in this pull request

- Incorporate a regular expression in the `ignore` list of the
`BIDSLayoutIndexer` that flags subjects who are _not_ in
`Config.participant_label` (when provided).

---------

Co-authored-by: Chris Markiewicz <[email protected]>
  • Loading branch information
tsalo and effigies authored Mar 9, 2024
1 parent 3d0d0b6 commit c46c893
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions fmriprep/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,18 +472,24 @@ def init(cls):
_db_path.mkdir(exist_ok=True, parents=True)

# Recommended after PyBIDS 12.1
ignore_patterns = [
'code',
'stimuli',
'sourcedata',
'models',
re.compile(r'^\.'),
re.compile(r'sub-[a-zA-Z0-9]+(/ses-[a-zA-Z0-9]+)?/(beh|dwi|eeg|ieeg|meg|perf)'),
]
if cls.participant_label and cls.bids_database_dir is None:
# Ignore any subjects who aren't the requested ones.
# This is only done if the database is written out to a run-specific folder.
ignore_patterns.append(
re.compile(r'sub-(?!(' + '|'.join(cls.participant_label) + r')(\b|_))')
)

_indexer = BIDSLayoutIndexer(
validate=False,
ignore=(
'code',
'stimuli',
'sourcedata',
'models',
re.compile(r'^\.'),
re.compile(
r'sub-[a-zA-Z0-9]+(/ses-[a-zA-Z0-9]+)?/(beh|dwi|eeg|ieeg|meg|perf)'
),
),
ignore=ignore_patterns,
)
cls._layout = BIDSLayout(
str(cls.bids_dir),
Expand Down

0 comments on commit c46c893

Please sign in to comment.