meta data for this page
Compound Arguments
Let's say that we would like to loop over a series of directories. Within each directory, read all the files from that directory, process them, then write out the results to a different directory of the same name in a different location. First, the output directories need to exist, or be created
using “mkdir”, if they do not exist.
Next, two nested loops are needed to look over a series of directories and loop over the files within each directory. The “start” module defines the directory where the multiple directories are located. The outer “ls” loop selects which directories you want look at, by matching them with its filter. The “mkdir” module creates a new directory to store the results. The “cd” module takes the directory name and file name, passed by “mkdir”, and passes on the combined directory and file name as the new directory name, with a blank file name. The second “ls” loop looks for the individual image file names that match its filter. These names are passed to “exec” which uses them to execute the attached job.
Let's take an example. We will look at a few of the Smith directories and within each directory we will read each input image, pack it, and store the results in a directory of the same name that was created in a neighboring directory.
The “start” module will point to the “D:\Image Files\Raws” directory. The first “ls” module will use the filter “Smith *93*” to pick out the input directories. The “mkdir” module will create another “Smith*93*” directory in “D:\Image Files\Packed”. The “cd” module will choose “child”, thereby changing the directory to “directory\file”. The second “ls” will list each input file with the filter, “*.tif”.
The attached job has two dynamic variables, “$input$” and “$output$”. The “$input$” variable is in the ReadImage and the “$output$” variable is in the Writelmage module.
In “mkdir” the destination argument will have a specification needed to create the necessary output directories. In “exec” are the specifications for the two dynamic variables. The goal is to write the output files into their own personal directory. Those directories are created by “mkdir”.
The arguments are as follows:
destination | $D“P”$::Packed::$F$ |
input | $D$::$F$ |
output | $D“PP”$::Packed::$D“F”$::$F$ |
The “mkdir” module receives “D:\Image Files\Raws” as the “directory”, i.e. “$D$”, and the individual Smith directories, each as a “filename”, or “$F$”. The argument takes the directory name, “D:\Image Files\Raws”, goes to its parent, or “D:\Image Files”, adds the directory name “Packed”, then adds the individual Smith directory name to get “D:\Image Files\Packed\Smith..”, which it then creates.
The “input” variable is used inside of each input Smith directory. The directory and file names are therefore the name of the Smith directory and the different image files within that directory. The argument creates the input image file name by combining the input directory name with the input file name, as expected.
The “output” variable is the most complicated, since it includes parts of both the input directory and file names. The directory name is modified by starting at the input directory name and backing up two directory levels. After that modification are added the file separator, “::”, followed by the name of the directory where the output directories are storied, namely “Packed”, followed by the file separation marker, “::”, then followed by the subdirectory name, and the individual file name.
This subdirectory name is created from the original directory name. The end of that name is just the individual Smith directory name. That name is extracted using the “F” modifier on the directory name, i.e. “$D”F“$, to get the name of the individual Smith directory, “Smith…”.
One trick to ensuring that you have not made a mistake in the output name is to use Show instead of Writelmage in your initial testing. Put into the “title” argument of Show the dynamic variable “$title$”, then in “exec” in the “title” argument, put the sequence above that you think will generate the proper output file name. That title will appear at the top of the Show display window. That gives you a chance to see if the output file name is correct before you commit to writing out the files with Writelmage.
ReadStack
ReadStack will read in several individual files and generate one multiband output file that contains all of the bands from the input files. To use ReadStack in a flowchart, you need one entry for each of the input file names in “exec”.
Let's say that you would like to make a color image for each of several images, where each set of input images is in its own directory. For example, in directory Smith_093r you will find three color images that you want to read with ReadStack. In red-green-blue order, their names are:
Smith_093r+MB630RD_11_F.tif Smith_093r+MB530GN_07_F.tif Smith_093r+MB450RB_04_F.tif
If you were only operating on the 93r directory, you would enter those name directly into ReadStack. To run this job on multiple directories, you need to change the explicit names of the files within “exec”. This is accomplished with a substitution modifier.
When you get into a specific directory, in this case Smith_093r, the filter for “ls” should pick out one of the desired images, say the red image, Smith_093r+MB630RD_11_F.tif. Of course, the filter cannot include the page name (093r), because the name of the red file will not be exactly the same in each directory. The next two images are specified by a substitution to convert the first name to the subsequent names. To get the first image as the listed file name, you could use the following filter in “ls”:
This filter will pass the name of the red image file to “exec”, along with the name of the directory that contains it.
The names that you desire in the ReadStack argument are shown on the left, but the exact input file names will be different for each image directory. To implement this in a flowchart, you put a single dynamic variable into ReadStack. For example:
The dynamic variable name can be anything that helps you remember which input it points to.
The entry in “exec” depends on the fact that a single file name will be entering “exec” at one time. All of the other input names are created by substitutions of the first name.
There must be only one entry line in ReadStack, while in the “exec” argument, there must be one line for each input file name. Given that the three files have a common structure, the parts of the name that describe the wavelength can be used to identify the three files in the different directories that have different names.
WriteStack
WriteStack is module that reads in a single, multiband image file and writes out individual single-band images, one for each input band.
To use WriteStack in a flowchart, the same process is used as shown above. A single dynamic variable is entered into the WriteStack argument field. In the “exec” argument field, there is one line for each output file to be generated. Each entry should use the input file name and make substitutions to create unique names for each output image.