Skip to content

ENH: Allow dictionary input for BIDSLayout derivatives parameter to s…#1257

Open
anushkagupta200615-jpg wants to merge 1 commit into
bids-standard:mainfrom
anushkagupta200615-jpg:fix-issue-1155
Open

ENH: Allow dictionary input for BIDSLayout derivatives parameter to s…#1257
anushkagupta200615-jpg wants to merge 1 commit into
bids-standard:mainfrom
anushkagupta200615-jpg:fix-issue-1155

Conversation

@anushkagupta200615-jpg

Copy link
Copy Markdown

Fixes #1155

Description

This PR introduces the ability to pass a dictionary to the derivatives parameter in BIDSLayout (or layout.add_derivatives()) to map custom names to derivative pipelines.

Previously, PyBIDS strictly extracted the pipeline name from the derivative's base directory name or dataset_description.json. This was inflexible and forced users to query derivatives using potentially messy directory names.

Now, users can pass a dictionary mapping custom names to derivative paths (e.g., layout = BIDSLayout(data_dir, derivatives={'my_clean_pipeline': '/path/to/ugly_pipeline_name_v1.0.0'})). The specified dictionary key will explicitly override the derivative's source_pipeline property, allowing intuitive and clean queries via layout.get(scope='my_clean_pipeline').

Changes Made

  • Modified _get_derivative_dirs in src/bids/layout/layout.py to support dict paths, yielding the custom key instead of parsing the directory name.
  • Modified add_derivatives in src/bids/layout/layout.py to prevent listify from destroying dictionary structures, and overrode the spawned BIDSLayout's source_pipeline property with the user's custom dictionary key.
  • Updated _sanitize_init_args in src/bids/layout/models.py to properly serialize and sanitize dictionary initialization arguments for the layout database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow dictionary input to BIDSLayout(derivatives=<>)

1 participant