|
26 | 26 |
|
27 | 27 | """
|
28 | 28 | from __future__ import print_function, division, unicode_literals, absolute_import
|
29 |
| -from builtins import open, object |
30 | 29 |
|
31 | 30 | from glob import glob
|
32 | 31 | import os
|
33 | 32 |
|
34 | 33 | from ... import logging
|
35 | 34 | from ...utils.filemanip import fname_presuffix
|
36 |
| -from ..base import traits, isdefined, CommandLine, CommandLineInputSpec |
| 35 | +from ..base import traits, isdefined, CommandLine, CommandLineInputSpec, PackageInfo |
37 | 36 | from ...external.due import BibTeX
|
38 | 37 |
|
39 | 38 | IFLOGGER = logging.getLogger('interface')
|
40 | 39 |
|
41 | 40 |
|
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. |
46 | 44 |
|
47 | 45 | output type refers to the type of file fsl defaults to writing
|
48 | 46 | eg, NIFTI, NIFTI_GZ
|
49 | 47 |
|
| 48 | + Examples |
| 49 | + -------- |
| 50 | +
|
| 51 | + >>> from nipype.interfaces.fsl import Info |
| 52 | + >>> Info.version() # doctest: +SKIP |
| 53 | + >>> Info.output_type() # doctest: +SKIP |
| 54 | +
|
| 55 | +
|
50 | 56 | """
|
51 | 57 |
|
52 | 58 | ftypes = {'NIFTI': '.nii',
|
53 | 59 | 'NIFTI_PAIR': '.img',
|
54 | 60 | 'NIFTI_GZ': '.nii.gz',
|
55 | 61 | 'NIFTI_PAIR_GZ': '.img.gz'}
|
56 | 62 |
|
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') |
69 | 66 |
|
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] |
79 | 70 |
|
80 | 71 | @classmethod
|
81 | 72 | def output_type_to_ext(cls, output_type):
|
|
0 commit comments