CommandLineParsing

From NAMIC Wiki
Revision as of 13:29, 18 December 2006 by Andy (talk | contribs) (Update from Wiki)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Home < CommandLineParsing

Abstract

The purpose of this proposal is to facilitate a "run-everywhere" philosophy for algorithm writers. If NAMIC adopts a standard for algorithm "self-description" that is followed when command line executables are written, Slicer, the grid, clusters, etc... should be able to use the executables directly in their environment.


Proposal

If we adopt a standard XML description of the parameters to the algorithm, any application should be able to parse the XML and construct a GUI suitable for interaction with the software.

Here is the an example of the proposed XML format, with suitable comments.


<?xml version="1.0" encoding="utf-8"?>
<executable class="register">
  <name>Register3d</name>
  <version>1.0</version>
  <description>This registers and resamples two images</description>

  <parameters>
    <switch name="interpolate" flag="i" default="true" required="false">
      <description></description>
    </switch>

    <value name="metric" flag="m" default="mattes" required="false" type="string">
      <description></description>
      <constraints>
        <list>
          <constraint>mattes</constraint>
          <constraint>mi</constraint>
          <constraint>normalizedcorrelation</constraint>
        </list>
      </constraints>
    </value>

    <value name="threshold" flag="t" type="integer">
      <constraints>
        <range minimum="0" maximum="100"/>
      </constraints>
    </value>

    <value name="iterations" flag="e" type="iteration" allowrepeats="true">
      <constraints>
        <range minimum="1"/>
      </constraints>
    </value>

    <xor>
      <value name="file" flag="f" type="filename"/>
      <value name="url" flag="u"/>
    </xor>

    <unlabeledvalue name="fixedimage" position="0" type="filename"/>
    <unlabeledvalue name="movingimage" position="1" type="filename"/>
    <unlabeledvalue name="outputimage" position="2" type="filename"/>
  </parameters>
</executable>

Related Work

MetaCommand

Julien Jomier and Stephen Aylward have added support for command line parsing to itk with the MetaCommand class (Utilities/MetaIO/metaCommand.{h,cxx}). It supports a -xml flag to output args in an xml syntax.

Qt Designer XML Format

Qt has an xml syntax for representing their GUI layouts. It's unclear if this tool could be used to design layouts used by other GUI packages.

ParaView Server

ParaView has a syntax to extend the GUI described on their wiki here.

LONI Pipeline

Parameters to executables are described in an XML file as part of the process of wrapping them for the pipeline.