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!
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!
See an example here:
Thank you, Andras.
However, I do not see in this example any place calling slicer.modules.segmentlungairways. Am I missing something?
Thanks again.
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.
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)
If any error occurs then you can find it in the application log.
I would also suggest to check out this documentation section. In particular, run the Get list of parameter names script to verify that the module name and all parameter names are correct.
I got the CLI call working like this in 4.13:
# 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)