Hi,
I followed this tutorial on how to use existing modules in slicer through cli library:
It sounds not bad (considering my understanding in cli is close to 0…)
Anyway, since I want to use registration module (such as BRAINSfit) I’d like to have the option to cancel the operation after running it. but the cli cancel command is not implemented yet in the cli.py file that I’ve found.
so my questions:
- Is using slicer.cli is a good way execute existing modules proggramatically? If not- what is?
- How can I cancel the running process with cli?
Thanks!
Here is part of the code- the apply btton, executing the add Scalar Volume module (but can’t stop in the middle):
def onApplyButton(self):
# allow cancel the process
if self.InProgress:
self.InProgress = False
self.abortRequested = True
raise ValueError("User requested cancel.")
# self.cliNode.cancel() # not implemented
self.applyutton.text = "Cancelling..."
self.applyButton.enabled = False
return
self.InProgress = True
self.applyButton.text = "Cancel"
fixedImage = self.fixedSelector.currentNode()
movingImage = self.moveImgSelector.currentNode()
outputImage = self.outputSelector.currentNode()
if self.registratoinMethod == 'addScalarVolumes':
moduleVar = slicer.modules.addscalarvolumes
parameters = {}
parameters["inputVolume1"] = fixedImage.GetID()
parameters["inputVolume2"] = movingImage.GetID()
parameters["outputVolume"] = outputImage.GetID()
parameters["interpolation order"] = 0
# get the module as object
slicer.app.processEvents()
self.cliNode = slicer.cli.run(moduleVar,None, parameters)
print self.cliNode.cancel.
self.bar.setCommandLineModuleNode(self.cliNode)
# logic.run(self.fixedSelector.currentNode(),
# self.outputSelector.currentNode())
# logic.run(fixedImage,movingImage,outputImage)
# make the output volume appear in all the slice views
slicer.util.setSliceViewerLayers(
background=outputImage)