fslchfiletype

125 views
Skip to first unread message

Yasin Yazıcı

unread,
Aug 26, 2014, 11:08:50 PM8/26/14
to nipy...@googlegroups.com
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

Satrajit Ghosh

unread,
Aug 26, 2014, 11:27:59 PM8/26/14
to nipy-user
hi yasin,

add `copyfile=False` to the metadata for in_file, this will create a symbolic link to the file in the node's working directory.

depending on which filetypes you are converting between, you could also write a nibabel function.

cheers,

satra


--

---
You received this message because you are subscribed to the Google Groups "NiPy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nipy-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Satrajit Ghosh

unread,
Aug 27, 2014, 8:09:47 PM8/27/14
to nipy-user
hi yasin,

i just checked this with the current development version of nipype and it works fine. could you please test it with the current version?

cheers,

satra

Yasin Yazıcı

unread,
Sep 8, 2014, 8:06:47 AM9/8/14
to nipy...@googlegroups.com
Hi Satra,
Yes, it works fine if out_file is not specified, however when it specified, the output is saved the current folder (pwd) of python. I have re-installed nipype recently,so I don't think its about the version. For now, I'm using output_datatype of some of the fsl functions to convert between ANALYZE and NIFTI.

Kind Regards
Yasin
 

Satrajit Ghosh

unread,
Sep 8, 2014, 8:20:41 AM9/8/14
to nipy-user
replace this line:

        if not isdefined(outputs['out_file']):
            outputs
['out_file'] = self._gen_fname(self.inputs.in_file,ext =ext,change_ext=True)
with:

        if not isdefined(outputs['out_file']):
            outputs
['out_file'] = self._gen_fname(self.inputs.in_file,ext =ext,change_ext=True)
        else:
            outputs['out_file'] = os.path.abspath(outputs['out_file'])

cheers,

satra

--
Reply all
Reply to author
Forward
0 new messages