Skip to content

Commit a58af1f

Browse files
committed
Improved input options description.
1 parent e4ed610 commit a58af1f

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

nipype/utils/nipype_cmd.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,21 @@ def add_options(parser=None, module=None, function=None):
1919
if parser and module and function:
2020
__import__(module)
2121
interface = getattr(sys.modules[module],function)()
22-
23-
for k,v in interface.inputs.items():
24-
if hasattr(v, "mandatory") and v.mandatory:
25-
parser.add_argument(k, help=v.desc)
22+
23+
inputs = interface.input_spec()
24+
for name, spec in sorted(interface.inputs.traits(transient=None).items()):
25+
desc = "\n".join(interface._get_trait_desc(inputs, name, spec))[len(name)+2:]
26+
if hasattr(spec, "mandatory") and spec.mandatory:
27+
parser.add_argument(name, help=desc)
2628
else:
27-
parser.add_argument("--%s"%k, dest=k,
28-
help=v.desc)
29+
parser.add_argument("--%s"%name, dest=name,
30+
help=desc)
2931
return parser, interface
3032

3133
def run_instance(interface, options):
3234
if interface:
3335
print "setting function inputs"
36+
3437
for input_name, _ in interface.inputs.items():
3538
if getattr(options, input_name) != None:
3639
value = getattr(options, input_name)

nipype/utils/tests/test_cmd.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,31 +120,40 @@ def test_run_4d_realign_help(self):
120120
Run FmriRealign4d
121121
122122
positional arguments:
123-
in_file File to realign
124-
tr TR in seconds
123+
in_file (a list of items which are an existing file name) File
124+
to realign
125+
tr (a float) TR in seconds
125126
126127
optional arguments:
127128
-h, --help show this help message and exit
128129
--between_loops BETWEEN_LOOPS
129-
loops used to realign different runs
130+
(a list of items which are an integer, nipype default
131+
value: [5]) loops used to realign different runs
130132
--ignore_exception IGNORE_EXCEPTION
131-
Print an error message instead of throwing an
132-
exception in case the interface fails to run
133-
--loops LOOPS loops within each run
133+
(a boolean, nipype default value: False) Print an
134+
error message instead of throwing an exception in case
135+
the interface fails to run
136+
--loops LOOPS (a list of items which are an integer, nipype default
137+
value: [5]) loops within each run
134138
--slice_order SLICE_ORDER
135-
0 based slice order. This would be equivalent to
139+
(a list of items which are an integer) 0 based slice
140+
order. This would be equivalent to
136141
enteringnp.argsort(spm_slice_order) for this field.
137142
This effectsinterleaved acquisition. This field will
138143
be deprecated infuture Nipy releases and be replaced
139-
by actual sliceacquisition times.
140-
--speedup SPEEDUP successive image sub-sampling factors for acceleration
141-
--start START time offset into TR to align slices to
144+
by actual sliceacquisition times. requires:
145+
time_interp
146+
--speedup SPEEDUP (a list of items which are an integer, nipype default
147+
value: [5]) successive image sub-sampling factors for
148+
acceleration
149+
--start START (a float, nipype default value: 0.0) time offset into
150+
TR to align slices to
142151
--time_interp TIME_INTERP
143-
Assume smooth changes across time e.g., fmri series.
144-
If you don't want slice timing correction set this to
145-
undefined
152+
(True) Assume smooth changes across time e.g., fmri
153+
series. If you don't want slice timing correction set
154+
this to undefined requires: slice_order
146155
--tr_slices TR_SLICES
147-
TR slices
156+
(a float) TR slices requires: time_interp
148157
""")
149158

150159

0 commit comments

Comments
 (0)