diff --git a/xcp_d/cli/parser.py b/xcp_d/cli/parser.py index 9be52ad1f..421df9b7b 100644 --- a/xcp_d/cli/parser.py +++ b/xcp_d/cli/parser.py @@ -150,6 +150,16 @@ def _bids_filter(value, parser): "filtering-inputs-with-bids-filter-files" ), ) + g_bids.add_argument( + "--bids-database-dir", + metavar="PATH", + type=Path, + help=( + "Path to a PyBIDS database folder, for faster indexing " + "(especially useful for large datasets). " + "Will be created if not present." + ), + ) g_surfx = parser.add_argument_group("Options for CIFTI processing") g_surfx.add_argument( diff --git a/xcp_d/config.py b/xcp_d/config.py index 7dbe500e3..b5329e1ff 100644 --- a/xcp_d/config.py +++ b/xcp_d/config.py @@ -461,10 +461,10 @@ def init(cls): ) ), ] - if cls.participant_label: + if cls.participant_label and cls.bids_database_dir is None: # Ignore any subjects who aren't the requested ones. 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( diff --git a/xcp_d/tests/tests.py b/xcp_d/tests/tests.py index 1162e428b..438b98730 100644 --- a/xcp_d/tests/tests.py +++ b/xcp_d/tests/tests.py @@ -56,6 +56,8 @@ def mock_config(): config.execution.work_dir = Path(mkdtemp()) config.execution.fmri_dir = Path(doc.download_example_data(out_dir=mkdtemp())) config.execution.xcp_d_dir = Path(mkdtemp()) + config.execution.bids_database_dir = None + config.execution._layout = None config.execution.init() yield