4DImageMath =========== .. code-block:: none USAGE: 4DImageMath [--returnparameterfile ] [--processinformationaddress ] [--xml] [--echo] [--crop >] [--shred >] [--compose] [--dotproduct] [--amin] [--amax] [--sum] [--median] [--mean] [--norm ] [-a ] [--sqrt] [--square] [--log] [--exp] [--abs] [-f ] [--pow ] [--min ] [--max ] [--mul ] [--div ] [--sub ] [--add ] [-v ] [--nt ] [--outformat ] [--box >] [-m ] [--] [--version] [-h] > ... Where: --returnparameterfile Filename in which to write simple return parameters (int, float, int-vector, etc.) as opposed to bulk return parameters (image, geometry, transform, measurement, table). --processinformationaddress Address of a structure to store process information (progress, abort, etc.). (value: 0) --xml Produce xml description of command line arguments (value: 0) --echo Echo the command line arguments (value: 0) --crop > Crop image by 8 parameters (x0,x1,y0,y1,z0,z1,t0,t1). (value: -1,-1,-1 ,-1,-1,-1,-1,-1) --shred > Shred vector elements along axis according to offset, chunk size, and space specified by parameters 1 to 3. (value: 0,0,0) --compose Compose images along axis (>=2 input images). (value: 0) --dotproduct Dot product along axis (2 input images) (value: 0) --amin minimal value along axis (value: 0) --amax maximal value along axis (value: 0) --sum Sum along axis (value: 0) --median Median along axis (value: 0) --mean Mean along axis (value: 0) --norm Calculate norm of vector along axis. (value: L2) -a , --axis Axis (x/y/z/t, i.e., 0/1/2/3). --sqrt sqrt: square root, i.e., -f 'sqrt(x)' (value: 0) --square square, i.e., -f 'x*x' (value: 0) --log natural logarithm, i.e., -f 'log(x)' (value: 0) --exp exponential, i.e., -f 'exp(x)' (value: 0) --abs absolute value, i.e., -f 'abs(x)' (value: 0) -f , --func Perform functions on elements of the input images (one or more inputs). Input images should have the same size, and it does not change the size in the output image. Note: it is slower (-f 'abs') than functions (--abs). Example: cos(x)+3*x+abs(x)+2 +x^3 x[0]+x[1]*x[1]+3*x[2] // need >3 inputs max(x[0],x[1],x[2]) // need >3 inputs if (x>0.5) 1.0; else 0.0; // mask the input image using threshold 0.5 --pow Pow image file or a constant. --min Take minimum of the input and the following image or constant. --max Take maximum of the input and the following image or constant. --mul Multiply image file or a constant. --div Divide image file or a constant. --sub Substract (minus) image file or a constant. --add Add image file or a constant. -v , --verbose Verbose level. 0: no output log. 1: normal log. 2: log for debug log. 3: log for large matrix or vectors. (value: 1) --nt Number of threads. If it not positive, then the default number for multiple threads is used. (value: -1) --outformat Output format. NONE: same as the input. 4D: itk 4D image, VECTOR: 3D vector image. (value: NONE) --box > only perform calculation in a given box (x0,x1,y0,y1,z0,z1). Set zero out of the region. (value: -1,-1,-1,-1,-1,-1) -m , --mask Mask image file (3d or 4d image). Set zero out of the region. --, --ignore_rest Ignores the rest of the labeled arguments following this flag. --version Displays version information and exits. -h, --help Displays usage information and exits. > (accepted multiple times) Image list. At least two files (one or more input images, and one output image) Description: Perform math operators on 4D image (4D itk::Image or 3D itk::VectorImage). Examples: 4DImageMath image1.nii.gz out.nii.gz -f 'cos(x)+3*x+sqrt(abs(x))+sqrt(2) +x^3' -m mask.nii.gz 4DImageMath image1.nii.gz out.nii.gz -f 'if (x>0.5) 1.0; else 0.0;' -m mask.nii.gz 4DImageMath image1.nii.gz out.nii.gz --abs -m mask.nii.gz 4DImageMath image1.nii.gz out.nii.gz --exp -m mask.nii.gz 4DImageMath image1.nii.gz out.nii.gz --add image2.nii.gz -m mask.nii.gz 4DImageMath image1.nii.gz out.nii.gz --add 2.0 -m mask.nii.gz 4DImageMath image1.nii.gz image2.nii.gz out.nii.gz -f 'x[0]+x[1]' -m mask.nii.gz 4DImageMath image1.nii.gz image2.nii.gz out.nii.gz -f 'x[0]^2+cos(x[1])' -m mask.nii.gz 4DImageMath image1.nii.gz image2.nii.gz out.nii.gz --axis t --dotproduct 4DImageMath image1.nii.gz image2.nii.gz image3.nii.gz out.nii.gz -f 'max(x[0],x[1],x[2]/2.0)' -m mask.nii.gz 4DImageMath image1.nii.gz out.nii.gz --axis t --mean -m mask.nii.gz 4DImageMath image1.nii.gz out.nii.gz --axis x --norm L2 -m mask.nii.gz 4DImageMath image1.nii.gz image2.nii.gz image3.nii.gz out.nii.gz --axis t --compose Author(s): Jian Cheng (jian.cheng.1983@gmail.com) Acknowledgements: Thank you everyone.