2929 SimpleInterface
3030)
3131
32- has_gradunwarp = False
33- try :
34- from gradunwarp .core .gradient_unwarp import GradientUnwarpRunner
35- has_gradunwarp = True
36- except ImportError :
37- pass
38-
39-
4032class _GradUnwarpInputSpec (TraitedSpec ):
4133 infile = File (exists = True , mandatory = True , desc = "input image to be corrected" )
4234 gradfile = File (exists = True , default = None , desc = "gradient file" )
4335 coeffile = File (exists = True , default = None , desc = "coefficients file" )
44- outfile = File (
45- name_source = ['in_file' ],
46- name_template = ['%s_gradunwarped' ],
47- keep_extension = True ,
48- desc = "output corrected image"
49- )
36+ outfile = File ("gradunwarped.nii.gz" , mandatory = True , usedefault = True , desc = "output corrected image" )
5037 vendor = traits .Enum ("siemens" , "ge" , usedefault = True , desc = "scanner vendor" )
5138 warp = traits .Bool (desc = "warp a volume (as opposed to unwarping)" )
5239 nojac = traits .Bool (desc = "Do not perform Jacobian intensity correction" )
@@ -68,11 +55,18 @@ class GradUnwarp(SimpleInterface):
6855 input_spec = _GradUnwarpInputSpec
6956 output_spec = _GradUnwarpOutputSpec
7057
58+ def version ():
59+ try :
60+ import gradunwarp
61+ except ImportError :
62+ return
63+ return gradunwarp .__version__
64+
7165 def _run_interface (self , runtime ):
7266
73- if not has_gradunwarp :
67+ if not GradUnwarp . version () :
7468 raise RuntimeError ('missing gradunwarp dependency' )
75-
69+ from gradunwarp . core . gradient_unwarp import GradientUnwarpRunner
7670 gur = GradientUnwarpRunner (self .inputs )
7771 gur .run ()
7872 gur .write ()
0 commit comments