29
29
SimpleInterface
30
30
)
31
31
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
-
40
32
class _GradUnwarpInputSpec (TraitedSpec ):
41
33
infile = File (exists = True , mandatory = True , desc = "input image to be corrected" )
42
34
gradfile = File (exists = True , default = None , desc = "gradient file" )
43
35
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" )
50
37
vendor = traits .Enum ("siemens" , "ge" , usedefault = True , desc = "scanner vendor" )
51
38
warp = traits .Bool (desc = "warp a volume (as opposed to unwarping)" )
52
39
nojac = traits .Bool (desc = "Do not perform Jacobian intensity correction" )
@@ -68,11 +55,18 @@ class GradUnwarp(SimpleInterface):
68
55
input_spec = _GradUnwarpInputSpec
69
56
output_spec = _GradUnwarpOutputSpec
70
57
58
+ def version ():
59
+ try :
60
+ import gradunwarp
61
+ except ImportError :
62
+ return
63
+ return gradunwarp .__version__
64
+
71
65
def _run_interface (self , runtime ):
72
66
73
- if not has_gradunwarp :
67
+ if not GradUnwarp . version () :
74
68
raise RuntimeError ('missing gradunwarp dependency' )
75
-
69
+ from gradunwarp . core . gradient_unwarp import GradientUnwarpRunner
76
70
gur = GradientUnwarpRunner (self .inputs )
77
71
gur .run ()
78
72
gur .write ()
0 commit comments