22import argparse
33import inspect
44import sys
5- from nipype .interfaces .base import Interface , InputMultiPath
5+ from nipype .interfaces .base import Interface , InputMultiPath , traits
66from nipype .utils .misc import str2bool
77
88def listClasses (module = None ):
@@ -24,6 +24,9 @@ def add_options(parser=None, module=None, function=None):
2424 for name , spec in sorted (interface .inputs .traits (transient = None ).items ()):
2525 desc = "\n " .join (interface ._get_trait_desc (inputs , name , spec ))[len (name )+ 2 :]
2626 args = {}
27+
28+ if spec .is_trait_type (traits .Bool ):
29+ args ["action" ] = 'store_true'
2730
2831 if hasattr (spec , "mandatory" ) and spec .mandatory :
2932 if spec .is_trait_type (InputMultiPath ):
@@ -43,16 +46,17 @@ def run_instance(interface, options):
4346 for input_name , _ in interface .inputs .items ():
4447 if getattr (options , input_name ) != None :
4548 value = getattr (options , input_name )
46- #traits cannot cast from string to float or int
47- try :
48- value = float (value )
49- except :
50- pass
51- #try to cast string input to boolean
52- try :
53- value = str2bool (value )
54- except :
55- pass
49+ if not isinstance (value , bool ):
50+ #traits cannot cast from string to float or int
51+ try :
52+ value = float (value )
53+ except :
54+ pass
55+ #try to cast string input to boolean
56+ try :
57+ value = str2bool (value )
58+ except :
59+ pass
5660 try :
5761 setattr (interface .inputs , input_name ,
5862 value )
0 commit comments