../common/images/vh_36.pngVHIST 1.84.0
Docu Home

vhistadd

Table of Contents

Introduction

vhistadd is a command-line tool used for creating or appending to VHIST files.

We think that vhistadd is a comparatively easy to use - although the number of commandline options featured by vhistadd can be a bit intimidating. Therefore we developed VHISTzard, a user-friendly graphical user interface tool, which assists with assembling commandlines and running vhistadd. By using vhistzard, you can create VHIST files without a detailed knowledge of vhistadd or its commandline options.

In order to show a glimpse of what vhistadd can do for you, we have added some examples.

Arg-Files

You can write the arguments of a vhistadd call into a file and then specify this file when calling vhistadd instead of typing the whole commandline into the shell. Such files are called Arg-Files by VHIST.

Orginally, this feature was implemented due to limitations of the MS Windows platform, where only commandline arguments of fairly moderate size can be passed to programs (2048 characters on Windows 2000, 8191 on Windows XP [1], typical UNIX commandlines can be >100KB long). The corresponding error message does not make this obvious: "Window cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item."

Since 2048 characters is not enough for all but the simplest use cases, a more powerful mechanism was needed. Arg-Files have several advantages to normal commandline calls: Arg-Files can have any length, can easily be archived, copied around and passed to other users. They can even be embedded into the VHIST file they generate, the lines in an Arg-File can be of arbitrary length and the syntax for Arg-Files are independent of the platform, operating system or shell. The Arg-File format is very similar to the syntax of the bash [2] shell: single arguments are separated by one or several whitespace characters (space, tab or newline). Strings which contain whitespaces must be enclosed in quotes (") and enviroment variables start with a $ sign, e.g. $PATH. Comments start with a hash symbol # and continue until the end of the line.

Synopsis

This table contains a brief summary of the commandline options for vhistadd.py.

Function Commandline Option
Built-in help -h or –help
Get Version -V or –version
Use an Arg File -c or –cmdfile <cmdfile>
Sync current directory –sync-cwd
Output VHIST file -O <filename1> [-O <filename2> …] [other options]
Append to VHIST file -A <filename>
VHIST root file -I <filename> or vhistadd.py -J <filename>
Pre-defined attributes (workflow step) -s <key> <value> [-s <key> <value>] …
User-defined attributes (workflow step) -U <key> <value> [-U <key> <value>] …
User-defined attributes with unit (workflow step) -W <key> <value> <unit> [-W <key> <value> <unit>] …
PDF-related properties -d <key> <value> [-d <key> <value>] …
Input file(s) with qualifiers -i <filename> … <qualifiers> [-i <filename> … <qualifiers>]
Output file(s) with qualifiers -o <filename> … <qualifiers> [-o <filename> … <qualifiers>]
Customization: PDF first page -1 or –firstpage
Customization: embedded readme -r or –readme
8.14 -v or -q
Pretend Mode -p
Stdin Mode –stdin

This table contains the qualifiers that can be attached to input or output files.

Type of File Qualifier
Pre-defined flags (files) [-f <flag>] [-f <flag>] …
Pre-defined attributes (files) -a <key> <value> [-a <key> <value>] …
User-defined attributes (files) -u <key> <value> [-u <key> <value>] …
User-defined attributes with unit (files) -w <key> <value> [-w <key> <value>] …

Built-in Help

-h or –help
gives a brief description of all options.

Get Version Information

-v or –version
will print out vhistadd's version information and exit.

Use an Arg-File

-c <cmdfile> or
–cmdfile <cmdfile>
will read a file <cmdfile>.

An Arg-File is a file containing the commandline of one vhistadd call as described in 2.

Sync Current Working Directory

It is possible to synchronize the current working directory used by vhistadd with the path of the selected Arg-File. If synchronizing is enabled, all paths (with the exception of readme- and firstpage files) specified in the commandline or any Arg-File are relative to the path of the first Arg-File.

Options

Output VHIST file

-O <filename> [-O <filename>] [-O <filename>] …

The name of the VHIST file which will be generated during this workflow step. If more than one file is specified, several VHIST files with identical content will be generated. At least one -O (capital letter "O") option must be specified.

By design, vhistadd prevents you form overwriting existing VHIST files except (a) when an output VHIST file is also specified as a VHIST root file or (b) you choose the Append to VHIST file option.

Append to VHIST file

-A <filename>

If the file exists, the current workflow step will be appended to the file, preserving all previous content. If it does not exits, a new VHIST file of that name will be created.

VHIST root file

-I <filename> (file must exist)
-J <filename> (ignore if file cannot be read)

The name of the VHIST file, which is used as the basis for the new VHIST file. The generated workflow step is appended to a copy of this VHIST document. The VHIST root file is not modified except if the root file is also specified as an output VHIST file. If this option is not specified, vhistadd starts with an empty document. The -I option will cause vhistadd to stop with an error message if the VHIST root file cannot be read, use -J if vhistadd should ignore a missing root file (we have introduced -A, see previous subsection, to achieve the same effect without having to specify an output VHIST file with -O).

Pre-defined attributes (workflow step)

-s <key> <value>

We distinguish between User-defined attributes (workflow step) and pre-defined properties or attributes of a workflow step. This option is used to set one or more of the following pre-defined attributes (it is an error to use other keywords with this option):

Attribute Brief Description
title The title of the workflowstep.
description A short description of the workflowstep. Longer descriptions can be embedded as input files.
comment Additional comments referring to this workflowstep.
tool A version string of the tool used in the workflowstep.
toolversion An alias for tool.
toolpath The path to the executable of the tool.
host The name of the host, on which the workflowstep was performed.
user The name of the user, who performed the workflowstep.
command The commandline used to exectue the workflowstep.

User-defined attributes (workflow step)

-U <key> <value>
to set a user-defined attribute.

We distinguish between user-defined and Pre-defined attributes (workflow step).

-U "my key" "my value"

creates the user-defined attribute

my key

and sets it to

my value.

User-defined attributes with units (workflow step)

-W <key> <value> <unit>
to set a user-defined attribute with an associated unit.

We distinguish between user-defined and Pre-defined attributes (workflow step).

-W "my key" "my value" "my unit"

creates the user-defined attribute

my key

and sets it to

my value. The value of the attribute has the unit my unit.

PDF-related properties

-d <key> <value> or
-doc <key> value>
 
Valid keys are: producer, creator, author, keywords, title, subject

These properties are important when viewing VHIST files using a PDF browser. We refer to [3] for a detailed description.

These properties can currently only be set for newly created VHIST files. When appending a workflowstep to an existing VHIST file, an attempt to set PDF-related properties is ignored.

Input file(s) with qualifiers

-i <filename> or
–infile <filename>
specifies one or more input files.

The VHIST format distinguishes between the files present before the workflow step (infiles) and files which result from executing the specified tool (outfiles).

After -i <filename>, but before the next -i option, a number of addition options refering to this file can be added. See Pre-defined flags (files) Pre-defined attributes (files), User-defined attributes (files) for further options.

Output file(s) with qualifiers

-o <filename> or
–outfile <filename>
to specify one or more output files.

The VHIST format distinguishes between files present before the workflow step (infiles) and files which result from executing the specified tool (outfiles).

After -i <filename>, but before the next -i option, a number of addition options refering to this file can be added. See Pre-defined flags (files) Pre-defined attributes (files), User-defined attributes (files) for further options.

Pre-defined flags (files)

-f <key>
sets one or more pre-defined flags.
It is an error to use other flagnames than the ones defined below with
this option.

A flag enabling or disabling a property of the previously specified in- or outfile. The flags can be negated by prepending the flag's name with no-, e.g. no-embed.

Flag Brief description
automd5 The MD5 sum [4] of the file's content is automatically calculated by vhistadd. If the file is embedded, this option is forced. By default, this option is enabled.
embed The file's content is embedded into the generated VHIST file. By default, this option is enabled.
compress The file is compressed using the flate compression method [5]. If the file's content is not embedded, this flag is ignored. By default, this option is enabled.
optional The file is optional and only included in the VHIST file if it is readable, otherwise it is silently ignored. By default, this flag is not set, i.e. if vhistadd needs to access the file to compute the MD5 sum or read the last modification date but the the file is not available, vhistadd will abort with an error message. If this flag is not set, but either flags embed or automd5 are set and the file is not readable, vhistadd will also abort with an error message.
previewws Hint that a VHIST browser with a suitable template can use this file as a preview image for the whole workflow step. Currenty must be a JPEG or PNG image.
preview Hint that a VHIST browser with a suitable template can use this file as a preview image for the next embedded file. Currenty must be a JPEG or PNG image. Tip: define a "description" attribute to ensure correct identification of the associated data file.
thumbnail Hint that a VHIST browser with a suitable template can use this file as a small preview image (usually called "thumbnail", e.g. a typical file icon for image files). Currenty must be a JPEG or PNG image.
thumbnailonly Similiar to "thumbnail" but can be used to hint that this thumbnail image should be used in the context of the immediately following file and that no detailed information about this (illustrative) image is required (or, indeed, desired) as all relevant data will be supplied by the next image's attributes. CAVEAT: If the associated data file is of the type outfile, the thumbnail should also be of this type, similiar with the type infile.

Pre-defined attributes (files)

-a <key> <value>
sets one or more pre-defined attributes. It is an error to
use other keywords than the ones defined below with this option.

An attribute describing a property of the previously specified in- or outfile.

Attribute Brief Description
filetype A user-defined text describing the file type. We suggest a convention reminiscent of the MIME [6] standard, e.g. binary/Analyze-Header.
description A short description of the in- or outfile. There is no formal size limit, however, we suggest not to use this option with text significantly longer then a few lines. If required, put the description in a file which can then be embedded.
comment Additional comments referring to the in- or outfile. We suggest to use this entry for observations during this particular workflow steps, e.g. unusually poor quality of data due to some hardware malfunction.
md5file The name of a file which contains an MD5 checksum [4] in the first line. The sum is used as user specified md5 sum for the in- or outfile. This attribute is useful in situations in which a file is not embedded and the checksum was already generated by another application, e.g. for very large files where caluclating MD5 sum is only feasible with low-priority background processes.

User-defined attributes (files)

-u <key> <value>
sets a key value pair of your choice.

We distinguish between user-defined attributes and Pre-defined attributes (files)

-u "my key" "my value"

sets the attribute

my key

to the value

my value.

User-defined attributes with unit (files)

-w <key> <value> <unit>
sets a key value unit tripple of your choice.

We distinguish between user-defined attributes and Pre-defined attributes (files)

-w "my key" "my value" "my unit"

sets the attribute

my key

to the value

my value. The value of the attribute has the unit my unit.

Verbosity

-v or
–verbose

Use this option to have vhistadd generate more verbose output to stdout.

-q or
–quiet

If this option is set, the output to stdout is reduced to errors only.

Pretend Mode

-p or
–pretend

If this option is set, vhistadd only parses the commandline and generates the workflow step but does not generate a VHIST file. This option is useful for verifying a commandline.

Stdin Mode

–stdin

vhistadd reads its commandline not from an argfile, but from stdin.

Customization: PDF first page

-1 or
–firstpage

A file containing the content of the first page of a newly created VHIST document. The content of the file must be encoded in UTF-8 [7]. The text can contain Wiki-like markup which supports bold, italic and one coloured (blue) font attributes. By default, vhistadd will use res/title.txt.

This option is ignored if the workflow step is appended to an existing VHIST file.

Customization: embedded readme

-r or
–readme

A file containing the readme, which is embedded at the beginning of a newly created VHIST document. The content of the file must be encoded in an ASCII compatible encoding, UTF-8 [7] is preferred. By default, vhistadd will use res/embedded_readme.txt. This option is ignored if the workflow step is appended to an existing VHIST file.

vhistadd examples

Please note that the following examples assume that you are using the "plain vanilla" Python version of vhistadd. The important part of the examples are the commandline parameters (everything after the initial vhistadd.py). We suggest you use bin/setup.py for setting up paths and symbolic links on unixoid platforms (Linux, Mac OS X).

The actual calling syntax of the vhistadd tool depends on your platform and configuration, e.g.

UNIX/Linux/Mac OS X, assuming vhistadd was installed in /usr/local/vhist: /usr/local/vhist/bin/vhistadd.py …

UNIX/Linux/Mac OS X, with a suitable PATH variable, or ALIAS vhistadd.py …

UNIX/Linux/Mac OS X, if the vhistadd.py file is (for some reason) not directly executable: python vhistadd.py …

MS Windows without Python, assuming the VHIST executables were installed in Program Files (no Python distribution is then necessary): C:\Program Files\VHIST\bin\vhistadd.exe

MS Windows with Python, assuming the VHIST executables were installed in Program Files (you need to install a Python distribution first): cmd vhistadd.py

Example 1

The following examples will generate a new VHIST file hello.vhist which "documents" a simple application of the echo command. CAVEAT: vhistadd will fail if hello.vhist already exists (this is by design to prevent you from unintentionally overwriting important data). You also need to take into account the general problems of passing commandline arguments with special characters (spaces, inverted commas) by escaping them (e.g. use "\!" if your text contains an exclamation mark) and/or using a suitable type of inverted commas.

vhistadd.py -s title "Hello VHIST" -s command "echo 'Hello VHIST'" -O hello.vhist

Example 2

This example demonstrates how add information about a workflow step involving the co-registration of two image volumes (which is an important task in multi-modality imaging of human brains) using vhistadd. We think the general idea about documenting this non-trivial task involving multiple files can be easily transferred to other experimental setups.

Assuming we have a program my-coreg-tool that is capable of performing fully-automatic co-registration of image volumes and two image volumes of the same patient from two different modalities (here: MRI and PET scans of the same patient's brain). The tool will write a coreg.log protocol which we want to embed in the VHIST file (usually logs are so small that this is the recommended pratice) in addition to information about the co-registration result (another image volume: regimage-pet.v).

We have used the ECAT7 file type in this example, which encodes one image volume with meta information in a single file; binary indicates that this file type does not store information in any "human-readable" form.

vhistadd.py
 # the workflow step's title
 -s title "Co-Registration Task"
 # the program's name and version
 -s tool "my-coreg-tool v1.23"
 # the program's full path
 -s toolpath "/usr/bin/my-coreg-tool"
 # input file: co-registration log, will be embedded
 -i coreg.log -f embed)
 # setting optional file type info on previous file
 -a filetype "text/log")
 # input file: PET image volume of patient, do not embed
 -i "pat-pet.jpg" -f no-embed
 # setting optional file type info on previous file
 -a filetype "binary/ECAT7"
 # input file: MRI image volume of patient, do not embed
 -i "pat-mri.gif" -f no-embed
 # setting optional file type info on previous file
 -a filetype "binary/ECAT7"
 # output file: co-reg. PET image volume of patient
 -o "regimage-pet.png" -f no-embed
 # setting optional file type info on previous file
 -a filetype "binary/ECAT7"
 # VHIST output file (mandatory)
 -O "regimage-pet.png.vhist"

Please note that we have tried to keep this example brief. In the sense of "Good Scientific Practice" you can easily improve on this template by adding further attributes to the workflow step or individual files: Pre-defined attributes (workflow step), User-defined attributes (workflow step), User-defined attributes (files).

Example 3

Based on the output of the previous example we now want to apply a 3D image filter to the registered image volume. Documentation of this next workflow step should take advantage of the existing processing history, i.e. use the VHIST file generated in the previous step.

This is achieved by specifying the previous VHIST as the VHIST root file: the VHIST file generated in this workflow step will then contain a copy of the full previous history, the new meta information on the current process (here: 3D filtering) is appended as a new section at the end.

vhistadd.py
  # the workflow step's title
  -s title "Gauss 3D Filter"
  # an optional description
  -s description "apply filter to PET image"
  # the program's name and version
  -s tool "my-filter-tool v2.34"
  # the program's full path
  -s toolpath "C:\\Programs and Files\\my-filter-tool.exe
  # optional attribute (key-value-pair)
  -U "gauss-fwhm-mm" "2.3"
  # input file: image volume, do not embed
  -i regimage-pet.png" -f no-embed
  # output file: filter.log, will be embedded
  -o "filter.log" - f embed
  # the VHIST root file
  -I "regimage-pet.v.vhist"
  # VHIST file to generate
  -O regimage-filtered.v.vhist

Footnotes:

[1]

Microsoft Inc., Command prompt (Cmd.exe) command-line string limitation. URL http://support.microsoft.com/kb/830473/EN-US

[2]

GNU Project, BASH - GNU Project - Free Software Foundation (FSF). URL http://[[www.gnu.org/software/bash/]]

[3]

Adobe Corp., Adobe Systems Incorporated, PDF Reference, fourth edition, Adobe Portable Document Format Version 1.5. URL http://www.adobe.com/devnet/pdf/pdf_reference.html

[4]

R. Rivest, The MD5 Message-Digest Algorithm, RFC 1321.

[5]

L.P. Deutsch, DEFLATe Compressed Data Format version 1.3. URL http://www.ietf.org/rfc/rfc1951.txt

[6]

W3C, RFC 2046, Multipurpose Internet Mail Extensions (MIME) Part Two: Media. URL http://www.ietf.org/rfc/rfc2781.txt

[7]

W3C, Unicode (UTF-8, UTF-16) URL http://www.ietf.org/rfc/rfc2781.txt

(C) 2005-2013 Max Planck Institute for Neurological Research Cologne, Germany