Skip to content

Commit 3f2612a

Browse files
committed
update documentation
1 parent 8ef4d64 commit 3f2612a

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

doc/users/interface_tutorial.rst

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
Tutorial : Interfaces
55
=======================
66

7-
Specifying options
8-
------------------
7+
Specifying input settings
8+
-------------------------
99

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
1313
the fsl module, the class :class:`nipype.interfaces.fsl.Bet` wraps the
1414
``bet`` command-line tool. Using the command-line tool, one would
15-
specify options using flags like ``-o``, ``-m``, ``-f <f>``, etc...
15+
specify input settings using flags like ``-o``, ``-m``, ``-f <f>``, etc...
1616
However, in nipype, options are assigned to Python attributes and can
1717
be specified in the following ways:
1818

19-
Options can be assigned when you first create an interface object:
19+
Settings can be assigned when you first create an interface object:
2020

2121
.. testcode::
2222

2323
import nipype.interfaces.fsl as fsl
2424
mybet = fsl.BET(in_file='foo.nii', out_file='bar.nii')
2525
result = mybet.run()
2626

27-
Options can be assigned through the ``inputs`` attribute:
27+
Settings can be assigned through the ``inputs`` attribute:
2828

2929
.. testcode::
3030

@@ -34,14 +34,53 @@ Options can be assigned through the ``inputs`` attribute:
3434
mybet.inputs.out_file = 'bar.nii'
3535
result = mybet.run()
3636

37-
Options can be assigned when calling the ``run`` method:
37+
Settings can be assigned when calling the ``run`` method:
3838

3939
.. testcode::
4040

4141
import nipype.interfaces.fsl as fsl
4242
mybet = fsl.BET()
4343
result = mybet.run(in_file='foo.nii', out_file='bar.nii', frac=0.5)
4444

45+
Settings can be saved to a json file:
46+
47+
.. testcode::
48+
49+
import nipype.interfaces.fsl as fsl
50+
mybet = fsl.BET(in_file='foo.nii', out_file='bar.nii', frac=0.5)
51+
mybet.save_inputs_to_json('bet-settings.json')
52+
53+
Once saved, the three inputs set for `mybet` will be stored in a JSON
54+
file. These settings can also be loaded from a json file:
55+
56+
.. testcode::
57+
58+
import nipype.interfaces.fsl as fsl
59+
mybet = fsl.BET()
60+
mybet.load_inputs_from_json('bet-settings.json', overwrite=False)
61+
62+
63+
Loading settings will overwrite previously set inputs by default, unless
64+
the `overwrite` argument is `False`. Conveniently, the settings can be
65+
also read during the interface instantiation:
66+
67+
.. testcode::
68+
69+
import nipype.interfaces.fsl as fsl
70+
mybet = fsl.BET(from_file='bet-settings.json')
71+
72+
If the user provides settings during interface creation, they will take
73+
precedence over those loaded using `from_file`:
74+
75+
.. testcode::
76+
77+
import nipype.interfaces.fsl as fsl
78+
mybet = fsl.BET(from_file='bet-settings.json', frac=0.7)
79+
80+
In this case, `mybet.inputs.frac` will contain the value `0.7` regardless
81+
the value that could be stored in the `bet-settings.json` file.
82+
83+
4584
Getting Help
4685
------------
4786

0 commit comments

Comments
 (0)