table of contents
MINCCALC(1) | MINC User's Guide | MINCCALC(1) |
NAME¶
minccalc - perform complex math operations on minc filesSYNOPSIS¶
mincalc [<options>] <in1>.mnc [<in2>.mnc...] <out>.mncDESCRIPTION¶
Minccalc will perform complex, voxel-by-voxel math operations, on one or more minc files of the same shape and having the same coordinate sampling, producing a single output file. The operations to be performed are input using the -expression argument (see EXPRESSIONS). By default, the output file is the last non-option argument. However, if the -outfile option is used, then all non-option arguments are considered input files and the output file names come from the -outfile options, of which there can be more than one.OPTIONS¶
Note that options can be specified in abbreviated form (as long as they are unique) and can be given anywhere on the command line.- -2
- Create MINC 2.0 format output files.
- -help
- Print summary of command-line options and exit.
- -version
- Print the program's version number and exit.
- -clobber
- Overwrite an existing file.
- -noclobber
- Don't overwrite an existing file (default).
- -no_clobber
- Synonym for -noclobber.
- -verbose
- Print out progress information for each chunk of data copied (default).
- -quiet
- Do not print out progress information.
- -debug
- Print out debugging information.
- -copy_header
- Copy all of the header information from the first input file (default for one input file).
- -nocopy_header
- Do not copy all of the header from the first input file; copy only coordinate information (default for more than one input file).
- -filetype
- Create an output file with the same type as the first input file (default).
- -byte
- Store output voxels in 8-bit integer format.
- -short
- Store output voxels in 16-bit integer format.
- -int
- Store output voxels in 32-bit integer format.
- -long
- Superseded by -int.
- -float
- Store output voxels in 32-bit floating point format.
- -double
- Store output voxels in 64-bit floating point format.
- -signed
- Use signed, two's complement integer format. Applies only if the output voxel type is specified to be an integer type (one of -byte, -short, -int or -long).
- -unsigned
- Use unsigned integer format. Applies only if the output voxel type is specified to be an integer type (one of -byte, -short, -int or -long).
- -range min max
- Restrict the valid range of integer data. Applies only if one of the -byte, -short, -int or -long options is specified.
- -max_buffer_size_in_kb size
- Specify the maximum size of the internal buffers (in kbytes). Default is 4096 (4MB).
- -dimension dimname
- Specify a dimension along which we wish to perform a cumulative operation.
- -check_dimensions
- Check that all input files have matching sampling in world dimensions (default).
- -nocheck_dimensions
- Ignore any differences in world dimensions sampling for input files.
- -propagate_nan
- For cumulative vector operations (sum, prod and avg), invalid data (Not-A-Number or NaN) in any element of the vector will produce invalid data in the result (default).
- -ignore_nan
- For cumulative vector operations, invalid data (NaN) in the vector is ignored, ie. treated as though it is not present.
- -nan
- When an illegal operation is attempted at a voxel (such as divide by zero), the result is invalid data (NaN) (default). Having no valid input data for a cumulative operation is also considered an illegal operation when -ignore_nan is used.
- -zero
- When an illegal operation is attempted at a voxel (such as divide by zero), the result is value zero.
- -illegal_value value
- When an illegal operation is attempted at a voxel (such as divide by zero), the result is the value specified by this option.
- -expression string
- Specify the expression to evaluate at each voxel (see EXPRESSIONS).
- -expfile filename
- Specify a file containing an expression to evaluate at each
voxel (see EXPRESSIONS). If filename ``-'' is given, then the expression
is read from stdin. The only difference from command-line expressions is
that comments can be given in the file. A comment line is specified by
placing a ``#'' as the first non-whitespace character of the line.
Minccalc scripts can be created by setting the first line to
#! /usr/local/mni/bin/minccalc -expfile
- -outfile symbol output-file
- Specify that output should be written to the specified file, taking values from the symbol which should be created in the expression (see the EXAMPLES section). If this option is given, then all non-option arguments are taken as input files. This option can be used multiple times for multiple output files.
- -eval_width value
- Specify the number of voxels to process in parallel.
Default is 200.
EXPRESSIONS¶
The -expression argument is a single string that describes the function to evaluate. The function expression is typically written in terms of the vector A.A[0] + A[1]
ratio = A[0]/A[1]; A[2]*exp(-ratio)
isnan(v) - 1 if v is invalid and 0 otherwise
clamp(v1,v2,v3) - v1 bounded by [v2, v3]
segment(v1,v2,v3) - tests if v1 is in [v2, v3]
[ value1, value2, ... ]
[ a : b ] generates {a, a+1, ..., b-1, b}
[ a : b ) generates {a, a+1, ..., b-1}
( a : b ] generates {a+1, ..., b-1, b}
( a : b ) generates {a+1, ..., b-1}
{ i in [1:3] | 4 - i }
avg - the average value of the scalars in vector
len - the length of
sum - the sum of the elements of
prod - the product of the elements of
max - the maximum value of
min - the minimum value of
imax - the index of the maximum value of
imin - the index of the minimum value of
V[s] - the s'th element of vector V with origin 0.
a = A[2] * log(2)
total=0; for{i in [0:len(A))} total=total+A[i]; total
total=0; len{i in [0:len(A)) | total=total+A[i]}; total
total=total2 = 0;
for {i in [0:len(A))} {
total = total + A[i];
total2 = total2 + A[i]^2
}
A[0]<0 ? 0 : A[0]
if (A[0]<0) result=0 else result=A[0]
for i in [0:len(A)) {total=total+A[i]} ; total/len(A)
if (A[i]>0) {result=2;} else {result=1} ; result*5
let a = 1, b = 2 in a + b
EXAMPLES¶
Here is an expression for calculating standard deviation, taking into account the possibility of invalid input data, which is ignored:s0 = s1 = s2 = 0;
for { i in [0:len(A)) } {
v=A[i];
if (!isnan(v)) {
s0 = s0 + 1;
s1 = s1 + v;
s2 = s2 + v*v;
}
};
if (s0 > 1) {
sqrt((s2 - s1*s1/s0) / (s0-1));
}
else {
NaN;
};
if (s0 > 1)
sqrt((s2 - s1*s1/s0) / (s0-1))
else if (s0 > 0)
0
else
NaN
minccalc -expfile stdev \
-outfile mean mean.mnc \
-outfile stdev stdev.mnc \
infile1.mnc infile2.mnc ...
s0 = s1 = s2 = 0;
for {i in [0:len(A))} {
v=A[i];
if (!isnan(v)) {
s0 = s0 + 1;
s1 = s1 + v;
s2 = s2 + v*v;
}
};
stdev = (s0 > 1) ? sqrt((s2 - s1*s1/s0) / (s0-1)) :
(s0 > 0) ? 0 : NaN ;
mean = (s0 > 0) ? s1 / s0 : NaN ;
CAVEATS¶
A few things you should remember...sum, len, prod, ... etc
AUTHOR¶
Andrew Janke - a.janke@gmail.comCOPYRIGHTS¶
Copyright © 2000 by Andrew JankeSEE ALSO¶
mincmath(1)$Date: 2008-01-11 04:24:16 $ |