ENH: Allow dictionary input for BIDSLayout derivatives parameter to s…#1257
Open
anushkagupta200615-jpg wants to merge 1 commit into
Open
ENH: Allow dictionary input for BIDSLayout derivatives parameter to s…#1257anushkagupta200615-jpg wants to merge 1 commit into
anushkagupta200615-jpg wants to merge 1 commit into
Conversation
…upport custom pipeline names (fixes bids-standard#1155)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1155
Description
This PR introduces the ability to pass a dictionary to the
derivativesparameter inBIDSLayout(orlayout.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'ssource_pipelineproperty, allowing intuitive and clean queries vialayout.get(scope='my_clean_pipeline').Changes Made
_get_derivative_dirsinsrc/bids/layout/layout.pyto supportdictpaths, yielding the custom key instead of parsing the directory name.add_derivativesinsrc/bids/layout/layout.pyto preventlistifyfrom destroying dictionary structures, and overrode the spawnedBIDSLayout'ssource_pipelineproperty with the user's custom dictionary key._sanitize_init_argsinsrc/bids/layout/models.pyto properly serialize and sanitize dictionary initialization arguments for the layout database.