Skip to content

Commit

Permalink
Merge tag '1.7.7' into maint/1.7.x
Browse files Browse the repository at this point in the history
1.7.7 (March 24, 2023)

Patch release that optimizes BIDS metadata handling by reusing cached index databases.

* ENH: Allow passing a ``database_path`` to create a ``BIDSLayout`` (#788)
  • Loading branch information
effigies committed Mar 24, 2023
2 parents 7d0bc69 + d5bc748 commit c0279e0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.7.7 (March 24, 2023)
======================
Patch release that optimizes BIDS metadata handling by reusing cached index databases.

* ENH: Allow passing a ``database_path`` to create a ``BIDSLayout`` (#788)

1.7.6 (March 06, 2023)
======================
Patch release in the 1.7.x series.
Expand Down
9 changes: 8 additions & 1 deletion niworkflows/interfaces/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class _BIDSBaseInputSpec(BaseInterfaceInputSpec):
(None, Directory(exists=True)), usedefault=True, desc="optional bids directory"
)
bids_validate = traits.Bool(True, usedefault=True, desc="enable BIDS validator")
index_db = Directory(exists=True, desc="a PyBIDS layout cache directory")


class _BIDSInfoInputSpec(_BIDSBaseInputSpec):
Expand Down Expand Up @@ -832,7 +833,13 @@ def _outputs(self):
def _run_interface(self, runtime):
self.layout = self.inputs.bids_dir or self.layout
self.layout = _init_layout(
self.inputs.in_file, self.layout, self.inputs.bids_validate
self.inputs.in_file,
self.layout,
self.inputs.bids_validate,
database_path=(
self.inputs.index_db if isdefined(self.inputs.index_db)
else None
)
)

# Fill in BIDS entities of the output ("*_id")
Expand Down
8 changes: 6 additions & 2 deletions niworkflows/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def get_metadata_for_nifti(in_file, bids_dir=None, validate=True):
return _init_layout(in_file, bids_dir, validate).get_metadata(str(in_file))


def _init_layout(in_file=None, bids_dir=None, validate=True):
def _init_layout(in_file=None, bids_dir=None, validate=True, database_path=None):
if isinstance(bids_dir, BIDSLayout):
return bids_dir

Expand All @@ -294,7 +294,11 @@ def _init_layout(in_file=None, bids_dir=None, validate=True):
if bids_dir is None:
raise RuntimeError("Could not infer BIDS root")

layout = BIDSLayout(str(bids_dir), validate=validate)
layout = BIDSLayout(
str(bids_dir),
validate=validate,
database_path=database_path,
)
return layout


Expand Down

0 comments on commit c0279e0

Please sign in to comment.