Skip to content

Commit dd55523

Browse files
committed
added version checking in afni.SkullStrip to avoid use of virtual display with AFNI >= 16
1 parent a9e2b51 commit dd55523

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

nipype/interfaces/afni/base.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,23 @@ def version():
3737
Version number as string or None if AFNI not found
3838
3939
"""
40+
import re
4041
clout = CommandLine(command='afni_vcheck',
4142
terminal_output='allatonce').run()
42-
out = clout.runtime.stdout
43-
return out.split('\n')[1]
43+
out = clout.runtime.stdout.split('\n')[1]
44+
45+
# Try to parse the version number
46+
m = re.search(r'[\.\d]*$', out)
47+
# is the format kept through versions before 16.x?
48+
if m is None or not m.group(0):
49+
return out
50+
51+
v = m.group(0).split('.')
52+
try:
53+
v = [int(n) for n in v]
54+
except ValueError:
55+
return out
56+
return tuple(v)
4457

4558
@classmethod
4659
def outputtype_to_ext(cls, outputtype):

nipype/interfaces/afni/preprocess.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,15 @@ class SkullStrip(AFNICommand):
12351235
input_spec = SkullStripInputSpec
12361236
output_spec = AFNICommandOutputSpec
12371237

1238+
def __init__(self, **inputs):
1239+
from .base import Info
1240+
super(SkullStrip, self).__init__(**inputs)
1241+
v = Info.version()
1242+
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
1246+
12381247

12391248
class TCatInputSpec(AFNICommandInputSpec):
12401249
in_files = InputMultiPath(

0 commit comments

Comments
 (0)