@@ -1296,32 +1296,36 @@ class SelectFilesInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec):
1296
1296
class SelectFiles (IOBase ):
1297
1297
"""Flexibly collect data from disk to feed into workflows.
1298
1298
1299
- This interface uses the {}-based string formatting syntax to plug
1299
+ This interface uses Python's {}-based string formatting syntax to plug
1300
1300
values (possibly known only at workflow execution time) into string
1301
- templates and collect files from persistant storage. These templates
1302
- can also be combined with glob wildcards. The field names in the
1303
- formatting template (i.e. the terms in braces) will become inputs
1304
- fields on the interface, and the keys in the templates dictionary
1305
- will form the output fields.
1301
+ templates and collect files from persistant storage. These templates can
1302
+ also be combined with glob wildcards (*, ?) and character ranges ([...]).
1303
+ The field names in the formatting template (i.e. the terms in braces) will
1304
+ become inputs fields on the interface, and the keys in the templates
1305
+ dictionary will form the output fields.
1306
1306
1307
1307
Examples
1308
1308
--------
1309
1309
1310
1310
>>> import pprint
1311
1311
>>> from nipype import SelectFiles, Node
1312
1312
>>> templates={"T1": "{subject_id}/struct/T1.nii",
1313
- ... "epi": "{subject_id}/func/f[0, 1].nii"}
1313
+ ... "epi": "{subject_id}/func/f[0,1].nii"}
1314
1314
>>> dg = Node(SelectFiles(templates), "selectfiles")
1315
1315
>>> dg.inputs.subject_id = "subj1"
1316
1316
>>> pprint.pprint(dg.outputs.get()) # doctest:
1317
1317
{'T1': <undefined>, 'epi': <undefined>}
1318
1318
1319
- The same thing with dynamic grabbing of specific files:
1319
+ Note that SelectFiles does not support lists as inputs for the dynamic
1320
+ fields. Attempts to do so may lead to unexpected results because brackets
1321
+ also express glob character ranges. For example,
1320
1322
1321
- >>> templates["epi"] = "{subject_id}/func/f{run!s }.nii"
1323
+ >>> templates["epi"] = "{subject_id}/func/f{run}.nii"
1322
1324
>>> dg = Node(SelectFiles(templates), "selectfiles")
1323
1325
>>> dg.inputs.subject_id = "subj1"
1324
- >>> dg.inputs.run = [2, 4]
1326
+ >>> dg.inputs.run = [10, 11]
1327
+
1328
+ would match f0.nii or f1.nii, not f10.nii or f11.nii.
1325
1329
1326
1330
"""
1327
1331
input_spec = SelectFilesInputSpec
0 commit comments