Skip to content

Commit 8b08f90

Browse files
committed
update documentation
1 parent 1d22038 commit 8b08f90

File tree

2 files changed

+67
-4
lines changed

2 files changed

+67
-4
lines changed

doc/users/interface_tutorial.rst

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Specifying input settings
1010
The nipype interface modules provide a Python interface to external
1111
packages like FSL_ and SPM_. Within the module are a series of Python
1212
classes which wrap specific package functionality. For example, in
13-
the fsl module, the class :class:`nipype.interfaces.fsl.Bet` wraps the
13+
the fsl module, the class :class:`nipype.interfaces.fsl.BET` wraps the
1414
``bet`` command-line tool. Using the command-line tool, one would
1515
specify input settings using flags like ``-o``, ``-m``, ``-f <f>``, etc...
1616
However, in nipype, options are assigned to Python attributes and can
@@ -81,6 +81,69 @@ In this case, ``mybet.inputs.frac`` will contain the value ``0.7`` regardless
8181
the value that could be stored in the ``bet-settings.json`` file.
8282

8383

84+
Controlling the standard output and error
85+
-----------------------------------------
86+
87+
It is very likely that the software wrapped within the interface writes
88+
to the standard output or the standard error of the terminal.
89+
Interfaces provide a means to access and retrieve these outputs, by
90+
using the ``terminal_output`` attribute: ::
91+
92+
import nipype.interfaces.fsl as fsl
93+
mybet = fsl.BET(from_file='bet-settings.json')
94+
mybet.terminal_output = 'file_split'
95+
96+
In the example, the ``terminal_output = 'file_split'`` will redirect the
97+
standard output and the standard error to split files (called
98+
``stdout.nipype`` and ``stderr.nipype`` respectively).
99+
The possible values for ``terminal_output`` are:
100+
101+
*file*
102+
Redirects both standard output and standard error to the same file
103+
called ``output.nipype``.
104+
Messages from both streams will be overlapped as they arrive to
105+
the file.
106+
107+
*file_split*
108+
Redirects the output streams separately, to ``stdout.nipype``
109+
and ``stderr.nipype`` respectively, as described in the example.
110+
111+
*file_stdout*
112+
Only the standard output will be redirected to ``stdout.nipype``
113+
and the standard error will be discarded.
114+
115+
*file_stderr*
116+
Only the standard error will be redirected to ``stderr.nipype``
117+
and the standard output will be discarded.
118+
119+
*stream*
120+
Both output streams are redirected to the current logger printing
121+
their messages interleaved and immediately to the terminal.
122+
123+
*allatonce*
124+
Both output streams will be forwarded to a buffer and stored
125+
separately in the `runtime` object that the `run()` method returns.
126+
No files are written nor streams printed out to terminal.
127+
128+
*none*
129+
Both outputs are discarded
130+
131+
In all cases, except for the ``'none'`` setting of ``terminal_output``,
132+
the ``run()`` method will return a "runtime" object that will contain
133+
the streams in the corresponding properties (``runtime.stdout``
134+
for the standard output, ``runtime.stderr`` for the standard error, and
135+
``runtime.merged`` for both when streams are mixed, eg. when using the
136+
*file* option). ::
137+
138+
import nipype.interfaces.fsl as fsl
139+
mybet = fsl.BET(from_file='bet-settings.json')
140+
mybet.terminal_output = 'file_split'
141+
...
142+
result = mybet.run()
143+
result.runtime.stdout
144+
' ... captured standard output ...'
145+
146+
84147
Getting Help
85148
------------
86149

doc/users/saving_workflows.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,20 @@ This will create a file "outputtestsave.py" with the following content:
8282
bet2.inputs.environ = {'FSLOUTPUTTYPE': 'NIFTI_GZ'}
8383
bet2.inputs.ignore_exception = False
8484
bet2.inputs.output_type = 'NIFTI_GZ'
85-
bet2.inputs.terminal_output = 'stream'
85+
bet2.terminal_output = 'stream'
8686
# Node: testsave.bet
8787
bet = Node(BET(), name="bet")
8888
bet.iterables = ('frac', [0.3, 0.4])
8989
bet.inputs.environ = {'FSLOUTPUTTYPE': 'NIFTI_GZ'}
9090
bet.inputs.ignore_exception = False
9191
bet.inputs.output_type = 'NIFTI_GZ'
92-
bet.inputs.terminal_output = 'stream'
92+
bet.terminal_output = 'stream'
9393
# Node: testsave.maths
9494
maths = Node(ImageMaths(), name="maths")
9595
maths.inputs.environ = {'FSLOUTPUTTYPE': 'NIFTI_GZ'}
9696
maths.inputs.ignore_exception = False
9797
maths.inputs.output_type = 'NIFTI_GZ'
98-
maths.inputs.terminal_output = 'stream'
98+
maths.terminal_output = 'stream'
9999
testsave.connect(bet2, ('mask_file', func), maths, "in_file2")
100100
testsave.connect(bet, "mask_file", maths, "in_file")
101101
testsave.connect(testfunc, "output", maths, "op_string")

0 commit comments

Comments
 (0)