From d0f1aa5241a7e552abdfc348bd33103ad3bd3ac5 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Fri, 23 Feb 2024 10:37:10 -0500 Subject: [PATCH 1/4] Ignore unselected subjects in BIDSLayoutIndexer. --- fmriprep/config.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/fmriprep/config.py b/fmriprep/config.py index 96deb1046..756a43ebf 100644 --- a/fmriprep/config.py +++ b/fmriprep/config.py @@ -471,18 +471,23 @@ 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: + # Ignore any subjects who aren't the requested ones. + ignore_patterns.append( + re.compile(r'sub-(?!' + '|'.join(cls.participant_label) + r')\w+') + ) + _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), From 4769d1a5c316458eb5a75d7a5be4009128ac51a7 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Tue, 5 Mar 2024 11:09:17 -0500 Subject: [PATCH 2/4] Address review. --- fmriprep/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fmriprep/config.py b/fmriprep/config.py index b85acf1a7..0e17af7de 100644 --- a/fmriprep/config.py +++ b/fmriprep/config.py @@ -480,8 +480,9 @@ def init(cls): 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: + 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')\w+') ) From 46e05b9165bde7d6d06e57cd46be0369705eae47 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Fri, 8 Mar 2024 13:00:42 -0500 Subject: [PATCH 3/4] Update fmriprep/config.py Co-authored-by: Chris Markiewicz --- fmriprep/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fmriprep/config.py b/fmriprep/config.py index 0e17af7de..246f13ccf 100644 --- a/fmriprep/config.py +++ b/fmriprep/config.py @@ -484,7 +484,7 @@ def init(cls): # 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')\w+') + re.compile(r'sub-(?!(' + '|'.join(cls.participant_label) + r')\b)') ) _indexer = BIDSLayoutIndexer( From acf39af9a7386dac496a2b2d0b7b6800fad1655f Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 8 Mar 2024 13:40:36 -0500 Subject: [PATCH 4/4] FIX: Check for word boundary or underscore to identify end-of-entity --- fmriprep/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fmriprep/config.py b/fmriprep/config.py index 246f13ccf..d0d4668e8 100644 --- a/fmriprep/config.py +++ b/fmriprep/config.py @@ -484,7 +484,7 @@ def init(cls): # 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)') + re.compile(r'sub-(?!(' + '|'.join(cls.participant_label) + r')(\b|_))') ) _indexer = BIDSLayoutIndexer(