Skip to content

Commit fa6dfbb

Browse files
authored
Merge pull request #3041 from AKSoo/docs
[DOC] Update SelectFiles docstring to match actual behavior
2 parents a018603 + 2549ec1 commit fa6dfbb

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

nipype/interfaces/io.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,31 +1350,35 @@ class SelectFiles(IOBase):
13501350
"""
13511351
Flexibly collect data from disk to feed into workflows.
13521352
1353-
This interface uses the {}-based string formatting syntax to plug
1353+
This interface uses Python's {}-based string formatting syntax to plug
13541354
values (possibly known only at workflow execution time) into string
1355-
templates and collect files from persistant storage. These templates
1356-
can also be combined with glob wildcards. The field names in the
1357-
formatting template (i.e. the terms in braces) will become inputs
1358-
fields on the interface, and the keys in the templates dictionary
1359-
will form the output fields.
1355+
templates and collect files from persistant storage. These templates can
1356+
also be combined with glob wildcards (``*``, ``?``) and character ranges (``[...]``).
1357+
The field names in the formatting template (i.e. the terms in braces) will
1358+
become inputs fields on the interface, and the keys in the templates
1359+
dictionary will form the output fields.
13601360
13611361
Examples
13621362
--------
13631363
>>> import pprint
13641364
>>> from nipype import SelectFiles, Node
13651365
>>> templates={"T1": "{subject_id}/struct/T1.nii",
1366-
... "epi": "{subject_id}/func/f[0, 1].nii"}
1366+
... "epi": "{subject_id}/func/f[0,1].nii"}
13671367
>>> dg = Node(SelectFiles(templates), "selectfiles")
13681368
>>> dg.inputs.subject_id = "subj1"
13691369
>>> pprint.pprint(dg.outputs.get()) # doctest:
13701370
{'T1': <undefined>, 'epi': <undefined>}
13711371
1372-
The same thing with dynamic grabbing of specific files:
1372+
Note that SelectFiles does not support lists as inputs for the dynamic
1373+
fields. Attempts to do so may lead to unexpected results because brackets
1374+
also express glob character ranges. For example,
13731375
1374-
>>> templates["epi"] = "{subject_id}/func/f{run!s}.nii"
1376+
>>> templates["epi"] = "{subject_id}/func/f{run}.nii"
13751377
>>> dg = Node(SelectFiles(templates), "selectfiles")
13761378
>>> dg.inputs.subject_id = "subj1"
1377-
>>> dg.inputs.run = [2, 4]
1379+
>>> dg.inputs.run = [10, 11]
1380+
1381+
would match f0.nii or f1.nii, not f10.nii or f11.nii.
13781382
13791383
"""
13801384

0 commit comments

Comments
 (0)