Skip to content

Commit

Permalink
Merge pull request #2494 from oesteban/enh/bids-layout-indexer
Browse files Browse the repository at this point in the history
ENH: Use ``BIDSLayoutIndexer`` and do not index unnecessary modalities
  • Loading branch information
oesteban authored Aug 30, 2021
2 parents be3ccc5 + 089d85b commit 1ac52cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions fmriprep/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ def init(cls):

if cls._layout is None:
import re
from bids.layout.index import BIDSLayoutIndexer
from bids.layout import BIDSLayout

if cls.bids_database_dir:
Expand All @@ -446,19 +447,27 @@ def init(cls):
_db_path = cls.work_dir / cls.run_uuid / "bids_db"

_db_path.mkdir(exist_ok=True, parents=True)
cls._layout = BIDSLayout(
str(cls.bids_dir),

# Recommended after PyBIDS 12.1
_indexer = BIDSLayoutIndexer(
validate=False,
database_path=_db_path,
reset_database=cls.bids_database_dir is None,
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)"
),
),
)
cls._layout = BIDSLayout(
str(cls.bids_dir),
database_path=_db_path,
reset_database=cls.bids_database_dir is None,
indexer=_indexer,
)
cls.bids_database_dir = _db_path
cls.layout = cls._layout
if cls.bids_filters:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ install_requires =
numpy
pandas
psutil >= 5.4
pybids >= 0.11.1
pybids >= 0.12.1
pyyaml
requests
scikit-image ~= 0.17.2
Expand Down

0 comments on commit 1ac52cf

Please sign in to comment.