Created
February 14, 2011 23:03
-
-
Save satra/826775 to your computer and use it in GitHub Desktop.
itkNaryMaximumImageFilter definition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from nipype.interfaces.base import (CommandLine, CommandLineInputSpec, | |
TraitedSpec, File, | |
InputMultiPath, traits) | |
from nipype.utils.misc import isdefined | |
from nipype.utils.filemanip import fname_presuffix | |
class ITKNaryMaximumImageFilterInputSpec(CommandLineInputSpec): | |
tcl_script = File(exists=True, argstr = '-b %s', position = 1, | |
desc='Full path to itkNary tcl script', mandatory = True) | |
in_files = InputMultiPath(File(exists=True), argstr='%s...', sep=',', | |
desc = "List of images", mandatory = True, position = 2) | |
file_mode = traits.Str(argstr='%s', desc = "fileMode", exists = True, | |
mandatory = True, position = -2) | |
out_file = File(argstr = '%s', desc = "output filename", | |
position = -1, genfile=True) | |
class ITKNaryMaximumImageFilterOutputSpec(TraitedSpec): | |
out_file = File(exists = True, desc = "outFilename") | |
class ITKNaryMaximumImageFilter(CommandLine): | |
input_spec = ITKNaryMaximumImageFilterInputSpec | |
output_spec = ITKNaryMaximumImageFilterOutputSpec | |
_cmd = "brains3" | |
def _gen_outfilename(self): | |
outfile = self.inputs.out_file | |
if not isdefined(outfile): | |
outfile = fname_presuffix(self.inputs.in_files[0],suffix='_out') | |
return outfile | |
def _gen_filename(self, name): | |
if name == 'out_file': | |
return self._gen_outfilename() | |
return None | |
def _list_outputs(self): | |
outputs = self.output_spec().get() | |
outputs['out_file'] = self._gen_outfilename() | |
return outputs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [35]: filter = itktest.ITKNaryMaximumImageFilter() | |
In [36]: filter.inputs.tcl_script = os.path.abspath('script.tcl') | |
In [37]: filter.inputs.in_files = ['img1.nii','img2.nii', 'img3.nii'] | |
In [38]: filter.inputs.file_mode = 'x' | |
In [39]: filter.cmdline | |
Out[39]: 'brains3 -b /software/temp/nipype-tutorial/temp/script.tcl img1.nii,img2.nii,img3.nii x img1_out.nii' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment