Skip to content

Commit 16b949f

Browse files
committed
Cleanup of AverageImages.
1 parent 035c308 commit 16b949f

File tree

2 files changed

+18
-76
lines changed

2 files changed

+18
-76
lines changed
Lines changed: 18 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
"""
4+
Change directory to provide relative paths for doctests
5+
>>> import os
6+
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
7+
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
8+
>>> os.chdir(datadir)
9+
10+
"""
311
# Standard library imports
412
import os
513

614
# Local imports
7-
from ..base import (TraitedSpec, File, traits, InputMultiPath, OutputMultiPath, isdefined)
8-
from ...utils.filemanip import split_filename
15+
from ..base import TraitedSpec, File, traits, InputMultiPath
916
from .base import ANTSCommand, ANTSCommandInputSpec
1017

1118
class AverageImagesInputSpec(ANTSCommandInputSpec):
1219
dimension = traits.Enum(3, 2, argstr='%d', usedefault=False, mandatory=True, position=0, desc='image dimension (2 or 3)')
1320
output_average_image = File(argstr='%s', mandatory=True, position=1, desc='Outputfname.nii.gz: the name of the resulting image.')
14-
normalize = traits.Enum(0, 1, argstr="%s", mandatory=True, position=2, desc='Normalize: 0 (false) or 1 (true); if true, the 2nd image' +
21+
normalize = traits.Bool(argstr="%d", mandatory=True, position=2, desc='Normalize: if true, the 2nd image' +
1522
'is divided by its mean. This will select the largest image to average into.')
1623
images = InputMultiPath(File(exists=True), argstr='%s', mandatory=True, position=3, desc=('image to apply transformation to (generally a coregistered functional)') )
1724

@@ -22,7 +29,13 @@ class AverageImages(ANTSCommand):
2229
"""
2330
Examples
2431
--------
25-
>>>
32+
>>> avg = AverageImages()
33+
>>> avg.inputs.dimension = 3
34+
>>> avg.inputs.output_average_image = "average.nii.gz"
35+
>>> avg.inputs.normalize = True
36+
>>> avg.inputs.images = ['rc1s1.nii', 'rc1s1.nii']
37+
>>> avg.cmdline
38+
'AverageImages 3 average.nii.gz 1 rc1s1.nii rc1s1.nii'
2639
"""
2740
_cmd = 'AverageImages'
2841
input_spec = AverageImagesInputSpec
@@ -34,49 +47,4 @@ def _format_arg(self, opt, spec, val):
3447
def _list_outputs(self):
3548
outputs = self._outputs().get()
3649
outputs['output_average_image'] = os.path.realpath(self.inputs.output_average_image)
37-
return outputs
38-
39-
"""
40-
Usage:
41-
42-
AverageImages ImageDimension Outputfname.nii.gz Normalize <images>
43-
44-
=======================================================================
45-
46-
Compulsory arguments:
47-
48-
ImageDimension: 2 or 3 (for 2 or 3 dimensional input).
49-
50-
Outputfname.nii.gz: the name of the resulting image.
51-
52-
Normalize: 0 (false) or 1 (true); if true, the 2nd image is divided by
53-
its mean. This will select the largest image to average into.
54-
55-
-h
56-
Print the help menu (short version).
57-
<VALUES>: 0
58-
59-
--help
60-
Print the help menu.
61-
<VALUES>: 0
62-
63-
=======================================================================
64-
65-
How to run the test case:
66-
67-
cd {TEST_DATA}/EXPERIEMENTS/ANTS_NIPYPE_SMALL_TEST
68-
{BINARIES_DIRECTORY}/bin/AverageImages \
69-
3 \
70-
average.nii.gz \
71-
1 \
72-
*.nii.gz
73-
74-
=======================================================================
75-
76-
Change directory to provide relative paths for doctests
77-
>>> import os
78-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
79-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
80-
>>> os.chdir(datadir)
81-
82-
"""
50+
return outputs

nipype/interfaces/ants/tests/test_AverageImages.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)