From bdef3a33d17614c5afaec4db28c5c1e1875e1620 Mon Sep 17 00:00:00 2001 From: AKSoo Date: Thu, 19 Sep 2019 13:22:17 +0900 Subject: [PATCH 1/2] SelectFiles docstring corrected --- nipype/interfaces/io.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/nipype/interfaces/io.py b/nipype/interfaces/io.py index c409d4e78a..f3b2f7e267 100644 --- a/nipype/interfaces/io.py +++ b/nipype/interfaces/io.py @@ -1296,13 +1296,13 @@ 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 -------- @@ -1310,18 +1310,22 @@ class SelectFiles(IOBase): >>> 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': , 'epi': } - 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. """ input_spec = SelectFilesInputSpec From 2549ec11bcc84bbe08321e1595f48155f186aab0 Mon Sep 17 00:00:00 2001 From: Sin Kim Date: Mon, 30 Dec 2019 14:45:07 +0900 Subject: [PATCH 2/2] Update nipype/interfaces/io.py Co-Authored-By: Oscar Esteban --- nipype/interfaces/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/io.py b/nipype/interfaces/io.py index f3b2f7e267..b7ada6d819 100644 --- a/nipype/interfaces/io.py +++ b/nipype/interfaces/io.py @@ -1299,7 +1299,7 @@ class SelectFiles(IOBase): 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 (*, ?) and character ranges ([...]). + 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.