Skip to content

Commit 748f8c7

Browse files
committed
Adding example of string converter in SelectFiles
1 parent ef0aba7 commit 748f8c7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

nipype/interfaces/io.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,13 @@ class SelectFiles(IOBase):
588588
>>> dg.outputs.get()
589589
{'T1': <undefined>, 'epi': <undefined>}
590590
591+
The same thing with dynamic grabbing of specific files:
592+
593+
>>> templates["epi"] = "{subject_id}/func/f{run!s}.nii"
594+
>>> dg = Node(SelectFiles(templates), "selectfiles")
595+
>>> dg.inputs.subject_id = "subj1"
596+
>>> dg.inputs.run = [2, 4]
597+
591598
"""
592599
input_spec = SelectFilesInputSpec
593600
output_spec = DynamicTraitedSpec

nipype/interfaces/tests/test_io.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ def test_selectfiles():
4242
"interfaces/spm/preprocess.py")
4343
yield assert_equal, res.outputs.preprocess, [wanted]
4444

45+
templates = {"converter": "interfaces/dcm{to!s}nii.py"}
46+
dg = nio.SelectFiles(templates, base_directory=base_dir)
47+
dg.inputs.to = 2
48+
res = dg.run()
49+
wanted = op.join(base_dir, "interfaces/dcm2nii.py")
50+
yield assert_equal, res.outputs.converter, wanted
51+
4552

4653
def test_datasink():
4754
ds = nio.DataSink()

0 commit comments

Comments
 (0)