Skip to content

Commit fcff92d

Browse files
authored
Merge pull request #2295 from oesteban/fix/fslversion
[ENH] Memoize FSL version check
2 parents 9da0851 + 3fd6c28 commit fcff92d

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
Upcoming release
22
================
33

4+
45
0.14.0 (<TBD>)
56
==============
67

78
###### [Full changelog](https://github.com/nipy/nipype/milestone/13)
89

10+
* ENH: Memoize version checks (https://github.com/nipy/nipype/pull/2274, https://github.com/nipy/nipype/pull/2295)
11+
12+
913
0.14.0rc1 (November 21, 2017)
1014
-----------------------------
1115

nipype/interfaces/fsl/base.py

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,56 +26,47 @@
2626
2727
"""
2828
from __future__ import print_function, division, unicode_literals, absolute_import
29-
from builtins import open, object
3029

3130
from glob import glob
3231
import os
3332

3433
from ... import logging
3534
from ...utils.filemanip import fname_presuffix
36-
from ..base import traits, isdefined, CommandLine, CommandLineInputSpec
35+
from ..base import traits, isdefined, CommandLine, CommandLineInputSpec, PackageInfo
3736
from ...external.due import BibTeX
3837

3938
IFLOGGER = logging.getLogger('interface')
4039

4140

42-
class Info(object):
43-
"""Handle fsl output type and version information.
44-
45-
version refers to the version of fsl on the system
41+
class Info(PackageInfo):
42+
"""
43+
Handle FSL ``output_type`` and version information.
4644
4745
output type refers to the type of file fsl defaults to writing
4846
eg, NIFTI, NIFTI_GZ
4947
48+
Examples
49+
--------
50+
51+
>>> from nipype.interfaces.fsl import Info
52+
>>> Info.version() # doctest: +SKIP
53+
>>> Info.output_type() # doctest: +SKIP
54+
55+
5056
"""
5157

5258
ftypes = {'NIFTI': '.nii',
5359
'NIFTI_PAIR': '.img',
5460
'NIFTI_GZ': '.nii.gz',
5561
'NIFTI_PAIR_GZ': '.img.gz'}
5662

57-
@staticmethod
58-
def version():
59-
"""Check for fsl version on system
60-
61-
Parameters
62-
----------
63-
None
64-
65-
Returns
66-
-------
67-
version : str
68-
Version number as string or None if FSL not found
63+
if os.getenv('FSLDIR'):
64+
version_file = os.path.join(
65+
os.getenv('FSLDIR'), 'etc', 'fslversion')
6966

70-
"""
71-
# find which fsl being used....and get version from
72-
# /path/to/fsl/etc/fslversion
73-
try:
74-
basedir = os.environ['FSLDIR']
75-
except KeyError:
76-
return None
77-
out = open('%s/etc/fslversion' % (basedir)).read()
78-
return out.strip('\n')
67+
@staticmethod
68+
def parse_version(raw_info):
69+
return raw_info.splitlines()[0]
7970

8071
@classmethod
8172
def output_type_to_ext(cls, output_type):

0 commit comments

Comments
 (0)