Skip to content

Commit 628bdd5

Browse files
authored
Merge pull request #1915 from anbai106/anbai
bug for datagrabber
2 parents 7f6f35f + b8eda2d commit 628bdd5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

nipype/interfaces/io.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,10 @@ class DataGrabberInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec):
10441044
True,
10451045
usedefault=True,
10461046
desc='Generate exception if list is empty for a given field')
1047+
drop_blank_outputs = traits.Bool(
1048+
False, usedefault=True,
1049+
desc="Remove ``None`` entries from output lists"
1050+
)
10471051
sort_filelist = traits.Bool(
10481052
mandatory=True, desc='Sort the filelist that matches the template')
10491053
template = Str(
@@ -1242,8 +1246,11 @@ def _list_outputs(self):
12421246
if self.inputs.sort_filelist:
12431247
outfiles = human_order_sorted(outfiles)
12441248
outputs[key].append(list_to_filename(outfiles))
1245-
if any([val is None for val in outputs[key]]):
1246-
outputs[key] = []
1249+
if self.inputs.drop_blank_outputs:
1250+
outputs[key] = [x for x in outputs[key] if x is not None]
1251+
else:
1252+
if any([val is None for val in outputs[key]]):
1253+
outputs[key] = []
12471254
if len(outputs[key]) == 0:
12481255
outputs[key] = None
12491256
elif len(outputs[key]) == 1:

0 commit comments

Comments
 (0)