19
19
import os
20
20
21
21
from ... import logging
22
- from ..base import CommandLine , CommandLineInputSpec , traits , Undefined
22
+ from ..base import (CommandLine , CommandLineInputSpec , traits , Undefined ,
23
+ PackageInfo )
23
24
from ...utils .filemanip import split_filename
24
25
25
26
iflogger = logging .getLogger ("nipype.interface" )
@@ -29,6 +30,14 @@ def get_custom_path(command, env_dir="NIFTYREGDIR"):
29
30
return os .path .join (os .getenv (env_dir , "" ), command )
30
31
31
32
33
+ class Info (PackageInfo ):
34
+ version_cmd = get_custom_path ('reg_aladin' ) + ' --version'
35
+
36
+ @staticmethod
37
+ def parse_version (raw_info ):
38
+ return raw_info
39
+
40
+
32
41
class NiftyRegCommandInputSpec (CommandLineInputSpec ):
33
42
"""Input Spec for niftyreg interfaces."""
34
43
@@ -55,9 +64,8 @@ def __init__(self, required_version=None, **inputs):
55
64
self .num_threads = 1
56
65
super (NiftyRegCommand , self ).__init__ (** inputs )
57
66
self .required_version = required_version
58
- _version = self .version_from_command ()
67
+ _version = self .version
59
68
if _version :
60
- _version = _version .decode ("utf-8" )
61
69
if self ._min_version is not None and StrictVersion (
62
70
_version
63
71
) < StrictVersion (self ._min_version ):
@@ -91,11 +99,9 @@ def _environ_update(self):
91
99
self .inputs .omp_core_val = Undefined
92
100
93
101
def check_version (self ):
94
- _version = self .version_from_command ()
102
+ _version = self .version
95
103
if not _version :
96
104
raise Exception ("Niftyreg not found" )
97
- # Decoding to string:
98
- _version = _version .decode ("utf-8" )
99
105
if StrictVersion (_version ) < StrictVersion (self ._min_version ):
100
106
err = "A later version of Niftyreg is required (%s < %s)"
101
107
raise ValueError (err % (_version , self ._min_version ))
@@ -107,10 +113,10 @@ def check_version(self):
107
113
108
114
@property
109
115
def version (self ):
110
- return self . version_from_command ()
116
+ return Info . version ()
111
117
112
118
def exists (self ):
113
- return self .version_from_command () is not None
119
+ return self .version is not None
114
120
115
121
def _format_arg (self , name , spec , value ):
116
122
if name == "omp_core_val" :
0 commit comments