@@ -1350,31 +1350,35 @@ class SelectFiles(IOBase):
1350
1350
"""
1351
1351
Flexibly collect data from disk to feed into workflows.
1352
1352
1353
- This interface uses the {}-based string formatting syntax to plug
1353
+ This interface uses Python's {}-based string formatting syntax to plug
1354
1354
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.
1360
1360
1361
1361
Examples
1362
1362
--------
1363
1363
>>> import pprint
1364
1364
>>> from nipype import SelectFiles, Node
1365
1365
>>> 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"}
1367
1367
>>> dg = Node(SelectFiles(templates), "selectfiles")
1368
1368
>>> dg.inputs.subject_id = "subj1"
1369
1369
>>> pprint.pprint(dg.outputs.get()) # doctest:
1370
1370
{'T1': <undefined>, 'epi': <undefined>}
1371
1371
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,
1373
1375
1374
- >>> templates["epi"] = "{subject_id}/func/f{run!s }.nii"
1376
+ >>> templates["epi"] = "{subject_id}/func/f{run}.nii"
1375
1377
>>> dg = Node(SelectFiles(templates), "selectfiles")
1376
1378
>>> 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.
1378
1382
1379
1383
"""
1380
1384
0 commit comments