ImageMath: Image Math

Description Usage Arguments Value Author(s) Examples

Description

Perform math-operations on the given image

Usage

1
2
ImageMath( "<ImageDimension>" , "<OutputImage>" , "<operator>" , "<Image1.ext>" [, "<Image2.ext>"] )
See section 'Arguments' for details. Number and type of arguments vary depending on 'operator' used.

Arguments

imageDimension 2|3

Number of dimensions of the input image

outputImage

result image

operator

Must be one of the operators listed below.
Mathematical Operations:

  • m : Multiply

  • + : Add

  • - : Subtract

  • / : Divide

  • ^ : Power

  • exp : Take exponent exp(imagevalue*value)

  • addtozero : add image-b to image-a only over points where image-a has zero values

  • overadd : replace image-a pixel with image-b pixel if image-b pixel is non-zero

  • abs : absolute value

  • total : Sums up values in an image or in image1*image2 (img2 is the probability mask)

  • Decision : Computes result=1./(1.+exp(-1.0*( pix1-0.25)/pix2))

  • Neg : Produce image negative

Spatial Filtering:

  • G : Smooth with Gaussian of sigma = s

    Usage:

    G Image1.ext s

  • MD : Morphological Dilation with radius s

    Usage:

    MD Image1.ext s

  • ME : Morphological Erosion with radius s

    Usage:

    ME Image1.ext s

  • MO : Morphological Opening with radius s

    Usage:

    MO Image1.ext s

  • MC : Morphological Closing with radius s

    Usage:

    MC Image1.ext s

  • GD : Grayscale Dilation with radius s

    Usage:

    GD Image1.ext s

  • GE : Grayscale Erosion with radius s

    Usage:

    GE Image1.ext s

  • GO : Grayscale Opening with radius s

    Usage:

    GO Image1.ext s

  • GC : Grayscale Closing with radius s

    Usage:

    GC Image1.ext s

Time Series Operations:

  • CompCorrAuto : Outputs a csv file containing global signal vector and N comp-corr eigenvectors determined from PCA of the high-variance voxels. Also outputs a comp-corr + global signal corrected 4D image as well as a 3D image measuring the time series variance. Requires a label image with label 1 identifying voxels in the brain.

    Usage:

    CompCorrAuto 4D_TimeSeries.nii.gz LabeLimage.nii.gz N-comp-corr-eigenvectors

  • CompCorr : Outputs a comp-corr corrected 4D image as well as a 3D image measuring the correlation of a time series voxel/region with a reference voxel/region factored out. Requires a label image with 1=overall region of interest, 2=reference voxel, 3=region to factor out. If there is no 3rd label, then only the global signal is factored out.

    Usage:

    CompCorr 4D_TimeSeries.nii.gz LabeLimage.nii.gz Sigma-for-temporal-smoothing

  • TimeSeriesSubset : Outputs n 3D image sub-volumes extracted uniformly from the input time-series 4D image.

    Usage:

    TimeSeriesSubset 4D_TimeSeries.nii.gz n

  • TimeSeriesToMatrix : Converts a 4D image + mask to matrix (stored as csv file) where rows are time and columns are space.

    Usage:

    TimeSeriesToMatrix 4D_TimeSeries.nii.gz mask

  • ComputeTimeSeriesLeverage : Outputs a csv file that identifies the raw leverage and normalized leverage for each time point in the 4D image. leverage, here, is the difference of the time-point image from the average of the n images. the normalized leverage is = average( sum_k abs(Leverage(t)-Leverage(k)) )/Leverage(t).

    Usage:

    ComputeTimeSeriesLeverage 4D_TimeSeries.nii.gz k_neighbors

Tensor Operations:

  • 4DTensorTo3DTensor : Outputs a 3D_DT_Image with the same information.

    Usage:

    4DTensorTo3DTensor 4D_DTImage.ext

  • ComponentTo3DTensor : Outputs a 3D_DT_Image with the same information as component images.

    Usage:

    ComponentTo3DTensor component_image_prefix[xx,xy,xz,yy,yz,zz] extension

  • ExtractComponentFrom3DTensor : Outputs a component images.

    Usage:

    ExtractComponentFrom3DTensor dtImage.ext which=xx,xy,xz,yy,yz,zz

  • ExtractVectorComponent : Produces the WhichVec component of the vector

    Usage:

    ExtractVectorComponent VecImage WhichVec

  • TensorColor : Produces RGB values identifying principal directions

    Usage:

    TensorColor DTImage.ext

  • TensorFA : Tensor FA

    Usage:

    TensorFA DTImage.ext

  • TensorFADenominator : Tensor FA denominator

    Usage:

    TensorFADenominator DTImage.ext

  • TensorFANumerator : Tensor FA numerator

    Usage:

    TensorFANumerator DTImage.ext

  • TensorIOTest : Will write the DT image back out ... tests I/O processes for consistency.

    Usage:

    TensorIOTest DTImage.ext

  • TensorMeanDiffusion : Tensor mean diffusion

    Usage:

    TensorMeanDiffusion DTImage.ext

  • TensorToVector : Produces vector field identifying one of the principal directions, 2 = largest eigenvalue

    Usage:

    TensorToVector DTImage.ext WhichVec

  • TensorToVectorComponent : 0 => 2 produces component of the principal vector field (largest eigenvalue). 3 = 8 => gets values from the tensor

    Usage:

    TensorToVectorComponent DTImage.ext WhichVec

Unclassified Operators:

  • Byte : Convert to Byte image in [0,255]

  • CompareHeadersAndImages: Tries to find and fix header errors. Outputs a repaired image with new header. Never use this if you trust your header information.

    Usage:

    CompareHeadersAndImages Image1 Image2

  • ConvertImageSetToMatrix: Each row/column contains image content extracted from mask applied to images in *img.nii. ConvertImageSetToMatrix output can be an image type or csv file type.

    Usage:

    ConvertImageSetToMatrix rowcoloption Mask.nii *images.nii

  • RandomlySampleImageSetToCSV: N random samples are selected from each image in a list. RandomlySampleImageSetToCSV outputs a csv file type.

    Usage:

    RandomlySampleImageSetToCSV N_samples *images.nii

  • ConvertImageSetToEigenvectors: Each row/column contains image content extracted from mask applied to images in *img.nii. ConvertImageSetToEigenvectors output will be a csv file for each label value > 0 in the mask.

    Usage:

    ConvertImageSetToEigenvectors N_Evecs Mask.nii *images.nii

  • ConvertImageToFile : Writes voxel values to a file

    Usage:

    ConvertImageToFile imagevalues.nii Optional-ImageMask.nii

  • ConvertLandmarkFile : Converts landmark file between formats. See ANTS.pdf for description of formats.

    Usage:

    ConvertLandmarkFile InFile.txt

    Example 1:

    ImageMath 3 outfile.vtk ConvertLandmarkFile infile.txt

  • ConvertToGaussian : Convert to Gaussian

    Usage:

    ConvertToGaussian TValueImage sigma-float

  • ConvertVectorToImage : The vector contains image content extracted from a mask. Here the vector is returned to its spatial origins as image content

    Usage:

    ConvertVectorToImage Mask.nii vector.nii

  • CorrelationUpdate : In voxels, compute update that makes Image2 more like Image1.

    Usage:

    CorrelationUpdate Image1.ext Image2.ext RegionRadius

  • CountVoxelDifference : The where function from IDL

    Usage:

    CountVoxelDifference Image1 Image2 Mask

  • CorruptImage : Currupt image

    Usage:

    CorruptImage Image NoiseLevel Smoothing

  • D : DistanceTransform

  • DiceAndMinDistSum : Outputs DiceAndMinDistSum and Dice Overlap to text log file + optional distance image

    Usage:

    DiceAndMinDistSum LabelImage1.ext LabelImage2.ext OptionalDistImage

  • EnumerateLabelInterfaces: Enumerate label interfaces

    Usage:

    EnumerateLabelInterfaces ImageIn ColoredImageOutname NeighborFractionToIgnore

  • ExtractSlice : Extracts slice number from last dimension of volume (2,3,4) dimensions

    Usage:

    ExtractSlice volume.nii.gz slicetoextract

  • FastMarchingSegmentation: final output is the propagated label image. Optional stopping value: higher values allow more distant propagation

    Usage:

    FastMarchingSegmentation speed/binaryimagemask.ext initiallabelimage.ext Optional-Stopping-Value

  • FillHoles : Parameter = ratio of edge at object to edge at background; Parameter = 1 is a definite hole bounded by object only, 0.99 is close; Default of parameter > 1 will fill all holes

    Usage:

    FillHoles Image.ext parameter

  • FitSphere : Fit sphere

    Usage:

    FitSphere GM-ImageIn WM-Image MaxRad-Default=5

  • FlattenImage : Replaces values greater than percentageofMax*Max to the value percentageofMax*Max

    Usage:

    FlattenImage Image percentageofMax

  • GetLargestComponent : Get the largest object in an image

    Usage:

    GetLargestComponent InputImage MinObjectSize

  • Grad : Gradient magnitude with sigma s (if normalize, then output in range [0, 1])

    Usage:

    Grad Image.ext s normalize?

  • HistogramMatch : Histogram matching

    Usage:

    HistogramMatch SourceImage ReferenceImage NumberBins-Default=255 NumberPoints-Default=64

  • InvId : computes the inverse-consistency of two deformations and write the inverse consistency error image

    Usage:

    InvId VectorFieldName VectorFieldName

  • LabelStats : Compute volumes / masses of objects in a label image. Writes to text file

    Usage:

    LabelStats labelimage.ext valueimage.nii

  • Laplacian : Laplacian computed with sigma s (if normalize, then output in range [0, 1])

    Usage:

    Laplacian Image.ext s normalize?

  • Lipschitz : Computes the Lipschitz norm of a vector field

    Usage:

    Lipschitz VectorFieldName

  • MakeImage : Make Image

    Usage:

    MakeImage SizeX SizeY SizeZ;

  • Normalize : Normalize to [0,1]. Option instead divides by average value

    Usage:

    Normalize Image.ext opt

  • PadImage : If Pad-Number is negative, de-Padding occurs

    Usage:

    PadImage ImageIn Pad-Number

  • CenterImage2inImage1 : Center image2 to image1

    Usage:

    ReferenceImageSpace ImageToCenter

  • PH : Print Header

  • PoissonDiffusion : Solves Poisson's equation in a designated region using non-zero sources

    Usage:

    PoissonDiffusion inputImage labelImage [sigma=1.0] [regionLabel=1] [numberOfIterations=500] [convergenceThreshold=1e-10]

  • PropagateLabelsThroughMask: Final output is the propagated label image. Optional stopping value: higher values allow more distant propagation

    Usage:

    PropagateLabelsThroughMask speed/binaryimagemask.nii.gz initiallabelimage.nii.gz Optional-Stopping-Value

  • PValueImage : P value image

    Usage:

    PValueImage TValueImage dof

  • RemoveLabelInterfaces: Remove label interfaces

    Usage:

    RemoveLabelInterfaces ImageIn

  • ROIStatistics : computes anatomical locations, cluster size and mass of a stat image which should be in the same physical space (but not nec same resolution) as the label image.

    Usage:

    ROIStatistics LabelNames.txt labelimage.ext valueimage.nii

  • SetOrGetPixel : Set or get pixel; You can also pass a boolean at the end to force the physical space to be used

    Usage:

    SetOrGetPixel ImageIn Get/Set-Value IndexX IndexY IndexZ

    Example 1:

    ImageMath 2 outimage.nii SetOrGetPixel Image Get 24 34; Gets the value at 24, 34

    Example 2:

    ImageMath 2 outimage.nii SetOrGetPixel Image 1.e9 24 34; This sets 1.e9 as the value at 23 34

  • Segment : Segment an Image with option of Priors, weight 1 => maximally local/prior-based

    Usage:

    Segment Image1.ext N-Classes LocalityVsGlobalityWeight-In-ZeroToOneRange OptionalPriorImages

  • stack : Will put 2 images in the same volume

    Usage:

    Stack Image1.ext Image2.ext

  • ThresholdAtMean : See the code

    Usage:

    ThresholdAtMean Image percentageofMean

  • TileImages : Tile Images

    Usage:

    TileImages NumColumns ImageList

  • TriPlanarView : Tri planar view

    Usage:

    TriPlanarView ImageIn.nii.gz PercentageToClampLowIntensity PercentageToClampHiIntensity x-slice y-slice z-slice

  • TruncateImageIntensity: Truncate image intensity

    Usage:

    TruncateImageIntensity InputImage.ext [lowerQuantile=0.05] [upperQuantile=0.95] [numberOfBins=65] [binary-maskImage]

  • Where : The where function from IDL

    Usage:

    Where Image ValueToLookFor maskImage-option tolerance

Value

0 – Success
1 – Failure

Author(s)

Shrinidhi KL

Examples

1
2
3
4
5
## Not run: 
ImageMath( 3 , "output_img.nii" , "D", "input_img.nii" , 1 )
ImageMath( 3 , "output_img.nii" , "MD", "input_img.nii" , 1 )

## End(Not run)

stnava/itkImageR documentation built on May 30, 2019, 7:21 p.m.