Skip to content

Commit 3dc803c

Browse files
committed
address comments
1 parent 50f8d81 commit 3dc803c

File tree

2 files changed

+11
-34
lines changed

2 files changed

+11
-34
lines changed

nipype/interfaces/afni/preprocess.py

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from ...utils.filemanip import (load_json, save_json, split_filename,
1414
fname_presuffix)
1515
from ..base import (CommandLineInputSpec, CommandLine, TraitedSpec, traits,
16-
isdefined, File, InputMultiPath, Undefined, Str,
16+
isdefined, File, InputMultiPath, Undefined, Str,
1717
InputMultiObject)
1818

1919
from .base import (AFNICommandBase, AFNICommand, AFNICommandInputSpec,
@@ -2563,7 +2563,7 @@ class TProject(AFNICommand):
25632563
_cmd = '3dTproject'
25642564
input_spec = TProjectInputSpec
25652565
output_spec = AFNICommandOutputSpec
2566-
2566+
25672567

25682568
class TShiftInputSpec(AFNICommandInputSpec):
25692569
in_file = File(
@@ -2791,12 +2791,12 @@ class WarpInputSpec(AFNICommandInputSpec):
27912791
verbose = traits.Bool(
27922792
desc='Print out some information along the way.', argstr='-verb')
27932793
save_warp = traits.Bool(
2794-
False, usedefault=True, desc='save warp as .mat file')
2794+
desc='save warp as .mat file', requires=['verbose'])
27952795

27962796

27972797
class WarpOutputSpec(TraitedSpec):
27982798
out_file = File(desc='Warped file.', exists=True)
2799-
warp_file = File(desc='warp transfrom .mat file')
2799+
warp_file = File(desc='warp transform .mat file')
28002800

28012801

28022802
class Warp(AFNICommand):
@@ -2835,39 +2835,16 @@ def _run_interface(self, runtime):
28352835

28362836
if self.inputs.save_warp:
28372837
import numpy as np
2838-
if not self.inputs.out_file:
2839-
warp_file = fname_presuffix(self.inputs.in_file,
2840-
suffix='_warp_transform.mat',
2841-
use_ext=False)
2842-
else:
2843-
warp_file = fname_presuffix(self.inputs.out_file,
2844-
suffix='_transform.mat',
2845-
use_ext=False)
2838+
warp_file = self._list_outputs()['warp_file']
28462839
np.savetxt(warp_file, [runtime.stdout], fmt=str('%s'))
28472840
return runtime
28482841

28492842
def _list_outputs(self):
2850-
outputs = self.output_spec().get()
2851-
if not self.inputs.out_file:
2852-
fname, ext = os.path.splitext(self.inputs.in_file)
2853-
if '.gz' in ext:
2854-
_, ext2 = os.path.splitext(fname)
2855-
ext = ext2 + ext
2856-
out_file = self._gen_fname(self.inputs.in_file, suffix='_warp',
2857-
ext=ext)
2858-
outputs['out_file'] = os.path.abspath(out_file)
2859-
if self.inputs.save_warp:
2860-
warp_file = fname_presuffix(self.inputs.in_file,
2861-
suffix='_warp_transform.mat',
2862-
use_ext=False)
2863-
outputs['warp_file'] = os.path.abspath(warp_file)
2864-
else:
2865-
outputs['out_file'] = os.path.abspath(self.inputs.out_file)
2866-
if self.inputs.save_warp:
2867-
warp_file = fname_presuffix(self.inputs.out_file,
2868-
suffix='_transform.mat',
2869-
use_ext=False)
2870-
outputs['warp_file'] = os.path.abspath(warp_file)
2843+
outputs = super(Warp, self)._list_outputs()
2844+
if self.inputs.save_warp:
2845+
outputs['warp_file'] = fname_presuffix(outputs['out_file'],
2846+
suffix='_transform.mat',
2847+
use_ext=False)
28712848

28722849
return outputs
28732850

nipype/interfaces/afni/tests/test_auto_Warp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_Warp_inputs():
3434
name_template='%s_warp',
3535
),
3636
outputtype=dict(),
37-
save_warp=dict(usedefault=True, ),
37+
save_warp=dict(requires=['verbose'], ),
3838
tta2mni=dict(argstr='-tta2mni', ),
3939
verbose=dict(argstr='-verb', ),
4040
zpad=dict(argstr='-zpad %d', ),

0 commit comments

Comments
 (0)