Skip to content

Commit 9e3ae7e

Browse files
committed
fix interface
1 parent fb04e5d commit 9e3ae7e

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

niworkflows/interfaces/gradunwarp.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,11 @@
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-
4032
class _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()

niworkflows/testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ def wrapper(*args, **kwargs):
4242
has_fsl = fsl.Info.version() is not None
4343
has_freesurfer = fs.Info.version() is not None
4444
has_afni = afni.Info.version() is not None
45-
has_gradunwarp = gradunwarp.has_gradunwarp
45+
has_gradunwarp = gradunwarp.GradUnwarp.version()

0 commit comments

Comments
 (0)