Skip to content

Commit c46c893

Browse files
tsaloeffigies
andauthored
Ignore unselected subjects in BIDSLayoutIndexer (#3236)
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]>
1 parent 3d0d0b6 commit c46c893

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

fmriprep/config.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -472,18 +472,24 @@ def init(cls):
472472
_db_path.mkdir(exist_ok=True, parents=True)
473473

474474
# Recommended after PyBIDS 12.1
475+
ignore_patterns = [
476+
'code',
477+
'stimuli',
478+
'sourcedata',
479+
'models',
480+
re.compile(r'^\.'),
481+
re.compile(r'sub-[a-zA-Z0-9]+(/ses-[a-zA-Z0-9]+)?/(beh|dwi|eeg|ieeg|meg|perf)'),
482+
]
483+
if cls.participant_label and cls.bids_database_dir is None:
484+
# Ignore any subjects who aren't the requested ones.
485+
# This is only done if the database is written out to a run-specific folder.
486+
ignore_patterns.append(
487+
re.compile(r'sub-(?!(' + '|'.join(cls.participant_label) + r')(\b|_))')
488+
)
489+
475490
_indexer = BIDSLayoutIndexer(
476491
validate=False,
477-
ignore=(
478-
'code',
479-
'stimuli',
480-
'sourcedata',
481-
'models',
482-
re.compile(r'^\.'),
483-
re.compile(
484-
r'sub-[a-zA-Z0-9]+(/ses-[a-zA-Z0-9]+)?/(beh|dwi|eeg|ieeg|meg|perf)'
485-
),
486-
),
492+
ignore=ignore_patterns,
487493
)
488494
cls._layout = BIDSLayout(
489495
str(cls.bids_dir),

0 commit comments

Comments
 (0)