File tree Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Original file line number Diff line number Diff line change 4
4
"""The ants module provides basic functions for interfacing with ANTS tools."""
5
5
from __future__ import print_function , division , unicode_literals , absolute_import
6
6
from builtins import str
7
+
8
+ import os
9
+ import subprocess
10
+
7
11
# Local imports
8
- from ... import logging
12
+ from ... import logging , LooseVersion
9
13
from ..base import CommandLine , CommandLineInputSpec , traits , isdefined
10
14
logger = logging .getLogger ('interface' )
11
15
25
29
ALT_ITKv4_THREAD_LIMIT_VARIABLE = 'ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS'
26
30
27
31
32
+ class Info (object ):
33
+ _version = None
34
+
35
+ @property
36
+ def version (self ):
37
+ if self ._version is None :
38
+ try :
39
+ basedir = os .environ ['ANTSPATH' ]
40
+ except KeyError :
41
+ return None
42
+
43
+ cmd = os .path .join (basedir , 'antsRegistration' )
44
+ try :
45
+ res = subprocess .check_output ([cmd , '--version' ]).decode ('utf-8' )
46
+ except OSError :
47
+ return None
48
+
49
+ v_string = res .splitlines ()[0 ].split (': ' )[1 ]
50
+ # 2.2.0-equivalent version string
51
+ if LooseVersion (v_string ) >= LooseVersion ('2.1.0.post789-g0740f' ):
52
+ self ._version = '2.2.0'
53
+ else :
54
+ self ._version = '.' .join (v_string .split ('.' )[:3 ])
55
+
56
+ return self ._version
57
+
58
+
28
59
class ANTSCommandInputSpec (CommandLineInputSpec ):
29
60
"""Base Input Specification for all ANTS Commands
30
61
"""
@@ -84,3 +115,7 @@ def set_default_num_threads(cls, num_threads):
84
115
<instance>.inputs.num_threads
85
116
"""
86
117
cls ._num_threads = num_threads
118
+
119
+ @property
120
+ def version (self ):
121
+ return Info ().version
You can’t perform that action at this time.
0 commit comments