How can I write a python CLI code using slicer internal module

CLI modules are Python scripts or command-line applications that do not rely on Slicer. They can be executed within Slicer’s environment or without Slicer. What Slicer offers is displaying automatically-generated GUI, writing all inputs to file, executing the application, continuous progress reporting, and in the end reading back all outputs into the scene.

The automatically generated GUI is typically convenient enough for development, testing, and research/engineering use. For clinical use, often a Python scripted loadable module is developed as a front-end, which provides a more sophisticated GUI and calls the CLI module in the background.

To designate an output image as labelmap, specify type="label", as it is done for example in ModelToLabelMap module:

2 Likes