22# vi: set ft=python sts=4 ts=4 sw=4 et:
33"""Provide interface to AFNI commands."""
44
5- from builtins import object
6-
7-
85import os
6+ from sys import platform
7+ from builtins import object
98
109from ... import logging
1110from ...utils .filemanip import split_filename
1211from ..base import (
1312 CommandLine , traits , CommandLineInputSpec , isdefined , File , TraitedSpec )
1413
1514# Use nipype's logging system
16- iflogger = logging .getLogger ('interface' )
15+ IFLOGGER = logging .getLogger ('interface' )
1716
1817
1918class Info (object ):
@@ -46,14 +45,14 @@ def version():
4645 currv = clout .runtime .stdout .split ('\n ' )[1 ].split ('=' , 1 )[1 ].strip ()
4746 except IOError :
4847 # If afni_vcheck is not present, return None
49- iflogger .warn ('afni_vcheck executable not found.' )
48+ IFLOGGER .warn ('afni_vcheck executable not found.' )
5049 return None
5150 except RuntimeError as e :
5251 # If AFNI is outdated, afni_vcheck throws error.
5352 # Show new version, but parse current anyways.
5453 currv = str (e ).split ('\n ' )[4 ].split ('=' , 1 )[1 ].strip ()
5554 nextv = str (e ).split ('\n ' )[6 ].split ('=' , 1 )[1 ].strip ()
56- iflogger .warn (
55+ IFLOGGER .warn (
5756 'AFNI is outdated, detected version %s and %s is available.' % (currv , nextv ))
5857
5958 if currv .startswith ('AFNI_' ):
@@ -117,6 +116,17 @@ def standard_image(img_name):
117116 return os .path .join (basedir , img_name )
118117
119118
119+ class AFNICommandBase (CommandLine ):
120+ """
121+ A base class to fix a linking problem in OSX and afni.
122+ See http://afni.nimh.nih.gov/afni/community/board/read.php?1,145346,145347#msg-145347
123+ """
124+ def _run_interface (self , runtime ):
125+ if platform == 'darwin' :
126+ runtime .environ ['DYLD_FALLBACK_LIBRARY_PATH' ] = '/usr/local/afni/'
127+ return super (AFNICommandBase , self )._run_interface (runtime )
128+
129+
120130class AFNICommandInputSpec (CommandLineInputSpec ):
121131 outputtype = traits .Enum ('AFNI' , list (Info .ftypes .keys ()),
122132 desc = 'AFNI output filetype' )
@@ -130,8 +140,8 @@ class AFNICommandOutputSpec(TraitedSpec):
130140 exists = True )
131141
132142
133- class AFNICommand (CommandLine ):
134-
143+ class AFNICommand (AFNICommandBase ):
144+ """Shared options for several AFNI commands """
135145 input_spec = AFNICommandInputSpec
136146 _outputtype = None
137147
0 commit comments