Skip to content

Commit 1d22038

Browse files
committed
make ants.OutlierCount use the terminal_output. Close #1406
1 parent 19a356b commit 1d22038

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

nipype/interfaces/afni/preprocess.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,23 +1718,14 @@ class OutlierCountInputSpec(CommandLineInputSpec):
17181718
out_file = File(
17191719
name_template='%s_outliers',
17201720
name_source=['in_file'],
1721-
argstr='> %s',
17221721
keep_extension=False,
1723-
position=-1,
17241722
desc='capture standard output')
17251723

17261724

17271725
class OutlierCountOutputSpec(TraitedSpec):
1728-
out_outliers = File(
1729-
exists=True,
1730-
desc='output image file name')
1731-
out_file = File(
1732-
name_template='%s_tqual',
1733-
name_source=['in_file'],
1734-
argstr='> %s',
1735-
keep_extension=False,
1736-
position=-1,
1737-
desc='capture standard output')
1726+
out_outliers = File(exists=True,
1727+
desc='output image file name')
1728+
out_file = File(desc='capture standard output')
17381729

17391730

17401731
class OutlierCount(CommandLine):
@@ -1759,20 +1750,34 @@ class OutlierCount(CommandLine):
17591750
_cmd = '3dToutcount'
17601751
input_spec = OutlierCountInputSpec
17611752
output_spec = OutlierCountOutputSpec
1753+
_terminal_output = 'file_split'
17621754

17631755
def _parse_inputs(self, skip=None):
17641756
if skip is None:
17651757
skip = []
17661758

1759+
# This is not strictly an input, but needs be
1760+
# set before run() is called.
1761+
if self.terminal_output == 'none':
1762+
self.terminal_output = 'file_split'
1763+
17671764
if not self.inputs.save_outliers:
17681765
skip += ['outliers_file']
17691766
return super(OutlierCount, self)._parse_inputs(skip)
17701767

1768+
def _run_interface(self, runtime):
1769+
runtime = super(OutlierCount, self)._run_interface(runtime)
1770+
1771+
# Read from runtime.stdout or runtime.merged
1772+
with open(op.abspath(self.inputs.out_file), 'w') as outfh:
1773+
outfh.write(runtime.stdout or runtime.merged)
1774+
return runtime
1775+
17711776
def _list_outputs(self):
17721777
outputs = self.output_spec().get()
1778+
outputs['out_file'] = op.abspath(self.inputs.out_file)
17731779
if self.inputs.save_outliers:
17741780
outputs['out_outliers'] = op.abspath(self.inputs.outliers_file)
1775-
outputs['out_file'] = op.abspath(self.inputs.out_file)
17761781
return outputs
17771782

17781783

nipype/interfaces/afni/tests/test_auto_OutlierCount.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ def test_OutlierCount_inputs():
3636
mask=dict(argstr='-mask %s',
3737
xor=['autoclip', 'automask'],
3838
),
39-
out_file=dict(argstr='> %s',
40-
keep_extension=False,
39+
out_file=dict(keep_extension=False,
4140
name_source=['in_file'],
4241
name_template='%s_outliers',
43-
position=-1,
4442
),
4543
outliers_file=dict(argstr='-save %s',
4644
keep_extension=True,
@@ -66,12 +64,7 @@ def test_OutlierCount_inputs():
6664

6765

6866
def test_OutlierCount_outputs():
69-
output_map = dict(out_file=dict(argstr='> %s',
70-
keep_extension=False,
71-
name_source=['in_file'],
72-
name_template='%s_tqual',
73-
position=-1,
74-
),
67+
output_map = dict(out_file=dict(),
7568
out_outliers=dict(),
7669
)
7770
outputs = OutlierCount.output_spec()

0 commit comments

Comments
 (0)