Scripts typically have parameters that one would like to change while leaving the core of the code untouched. Examples for such changable parameteres are the input image file and image processing parameters such as filter sizes and thresholds. It is very important to learn how to “expose” such parameters in ways that do not require digging into and modifying the actual code too much.
Prerequisites
Before starting this lesson, you should be familiar with:
Generally, what could be the pros and cons (considerations) of the different ways (see figure and concept map) in which scripting parameters can be handled?
Specifically, what are the pros and cons of using UI elements for fetching parameters?
Solution
This is a complex topic. Considerations could be: (i) How can I keep track which images were analyzed with which parameters? (ii) How can I ensure that users of my script use valid parameters? (iii) How experienced are the users of my script (e.g. would they be able to modify the script itself)? (iv) If the script itself is modified when changing a parameter, how do I keep track of the different “versions” of the script?
Pro: UI elements typically allow you to restrict the input values to a valid range and it makes your script easy to use for people without programming experience. Con: Every time you want to run the script you have to interact with the UI and, unless you implement something special, you don’t keep track which parameters were used to run the script.