Slicer/SlicerExecutionModel — pull request #20 by thewtex (2013-08-21 07:22:18+00:00)
Title: Parameter serializer support.

Motivation
----------

The ability to store, restore, and programmatically manipulate algorithm parameters has many benefits. The set of parameters used in an analysis can be archived for future reference or shared for reproducibility purposes. A collection of parameter sets tuned for particular types of input data can be stored and restored. If a standard file format with libraries easily accessible across programming languages is used to serialize the parameters, automated exploration of the parameter space is possible.

This branch adds command line flags to serialize and deserialize the parameters used by the Command Line Interface (CLI) in the JSON_ file format.

Building
--------

Check out the *ParameterSerializer* branch of this repository. During CMake configuration, set *SlicerExecutionModel_USE_SERIALIZER* to *ON* and the build paths to the jsoncpp-cmake_ and ParameterSerializer_ projects with *JsonCpp_DIR* and *ParameterSerializer_DIR*.

Implementation
--------------

Two new flags will be automatically added to all CLI's:

1) --parametersarchive
2) --parameterstorestore

The *--parametersarchive* flag specifies the path to a JSON file where all the parameters used in the current analysis will be **archived**. The *--parameterstorestore* flag specifies the path to a JSON file created by the *--parametersarchive* in a previous execution. Parameters from the previous execution will then be **restored** for the current analysis.

While the layout of the JSON file reflects the self-descriptive metadata of the CLI XML file, it also contains *Value* entries for each parameter.

Since parameters can be specified in different ways, an order of precedence determines which specification is used in the analysis. This order is, from highest to lowest:

1) Command line arguments.
2) Parameters restored from the JSON file.
3) The default parameter value in the CLI XML file.

Required parameters, such as positional arguments, currently must always be specified on the command line even if `--parameterstorestore` is given.

.. _SlicerExecutionModel: https://github.com/Slicer/SlicerExecutionModel
.. _JSON: http://www.json.org/
.. _jsoncpp-cmake: https://github.com/TubeTK/jsoncpp-cmake
.. _ParameterSerializer: https://github.com/TubeTK/TubeTK-ParameterSerializer