Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Support named derivative paths #3264

Merged
merged 13 commits into from
Mar 29, 2024
Prev Previous commit
Next Next commit
Update fmriprep/cli/parser.py
Co-authored-by: Chris Markiewicz <[email protected]>
tsalo and effigies authored Mar 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 7bbb0748ed5d2b2c9710ea5912e3702084bc3b5d
17 changes: 10 additions & 7 deletions fmriprep/cli/parser.py
Original file line number Diff line number Diff line change
@@ -63,14 +63,17 @@ def __call__(self, parser, namespace, values, option_string=None):
delattr(namespace, self.dest)

class ToDict(Action):
def __call__(self, parser, namespace, values, option_string=None):
d = {}
for i_kv, kv in enumerate(values):
if '=' not in kv:
k = f'deriv-{i_kv}'
v = kv
else:
k, v = kv.split('=')
for spec in values:
try:
name, loc = spec.split('=')
loc = Path(loc)
except ValueError:
loc = Path(spec)
name = loc.name

if name in d:
raise ValueError(f"Received duplicate derivative name: {name}")
d[k] = Path(v)
setattr(namespace, self.dest, d)

Loading