Hi,
The code below is written for fslchfiletype function. It is very similar to other fsl commands in nipype folder. It works fine when out_file is specified. However, if out_file is not specified it raises an error like below
FileNotFoundError: File/Directory 'a directory in here' not found for FslChFileType output 'out_file'.
Interface FslChFileType failed to run.
The reason is if output is not specified fslchfiletype set output directory to current directory not to input`s (in_file) directory. So if the pipeline script is in a specific directory and in_file is not in the same directory (generally in tmp file), nipype can not find the output because it is searching the input directory.
class FslChFileTypeInputSpec(FSLCommandInputSpec):
file_type = traits.Str(desc='file type', argstr='%s', position=0, mandatory=True)
in_file = File(desc="input file", exists=True, argstr="%s", position=1, mandatory=True)
out_file = File(genfile=True, desc="output file", argstr="%s", hash_files=False)
class FslChFileTypeOutputSpec(TraitedSpec):
out_file = File(desc = "out file", exists = True)
class FslChFileType(FSLCommand):
input_spec = FslChFileTypeInputSpec
output_spec = FslChFileTypeOutputSpec
cmd = 'fslchfiletype'
def _list_outputs(self):
outputs = self._outputs().get()
ext = Info.output_type_to_ext(self.inputs.file_type)
outputs['out_file'] = self.inputs.out_file
if not isdefined(outputs['out_file']):
outputs['out_file'] = self._gen_fname(self.inputs.in_file,ext = ext,change_ext=True)
return outputs
def _gen_filename(self, name):
if name == "out_file":
return self._list_outputs()["out_file"]
return None
How can I solve this problem and is there any command in nipype corresponding to fslchfiletype?
Regards