|
| ||
| teem | / | unrrdu |
unu make |
unu make: Create a nrrd (or nrrd header) from scratch. The data can be in a
file or coming from stdin. This provides an easy way of providing the bare
minimum information about some data so as to wrap it in a nrrd, either to pass
on for further unu processing, or to save to disk. However, with "-h", this
creates only a detached nrrd header file, without ever reading or writing
data.
Usage: unu make [-h] -i <file> -t <type> -s <sz0 sz1 ...> [-sp <spc0 \
spc1 ...>] [-l <lab0 lab1 ...>] [-c <content>] [-ls <lineskip>] \
[-bs <byteskip>] [-e <encoding>] [-en <endian>] [-o <nout>]
-h = Generate header ONLY: don't write out the whole nrrd,
don't even bother reading the input data, just output
the detached nrrd header file (usually with a ".nhdr"
extension) determined by the options below. The filename
given with "-i" should probably start with "./" to
indicate that the data file is to be found relative to
the header file (as opposed to the current working
directory of whomever is reading the nrrd)
-i <file> = Filename of data file; use "-" for stdin (string)
-t <type> = type of data (e.g. "uchar", "int", "float", "double",
etc.)
-s <sz0 sz1 ...> = number of samples along each axis (and implicit
indicator of dimension of nrrd) (1 or more ints)
-sp <spc0 spc1 ...> = spacing between samples on each axis. Use "nan" for any
non-spatial axes (e.g. spacing between red, green, and
blue along axis 0 of interleaved RGB image data)
(1 or more doubles)
-l <lab0 lab1 ...> = short string labels for each of the axes
(1 or more strings)
-c <content> = Specifies the content string of the nrrd, which is
built upon by many nrrd function to record a history of
operations (string)
-ls <lineskip> = number of ascii lines to skip before reading data
(int); default: "0"
-bs <byteskip> = number of bytes to skip (after skipping ascii lines, if
any) before reading data (int); default: "0"
-e <encoding> = output file format. Possibilities include:
o "raw": raw encoding
o "ascii": print data in ascii
o "hex": two hex digits per byte
o "gzip", "gz": gzip compressed raw data
o "bzip2", "bz2": bzip2 compressed raw data
default: "raw"
-en <endian> = Endianness of data; relevent for any data with value
representation bigger than 8 bits, with a non-ascii
encoding: "little" for Intel and friends; "big" for
everyone else. Defaults to endianness of this machine;
default: "big"
-o <nout> = output filename (string); default: "-"
This is the first unu command listed because it is often the
first one to be used in a longer chain of unu unu commands.
The main value in this program is the fact that you don't have to
remember and type nrrd field specifications according to the NRRD format. You tell "unu make"
the information about the data, and "unu make" will produce
the NRRD header for you.
It has two distinct roles:
The resulting mol.nhdr file is simply:unu make -h -i ./mol.150x150x150.gz -s 150 150 150 -t uchar -e gzip -o mol.nhdr
But this is enough to start using unu for other tasks, like doing axis-aligned maximum intensity projection:NRRD0001 type: unsigned char dimension: 3 sizes: 150 150 150 data file: ./mol.150x150x150.gz encoding: gz
unu project -i mol.nhdr -a 2 -m max -o mol-zmax.pgm
unu make -h -i ./mol.150x150x150 -s 150 150 150 -t uchar -e raw -o mol.nhdr NRRD0001 type: unsigned char dimension: 3 sizes: 150 150 150 data file: ./mol.150x150x150 encoding: raw
The "-ls 13" says to skip 13 lines of ASCII before getting to the data, and using the "-c" flag allows use to use the content field of the nrrd to emulate the second line of the VTK file. The "-t" and "-sp" options are set according to the "SCALARS" and "ASPECT_RATIO" lines of the VTK header.unu make -i ironProt.vtk -t uchar -s 68 68 68 -sp 1 1 1 -c "Iron protein" \ -e raw -ls 13 -o ironProt.nrrd
Since this data has large regions of constancy, compression will work well:
This results in a file that is more than four times smaller. The NRRD header is still uncompressed ASCII, but the data is compressed with gzip.unu make -i ironProt.vtk -t uchar -s 68 68 68 -sp 1 1 1 -c "Iron protein" \ -e raw -ls 13 | unu save -f nrrd -e gzip -o ironProt.nrrd
Inspection of the data is possible without creating a seperate nrrd file:
Assuming that the image viewer xv is available, than this will show a maximum intensity projection along the first axis:unu make -i ironProt.vtk -t uchar -s 68 68 68 -e raw -ls 13 \ | unu project -a 0 -m max | unu save -f pnm | xv -