From ffcb76b04ce09f223117c3fa5fbf91690b843a69 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 25 Sep 2014 17:22:06 -0400 Subject: [PATCH 1/4] Added input options to dcm2nii --- nipype/interfaces/dcm2nii.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index ba353c6239..85ad5e27b2 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -17,19 +17,25 @@ import re class Dcm2niiInputSpec(CommandLineInputSpec): - source_names = InputMultiPath(File(exists=True), argstr="%s", position=10, + source_names = InputMultiPath(File(exists=True), argstr="%s", position=16, 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) + anonymize = traits.Bool(True, argstr='-a', usedefault=True, position=0) + config_file = File(exists=True, argstr="-b %s", genfile=True, position=1) + collapse_folders = traits.Bool(True, argstr='-c', usedefault=True, position=2) + date_in_filename = traits.Bool(True, argstr='-d', usedefault=True, position=3) + events_in_filename = traits.Bool(True, argstr='-e', usedefault=True, position=4) + source_in_filename = traits.Bool(False, argstr='-f', usedefault=True, position=5) + gzip_output = traits.Bool(False, argstr='-g', usedefault=True, position=6) + id_in_filename = traits.Bool(False, argstr='-i', usedefault=True, position=7) + nii_output = traits.Bool(True, argstr='-n', usedefault=True, position=8) + output_dir = Directory(exists=True, argstr='-o %s', genfile=True, position=9) + protocol_in_filename = traits.Bool(True, argstr='-p', usedefault=True, position=10) + reorient = traits.Bool(argstr='-r', position=11) + spm_analyze = traits.Bool(argstr='-s', xor=['nii_output'], position=12) + convert_all_pars = traits.Bool(True, argstr='-v', usedefault=True, position=13) + reorient_and_crop = traits.Bool(False, argstr='-x', usedefault=True, position=14) args = traits.Str(argstr='%s', desc='Additional parameters to the command', - position=9) + position=15) class Dcm2niiOutputSpec(TraitedSpec): converted_files = OutputMultiPath(File(exists=True)) @@ -60,7 +66,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' From 4bfae3f30f645721964059db55671452db1062c4 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 25 Sep 2014 17:59:26 -0400 Subject: [PATCH 2/4] Dcm2nii and related tests --- nipype/interfaces/dcm2nii.py | 6 +-- nipype/interfaces/tests/test_auto_Dcm2nii.py | 47 +++++++++++++++----- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index 85ad5e27b2..37827e41fa 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -21,7 +21,7 @@ class Dcm2niiInputSpec(CommandLineInputSpec): copyfile=False, mandatory=True) anonymize = traits.Bool(True, argstr='-a', usedefault=True, position=0) config_file = File(exists=True, argstr="-b %s", genfile=True, position=1) - collapse_folders = traits.Bool(True, argstr='-c', usedefault=True, position=2) + collapse_folders = traits.Bool(True, argstr='-c', usedefault=True, position=2) date_in_filename = traits.Bool(True, argstr='-d', usedefault=True, position=3) events_in_filename = traits.Bool(True, argstr='-e', usedefault=True, position=4) source_in_filename = traits.Bool(False, argstr='-f', usedefault=True, position=5) @@ -56,7 +56,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 -b config.ini -c y -d y -e y -f n -g y -i n -n y -o . -p y -v y -x n functional_1.dcm' >>> converter.run() # doctest: +SKIP """ @@ -69,7 +69,7 @@ def _format_arg(self, opt, spec, val): 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']: + 'reorient_and_crop']: spec = deepcopy(spec) if val: spec.argstr += ' y' diff --git a/nipype/interfaces/tests/test_auto_Dcm2nii.py b/nipype/interfaces/tests/test_auto_Dcm2nii.py index 3c91992a72..8fea3ebe8c 100644 --- a/nipype/interfaces/tests/test_auto_Dcm2nii.py +++ b/nipype/interfaces/tests/test_auto_Dcm2nii.py @@ -4,50 +4,77 @@ def test_Dcm2nii_inputs(): input_map = dict(anonymize=dict(argstr='-a', - position=2, + position=0, + usedefault=True, ), args=dict(argstr='%s', - position=9, + position=15, + ), + collapse_folders=dict(argstr='-c', + position=2, + usedefault=True, ), config_file=dict(argstr='-b %s', genfile=True, - position=7, + position=1, ), convert_all_pars=dict(argstr='-v', - position=8, + position=13, + usedefault=True, + ), + date_in_filename=dict(argstr='-d', + position=3, + usedefault=True, ), environ=dict(nohash=True, usedefault=True, ), + events_in_filename=dict(argstr='-e', + position=4, + usedefault=True, + ), gzip_output=dict(argstr='-g', - position=0, + position=6, usedefault=True, ), id_in_filename=dict(argstr='-i', - position=3, + position=7, usedefault=True, ), ignore_exception=dict(nohash=True, usedefault=True, ), nii_output=dict(argstr='-n', - position=1, + position=8, usedefault=True, ), output_dir=dict(argstr='-o %s', genfile=True, - position=6, + position=9, + ), + protocol_in_filename=dict(argstr='-p', + position=10, + usedefault=True, ), reorient=dict(argstr='-r', - position=4, + position=11, ), reorient_and_crop=dict(argstr='-x', + position=14, + usedefault=True, + ), + source_in_filename=dict(argstr='-f', position=5, + usedefault=True, ), source_names=dict(argstr='%s', copyfile=False, mandatory=True, - position=10, + position=16, + ), + spm_analyze=dict(argstr='-s', + position=12, + xor=['nii_output'], ), terminal_output=dict(mandatory=True, nohash=True, From e639b87b7706726389bc4df55710f5833a84a973 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 25 Sep 2014 18:09:38 -0400 Subject: [PATCH 3/4] Added whitespaces --- nipype/interfaces/dcm2nii.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index 37827e41fa..8ebf0455c9 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -67,8 +67,8 @@ class Dcm2nii(CommandLine): def _format_arg(self, opt, spec, val): 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', + '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: From a686236281e184c5be01771c220ba0eff5b14fa6 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 26 Sep 2014 11:24:16 -0400 Subject: [PATCH 4/4] Removed unnecessary positional parameters as well as args argument --- nipype/interfaces/dcm2nii.py | 36 +++++++++----------- nipype/interfaces/tests/test_auto_Dcm2nii.py | 18 +--------- 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index 8ebf0455c9..6ba7b622f2 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -17,25 +17,23 @@ import re class Dcm2niiInputSpec(CommandLineInputSpec): - source_names = InputMultiPath(File(exists=True), argstr="%s", position=16, + source_names = InputMultiPath(File(exists=True), argstr="%s", position=-1, copyfile=False, mandatory=True) - anonymize = traits.Bool(True, argstr='-a', usedefault=True, position=0) - config_file = File(exists=True, argstr="-b %s", genfile=True, position=1) - collapse_folders = traits.Bool(True, argstr='-c', usedefault=True, position=2) - date_in_filename = traits.Bool(True, argstr='-d', usedefault=True, position=3) - events_in_filename = traits.Bool(True, argstr='-e', usedefault=True, position=4) - source_in_filename = traits.Bool(False, argstr='-f', usedefault=True, position=5) - gzip_output = traits.Bool(False, argstr='-g', usedefault=True, position=6) - id_in_filename = traits.Bool(False, argstr='-i', usedefault=True, position=7) - nii_output = traits.Bool(True, argstr='-n', usedefault=True, position=8) - output_dir = Directory(exists=True, argstr='-o %s', genfile=True, position=9) - protocol_in_filename = traits.Bool(True, argstr='-p', usedefault=True, position=10) - reorient = traits.Bool(argstr='-r', position=11) - spm_analyze = traits.Bool(argstr='-s', xor=['nii_output'], position=12) - convert_all_pars = traits.Bool(True, argstr='-v', usedefault=True, position=13) - reorient_and_crop = traits.Bool(False, argstr='-x', usedefault=True, position=14) - args = traits.Str(argstr='%s', desc='Additional parameters to the command', - position=15) + 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)) @@ -56,7 +54,7 @@ class Dcm2nii(CommandLine): >>> converter.inputs.gzip_output = True >>> converter.inputs.output_dir = '.' >>> converter.cmdline #doctest: +ELLIPSIS - 'dcm2nii -a y -b config.ini -c y -d y -e y -f n -g y -i n -n y -o . -p y -v y -x n 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 """ diff --git a/nipype/interfaces/tests/test_auto_Dcm2nii.py b/nipype/interfaces/tests/test_auto_Dcm2nii.py index 8fea3ebe8c..09b5208125 100644 --- a/nipype/interfaces/tests/test_auto_Dcm2nii.py +++ b/nipype/interfaces/tests/test_auto_Dcm2nii.py @@ -4,76 +4,60 @@ def test_Dcm2nii_inputs(): input_map = dict(anonymize=dict(argstr='-a', - position=0, usedefault=True, ), args=dict(argstr='%s', - position=15, ), collapse_folders=dict(argstr='-c', - position=2, usedefault=True, ), config_file=dict(argstr='-b %s', genfile=True, - position=1, ), convert_all_pars=dict(argstr='-v', - position=13, usedefault=True, ), date_in_filename=dict(argstr='-d', - position=3, usedefault=True, ), environ=dict(nohash=True, usedefault=True, ), events_in_filename=dict(argstr='-e', - position=4, usedefault=True, ), gzip_output=dict(argstr='-g', - position=6, usedefault=True, ), id_in_filename=dict(argstr='-i', - position=7, usedefault=True, ), ignore_exception=dict(nohash=True, usedefault=True, ), nii_output=dict(argstr='-n', - position=8, usedefault=True, ), output_dir=dict(argstr='-o %s', genfile=True, - position=9, ), protocol_in_filename=dict(argstr='-p', - position=10, usedefault=True, ), reorient=dict(argstr='-r', - position=11, ), reorient_and_crop=dict(argstr='-x', - position=14, usedefault=True, ), source_in_filename=dict(argstr='-f', - position=5, usedefault=True, ), source_names=dict(argstr='%s', copyfile=False, mandatory=True, - position=16, + position=-1, ), spm_analyze=dict(argstr='-s', - position=12, xor=['nii_output'], ), terminal_output=dict(mandatory=True,