|
33 | 33 |
|
34 | 34 | from ... import logging |
35 | 35 | from ...utils.filemanip import fname_presuffix |
36 | | -from ..base import traits, isdefined, CommandLine, CommandLineInputSpec |
| 36 | +from ..base import traits, isdefined, CommandLine, CommandLineInputSpec, PackageInfo |
37 | 37 | from ...external.due import BibTeX |
38 | 38 |
|
39 | 39 | IFLOGGER = logging.getLogger('interface') |
40 | 40 |
|
41 | 41 |
|
42 | | -class Info(object): |
43 | | - """Handle fsl output type and version information. |
44 | | -
|
45 | | - version refers to the version of fsl on the system |
| 42 | +class Info(PackageInfo): |
| 43 | + """ |
| 44 | + Handle FSL ``output_type`` and version information. |
46 | 45 |
|
47 | 46 | output type refers to the type of file fsl defaults to writing |
48 | 47 | eg, NIFTI, NIFTI_GZ |
49 | 48 |
|
| 49 | + Examples |
| 50 | + -------- |
| 51 | +
|
| 52 | + >>> from nipype.interfaces.fsl import Info |
| 53 | + >>> Info.version() # doctest: +SKIP |
| 54 | + >>> Info.output_type() # doctest: +SKIP |
| 55 | +
|
| 56 | +
|
50 | 57 | """ |
51 | 58 |
|
52 | 59 | ftypes = {'NIFTI': '.nii', |
53 | 60 | 'NIFTI_PAIR': '.img', |
54 | 61 | 'NIFTI_GZ': '.nii.gz', |
55 | 62 | 'NIFTI_PAIR_GZ': '.img.gz'} |
56 | 63 |
|
57 | | - @staticmethod |
58 | | - def version(): |
59 | | - """Check for fsl version on system |
60 | | -
|
61 | | - Parameters |
62 | | - ---------- |
63 | | - None |
| 64 | + if os.getenv('FSLDIR'): |
| 65 | + version_file = os.path.join( |
| 66 | + os.getenv('FSLDIR'), 'etc', 'fslversion') |
64 | 67 |
|
65 | | - Returns |
66 | | - ------- |
67 | | - version : str |
68 | | - Version number as string or None if FSL not found |
| 68 | + def parse_version(raw_info): |
| 69 | + return raw_info.splitlines()[0] |
69 | 70 |
|
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') |
79 | 71 |
|
80 | 72 | @classmethod |
81 | 73 | def output_type_to_ext(cls, output_type): |
|
0 commit comments