Skip to content

Commit 0ac706f

Browse files
committed
further cleanup
1 parent 79e3b46 commit 0ac706f

File tree

2 files changed

+64
-105
lines changed

2 files changed

+64
-105
lines changed

nipype/interfaces/afni/base.py

Lines changed: 14 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import os
77
import warnings
88

9-
from ...utils.filemanip import fname_presuffix, split_filename
9+
from ...utils.filemanip import split_filename
1010
from ..base import (
1111
CommandLine, traits, CommandLineInputSpec, isdefined, File, TraitedSpec)
1212

@@ -98,25 +98,26 @@ def standard_image(img_name):
9898
return os.path.join(basedir, img_name)
9999

100100

101-
class AFNIBaseCommandInputSpec(CommandLineInputSpec):
101+
class AFNICommandInputSpec(CommandLineInputSpec):
102102
outputtype = traits.Enum('AFNI', Info.ftypes.keys(),
103103
desc='AFNI output filetype')
104+
out_file = File(name_template="%s_afni", desc='output image file name',
105+
argstr='-prefix %s',
106+
name_source=["in_file"])
107+
108+
class AFNICommandOutputSpec(TraitedSpec):
109+
out_file = File(desc='output file',
110+
exists=True)
104111

105-
class AFNITraitedSpec(AFNIBaseCommandInputSpec):
106-
pass
107-
108-
109-
class AFNIBaseCommand(CommandLine):
110-
"""General support for AFNI commands. Every AFNI command accepts 'outputtype' input. For example:
111-
afni.Threedsetup(outputtype='NIFTI_GZ')
112-
"""
113112

114-
input_spec = AFNIBaseCommandInputSpec
113+
class AFNICommand(CommandLine):
114+
115+
input_spec = AFNICommandInputSpec
115116
_outputtype = None
116117

117118

118119
def __init__(self, **inputs):
119-
super(AFNIBaseCommand, self).__init__(**inputs)
120+
super(CommandLine, self).__init__(**inputs)
120121
self.inputs.on_trait_change(self._output_update, 'outputtype')
121122

122123
if self._outputtype is None:
@@ -148,58 +149,8 @@ def set_default_output_type(cls, outputtype):
148149
cls._outputtype = outputtype
149150
else:
150151
raise AttributeError('Invalid AFNI outputtype: %s' % outputtype)
152+
151153

152-
# def _gen_fname(self, basename, cwd=None, suffix='_afni', change_ext=True, prefix=''):
153-
# """Generate a filename based on the given parameters.
154-
#
155-
# The filename will take the form: cwd/basename<suffix><ext>.
156-
# If change_ext is True, it will use the extensions specified in
157-
# <instance>inputs.outputtype.
158-
#
159-
# Parameters
160-
# ----------
161-
# basename : str
162-
# Filename to base the new filename on.
163-
# cwd : str
164-
# Path to prefix to the new filename. (default is os.getcwd())
165-
# suffix : str
166-
# Suffix to add to the `basename`. (default is '_fsl')
167-
# change_ext : bool
168-
# Flag to change the filename extension to the FSL output type.
169-
# (default True)
170-
#
171-
# Returns
172-
# -------
173-
# fname : str
174-
# New filename based on given parameters.
175-
#
176-
# """
177-
#
178-
# if basename == '':
179-
# msg = 'Unable to generate filename for command %s. ' % self.cmd
180-
# msg += 'basename is not set!'
181-
# raise ValueError(msg)
182-
# if cwd is None:
183-
# cwd = os.getcwd()
184-
# ext = Info.outputtype_to_ext(self.inputs.outputtype)
185-
# if change_ext:
186-
# if suffix:
187-
# suffix = ''.join((suffix, ext))
188-
# else:
189-
# suffix = ext
190-
# fname = fname_presuffix(basename, suffix=suffix,
191-
# use_ext=False, newpath=cwd, prefix=prefix)
192-
# return fname
193-
194-
195-
class AFNICommandInputSpec(AFNIBaseCommandInputSpec):
196-
out_file = File(name_template="%s_afni", desc='output image file name',
197-
argstr='-prefix %s',
198-
name_source=["in_file"])
199-
200-
201-
class AFNICommand(AFNIBaseCommand):
202-
input_spec = AFNICommandInputSpec
203154

204155
def _overload_extension(self, value):
205156
path, base, _ = split_filename(value)
@@ -216,7 +167,3 @@ def _list_outputs(self):
216167
if ext == "":
217168
outputs[name] = outputs[name] + "+orig.BRIK"
218169
return outputs
219-
220-
class AFNICommandOutputSpec(TraitedSpec):
221-
out_file = File(desc='output file',
222-
exists=True)

0 commit comments

Comments
 (0)