diff --git a/nipype/algorithms/tests/test_auto_ErrorMap.py b/nipype/algorithms/tests/test_auto_ErrorMap.py new file mode 100644 index 0000000000..e729d7bd0a --- /dev/null +++ b/nipype/algorithms/tests/test_auto_ErrorMap.py @@ -0,0 +1,34 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from nipype.testing import assert_equal +from nipype.algorithms.metrics import ErrorMap + +def test_ErrorMap_inputs(): + input_map = dict(ignore_exception=dict(nohash=True, + usedefault=True, + ), + in_ref=dict(mandatory=True, + ), + in_tst=dict(mandatory=True, + ), + mask=dict(), + metric=dict(mandatory=True, + usedefault=True, + ), + out_map=dict(), + ) + inputs = ErrorMap.input_spec() + + for key, metadata in input_map.items(): + for metakey, value in metadata.items(): + yield assert_equal, getattr(inputs.traits()[key], metakey), value + +def test_ErrorMap_outputs(): + output_map = dict(distance=dict(), + out_map=dict(), + ) + outputs = ErrorMap.output_spec() + + for key, metadata in output_map.items(): + for metakey, value in metadata.items(): + yield assert_equal, getattr(outputs.traits()[key], metakey), value + diff --git a/nipype/algorithms/tests/test_auto_Overlap.py b/nipype/algorithms/tests/test_auto_Overlap.py new file mode 100644 index 0000000000..507b826812 --- /dev/null +++ b/nipype/algorithms/tests/test_auto_Overlap.py @@ -0,0 +1,46 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from nipype.testing import assert_equal +from nipype.algorithms.misc import Overlap + +def test_Overlap_inputs(): + input_map = dict(bg_overlap=dict(mandatory=True, + usedefault=True, + ), + ignore_exception=dict(nohash=True, + usedefault=True, + ), + mask_volume=dict(), + out_file=dict(usedefault=True, + ), + vol_units=dict(mandatory=True, + usedefault=True, + ), + volume1=dict(mandatory=True, + ), + volume2=dict(mandatory=True, + ), + weighting=dict(usedefault=True, + ), + ) + inputs = Overlap.input_spec() + + for key, metadata in input_map.items(): + for metakey, value in metadata.items(): + yield assert_equal, getattr(inputs.traits()[key], metakey), value + +def test_Overlap_outputs(): + output_map = dict(dice=dict(), + diff_file=dict(), + jaccard=dict(), + labels=dict(), + roi_di=dict(), + roi_ji=dict(), + roi_voldiff=dict(), + volume_difference=dict(), + ) + outputs = Overlap.output_spec() + + for key, metadata in output_map.items(): + for metakey, value in metadata.items(): + yield assert_equal, getattr(outputs.traits()[key], metakey), value + diff --git a/nipype/interfaces/base.py b/nipype/interfaces/base.py index 7917d6e852..81100b9fbd 100644 --- a/nipype/interfaces/base.py +++ b/nipype/interfaces/base.py @@ -1349,9 +1349,9 @@ def _terminal_output_update(self): def set_default_terminal_output(cls, output_type): """Set the default terminal output for CommandLine Interfaces. - This method is used to set default terminal output for - CommandLine Interfaces. However, setting this will not - update the output type for any existing instances. For these, + This method is used to set default terminal output for + CommandLine Interfaces. However, setting this will not + update the output type for any existing instances. For these, assign the .inputs.terminal_output. """ diff --git a/nipype/interfaces/freesurfer/tests/test_auto_SampleToSurface.py b/nipype/interfaces/freesurfer/tests/test_auto_SampleToSurface.py index 23b145b323..db34a4c76f 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_SampleToSurface.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_SampleToSurface.py @@ -91,7 +91,7 @@ def test_SampleToSurface_inputs(): ), subject_id=dict(), subjects_dir=dict(), - surf_reg=dict(argstr='--surfreg', + surf_reg=dict(argstr='--surfreg %s', requires=['target_subject'], ), surface=dict(argstr='--surf %s', diff --git a/nipype/interfaces/freesurfer/utils.py b/nipype/interfaces/freesurfer/utils.py index 91cfb84d55..3b41fece15 100644 --- a/nipype/interfaces/freesurfer/utils.py +++ b/nipype/interfaces/freesurfer/utils.py @@ -89,8 +89,8 @@ class SampleToSurfaceInputSpec(FSTraitedSpec): subject_id = traits.String(desc="subject id") target_subject = traits.String(argstr="--trgsubject %s", desc="sample to surface of different subject than source") - surf_reg = traits.Bool(argstr="--surfreg", requires=["target_subject"], - desc="use surface registration to target subject") + surf_reg = traits.String(argstr="--surfreg %s", requires=["target_subject"], + desc="registration surface to target subject (default sphere.reg)") ico_order = traits.Int(argstr="--icoorder %d", requires=["target_subject"], desc="icosahedron order when target_subject is 'ico'") @@ -1276,4 +1276,4 @@ def _gen_outfilename(self): return os.path.abspath(self.inputs.out_file) else: _, name, ext = split_filename(self.inputs.in_file) - return os.path.abspath(name + '_smoothed' + ext) \ No newline at end of file + return os.path.abspath(name + '_smoothed' + ext) diff --git a/nipype/testing/data/von_errmap.nii.gz b/nipype/testing/data/von_errmap.nii.gz index 8e79a46d12..86df607393 100644 Binary files a/nipype/testing/data/von_errmap.nii.gz and b/nipype/testing/data/von_errmap.nii.gz differ diff --git a/nipype/utils/nipype_cmd.py b/nipype/utils/nipype_cmd.py index 2b514e54d8..e2ae758354 100644 --- a/nipype/utils/nipype_cmd.py +++ b/nipype/utils/nipype_cmd.py @@ -19,7 +19,7 @@ def add_options(parser=None, module=None, function=None): if parser and module and function: __import__(module) interface = getattr(sys.modules[module],function)() - + inputs = interface.input_spec() for name, spec in sorted(interface.inputs.traits(transient=None).items()): desc = "\n".join(interface._get_trait_desc(inputs, name, spec))[len(name)+2:] @@ -33,7 +33,7 @@ def add_options(parser=None, module=None, function=None): def run_instance(interface, options): if interface: print "setting function inputs" - + for input_name, _ in interface.inputs.items(): if getattr(options, input_name) != None: value = getattr(options, input_name) @@ -48,23 +48,23 @@ def run_instance(interface, options): value) except ValueError, e: print "Error when setting the value of %s: '%s'"%(input_name, str(e)) - + print interface.inputs res = interface.run() - print res.outputs + print res.outputs def main(argv): - + if len(argv) == 2 and not argv[1].startswith("-"): listClasses(argv[1]) sys.exit(0) - + parser = argparse.ArgumentParser(description='Nipype interface runner', prog=argv[0]) parser.add_argument("module", type=str, help="Module name") parser.add_argument("interface", type=str, help="Interface name") parsed = parser.parse_args(args=argv[1:3]) - + _, prog = os.path.split(argv[0]) interface_parser = argparse.ArgumentParser(description="Run %s"%parsed.interface, prog=" ".join([prog] + argv[1:3])) interface_parser, interface = add_options(interface_parser, parsed.module, parsed.interface) diff --git a/nipype/utils/tests/test_cmd.py b/nipype/utils/tests/test_cmd.py index 55347ff4b9..894569ded3 100644 --- a/nipype/utils/tests/test_cmd.py +++ b/nipype/utils/tests/test_cmd.py @@ -22,24 +22,24 @@ def test_main_returns_2_on_empty(self): with self.assertRaises(SystemExit) as cm: with capture_sys_output() as (stdout, stderr): nipype_cmd.main(['nipype_cmd']) - + exit_exception = cm.exception self.assertEqual(exit_exception.code, 2) - - self.assertEqual(stderr.getvalue(), + + self.assertEqual(stderr.getvalue(), """usage: nipype_cmd [-h] module interface nipype_cmd: error: too few arguments """) self.assertEqual(stdout.getvalue(), '') - + def test_main_returns_0_on_help(self): with self.assertRaises(SystemExit) as cm: with capture_sys_output() as (stdout, stderr): nipype_cmd.main(['nipype_cmd', '-h']) - + exit_exception = cm.exception self.assertEqual(exit_exception.code, 0) - + self.assertEqual(stderr.getvalue(), '') self.assertEqual(stdout.getvalue(), """usage: nipype_cmd [-h] module interface @@ -53,15 +53,15 @@ def test_main_returns_0_on_help(self): optional arguments: -h, --help show this help message and exit """) - + def test_list_nipy_interfacesp(self): with self.assertRaises(SystemExit) as cm: with capture_sys_output() as (stdout, stderr): nipype_cmd.main(['nipype_cmd', 'nipype.interfaces.nipy']) - + exit_exception = cm.exception self.assertEqual(exit_exception.code, 0) - + self.assertEqual(stderr.getvalue(), '') self.assertEqual(stdout.getvalue(), """Available Interfaces: @@ -77,10 +77,10 @@ def test_run_4d_realign_without_arguments(self): with self.assertRaises(SystemExit) as cm: with capture_sys_output() as (stdout, stderr): nipype_cmd.main(['nipype_cmd', 'nipype.interfaces.nipy', 'FmriRealign4d']) - + exit_exception = cm.exception self.assertEqual(exit_exception.code, 2) - + self.assertEqual(stderr.getvalue(), """usage: nipype_cmd nipype.interfaces.nipy FmriRealign4d [-h] [--between_loops BETWEEN_LOOPS] @@ -95,15 +95,15 @@ def test_run_4d_realign_without_arguments(self): nipype_cmd nipype.interfaces.nipy FmriRealign4d: error: too few arguments """) self.assertEqual(stdout.getvalue(), '') - + def test_run_4d_realign_help(self): with self.assertRaises(SystemExit) as cm: with capture_sys_output() as (stdout, stderr): nipype_cmd.main(['nipype_cmd', 'nipype.interfaces.nipy', 'FmriRealign4d', '-h']) - + exit_exception = cm.exception self.assertEqual(exit_exception.code, 0) - + self.assertEqual(stderr.getvalue(), '') self.assertTrue("Run FmriRealign4d" in stdout.getvalue())