Skip to content

Commit 239cf8a

Browse files
committed
do not include parsing in interfaces
1 parent d23709c commit 239cf8a

File tree

3 files changed

+20
-39
lines changed

3 files changed

+20
-39
lines changed

nipype/interfaces/afni/preprocess.py

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717
from .base import (AFNICommandBase, AFNICommand, AFNICommandInputSpec, AFNICommandOutputSpec,
1818
Info, no_afni)
19-
from ..base import CommandLineInputSpec
20-
from ..base import (Directory, TraitedSpec,
19+
from ..base import (CommandLineInputSpec, CommandLine, Directory, TraitedSpec,
2120
traits, isdefined, File, InputMultiPath, Undefined)
2221
from ...external.six import string_types
2322
from ...utils.filemanip import (load_json, save_json, split_filename)
@@ -2374,7 +2373,7 @@ def _list_outputs(self):
23742373
return outputs
23752374

23762375

2377-
class OutlierCountInputSpec(AFNICommandInputSpec):
2376+
class OutlierCountInputSpec(CommandLineInputSpec):
23782377
in_file = File(argstr='%s', mandatory=True, exists=True, position=-2, desc='input dataset')
23792378
mask = File(exists=True, argstr='-mask %s', xor=['autoclip', 'automask'],
23802379
desc='only count voxels within the given mask')
@@ -2405,13 +2404,14 @@ class OutlierCountInputSpec(AFNICommandInputSpec):
24052404
keep_extension=False, position=-1, desc='capture standard output')
24062405

24072406

2408-
class OutlierCountOutputSpec(AFNICommandOutputSpec):
2407+
class OutlierCountOutputSpec(TraitedSpec):
24092408
outliers_file = File(exists=True, desc='output image file name')
2410-
outliers = traits.List(traits.Float,
2411-
desc='parse standard output to get the count of outliers')
2409+
out_file = File(
2410+
name_template='%s_tqual', name_source=['in_file'], argstr='> %s',
2411+
keep_extension=False, position=-1, desc='capture standard output')
24122412

24132413

2414-
class OutlierCount(AFNICommand):
2414+
class OutlierCount(CommandLine):
24152415
"""Create a 3D dataset from 2D image files using AFNI to3d command
24162416
24172417
For complete details, see the `to3d Documentation
@@ -2441,21 +2441,8 @@ def _parse_inputs(self, skip=None):
24412441
skip += ['outliers_file']
24422442
return super(OutlierCount, self)._parse_inputs(skip)
24432443

2444-
def _list_outputs(self):
2445-
outputs = self.output_spec().get()
2446-
outputs['outliers_file'] = (Undefined if not self.inputs.save_outliers
2447-
else self.inputs.outliers_file)
2448-
24492444

2450-
with open(self.inputs.out_file, 'r') as fout:
2451-
lines = fout.readlines()
2452-
# remove general information and warnings
2453-
outputs['outliers'] = [float(l)
2454-
for l in lines if re.match("[0-9]+$", l.strip())]
2455-
return outputs
2456-
2457-
2458-
class QualityIndexInputSpec(AFNICommandInputSpec):
2445+
class QualityIndexInputSpec(CommandLineInputSpec):
24592446
in_file = File(argstr='%s', mandatory=True, exists=True, position=-2, desc='input dataset')
24602447
mask = File(exists=True, argstr='-mask %s', xor=['autoclip', 'automask'],
24612448
desc='compute correlation only across masked voxels')
@@ -2481,11 +2468,11 @@ class QualityIndexInputSpec(AFNICommandInputSpec):
24812468
keep_extension=False, position=-1, desc='capture standard output')
24822469

24832470

2484-
class QualityIndexOutputSpec(AFNICommandOutputSpec):
2485-
qi_value = traits.List(traits.Float, desc='output quality index')
2471+
class QualityIndexOutputSpec(TraitedSpec):
2472+
out_file = File(desc='file containing the caputured standard output')
24862473

24872474

2488-
class QualityIndex(AFNICommand):
2475+
class QualityIndex(CommandLine):
24892476
"""Create a 3D dataset from 2D image files using AFNI to3d command
24902477
24912478
For complete details, see the `to3d Documentation
@@ -2506,13 +2493,3 @@ class QualityIndex(AFNICommand):
25062493
_cmd = '3dTqual'
25072494
input_spec = QualityIndexInputSpec
25082495
output_spec = QualityIndexOutputSpec
2509-
2510-
def _list_outputs(self):
2511-
outputs = self.output_spec().get()
2512-
with open(self.inputs.out_file, 'r') as fout:
2513-
lines = fout.readlines()
2514-
# remove general information
2515-
lines = [l for l in lines if l[:2] != "++"]
2516-
# remove general information and warnings
2517-
outputs['qi_value'] = [float(l.strip()) for l in lines]
2518-
return outputs

nipype/interfaces/afni/tests/test_auto_OutlierCount.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def test_OutlierCount_inputs():
4747
name_source=['in_file'],
4848
name_template='%s_outliers',
4949
),
50-
outputtype=dict(),
5150
polort=dict(argstr='-polort %d',
5251
),
5352
qthr=dict(argstr='-qthr %.5f',
@@ -65,8 +64,12 @@ def test_OutlierCount_inputs():
6564

6665

6766
def test_OutlierCount_outputs():
68-
output_map = dict(out_file=dict(),
69-
outliers=dict(),
67+
output_map = dict(out_file=dict(argstr='> %s',
68+
keep_extension=False,
69+
name_source=['in_file'],
70+
name_template='%s_tqual',
71+
position=-1,
72+
),
7073
outliers_file=dict(),
7174
)
7275
outputs = OutlierCount.output_spec()

nipype/interfaces/afni/tests/test_auto_QualityIndex.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ def test_QualityIndex_inputs():
88
),
99
autoclip=dict(argstr='-autoclip',
1010
usedefault=True,
11+
xor=['mask'],
1112
),
1213
automask=dict(argstr='-automask',
1314
usedefault=True,
15+
xor=['mask'],
1416
),
1517
clip=dict(argstr='-clip %f',
1618
),
@@ -28,14 +30,14 @@ def test_QualityIndex_inputs():
2830
usedefault=True,
2931
),
3032
mask=dict(argstr='-mask %s',
33+
xor=['autoclip', 'automask'],
3134
),
3235
out_file=dict(argstr='> %s',
3336
keep_extension=False,
3437
name_source=['in_file'],
3538
name_template='%s_tqual',
3639
position=-1,
3740
),
38-
outputtype=dict(),
3941
quadrant=dict(argstr='-quadrant',
4042
usedefault=True,
4143
),
@@ -54,7 +56,6 @@ def test_QualityIndex_inputs():
5456

5557
def test_QualityIndex_outputs():
5658
output_map = dict(out_file=dict(),
57-
qi_value=dict(),
5859
)
5960
outputs = QualityIndex.output_spec()
6061

0 commit comments

Comments
 (0)