This is an old revision of the document!
Script
The Script uses Lua 5.1 in order to read or modify header keys of the I/O. E.g. The dimension of an image stack can be read into a Variable by the Script and used as a factor in a different logic like BoxManipulation.
Usage
To add or modify header values with the Script it is necessary to connect the I/O of the logic to the Flow Control element Script. By double clicking on the graphic element of Script a new window opens.
In order to access a single image in a Cow workflow the Lua script needs to have the following syntax cow.io[#number of the image in the I/O]. Then to read a header value of that image the script needs to be expanded by the name of the header in quotation marks [“image header value name”].
cow.VariableName = cow.io[number of the image in the IO]["image header values name"]
Example
cow.AngleBeta = cow.io[0]["eulerBeta"]
Saves the Euler angle Beta of the 0-th image in the I/O to the Variable AngleBeta.
cow.dimension = cow.io[100]["dimX"]
Saves the dimension in X of the 100-th image in the I/O to the Variable dimension.
cow.dimension = cow.io[cow.iter]["dimX"]
Saves the dimension in X of the i-th image in the I/O to the Variable dimension. It is necessary to set up a iteration Variable, which is incremented by Calculate.
To overwrite the header value in the I/O
temporary variable name = cow.io[number of the image in the IO] temporary variable name["image header values name"] = new value cow.io[number of the image in the IO] = temporary variable name
Example
temp = cow.io[0] temp["dimX"] = 100 cow.io[0] = temp
Manipulates the header value dimX of the 0-th image in the I/O. The header dimX is set to 100.
temp = cow.io[100] temp["dimX"] = cow.dimension cow.io[100] = temp
Manipulates the header value dimX of the 100-th image in the I/O. The header dimX is set to the Variable dimension.
To write new header values to the I/O
temporary variable name = cow.io[number of the image in the IO] temporary variable name["new image header value name"] = new value cow.io[number of the image in the IO] = temporary variable name
Example
temp = cow.io[0] temp["linearFactor"] = cow.factor cow.io[0] = temp
Writes the new header value linearFactor for the 0-th image in the I/O. The header linear Factor is set to the Variable factor.
Manipulate the whole I/O
If each image in the I/O is supposed to be manipulated by its header value, the Script needs to be extended by the Flow Control elements Queue, Calculate and an additional iteration Variable.
cow.VariableName = cow.io[cow.IterationVariableName]["image header values name"]
Example
Properties Window
![]() | ![]() | |
![]() | ![]() | |
![]() | ![]() |
Properties Window
![]() | ![]() | |
![]() |
Properties Window
![]() | ![]() | |
![]() | ![]() | |
![]() | ![]() | |
![]() | ![]() |
Parameters and I/O
Input | Description |
---|---|
FirstInput | Input to be modified by the script |
Output | Description |
---|---|
FirstOutput | Output with either un- or modified header values |
Concept
The Script elements works withLua 5.1 Reference Manual. In the following link all Lua functions are listed at the end of the page.