Hi Satra
I have also another question that is related with command line (at least I think so). The code below name fslhd.py which I wrapped. It calls the fslhd from fsl and print its output to 'info.txt' by using '>' operator.
from nipype.interfaces.fsl.base import FSLCommand, FSLCommandInputSpec
from nipype.interfaces.base import TraitedSpec, File, traits, isdefined
import os
class FslHdInputSpec(FSLCommandInputSpec):
xml_style = traits.Bool(desc='print an XML-style', argstr='-x', position=0)
in_file = File(desc="input file", exists=True, argstr="%s", position=1, mandatory=True)
out_text_name = traits.Str(desc='output text name', argstr='> %s', position=2)
#out_file = File(desc="output file", argstr="%s")
class FslHdOutputSpec(TraitedSpec):
out_file = File(desc = "out file", exists = True)
class FslHd(FSLCommand):
input_spec = FslHdInputSpec
output_spec = FslHdOutputSpec
cmd = 'fslhd'
if __name__ == '__main__':
f = FslHd(xml_style = True , in_file = '/new_home/intern2012/yasin/data_sink/T2_N3rescalenorm_std.nii', out_text_name = 'info.txt')
print f.cmdline
f.run()
When I call it from terminal (python flshd.py), it prints a 'info.txt' as I wanted, but when it is implemented into a node as below it does not print the 'info.txt'. The partial code below works without error but doesn't print a text file.
# fslhd
fslhd = pe.Node(interface = fslhd.FslHd(), name = 'fslhd')
fslhd.inputs.xml_style = True
fslhd.inputs.in_file = '/new_home/intern2012/yasin/data_sink/T2_N3rescalenorm_std.nii'
fslhd.inputs.out_text_name = 'info.txt'
fslhd.run()
As far as I know, in the first situation the code runs through '
if __name__ == '__main__':
' . In the second one it does not import
'if __name__ == '__main__':'
. However non-important part is included into node. I could not understand where the problem is.
Regards
Yasin