Skip to content

Commit

Permalink
Merge pull request nipy#931 from mick-d/master
Browse files Browse the repository at this point in the history
Additional dcm2nii inputs
  • Loading branch information
chrisgorgo committed Sep 30, 2014
2 parents 0069aa3 + a686236 commit 25cb849
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 25 deletions.
35 changes: 21 additions & 14 deletions nipype/interfaces/dcm2nii.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,23 @@
import re

class Dcm2niiInputSpec(CommandLineInputSpec):
source_names = InputMultiPath(File(exists=True), argstr="%s", position=10,
source_names = InputMultiPath(File(exists=True), argstr="%s", position=-1,
copyfile=False, mandatory=True)
gzip_output = traits.Bool(False, argstr='-g', position=0, usedefault=True)
nii_output = traits.Bool(True, argstr='-n', position=1, usedefault=True)
anonymize = traits.Bool(argstr='-a', position=2)
id_in_filename = traits.Bool(False, argstr='-i', usedefault=True, position=3)
reorient = traits.Bool(argstr='-r', position=4)
reorient_and_crop = traits.Bool(argstr='-x', position=5)
output_dir = Directory(exists=True, argstr='-o %s', genfile=True, position=6)
config_file = File(exists=True, argstr="-b %s", genfile=True, position=7)
convert_all_pars = traits.Bool(argstr='-v', position=8)
args = traits.Str(argstr='%s', desc='Additional parameters to the command',
position=9)
anonymize = traits.Bool(True, argstr='-a', usedefault=True)
config_file = File(exists=True, argstr="-b %s", genfile=True)
collapse_folders = traits.Bool(True, argstr='-c', usedefault=True)
date_in_filename = traits.Bool(True, argstr='-d', usedefault=True)
events_in_filename = traits.Bool(True, argstr='-e', usedefault=True)
source_in_filename = traits.Bool(False, argstr='-f', usedefault=True)
gzip_output = traits.Bool(False, argstr='-g', usedefault=True)
id_in_filename = traits.Bool(False, argstr='-i', usedefault=True)
nii_output = traits.Bool(True, argstr='-n', usedefault=True)
output_dir = Directory(exists=True, argstr='-o %s', genfile=True)
protocol_in_filename = traits.Bool(True, argstr='-p', usedefault=True)
reorient = traits.Bool(argstr='-r')
spm_analyze = traits.Bool(argstr='-s', xor=['nii_output'])
convert_all_pars = traits.Bool(True, argstr='-v', usedefault=True)
reorient_and_crop = traits.Bool(False, argstr='-x', usedefault=True)

class Dcm2niiOutputSpec(TraitedSpec):
converted_files = OutputMultiPath(File(exists=True))
Expand All @@ -50,7 +54,7 @@ class Dcm2nii(CommandLine):
>>> converter.inputs.gzip_output = True
>>> converter.inputs.output_dir = '.'
>>> converter.cmdline #doctest: +ELLIPSIS
'dcm2nii -g y -n y -i n -o . -b config.ini functional_1.dcm'
'dcm2nii -a y -c y -b config.ini -v y -d y -e y -g y -i n -n y -o . -p y -x n -f n functional_1.dcm'
>>> converter.run() # doctest: +SKIP
"""

Expand All @@ -60,7 +64,10 @@ class Dcm2nii(CommandLine):
_cmd = 'dcm2nii'

def _format_arg(self, opt, spec, val):
if opt in ['gzip_output', 'nii_output', 'anonymize', 'id_in_filename', 'reorient', 'reorient_and_crop', 'convert_all_pars']:
if opt in ['anonymize', 'collapse_folders', 'date_in_filename', 'events_in_filename',
'source_in_filename', 'gzip_output', 'id_in_filename', 'nii_output',
'protocol_in_filename', 'reorient', 'spm_analyze', 'convert_all_pars',
'reorient_and_crop']:
spec = deepcopy(spec)
if val:
spec.argstr += ' y'
Expand Down
33 changes: 22 additions & 11 deletions nipype/interfaces/tests/test_auto_Dcm2nii.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,61 @@

def test_Dcm2nii_inputs():
input_map = dict(anonymize=dict(argstr='-a',
position=2,
usedefault=True,
),
args=dict(argstr='%s',
position=9,
),
collapse_folders=dict(argstr='-c',
usedefault=True,
),
config_file=dict(argstr='-b %s',
genfile=True,
position=7,
),
convert_all_pars=dict(argstr='-v',
position=8,
usedefault=True,
),
date_in_filename=dict(argstr='-d',
usedefault=True,
),
environ=dict(nohash=True,
usedefault=True,
),
events_in_filename=dict(argstr='-e',
usedefault=True,
),
gzip_output=dict(argstr='-g',
position=0,
usedefault=True,
),
id_in_filename=dict(argstr='-i',
position=3,
usedefault=True,
),
ignore_exception=dict(nohash=True,
usedefault=True,
),
nii_output=dict(argstr='-n',
position=1,
usedefault=True,
),
output_dir=dict(argstr='-o %s',
genfile=True,
position=6,
),
protocol_in_filename=dict(argstr='-p',
usedefault=True,
),
reorient=dict(argstr='-r',
position=4,
),
reorient_and_crop=dict(argstr='-x',
position=5,
usedefault=True,
),
source_in_filename=dict(argstr='-f',
usedefault=True,
),
source_names=dict(argstr='%s',
copyfile=False,
mandatory=True,
position=10,
position=-1,
),
spm_analyze=dict(argstr='-s',
xor=['nii_output'],
),
terminal_output=dict(mandatory=True,
nohash=True,
Expand Down

0 comments on commit 25cb849

Please sign in to comment.