Overview
Forum
Mango
iMango
Papaya
Multi-image Analysis GUI
Download
User Guide
Developer Guide
Troubleshooting
Acknowledgements

Mango Script Tutorial — Recording With and Without User Input

<< Previous Tutorial — First Script Next Tutorial — Class Structure >>

There are two recording modes available: With User Input and Without User Input. The previous tutorial recorded a script in Without User Input mode. In this case, when recording the Threshold to ROI action, it recorded this:

boolean_result = m_VolMan_manager.runThresholdToROI(50.0,True,False,False,False)

Note that this recorded action requires 5 parameters to run. Looking at the API for this method, we see this:

runThresholdToROI(threshold, percentMax, excludeZero, makeSeriesROI, seriesUsesDynamicThreshold)
	
Adds new ROI mask data based on a threshold.

Args:
    threshold (float) : the threshold
    percentMax (bool) : true if the threshold represents percent of image maximum...
    excludeZero (bool) : true to exclude zero from calculation
    makeSeriesROI (bool) : true to make a series ROI
    seriesUsesDynamicThreshold (bool) : true only if percentMax is also true...
Returns:
    (bool) true if new ROI mask data was added, false otherwise

We can see that when this action was recorded, it included the arguments we selected, namely the Threshold (50.0) and the selection of the option Percent Max (True). But what about if you did not want to use these same parameters each time you ran the script?

To allow user input, we record the script in With User Input mode. If we record the same Threshold to ROI action in this mode, we would see the following:

boolean_result = m_VolMan_manager.runThresholdToROI(
    *getMultiInput(m_VolMan_manager,'runThresholdToROI',['threshold',
    'percentMax','excludeZero','makeSeriesROI','seriesUsesDynamicThreshold'],
    ['double','boolean','boolean','boolean','boolean'],[50.0,True,False,False,
    False]))

Note the additional script text and specifically the call to getMultiInput(). This use of getMultiInput() is what creates the user input dialog. The additional script text includes the names of the parameters, the types, and their default values — all information used by getMultiInput() to create the user input dialog. If we run this script, we see something like the following image.

Note that the dialog options default to the values selected when recording the script, but the script allows these values to be changed while the script is running. When this dialog is closed, it returns the required list of arguments and the action method is called.

However, not all actions are scriptable. For example, drawing a ROI with a paint tool cannot be scripted. What happens if I am recording a script and perform one of these actions? In this case, you will see the following script line recorded:

m_VolMan_manager.pauseScriptForUserInput()

When the script is played back and this script line is executed, you will see the following in the Toolbox. At this point, the script is paused and the user may perform manual actions before continuing the script. When ready, click the Continue Script button.

<< Previous Tutorial — First Script Next Tutorial — Class Structure >>