# CIP (chest imaging platform) module

**URL:** <https://discourse.slicer.org/t/cip-chest-imaging-platform-module/12125>\
**Category:** Support\
**Created:** [June 19, 2020, 11:16pm UTC](https://discourse.slicer.org/t/cip-chest-imaging-platform-module/12125 "2020-06-19T23:16:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![szhang](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@szhang](https://discourse.slicer.org/u/szhang)\
**Post date:** [June 19, 2020, 11:16pm UTC](https://discourse.slicer.org/t/cip-chest-imaging-platform-module/12125/1 "2020-06-19T23:16:11Z")

</div>

Hello,  
I would like to call the module segmentlungairways in a loadable module, but not sure what is the syntax and what parameters are needed. Could you please provide an example?

Thank you!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 20, 2020, 3:46am UTC](https://discourse.slicer.org/t/cip-chest-imaging-platform-module/12125/2 "2020-06-20T03:46:55Z")

</div>

See an example here:

> <https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/CropVolume/Logic/vtkSlicerCropVolumeLogic.cxx#L493-L595>

---

<div class="post-metadata">

**Author:** ![szhang](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@szhang](https://discourse.slicer.org/u/szhang)\
**Post date:** [June 20, 2020, 8:13pm UTC](https://discourse.slicer.org/t/cip-chest-imaging-platform-module/12125/3 "2020-06-20T20:13:54Z")

</div>

Thank you, Andras.  
However, I do not see in this example any place calling slicer.modules.segmentlungairways. Am I missing something?

Thanks again.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 20, 2020, 8:48pm UTC](https://discourse.slicer.org/t/cip-chest-imaging-platform-module/12125/4 "2020-06-20T20:48:19Z")

</div>

You can run any other CLI modules the same way, you just change the module name and parameters.

To get started, I would recommend to write Python scripted modules, as the Python syntax is much simpler and you don’t need to rebuild anything and restart Slicer if you make changes.

---

<div class="post-metadata">

**Author:** ![szhang](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@szhang](https://discourse.slicer.org/u/szhang)\
**Post date:** [June 20, 2020, 9:22pm UTC](https://discourse.slicer.org/t/cip-chest-imaging-platform-module/12125/5 "2020-06-20T21:22:23Z")

</div>

I have to admit I need more help here.  
How I used to call airwaysegmentationcli is as below, but a simple substitution of the module name to “segmentlungairway” produces no error and no result, so how to correctly call this module then?

> cliParams = {“inputVolume”: inputVolume.GetID(), “reconstructionKernelType”: convolutionKernel,  
> “label”: outputVolume.GetID(),“seed”: fiducialsList.GetID(),  
> “labelValue”: self.labelValue}  
> slicer.cli.run(slicer.modules.airwaysegmentationcli, None, cliParams, wait\_for\_completion = True)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 20, 2020, 9:36pm UTC](https://discourse.slicer.org/t/cip-chest-imaging-platform-module/12125/6 "2020-06-20T21:36:00Z")

</div>

If any error occurs then you can find it in the application log.

I would also suggest to check out this [documentation section](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Python_scripting#Running_a_CLI_from_Python). In particular, run the _Get list of parameter names_ script to verify that the module name and all parameter names are correct.

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [September 16, 2021, 7:47pm UTC](https://discourse.slicer.org/t/cip-chest-imaging-platform-module/12125/7 "2021-09-16T19:47:27Z")

</div>

I got the CLI call working like this in 4.13:

```auto
# Create labelmap
self.airwayLabelMap = slicer.util.getFirstNodeByClassByName("vtkMRMLLabelMapVolumeNode",
                "AirwayLabelMap")
if not self.airwayLabelMap:
    self.airwayLabelMap = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLLabelMapVolumeNode",
                    "AirwayLabelMap")
# Set parameters
parameters = {}
# CT
parameters["inputVolume"] = self.inputVolume
# define one fiducial in the trachea
parameters["seed"] = self.tracheaFiducials
# output labelmap
parameters["airwayLabel"] = self.airwayLabelMap

# Kernel type parameter
# STANDARD: Most details, but susceptible for leaks 
# LUNG: Less details, more robust concerning leaks
# B70f: Low detail level, very robust
parameters["reconstructionKernelType"] = "STANDARD"

# Execute
segmentAirways = slicer.modules.segmentlungairways
cliNode = slicer.cli.runSync(segmentAirways, None, parameters)
# Process results
if cliNode.GetStatus() & cliNode.ErrorsMask:
    # error
    errorText = cliNode.GetErrorText()
    slicer.mrmlScene.RemoveNode(cliNode)
    raise ValueError("CLI execution failed: " + errorText)
# success
slicer.mrmlScene.RemoveNode(cliNode)

```
