2010 Winter Project Week Command Line Module Simple Return Types

From NAMIC
Jump to: navigation, search
Home < 2010 Winter Project Week Command Line Module Simple Return Types

Key Investigators

  • GE: Jim Miller

Objective

Extend the Command Line Module infrastructure to allow for simple return types (int, scalar, string).




Approach, Plan

  • Use a single wrapper to collect all the simple return values in a key:value pair format.
  • Receive the key:value wrapper from executables, shared libraries, and python
  • Display the output values in the GUI as non-editable items

Need to coordinate this with the Qt port.


Progress

  • Discussed designs with Andriy and Bill
  • Concerned about adding this while the Qt port is ongoing
  • Failed to entice Bill to do this for me this week


Update

Since the Winter Project Week, I have been able send simple Return Parameters from a Command Line Module to Slicer. Types supported include integer, float, double, string, boolean, integer-vector, float-vector, double-vector, string-vector, integer-enumeration, float-enumeration, double-enumeration, and string-enumeration.

Specifying a Return Parameter

Return Parameters are specified in the Module Description XML. They have no "flag", no "long flag", and no "index". They have a "channel" of "output".

   <float>
     <name>afloatreturn</name>
     <label>A floating point return value</label>
     <channel>output</channel>
     <default>7.0</default>
     <description>An example of a float return type</description>
   </float>


Using a Return Parameter

An extra parameter is passed to the module "--returnparameterfile" that is the filename in which to write Return Parameters. Format of the file is one line per parameter, with the line specified as "name = value", where "name" is the name of the parameter in the XML Module Description file.

 std::ofstream rts;
 rts.open(returnParameterFile.c_str());
 rts << "afloatreturn = 34.2" << std::endl;
 rts.close();

User interface for Return Parameters

Return Parameters appear in the Module GUI side panel like any other parameter. The difference is that they cannot be modified by the user. The values are updated when the module completes.


Modifications

Most of the Command Line Module infrastructure was modified to support Return Parameter: ModuleDescriptionParser, GenerateCPL, CommandLineModule, SlicerApplicationLogic.

Next steps

  • Points and regions
  • Separate nodes in MRML for primitive types?

References