Access color table in CLI module

One more question…

I noticed that the colormaps have an attribute “reference” in the tag “table” but I couldn’t find a way to access it.

<table hidden="true" type="color" reference="InputVolume">
  <name>ColorTable</name>
  <channel>input</channel>
  <longflag>color</longflag>
  <description><![CDATA[Color table to make labels to colors and objects]]></description>
</table>

I thought we could use the same method than for the other attributes like the file extension. But there is no GetParameterReference(int, int) function and the vtkMRMLCommandLineModuleNode.GetModuleDescription() is not available for python. The only thing I found is vtkMRMLCommandLineModuleNode.GetModuleDescriptionAsString() but it needs a way to structure the string to be parsed.

Any thoughts?

Colormap is an input to the CLI module. It is used for passing colormap with labelmap volumes. This allows the CLI to get label name corresponding to a voxel value.

Hi Andras, my question was more about how to get the labelmap node relative to a colormap given in a CLI command. I know it is possible in C++ but I could not find a way to do it in python.

CLI infrastructure sets the labelmap node automatically from the colormap node that you set in the display node of the volume node (volumeNode->GetDisplayNode()->SetAndObserveColorNodeID(…)).

Actually, this is why this post was in the previous post, because there is a context behind that. I am not trying to run the CLI from the regular CLI infrastructure but I am trying to create the command, send it to a database and run it remotely.

I was able to access the colormap knowing the labelmap node:
saveNode(getNode('MyLabelMap').GetDisplayNode().GetColorNode(), "myPath.txt")

But, in the example of Model Maker, there is a reference attribute in the xml file. This attribute says which LabelMapNode looking for to get the colormap. And I can’t access the reference attribute.

In the CLI you don’t get the reference attribute value, as MRML node IDs only make sense in a specific scene. Instead, you get the filename of the saved colormap node that is associated with the volume defined by reference attribute.

I noticed two different behaviors:

  • If you parse the CLI parameters without having run the CLI before, the colormap parameter has an empty value.
  • If you run the CLI and then try to parse the parameters, the colormap parameter has, as you said, the filename of the save colormap. (Which is enough for what I want)

I don’t really want to have to previously run the CLI and then generate a right command.

CLI node is for running CLIs. If you don’t want to run a CLI then you can get the information directly from the nodes in the scene.

If you need a better solution then please describe what exactly you would like to achieve as an end result, and then we can help better in figuring out how to get there.

2 posts were split to a new topic: Running CLI modules on a remote server