diff --git a/nipype/interfaces/afni/base.py b/nipype/interfaces/afni/base.py index 22870d5d19..0f953c82e4 100644 --- a/nipype/interfaces/afni/base.py +++ b/nipype/interfaces/afni/base.py @@ -6,13 +6,14 @@ import os -import warnings +from ... import logging from ...utils.filemanip import split_filename from ..base import ( CommandLine, traits, CommandLineInputSpec, isdefined, File, TraitedSpec) -warn = warnings.warn +# Use nipype's logging system +iflogger = logging.getLogger('interface') class Info(object): @@ -40,26 +41,29 @@ def version(): try: clout = CommandLine(command='afni_vcheck', 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 - warn('afni_vcheck executable not found.') + iflogger.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 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 out.startswith('AFNI_'): - out = out[5:] + if currv.startswith('AFNI_'): + currv = currv[5:] - v = out.split('.') + v = currv.split('.') try: v = [int(n) for n in v] except ValueError: - return out + return currv return tuple(v) @classmethod diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index 058a99a1af..85f2a4eaf9 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -8,10 +8,10 @@ >>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data')) >>> os.chdir(datadir) """ -import warnings import os import re +from warnings import warn from .base import AFNICommand, AFNICommandInputSpec, AFNICommandOutputSpec from ..base import CommandLineInputSpec, CommandLine, OutputMultiPath @@ -20,8 +20,6 @@ from ...utils.filemanip import (load_json, save_json, split_filename) from ...utils.filemanip import fname_presuffix -warn = warnings.warn - class To3DInputSpec(AFNICommandInputSpec): out_file = File(name_template="%s", desc='output image file name',