Skip to content

Commit 140b715

Browse files
committed
enh: add version checking
1 parent ec72e99 commit 140b715

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

nipype/interfaces/dcm2nii.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,19 @@
1010

1111
from ..utils.filemanip import split_filename
1212
from .base import (CommandLine, CommandLineInputSpec, InputMultiPath, traits,
13-
TraitedSpec, OutputMultiPath, isdefined, File, Directory)
13+
TraitedSpec, OutputMultiPath, isdefined, File, Directory,
14+
PackageInfo)
15+
16+
17+
class Info(PackageInfo):
18+
"""Handle dcm2niix version information"""
19+
20+
version_cmd = 'dcm2niix'
21+
22+
@staticmethod
23+
def parse_version(raw_info):
24+
m = re.search(r'version (\S+)', raw_info)
25+
return m[1] if m else None
1426

1527

1628
class Dcm2niiInputSpec(CommandLineInputSpec):
@@ -358,6 +370,10 @@ class Dcm2niix(CommandLine):
358370
output_spec = Dcm2niixOutputSpec
359371
_cmd = 'dcm2niix'
360372

373+
@property
374+
def version(self):
375+
return Info.version()
376+
361377
def _format_arg(self, opt, spec, val):
362378
bools = ['bids_format', 'merge_imgs', 'single_file', 'verbose', 'crop',
363379
'has_private', 'anon_bids', 'ignore_deriv', 'philips_float']

nipype/interfaces/tests/test_dcm2nii.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import shutil
44

55
from nipype.interfaces.dcm2nii import Dcm2niix
6-
no_dcm2niix = not shutil.which(Dcm2niix()._cmd)
6+
no_dcm2niix = not bool(Dcm2niix().version)
77
no_datalad = False
88
try:
99
from datalad import api # to pull and grab data

0 commit comments

Comments
 (0)