3-14. The batch processing commands
3-14-1. What is batch processing ?
3-14-1. What is batch processing ?
When you have to carry out the same operations with multiple sets of data, it is fastidious and inefficient to do it one-by-one. MUSTIG allows to define a script to perform these repetitive operations automatically. MUSTIG batch scripts are able to automatically alter the parameters of an algorithm, reinitialize, calculate and print image windows (see Image windows), and switch between DSP and PC processors (DSP version only). The batch processing script may call several MUSTIG programs if necessary.
3-14-2. Creating a Batch script
The batch script module is inside the "<->" box in the library. Slide it to your program window.
This Batch box may be renamed like any other macro to be given a more explicit name (Optimize parameters, acquire data, etc.). You may also delete the name and paste an icon previously copied into the clipboard using a specific software : this allows to create custom active buttons and add a "professional" touch to your applications (PC only).
If the Batch box is renamed into autoexec, it runs automatically when the MUSTIG program is opened. This allows to automatically launch an application (e.g. a data acquisition run) by just opening the program (Windows users just have to double-click on the program from the explorer to directly launch to application).
Open The Batch module with a double click : a blank window appears. Shift+Ctrl+Click in this window to enter the edit mode, and write the batch processing script. When you're done, click anywhere outside the window to exit the text edit mode.
The syntax of the script is then checked by MUSTIG. If syntax errors are detected, an error message is displayed.
If an error occurs while the Batch script is being executed (e.g. unknown label or Image window), the Batch processing stops and the breakpoint is selected in the Batch script window.
The input data (either scalar or string) that are likely to be altered by the batch processing script must be given a label to distinguish them (see Labeling pins). The name of the label is used in the batch processing script to refer to this input data. It must be unique.
The general syntax to change an input value during batch processing is :
"label name" = value
Relative changes can also be made using the following instructions :
"label name" += increment_value
"label name" -= decrement_value
"label name" *= multiplicative_factor
"label name" /= division_factor
Only image windows can be processed during batch processing. The general syntax to launch a command is :
COMMAND "Name of the Image Window"
A complete list of commands is available (see complete list of Batch processing commands) or in the online help of the batch module (Alt+H shortcut).
When you have to study the effect of a wide range of parameters, it is often very efficient to write loops. The general syntax for loops in MUSTIG batch processing scripts is :
Number_of_loops {
….
commands
…
}
3-14-4. Example of batch processing script
The following simple program generates a white noise signal of given length and calculates the energy of the signal (sum of the squared samples) :
An image window has been sled into the program window in order to gather the most interesting results and renamed as My Image Window. The inside of this image window could look like this :
N.B. : In fact the image window has a default size equal to a A4 sheet of paper (see Image windows). Only the most interesting part of the image window is shown.
Now, we want to study the effect of the signal length on the estimation of the global energy. In order to do this, we have to run the program with several values of the signal length, for example 100, 200, …, 1000.
Instead of running the program ten times by ourselves, let us fetch a Batch module from the Library, double-click to open it, and enter the following script :
"Signal length" = 0
10 {
"Signal length" += 100
CALCULATE "My Image Window"
PRINT "My Image Window"
}
Click outside the window to exit the text edit mode. Close the script window and set the Page setup parameters in the File menu.
Right-click on the Batch module to launch it : the script window and the Image window to calculate open, the ten simulations are quickly carried out and the ten result sheets are automatically sent to the printer.
3-14-5. Complete list of batch processing commands
Command and example |
Action |
Choosing of a MUSTIG program |
|
OPEN "File Name.MTG" |
Opens a MUSTIG program. Not necessary if the Batch module is in your program and if you do not call other programs. |
CLOSE "File Name.MTG" |
Closes a MUSTIG program |
SELECT "File Name.MTG" |
Selects a MUSTIG program (useful if several MUSTIG programs are used for the batch processing) |
Setting of input parameters |
|
"Label Name" = Value |
Changes the value of a labeled input scalar or text module |
"Label Name" += Value "Label Name" -= Value "Label Name" *= Value "Label Name" /= Value |
Increments a labeled scalar input module Decrements a labeled scalar input module Multiplies a labeled scalar input module Divides a labeled scalar input module |
Managing the image windows |
|
INITIALISE "Image Window Name" |
Reinitializes all the calculations and modules inside the specified image window |
CALCULATE "Image Window Name" |
Calculates an image window |
PRINT "Image Window Name" |
Prints an image window (make sure the Page Setup parameters are correct before launching the batch processing) |
Time management |
|
START "1h20m" |
Starts the batch processing at the specified time |
WAIT "1m" |
Waits the specified time (one minute here). May be useful if you are afraid your printer spooler to be too much loaded, or if you want to see the results before they are sent to the printer. |
DSP management |
|
DSP "ON" |
All the new calculations will be made on the DSP processor (DSP version of MUSTIG only) |
DSP "OFF" |
All the new calculations will be made on the PC processor |
Loops |
|
N{ Command 1 Command 2 … } |
Repeats the same instruction set N times |