Skip to content

Commit 47d05b2

Browse files
committed
fixed tests without AFNI installation
1 parent b400aa9 commit 47d05b2

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

nipype/interfaces/afni/base.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,13 @@ def version():
3838
3939
"""
4040
import re
41-
clout = CommandLine(command='afni_vcheck',
42-
terminal_output='allatonce').run()
41+
try:
42+
clout = CommandLine(command='afni_vcheck',
43+
terminal_output='allatonce').run()
44+
except IOError:
45+
# If afni_vcheck is not present, return None
46+
return None
47+
4348
out = clout.runtime.stdout.split('\n')[1]
4449

4550
# Try to parse the version number
@@ -173,3 +178,10 @@ def _list_outputs(self):
173178
if ext == "":
174179
outputs[name] = outputs[name] + "+orig.BRIK"
175180
return outputs
181+
182+
183+
def no_afni():
184+
""" Checks if AFNI is available """
185+
if Info.version() is None:
186+
return True
187+
return False

nipype/interfaces/afni/preprocess.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,13 +1236,17 @@ class SkullStrip(AFNICommand):
12361236
output_spec = AFNICommandOutputSpec
12371237

12381238
def __init__(self, **inputs):
1239-
from .base import Info
1239+
from .base import Info, no_afni
12401240
super(SkullStrip, self).__init__(**inputs)
1241-
v = Info.version()
12421241

1243-
# As of AFNI 16.0.00, redirect_x is not needed
1244-
if isinstance(v[0], int) and v[0] > 15:
1245-
self._redirect_x = False
1242+
if not no_afni():
1243+
v = Info.version()
1244+
1245+
# As of AFNI 16.0.00, redirect_x is not needed
1246+
if isinstance(v[0], int) and v[0] > 15:
1247+
self._redirect_x = False
1248+
else:
1249+
raise RuntimeWarning('afni_vcheck executable not found.')
12461250

12471251

12481252
class TCatInputSpec(AFNICommandInputSpec):

0 commit comments

Comments
 (0)