Hello, I am trying to automate some processes which use the modules pseudoLMGenerator and ALPACA but cannot find any of the functions which are available in the GUI.
For example if I try and set the base mesh in the pseudoLMGenerator I expected to find something along the lines of:
slicer.modules.pseudolmgenerator.logic().setBaseMesh() but not such function or anything similar is available after inputting slicer.modules.pseudolmgenerator.logic().
I have similar issues when trying to automate the ALPACA module also. My question is, is it possible to automate all GUI functions through python scripting and if so how do I find the documentation describing the correct syntax for scripting for these particular modules?
Thanks in advance for any help. Happy to provide further details/screenshots if needed.
It is possible to automate ALPACA and the pseudoLMGenerator. You will need to read through the moduleās code to see how to do this, but in general:
parameters such as input files/folders set in the GUI will be defined in the setup() function of the widget class
the widget class contains functions that handle GUI interactions, such as button presses
the logic class contains functions to run the algorithms. The input parameters can be passed directly, without needing to set GUI parameters.
For the PseudoLMGenerator module, there are multiple steps run by separate button presses. Looking at the button callbacks, you will find the logic functions called and input/output arguments.
ALPACA can be run in batch mode using a single call to the logic function here.
Iām happy to help here with any specific questions. You also might find these tutorials helpful.
To define the base mesh I try the following command:
slicer.modules.PseudoLMGeneratorWidget.modelSelector(modelNode)
Where modelNode is a loaded model. However I am met with the following error:
Traceback (most recent call last):
File āā, line 1, in
TypeError: āqMRMLNodeComboBoxā object is not callable
Would you be able to give example code on defining the base model for the pseudoLMGenerator followed by executing the āget subsample numberā command? Many thanks for your help!
You wonāt need to set the widget elements, like the modelSelector to automate this module. The steps you will need are in the button callback functions.
I can help you with a code snippet, but first can you give me an idea of what you are trying to do? In a typical workflow, pseudo-landmarks are placed only once on an atlas model and transferred to other specimens using ALPACA or projectSemiLM. Both of these modules preserve the relationship between the pseudo-landmarks, which running the pseudoLMGenerator multiple times can not do.
I am trying to generate pseudo landmarks for a mesh which are then used for input as āSource Landmarksā in the ALPACA registration process. I have managed to do the entire process manually using the GUI but it is automating the process that is eluding me.
You mention button callback functions, where would I find documentation/examples of these functions?
To put it another way, would you be able to give example code that is able to execute all the actions demonstrated in the following slicermorph youtube tutorials using the python interface?