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.

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 Script a new window opens. This is the editor to write the Lua script. After clicking OK the window closes. The advantage of the editor is that it shows the Lua syntax highlighting. Another possibility to edit the script is in the properties window.

To access an image in the I/O

cow.io[number of the image in the I/O]

Example
The following line reads the 100-th image in the current I/O.

cow.io[100]

To read a header key of the I/O

cow.io[number of the image in the I/O] ["image header value name"]

Example
The following line reads the Euler angle β of the 0-th image in the current I/O.

cow.io[0]["eulerBeta"] 

To read a header key of the I/O and write it to a Variable

cow.VariableName = cow.io[number of the image in the IO]["image header values name"] 

Example
The following line reads the dimension in X of the 100-th image in the current I/O to the Variable dimension, which is of type integer.

cow.dimension = cow.io[100]["dimX"] 

The following line reads the dimension in X of the i-th image in the I/O to the Variable dimension. It is necessary to set up a Variable named iter of type integer, which is incremented at the end of the script.

cow.dimension = cow.io[cow.iter]["dimX"]
cow.iter      = cow.iter + 1  

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"]

Properties Window

Properties Window

Properties Window

Input Description
FirstInput Input to be modified by the script
Output Description
FirstOutput Output with either un- or modified header values

The Script elements works withLua 5.1 Reference Manual. In the following link all Lua functions are listed at the end of the page.