-
Notifications
You must be signed in to change notification settings - Fork 532
[DOC] Update SelectFiles docstring to match actual behavior #3041
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1296,32 +1296,36 @@ class SelectFilesInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): | |
class SelectFiles(IOBase): | ||
"""Flexibly collect data from disk to feed into workflows. | ||
|
||
This interface uses the {}-based string formatting syntax to plug | ||
This interface uses Python's {}-based string formatting syntax to plug | ||
values (possibly known only at workflow execution time) into string | ||
templates and collect files from persistant storage. These templates | ||
can also be combined with glob wildcards. The field names in the | ||
formatting template (i.e. the terms in braces) will become inputs | ||
fields on the interface, and the keys in the templates dictionary | ||
will form the output fields. | ||
templates and collect files from persistant storage. These templates can | ||
also be combined with glob wildcards (*, ?) and character ranges ([...]). | ||
The field names in the formatting template (i.e. the terms in braces) will | ||
become inputs fields on the interface, and the keys in the templates | ||
dictionary will form the output fields. | ||
|
||
Examples | ||
-------- | ||
|
||
>>> import pprint | ||
>>> from nipype import SelectFiles, Node | ||
>>> templates={"T1": "{subject_id}/struct/T1.nii", | ||
... "epi": "{subject_id}/func/f[0, 1].nii"} | ||
... "epi": "{subject_id}/func/f[0,1].nii"} | ||
>>> dg = Node(SelectFiles(templates), "selectfiles") | ||
>>> dg.inputs.subject_id = "subj1" | ||
>>> pprint.pprint(dg.outputs.get()) # doctest: | ||
{'T1': <undefined>, 'epi': <undefined>} | ||
|
||
The same thing with dynamic grabbing of specific files: | ||
Note that SelectFiles does not support lists as inputs for the dynamic | ||
fields. Attempts to do so may lead to unexpected results because brackets | ||
also express glob character ranges. For example, | ||
|
||
>>> templates["epi"] = "{subject_id}/func/f{run!s}.nii" | ||
>>> templates["epi"] = "{subject_id}/func/f{run}.nii" | ||
>>> dg = Node(SelectFiles(templates), "selectfiles") | ||
>>> dg.inputs.subject_id = "subj1" | ||
>>> dg.inputs.run = [2, 4] | ||
>>> dg.inputs.run = [10, 11] | ||
|
||
would match f0.nii or f1.nii, not f10.nii or f11.nii. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh. I think I misunderstood #2712. I interpreted it as you saying that
would produce the result you describe. For the code above, I would have expected to match Possibly @mwaskom can clarify whether this was the intended behavior, though it's been a long time since #623. |
||
|
||
""" | ||
input_spec = SelectFilesInputSpec | ||
|
Uh oh!
There was an error while loading. Please reload this page.