# Applications¶

## Commands¶

Command Description
aggregate-images Aggregates multiple (co-registered) input images into a single output image or report statistics thereof within a specified region of interest. The input images have to be defined in the same discrete finite image space.
average-dofs This command averages a number of input transformations. It can be used to construct a brain image atlas and has been utilized for the construction of the spatio-temporal fetal/neonatal brain atlases available at http://brain-development.org/brain-atlases/.
average-images Computes voxel-wise average image of the given (transformed) input images.
average-measure Average voxel-wise measure within each region of interest (ROI).
average-overlap No description available.
bisect-dof This command bisects a rigid or affine transformation by calculating the matrix square root of the transformation matrix.
blend-surface Blends two surface meshes with index based one-to-one point correspondences by taking the point coordinates for selected points from the first surface mesh and all others from the second surface mesh. Points at the boundary of the point selection mask are blended between the two mesh positions of the corresponding points. For other points, i.e., those further away from the boundary, the blending factor is either 0 or 1.
calculate-boundary-map Compute a surface boundary map suitable for the computation of a surface map to a 2D primitive shape such as a disk, square, or polygon.
calculate-distance-map Computes distance transformation of binary object mask.
calculate-element-wise This tool can be used for basic calculations from a sequence of data values read either from an image or a VTK pointset. It can be used, for example, to add two data sequences and to divide the result by a constant. The current sequence can be written to an output file again using calculate-element-wise -out. Additionally, statistics of the current data sequence can be computed such as the mean or variance. The order of the data transformations and calculation of statistics is determined by the order of the command-line arguments.
calculate-exponential-map Reads a dense 3D (2D) stationary velocity field, computes the corresponding dense 3D (2D) displacement field, and writes the resulting vector field.
calculate-filtering Calculates statistics by filtering with a kernel.
calculate-gradients A blur with S.D. sigma is appled before the gradient is estimated
calculate-lie-bracket Computes the Lie bracket of two vector fiels $$z = [x, y]$$.
calculate-logarithmic-map Reads a dense 3D (2D) displacement field, computes the corresponding stationary 3D (2D) velocity field, and writes the resulting vector field.
calculate-surface-attributes Calculate attributes of input surface such as normals and curvature. If required, as in case of the curvature calculations, the input mesh is triangulated beforehand if it contains non-triangular faces.
calculate-surface-map This tool computes a mapping for each point on the surface of a given input shape embedded in 3D space. The output is a (piecewise linear) function which assigns each point on the surface of the input shape one or more values. In case of non-closed surfaces, the output map can interpolate any values given on the boundary of the surface at the interior points of the surface. More common use cases are to compute a bijective mapping from one geometric shape to another geometric shape with identical topology. The resulting map is a parameterization of the surface of the input shape. Such parameterization can be used for texturing, object morphing, and surface registration.
calculate-surface-spectrum Performs a spectral analysis of the general graph Laplacian matrix computed from the given input surface mesh(es).
calculate-volume-map This tool computes a mapping for each point of the volume of a given input point set. The input is either a piecewise linear complex (PLC), i.e., a tesselation of the surface, or a tesselation of the shape’s volume such as a tetrahedral mesh generated from a PLC. The output is a volumetric map which assigns points of the volume one or more values. The volumetric map can in general interpolate any values given on the surface of the map domain at the interior of the volume. More common use cases are to compute a bijective map from one volumetric shape to another with identical topology. The resulting map is a re-parameterization of the volume of the input shape. Such parameterization can be used for texturing, object deformation (cf. “cage deformation”), object morphing, and surface- constraint image registration.
change-label Changes the labels of the <init_labels> image inside the <mask> image according to probability maps <probmap_1> .. <probmap_N> with labels <label_1> .. <label_N> respectively and saves the result in <output>
close-image Closes holes by first dilating and then eroding an input image.
close-scalars Closes scalar data of an input point set by perfoming a dilation followed by the same number of erosions. When the input data array has more than one component, each component is processed separately.
combine-images Concatenate two or more either 2D images to form a 3D volume, or 3D volumes to form a 3D+t temporal sequence. All input images must have the same image attributes, except in either the third (2D) or the third and fourth (3D) image dimension.
compose-dofs Computes the composition T of the given input transformations such that
compose-maps Computes the composition g of the given input maps such that
construct-atlas Construct (spatio-temporal) atlas from images of the same anatomy of different subjects. To construct a spatio-temporal atlas, images of subjects at different ages spread over the atlas time range are required. Please cite the following preprint when you use this command in your research (or the respective peer-reviewed article when accepted): Schuh et al., “Unbiased construction of a temporally consistent morphological atlas of neonatal brain development”, bioRxiv, 2018. doi:10.1101/251512
convert-dof Converts between different transformation file formats:
convert-image Converts an image from one voxel type to another.
convert-pointset Convert point set from one (file) format to another.
copy-pointset-attributes Copies point and/or cell data from a source point set to a target point set and writes the resulting amended point set to the specified output file. When no separate output file is specified, the target point set is overwritten. This command can also convert from point data to cell data and vice versa.
cut-brain Cut input brain volume/mask into left and/or right hemisphere(s).
decimate-surface Decimates a (triangular) mesh using VTK’s vtkQuadricDecimation filter. In case of decimate-surface -pro, the vtkDecimatePro filter is used instead.
deform-mesh Iteratively minimizes a deformable surface model energy functional. The gradient of the energy terms are the internal and external forces of the deformable surface model.
delete-pointset-attributes Delete point data and/or cell data from input point set.
detect-edges Convolves the input image with an edge detection operator.
dilate-image Dilates an input image by replacing a voxel’s value by the maximum of the values of its neighboring voxels.
dilate-scalars Dilates scalar data of an input point set by replacing a value by the maximum of the adjacent data values. When the input data array has more than one component, each component is processed separately.
downsample-image Downsamples an image using an iterative Gaussian pyramid filter.
draw-em Runs the DrawEM segmentation at the input image with the provided N probability maps of structures. The main algorithm is outlined in [1].
edit-dof This tool provides a generic way of modifying the parameters of a transformation (linear as well as non-linear). It uses the generic interface member function Transformation::Set whose arguments are the name of the parameter and the value to be set as string.
edit-image Modifies the attributes of an image stored in the header.
em Runs EM segmentation at the input image with the provided N probability maps of structures. e.g. em input.nii.gz 5 bg.nii.gz csf.nii.gz gm.nii.gz wm.nii.gz dgm.nii.gz segmentation.nii.gz
em-hard-segmentation Computes the hard segmentation of the N atlases. Optionally MRF smoothing can be additionally applied.
erode-image Erodes an input image by replacing a voxel’s value by the minimum of the values of its neighboring voxels.
erode-scalars Erodes scalar data of an input point set by replacing a value by the minimum of the adjacent data values. When the input data array has more than one component, each component is processed separately.
evaluate-atlas Evaluate (spatio-temporal) atlas sharpness measures.
evaluate-cardiac-motion Evaluate cardiac motion. This command computes the displacement or strain at each vertex on a myocardial surface mesh.
evaluate-distance Evaluate distance between two given point sets. With increased verbosity (see evaluate-distance -v), the mean and standard deviation of the measured distances (verbosity level >=1) and the individual distance for each target point is reported (verbosity level >=2).
evaluate-distortion Computes the distortion of a surface mesh under deformation, when mapped to the surface of another solid with equivalent topology, or flattened to the plane or sphere, respectively.
evaluate-dof Calculates registration transformation quality measures such as the voxel-wise cumulative or mean inverse-consistency error (CICE/MICE) for pairs of forward transformation from target to source and backward transformation from source to target image. Another voxel-wise measure that can be computed using this program are the cumulative or mean transitivity error (CTE/MTE) given three transformations, from target (A) to B, from B to C, and from C to A again.
evaluate-jacobian Computes the Jacobian determinant of the given transformation at each target image voxel. If no <output> image name is given, the statistics of the Jacobian determinant distribution are printed to STDOUT instead, such as min, max, and mean.
evaluate-overlap Computes the overlap of either two intensity images (average SI) or two segmentations (see evaluate-overlap -label). If more than one source image is given, the overlap between each of these and the target is evaluated.
evaluate-similarity Evaluates the (dis-)similarity of two intensity images.
evaluate-surface-map Evaluates quantitative quality measures of a surface map.
evaluate-surface-mesh Prints surface mesh quality measures and topology information.
evaluate-surface-overlap Reports label statistics given two surface meshes and a text file listing the indices of corresponding points. The labels have to be stored as named point data array in both datasets.
evaluate-volume-map Evaluates quantitative measures of a surface map or volumetric map such as its harmonic energy.
extract-connected-components Extracts connected components from input segmentation label image. By default, the largest connected component is extracted. In case of extract-connected-components -output-component-labels, the labels of the components are written instead.
extract-connected-points Extract (largest) connected components of the input point set. The connected components are sorted by size, where the largest connected component has index 0.
extract-image-region Crop/pad image by extracting a region of interest and optionally split the extracted region into separate image files, e.g., individual slices of a volume saved as individual image files. The output image region is chosen such that it contains the union of all specified axis-aligned rectangular input image regions. In case of extract-image-region -pad, the output region does not have to be fully contained within the input image. Values outside are then set to the specified padding value.
extract-image-slice No description available.
extract-image-volume No description available.
extract-pointset-cells Extract point set/surface elements which meet the specified criteria.
extract-pointset-surface Extract surface of point set. If more than one input point set is given, it computes the boundary of the union, intersection, or difference volume computed from the volumes defined by the individual input surfaces.
extract-surface Extract the isosurface from an intensity image or segmentation.
fill-holes Fills holes in the input. Note: The code is adapted from fslmaths -fillh
fill-holes-nn-based Fills holes in the input. The surrounding voxels of the suspected-holes are measured and if the majority belongs to the input they are filled.
flip-image Swaps the two image dimensions at a time, in the order of the input options. Both, the image data and the coordinates of the image origin are swapped each time an input option is processed. To swap the image axes instead of the origin, use the flip-image -axes option before the swap options. This option should be used to reorder the image dimensions without changing the world coordinates of the voxels. When swapping of the coordinate axes is enabled, the coordinates of the image origin are kept the same, i.e., flip-image -origin is ignored. The default behavior is to swap the image data and the coordinates of the image origin. This may in many cases not have the desired effect, but has been this way already for some time.
help-rst No description available.
info Prints some useful information about the given input file, which can be an image, transformation (requires MIRTK Transformation module), or point set (requires MIRTK Point Set module).
init-dof This tool either creates a new affine transformation with the given parameters or approximates an affine transformation or non-rigid deformation given a set of corresponding landmarks or point displacements (see init-dof -displacements).
invert-dof Inverts any transformation. In case of a non-rigid transformation the output transformation only approximates the true inverse. When the inverse mapping is not defined at a given point, the output transformation at this point depends on the interpolation numerical approximate solution found.
kmeans Runs k-means clustering at the input image with the provided K number of classes. e.g. kmeans input.nii.gz 10 output.nii.gz
match-histogram Matches the intensity distribution of the source image to match the distribution of the target image using a piecewise linear function [1].
match-points Writes for each point in a target point set its corresponding point in the source point set. The found correspondences can be either written to an output point set with indices and difference vectors stored as point data, or a text file listing for each target point index the index of the corresponding source point.
measure-volume Measures the volume of each label in the input image
merge-surfaces Merge surface meshes at segmentation label boundaries. The input surfaces must follow closely the boundary of a segment in the given image segmentation. Two surfaces are then merged at the longest common intersection boundary. When the two surfaces share no such segmentation boundary, the surfaces are not connected.
normalize Normalizes the intensity distribution of an image to be similar to the intensity distribution of a given reference image. Moreover, this tool can be used to equalize the histograms of either a single given image or two images using the same transfer function.
offset-surface Displaces surface mesh points by a given amount along the surface normal to create an offset surface mesh. To prevent self-intersections, a dense offset surface can optionally first be sampled from an implicit offset surface model onto which each point of the input surface is projected.
open-image Removes small connections between objects by first eroding and then dilating an input image.
open-scalars Opens scalar data of an input point set by perfoming an erosion followed by the same number of dilations. When the input data array has more than one component, each component is processed separately.
project-onto-surface Assign scalars or labels to either the vertices or the cells of a surface mesh. When the input is a real-valued image, the values are linearly interpolated. When the input is a segmentation image, the value assigned to a vertex/cell is the label of the nearest voxel in the given segmentation image. For the projection of cortical labels onto the WM/GM or GM/CSF boundary, use project-onto-surface -white or project-onto-surface -pial.
recon-neonatal-cortex Reconstruct neonatal cortex from MR brain scan and Draw-EM segmentation
reflect-image Applies a one or more spatial reflections along an image axis. A more generic tool that can also be used to swap two axes is the flip-image command.
register Registers a set of images, polygonal surface meshes, and/or point clouds (e.g. fiducial markers). The set of input images can be comprised of multiple channels (e.g., acquired with different imaging modalities) at different time points. For longitudinal data, the temporal origin in the NIfTI header identifies the time point that each input image belongs to. How all input images and polydata sets are registered with one another is determined by an energy function. This energy function is formulated in a simplified math expression using MATLAB-style indexing for the individual input files, i.e.,
remesh-surface Remeshes a surface mesh such that the resulting mesh has an average edge length within the specified limits. The input surface mesh is triangulated when necessary before the local remeshing passes.
resample-image Resamples an image on a lattice with specified voxel size.
smooth-image This program blurs an input image using a Gaussian filter with a standard deviation equal to the specified sigma value. The dimensions in which the filter recursively applied can be specified by the respective options below. Note that more than one of these options can be specified and that each can also be given more than once. The blurring of the respective dimensions is then performed in the order of the given blurring options.
smooth-surface Smooths the node positions and/or scalar data of a surface mesh.
split-labels Measures the probability of the different labels in the N label maps <labelmap_1> .. <labelmap_N> according to the weights (maps) <weight_1> .. <weight_N> (based on occurence). It then outputs the probability of the specified R labels <label_1> .. <label_R> to <probmap_1> .. <probmap_R>
subdivide-brain-image This program reads a structural brain segmentation and derives from it a segmentation of the brain volume into the following output labels. This output segmentation can then be used to reconstruct topologically correct (i.e., closed genus-0) surfaces of the cGM/WM interface for the left and right hemisphere, where subcortical and deep brain structures are enclosed by these so-called white surfaces. Additionally, the brainstem+cerebellum segment can be respresented by another closed surface mesh. The union of these reconstructured surfaces encloses the entire brain volume, yet excluding cortical grey matter. By deforming the joint brain surface towards the cGM/CSF interface, the pial surface which encloses the entire brain volume including subcortical structures can be obtained. The right/left hemisphere assignment of cortical grey matter follows from the point correspondences between white and pial surfaces, respectively, the RH/LH label may be assigned to white surface mesh nodes upon merging the right/left white surface meshes. See merge-surfaces -source-array option.
transform-image Applies one or more transformations to an input image. Each voxel center of the target image is mapped by the composition of the transformations to the space of the source image. The output intensity for the target voxel is the source image intensity interpolated at the mapped point and cast to the output data type. When the input transformation is the identity map, this command effectively resamples the input image on the finite discrete grid of the transform-image -target image.
transform-points Applies one or more transformations to a set of points. Input point x, y, and z coordinates are either read from STDIN (space separated) or from a point set file. The corresponding transformed coordinates are then written either to STDOUT or an output point set file, respectively. If multiple transformations are specified, these are applied in the order as they appear on the command line.

## Options¶

The following options are common to all mirtk commands. For a complete list of options for each command, see the help page of the respective command linked above or the command help (mirtk help <command>).

### Standard options¶

-v, -verbose [n]

Increase/Set verbosity of output messages. (default: 0)

-debug [level]

Increase/Set debug level for output of intermediate results. (default: 0)

-version [major.minor]

Print version and exit or set version to emulate.

-revision

Print revision (or version) number only and exit.

-h, -help

Print help and exit.

### Terminal options¶

-color, -nocolor

Enable/disable colored output. (default: off)

### Parallelization options¶

-threads <n>

Use maximal <n> threads for parallel execution. (default: automatic)