Skip to content

fix: afni version check #3

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

Closed
wants to merge 1 commit into from
Closed
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
39 changes: 16 additions & 23 deletions nipype/interfaces/afni/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from sys import platform
from distutils import spawn

from ... import logging
from ... import logging, LooseVersion
from ...utils.filemanip import split_filename, fname_presuffix

from ..base import (
Expand Down Expand Up @@ -44,32 +44,25 @@ def version():

"""
try:
clout = CommandLine(command='afni_vcheck',
clout = CommandLine(command='afni --version',
terminal_output='allatonce').run()

# Try to parse the version number
currv = clout.runtime.stdout.split('\n')[1].split('=', 1)[1].strip()
except IOError:
# If afni_vcheck is not present, return None
IFLOGGER.warn('afni_vcheck executable not found.')
IFLOGGER.warn('afni executable not found.')
return None
except RuntimeError as e:
# If AFNI is outdated, afni_vcheck throws error.
# Show new version, but parse current anyways.
currv = str(e).split('\n')[4].split('=', 1)[1].strip()
nextv = str(e).split('\n')[6].split('=', 1)[1].strip()
IFLOGGER.warn(
'AFNI is outdated, detected version %s and %s is available.' % (currv, nextv))

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

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

version_stamp = clout.runtime.stdout.split('\n')[0].split('Version ')[1]
if version_stamp.startswith('AFNI'):
version_stamp = version_stamp.split('AFNI_')[1]
elif version_stamp.startswith('Debian'):
version_stamp = version_stamp.split('Debian-')[1].split('~')[0]
else:
return None

version = LooseVersion(version_stamp.replace('_', '.')).version[:3]
if version[0] < 1000:
version[0] = version[0] + 2000
return tuple(version)

@classmethod
def output_type_to_ext(cls, outputtype):
Expand Down
4 changes: 2 additions & 2 deletions nipype/interfaces/afni/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ def __init__(self, **inputs):
version = Info.version()

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

def _parse_inputs(self, skip=None):
Expand Down Expand Up @@ -2150,7 +2150,7 @@ def __init__(self, **inputs):
v = Info.version()

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


Expand Down