Created a module using extension wizard, however, the self.applyButton in Widget class is always disabled. I use PyCharm to debug, and in the function
‘’’
def onSelect(self):
self.applyButton.enabled = self.inputSelector.currentNode() and self.outputSelector.currentNode()
‘’’
when a new volume is loaded, the function onSelect is triggered, both inputSelector and outputSelector are not null. However, I could never see the applyButton enabled.
Why couldn’t the applyButton be enabled?
How should I enable it? Or should I change the code?
I would recommend to use the latest “scripteddesigner” module template. GUI state updates should be more clear now. If you have any questions about this latest template then let us know.
If you want to keep using the old template then adding a breakpoint in PyCharm execute the code step-by-step is a good way to understand what your code does (and why it is not the same what you expect).
The latest template you recommended using UI framework seems even harder to understand. Any resource as a tutorial showing how to build a customerized template?
I am more familiar with qt commands without using UI, do you have any tutorial explanation for the template without UI, please?
Maybe you have checked an earlier version? ScriptedDesigner template was already quite well documented, but I added even more comments. If anything is still unclear then let me know.
We have found that using a .ui file for creating GUI makes the GUI easier to design and the code easier to debug and maintain. If you are not familiar with it then check out this tutorial.
In the extension wizard template, the run function in Logic class was commented as “run the actual algorithm”, but there is not much explanation about how the thresholded output volume was calculated:
The example shows how to run a CLI module from Python. See more information about CLI modules in general in the Slicer developer tutorials, and more details about how to run them and how to get their input/output parameters are available here. Source code of CLI modules bundled with Slicer are available here.
You can run any other processing using VTK, SimpleITK, numpy, various Slicer modules provided by extensions, and any Python packages. See a variety of examples in the script repository.
Thank you for providing the link to the code of thresholdscalarvolume module!
Is the link below where I should investigate for the algorithm of ThresholdScalarVolume?
It seems that the module does not contain any comments, and I was not able to find out how the threshold was applied.
Most CLI modules use ITK filters to process data. You can find documentation, examples, and source code by searching for the filter name on the web (e.g., itk::ThresholdImageFilter).
You can run ITK filters directly in Python using SimpleITK, which is bundled with Slicer. You can also implement trivial operations, such as image thresholding using numpy. These are all described in the PerkLab Slicer programming tutorial that I linked above.