@@ -10,7 +10,7 @@ Specifying input settings
10
10
The nipype interface modules provide a Python interface to external
11
11
packages like FSL _ and SPM _. Within the module are a series of Python
12
12
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
14
14
``bet `` command-line tool. Using the command-line tool, one would
15
15
specify input settings using flags like ``-o ``, ``-m ``, ``-f <f> ``, etc...
16
16
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
81
81
the value that could be stored in the ``bet-settings.json `` file.
82
82
83
83
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
+
84
147
Getting Help
85
148
------------
86
149
0 commit comments