2
2
# vi: set ft=python sts=4 ts=4 sw=4 et:
3
3
"""Provide interface to AFNI commands."""
4
4
5
- from builtins import object
6
-
7
-
8
5
import os
6
+ from sys import platform
7
+ from builtins import object
9
8
10
9
from ... import logging
11
10
from ...utils .filemanip import split_filename
12
11
from ..base import (
13
12
CommandLine , traits , CommandLineInputSpec , isdefined , File , TraitedSpec )
14
13
15
14
# Use nipype's logging system
16
- iflogger = logging .getLogger ('interface' )
15
+ IFLOGGER = logging .getLogger ('interface' )
17
16
18
17
19
18
class Info (object ):
@@ -46,14 +45,14 @@ def version():
46
45
currv = clout .runtime .stdout .split ('\n ' )[1 ].split ('=' , 1 )[1 ].strip ()
47
46
except IOError :
48
47
# If afni_vcheck is not present, return None
49
- iflogger .warn ('afni_vcheck executable not found.' )
48
+ IFLOGGER .warn ('afni_vcheck executable not found.' )
50
49
return None
51
50
except RuntimeError as e :
52
51
# If AFNI is outdated, afni_vcheck throws error.
53
52
# Show new version, but parse current anyways.
54
53
currv = str (e ).split ('\n ' )[4 ].split ('=' , 1 )[1 ].strip ()
55
54
nextv = str (e ).split ('\n ' )[6 ].split ('=' , 1 )[1 ].strip ()
56
- iflogger .warn (
55
+ IFLOGGER .warn (
57
56
'AFNI is outdated, detected version %s and %s is available.' % (currv , nextv ))
58
57
59
58
if currv .startswith ('AFNI_' ):
@@ -117,6 +116,17 @@ def standard_image(img_name):
117
116
return os .path .join (basedir , img_name )
118
117
119
118
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
+
120
130
class AFNICommandInputSpec (CommandLineInputSpec ):
121
131
outputtype = traits .Enum ('AFNI' , list (Info .ftypes .keys ()),
122
132
desc = 'AFNI output filetype' )
@@ -130,8 +140,8 @@ class AFNICommandOutputSpec(TraitedSpec):
130
140
exists = True )
131
141
132
142
133
- class AFNICommand (CommandLine ):
134
-
143
+ class AFNICommand (AFNICommandBase ):
144
+ """Shared options for several AFNI commands """
135
145
input_spec = AFNICommandInputSpec
136
146
_outputtype = None
137
147
0 commit comments