Skip to content

[ENH] Check AFNI version in SkullStrip to avoid xvfb #1328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ before_install:
- if $INSTALL_DEB_DEPENDECIES; then travis_retry sudo apt-get install -qq fsl-atlases;
fi
- if $INSTALL_DEB_DEPENDECIES; then source /etc/fsl/fsl.sh; fi
- if $INSTALL_DEB_DEPENDECIES; then source /etc/afni/afni.sh; fi
install:
- conda update --yes conda
- conda create -n testenv --yes pip python=$TRAVIS_PYTHON_VERSION
Expand Down
35 changes: 31 additions & 4 deletions nipype/interfaces/afni/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,30 @@ def version():
Version number as string or None if AFNI not found

"""
clout = CommandLine(command='afni_vcheck',
terminal_output='allatonce').run()
out = clout.runtime.stdout
return out.split('\n')[1]
try:
clout = CommandLine(command='afni_vcheck',
terminal_output='allatonce').run()
except IOError:
# If afni_vcheck is not present, return None
warn('afni_vcheck executable not found.')
return None
except RuntimeError as e:
# If AFNI is outdated, afni_vcheck throws error
warn('AFNI is outdated')
return str(e).split('\n')[4].split('=', 1)[1].strip()

# Try to parse the version number
out = clout.runtime.stdout.split('\n')[1].split('=', 1)[1].strip()

if out.startswith('AFNI_'):
out = out[5:]

v = out.split('.')
try:
v = [int(n) for n in v]
except ValueError:
return out
return tuple(v)

@classmethod
def outputtype_to_ext(cls, outputtype):
Expand Down Expand Up @@ -160,3 +180,10 @@ def _list_outputs(self):
if ext == "":
outputs[name] = outputs[name] + "+orig.BRIK"
return outputs


def no_afni():
""" Checks if AFNI is available """
if Info.version() is None:
return True
return False
11 changes: 11 additions & 0 deletions nipype/interfaces/afni/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,17 @@ class SkullStrip(AFNICommand):
input_spec = SkullStripInputSpec
output_spec = AFNICommandOutputSpec

def __init__(self, **inputs):
from .base import Info, no_afni
super(SkullStrip, self).__init__(**inputs)

if not no_afni():
v = Info.version()

# As of AFNI 16.0.00, redirect_x is not needed
if isinstance(v[0], int) and v[0] > 15:
self._redirect_x = False


class TCatInputSpec(AFNICommandInputSpec):
in_files = InputMultiPath(
Expand Down