Skip to content

[ENH]: Add AFNI 3dDeconvolve/3dREMLfit interfaces #2095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 24, 2017
1 change: 1 addition & 0 deletions nipype/interfaces/afni/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
Eval, FWHMx,
MaskTool, Merge, Notes, Refit, Resample, TCat, TStat, To3D,
Unifize, ZCutUp, GCOR,)
from .model import (Deconvolve, Remlfit)
52 changes: 49 additions & 3 deletions nipype/interfaces/afni/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from sys import platform

from ... import logging
from ...utils.filemanip import split_filename
from ...utils.filemanip import split_filename, fname_presuffix

from ..base import (
CommandLine, traits, CommandLineInputSpec, isdefined, File, TraitedSpec)
from ...external.due import BibTeX
Expand Down Expand Up @@ -70,7 +71,7 @@ def version():
return tuple(v)

@classmethod
def outputtype_to_ext(cls, outputtype):
def output_type_to_ext(cls, outputtype):
"""Get the file extension for the given output type.

Parameters
Expand Down Expand Up @@ -217,7 +218,7 @@ def set_default_output_type(cls, outputtype):

def _overload_extension(self, value, name=None):
path, base, _ = split_filename(value)
return os.path.join(path, base + Info.outputtype_to_ext(self.inputs.outputtype))
return os.path.join(path, base + Info.output_type_to_ext(self.inputs.outputtype))

def _list_outputs(self):
outputs = super(AFNICommand, self)._list_outputs()
Expand All @@ -231,6 +232,51 @@ def _list_outputs(self):
outputs[name] = outputs[name] + "+orig.BRIK"
return outputs

def _gen_fname(self, basename, cwd=None, suffix=None, change_ext=True,
ext=None):
"""Generate a filename based on the given parameters.

The filename will take the form: cwd/basename<suffix><ext>.
If change_ext is True, it will use the extentions specified in
<instance>intputs.output_type.

Parameters
----------
basename : str
Filename to base the new filename on.
cwd : str
Path to prefix to the new filename. (default is os.getcwd())
suffix : str
Suffix to add to the `basename`. (defaults is '' )
change_ext : bool
Flag to change the filename extension to the FSL output type.
(default True)

Returns
-------
fname : str
New filename based on given parameters.

"""

if basename == '':
msg = 'Unable to generate filename for command %s. ' % self.cmd
msg += 'basename is not set!'
raise ValueError(msg)
if cwd is None:
cwd = os.getcwd()
if ext is None:
ext = Info.output_type_to_ext(self.inputs.outputtype)
if change_ext:
if suffix:
suffix = ''.join((suffix, ext))
else:
suffix = ext
if suffix is None:
suffix = ''
fname = fname_presuffix(basename, suffix=suffix,
use_ext=False, newpath=cwd)
return fname

def no_afni():
""" Checks if AFNI is available """
Expand Down
Loading