Skip to content

Commit 1ca5d4e

Browse files
authored
Merge pull request #3194 from fepegar/2615-packageinfo-niftyreg
FIX: Use PackageInfo to get NiftyReg version
2 parents c37fcfb + 328bd4e commit 1ca5d4e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

nipype/interfaces/niftyreg/base.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
import os
2020

2121
from ... import logging
22-
from ..base import CommandLine, CommandLineInputSpec, traits, Undefined
22+
from ..base import (CommandLine, CommandLineInputSpec, traits, Undefined,
23+
PackageInfo)
2324
from ...utils.filemanip import split_filename
2425

2526
iflogger = logging.getLogger("nipype.interface")
@@ -29,6 +30,14 @@ def get_custom_path(command, env_dir="NIFTYREGDIR"):
2930
return os.path.join(os.getenv(env_dir, ""), command)
3031

3132

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+
3241
class NiftyRegCommandInputSpec(CommandLineInputSpec):
3342
"""Input Spec for niftyreg interfaces."""
3443

@@ -55,9 +64,8 @@ def __init__(self, required_version=None, **inputs):
5564
self.num_threads = 1
5665
super(NiftyRegCommand, self).__init__(**inputs)
5766
self.required_version = required_version
58-
_version = self.version_from_command()
67+
_version = self.version
5968
if _version:
60-
_version = _version.decode("utf-8")
6169
if self._min_version is not None and StrictVersion(
6270
_version
6371
) < StrictVersion(self._min_version):
@@ -91,11 +99,9 @@ def _environ_update(self):
9199
self.inputs.omp_core_val = Undefined
92100

93101
def check_version(self):
94-
_version = self.version_from_command()
102+
_version = self.version
95103
if not _version:
96104
raise Exception("Niftyreg not found")
97-
# Decoding to string:
98-
_version = _version.decode("utf-8")
99105
if StrictVersion(_version) < StrictVersion(self._min_version):
100106
err = "A later version of Niftyreg is required (%s < %s)"
101107
raise ValueError(err % (_version, self._min_version))
@@ -107,10 +113,10 @@ def check_version(self):
107113

108114
@property
109115
def version(self):
110-
return self.version_from_command()
116+
return Info.version()
111117

112118
def exists(self):
113-
return self.version_from_command() is not None
119+
return self.version is not None
114120

115121
def _format_arg(self, name, spec, value):
116122
if name == "omp_core_val":

0 commit comments

Comments
 (0)