Skip to content

Commit 40859ca

Browse files
committed
name_source can be a list, make "infolder" a deprecated name
1 parent cdd5361 commit 40859ca

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

nipype/interfaces/afni/preprocess.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,23 @@
2424

2525
class To3DInputSpec(AFNICommandInputSpec):
2626
out_file = File("%s", desc='output image file name',
27-
argstr='-prefix %s', name_source="infolder", usedefault=True)
28-
27+
argstr='-prefix %s', name_source=["in_folder", "infolder"], usedefault=True)
28+
in_xor = ["infolder", "in_folder"]
29+
in_folder = Directory(desc='folder with DICOM images to convert',
30+
argstr='%s/*.dcm',
31+
position=-1,
32+
mandatory=True,
33+
exists=True,
34+
xor=in_xor)
35+
2936
infolder = Directory(desc='folder with DICOM images to convert',
3037
argstr='%s/*.dcm',
3138
position=-1,
3239
mandatory=True,
33-
exists=True)
40+
exists=True,
41+
deprecated=0.8,
42+
new_name="in_folder",
43+
xor=in_xor)
3444

3545
filetype = traits.Enum('spgr', 'fse', 'epan', 'anat', 'ct', 'spct',
3646
'pet', 'mra', 'bmap', 'diff',

nipype/interfaces/base.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,17 @@ def _gen_filename(self, name):
12051205
value = getattr(self.inputs, name)
12061206
if isdefined(value):
12071207
if "%s" in value:
1208-
_, base, _ = split_filename(getattr(self.inputs, trait_spec.name_source))
1208+
if isinstance(trait_spec.name_source, list):
1209+
for ns in trait_spec.name_source:
1210+
if isdefined(getattr(self.inputs, ns)):
1211+
name_source = ns
1212+
break
1213+
else:
1214+
name_source = trait_spec.name_source
1215+
if name_source.endswith(os.path.sep):
1216+
name_source = name_source[:-len(os.path.sep)]
1217+
_, base, _ = split_filename(getattr(self.inputs, name_source))
1218+
12091219
retval = value%base
12101220
else:
12111221
retval = value

0 commit comments

Comments
 (0)