convertx(1)

๐Ÿ’– convertx(1) โ€” The Computational Morphology Toolkit ๐Ÿ’–

okay bestie, gather round, because convertx is that girl. she's the one in the CMTK (Computational Morphology Toolkit) friend group who can change your image's file format AND its pixel data type AND casually do a whole glow-up of image operations on the way through. no cap.


โœจ NAME โœจ

convertx โ€” like, convert between image file formats and data types? that's literally her whole thing. ๐Ÿ’…

๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

convertx [options] infile outfile

๐ŸŒธ DESCRIPTION ๐ŸŒธ

so convertx converts between image file formats and pixel data types, and while she's at it she can also apply simple, general-purpose image operations. iconic behavior honestly.

and here's the part that's giving main character energy: you can put an arbitrary number of operations on the command line, and they get applied exactly in the order you gave them. in order. in the order. periodt. โœจ


๐Ÿ‘‘ OPTIONS ๐Ÿ‘‘

๐Ÿซถ Global Toolkit Options (these are shared by all CMTK tools)

yes bestie, every CMTK tool has these. they're the communal bestie group chat. ๐Ÿ’ฌ

  • --help โ€” writes the list of basic command line options to standard output. baby's first flag. ๐ŸŒฑ
  • --help-all โ€” writes the COMPLETE list of basic AND advanced command line options to standard output. the deluxe version. ๐Ÿ”ฅ
  • --wiki โ€” writes the list of command line options to standard output, but formatted in MediaWiki markup. for when you're being wiki-famous. ๐Ÿ“
  • --man โ€” writes the man page source in nroff markup to standard output. meta af. ๐ŸŒ€
  • --version โ€” writes the toolkit version to standard output. identity check! ๐Ÿชช
  • --echo โ€” writes the current command line to standard output. she repeats you back to yourself. ๐Ÿ—ฃ๏ธ
  • --verbose-level <integer> โ€” sets the verbosity level. how much do you want her to yap. ๐Ÿ“ข
  • --verbose, -v โ€” increments the verbosity level by 1. โš ๏ธ this one is deprecated โ€” it's only supported for backward compatibility, so likeโ€ฆ she's still here for you but don't build your whole personality on it. ๐Ÿฅฒ
  • --threads <integer> โ€” sets the maximum number of parallel threads (for POSIX threads and OpenMP). multitasking queen. ๐Ÿงตโœจ

๐Ÿ—‚๏ธ Image/Transformation Database

  • --db <string> โ€” path to the image/transformation database that should be updated with the newly created image. [Default: NONE] ๐Ÿ“š

๐Ÿ–ผ๏ธ Input Image Controls

  • --set-padding <double> โ€” sets a padding value: literally every pixel in the input image that has this value gets ignored in all subsequent operations. she's on do-not-disturb. ๐Ÿšซ
  • --unset-padding โ€” unsets the padding value: for all subsequent operations, all pixels are treated according to their value. everyone's invited again. ๐Ÿ’Œ
  • --labels โ€” says that the image values are to be treated as discrete labels. this means the appropriate intent code gets set in output files in NIfTI format. ๐Ÿท๏ธ
  • --grey โ€” says that the image values are to be treated as continuous grey levels. this resets the intent code in files read from NIfTI format. ๐ŸŒซ๏ธ

๐Ÿ”ข Data Type Conversion

pick your pixel flavor, bestie:

  • --char โ€” 8 bits, signed integer
  • --byte โ€” 8 bits, unsigned integer
  • --short โ€” 16 bits, signed integer
  • --ushort โ€” 16 bits, unsigned integer
  • --int โ€” 32 bits signed integer
  • --uint โ€” 32 bits unsigned integer
  • --float โ€” 32 bits floating point
  • --double โ€” 64 bits floating point

๐Ÿ’ซ Value Mappings

  • --map-values <string> โ€” applies a mapping function to pixel values. the mapping is defined as 'VAL0[,VAL1,...][:NEWVAL]' and it maps values VAL0, VAL1, etc. to the new value NEWVAL. if NEWVAL isn't given, the values get set to padding. ๐Ÿ’ซ
  • --map-values-only <string> โ€” applies a mapping function to pixel values and replaces unmapped pixels with padding. multiple such mapping rules can be concatenated as RULE0+RULE1[+...], and all the concatenated rules get applied simultaneously. the mapping is defined as 'VAL0[,VAL1,...][:NEWVAL]' to map values VAL0, VAL1, etc. to the new value NEWVAL. if NEWVAL isn't given, the values are set to padding. multiple such mapping rules can be concatenated as RULE0+RULE1[+...], and all the concatenated rules will be applied simultaneously. (yes, she said it twice. she MEANT it twice. ๐Ÿ’€)
  • --replace-padding <double> โ€” replaces padded pixel data with the given value. glow up for the ignored girlies. โœจ
  • --replace-inf-nan <double> โ€” replaces all infinite and not-a-number pixels with the given value. she does not tolerate inf or NaN drama. ๐Ÿšฎ

๐Ÿ”„ Image Flipping

  • --flip-x โ€” flip (mirror) along the x-direction
  • --flip-y โ€” flip (mirror) along the y-direction
  • --flip-z โ€” flip (mirror) along the z-direction

mirror mirror on the wall, who's the flipped-est of them all ๐Ÿชž

๐ŸŽญ Image Masking and Thresholding

  • --mask <string> โ€” binary mask file name: eliminates all image pixels where the mask is 0. โš ๏ธ masked-out pixels are NOT set to zero โ€” they get replaced with the currently-set padding value instead. so if you want them forced to zero, run --set-padding 0 before --mask. order matters, bestie, it always does. ๐Ÿซ 
  • --mask-inverse <string> โ€” inverse binary mask file name: eliminates all image pixels where the mask is NOT 0. and go read the notes about padding under --mask above, same deal applies. ๐Ÿ”
  • --thresh-below <double> โ€” sets all values below the threshold to the threshold value. ๐ŸŒก๏ธ
  • --thresh-above <double> โ€” sets all values above the threshold to the threshold value. ๐Ÿ”ฅ
  • --thresh-below-to-padding <double> โ€” sets all values below the threshold to the padding value. ๐Ÿซฅ
  • --thresh-above-to-padding <double> โ€” sets all values above the threshold to the padding value. ๐Ÿซฅ
  • --binarize-thresh <double> โ€” sets all values below the threshold to 0, and all values equal to or above it to 1. it's giving binary. 0๏ธโƒฃ1๏ธโƒฃ
  • --otsu-thresh โ€” binarizes the image to 0/1 using a threshold computed with Otsu's method. the argument is the number of histogram bins for the threshold computation. ๐Ÿงฎ
  • --otsu-thresh-nbins <integer> โ€” binarization using Otsu's method, with a user-defined number of histogram bins for the threshold computation. you're the boss of the bins now. ๐Ÿ—ƒ๏ธ
  • --prune-histogram <integer> โ€” thresholds the image by 'intensity histogram pruning', i.e. for the given argument n (in histogram bins), it determines thresholds such that the 1/n-th fraction of highest and lowest voxels get thresholded. bye to both extremes ๐Ÿช“
  • --prune-histogram-high <integer> โ€” just like --prune-histograms, but only removes high intensities. โœ‚๏ธ
  • --prune-histogram-low <integer> โ€” just like --prune-histograms, but only removes low intensities. โœ‚๏ธ

๐ŸŒˆ Intensity Transformations

  • --scale-to-range <string> โ€” scales image intensities to the range 'from:to', e.g. '0:255', before conversion to byte data. ๐Ÿ“
  • --histogram-equalization โ€” applies histogram equalization. โœจ
  • --histogram-equalization-nbins <integer> โ€” applies histogram equalization with <int> number of bins. ๐Ÿงบ
  • --match-histograms <string> โ€” transforms intensities to match the distribution in the image provided as the argument for this command. twinning fr. ๐Ÿ‘ฏ
  • --match-mean-sdev <string> โ€” scales intensities to match the mean and standard deviation of intensities in the image provided as the argument for this command. statistically matching, we love to see it. ๐Ÿ“Š

๐Ÿฆ  Morphological Operations

  • --revert โ€” reverts a binary mask, i.e. exchanges foreground and background. uno reverse card ๐Ÿƒ
  • --erode <integer> โ€” morphological erosion operator (by pixels). ๐Ÿฝ๏ธ
  • --dilate <integer> โ€” morphological dilation operator (by pixels). ๐ŸŽˆ
  • --erode-distance <double> โ€” morphological erosion operator (by distance). often preferable for anisotropic data, jsyk. ๐Ÿ“
  • --erode-distance-multilabel <double> โ€” morphological erosion operator (by distance) for multi-label maps. ๐Ÿ’… the result will be either byte, unsigned short, or unsigned int data, depending on the index of the largest used label in the input. so she picks her own outfit based on the input, basically.
  • --dilate-distance <double> โ€” morphological dilation operator (by distance). oftern preferable for anisotropic data. (she typed "oftern" and honestly? she's keeping it. ๐Ÿ’€)
  • --connected-components โ€” creates a connected components map with regions numbered by decreasing component size. biggest girlies get the lowest numbers. ๐Ÿ”ข
  • --boundary-map โ€” creates a boundary map. ๐Ÿšง
  • --multi-boundary-map โ€” creates a multi-valued boundary map. ๐Ÿšง๐Ÿšง
  • --distance-map โ€” computes an unsigned Euclidean distance map. the input image is interpreted as a binary mask. ๐Ÿ“
  • --signed-distance-map โ€” computes a signed Euclidean distance map (inside = negative, outside = positive). โž•โž–

๐Ÿงš Filter Operations

heads up: all the regional filters below take the filter radius in pixels as the parameter. a single integer defines the kernel radius in all three dimensions, and three comma-separated integers define separate radii for the three dimensions. say it with me: 1 or 1,1,1. iykyk. ๐ŸŽ€

  • --median-filter <string> โ€” median filter. radius in pixels as described above. ๐ŸŽฏ
  • --mean-filter <string> โ€” regional mean filter. radius in pixels as described above. โš–๏ธ
  • --fast-mean-filter <string> โ€” regional mean filter, but fast and in linear time. same radius rules. ๐ŸŽ๏ธ
  • --variance-filter <string> โ€” regional variance filter. same radius rules. ๐Ÿ“ˆ
  • --fast-variance-filter <string> โ€” fast (linear-time) regional variance filter. same radius rules. ๐ŸŽ๏ธ
  • --third-moment-filter <string> โ€” regional third moment filter. same radius rules. ๐Ÿฅ‰
  • --standard-deviation-filter <string> โ€” regional standard deviation filter. same radius rules. ๐Ÿ“‰
  • --smoothness-filter <string> โ€” regional 'smoothness' filter. same radius rules. ๐Ÿงด
  • --gaussian-filter-sigma <double> โ€” filters the image with a Gaussian kernel. this one takes a single real-valued parameter, which specifies the kernel coefficient sigma in world units [e.g., mm]. ๐Ÿซง
  • --gaussian-filter-fwhm <double> โ€” filters the image with a Gaussian kernel. this one takes a single real-valued parameter, which specifies the kernel full width at half maximum in world units [e.g., mm]. ๐Ÿซง
  • --laplace-filter โ€” filters the image with an edge-enhancing Laplacian kernel. edge edges edges. ๐Ÿ”ช

๐Ÿ•ธ๏ธ Grid Operations

  • --downsample-select <string> โ€” downsamples the image by pixel selection, using per-axis factors 'Fx,Fy,Fz' or a single factor 'Fxyz'. โœ‚๏ธ
  • --downsample-average <string> โ€” downsamples the image by averaging, using per-axis factors 'Fx,Fy,Fz' or a single factor 'Fxyz'. ๐Ÿงฎ
  • --resample <double> โ€” resamples the image to near-isotropic pixels while preserving the image field-of-view. takes one argument: the target resolution in world units [e.g., mm]. ๐Ÿ”„

aand that's part 1, bestie!! the page keeps going, so stay tuned for the rest ๐Ÿ’–โœจ

  • --resample-exact <double> โ€” resamples your image so the pixels become exactly isotropic at the resolution you give it, while keeping the image field-of-view matching as closely as humanly possible ๐ŸŽ€ it takes one argument: the target resolution in world units (so like, mm bestie) ๐Ÿ’…
  • --crop-by-index <string> โ€” crops the image to a region you specify with six grid index coordinates, handed over as comma-separated integers: x0,y0,z0,x1,y1,z1 โœ‚๏ธโœจ
  • --crop-by-threshold <double> โ€” crops the image to whatever region a given threshold decides, and the resulting image will contain all pixels larger than the parameter you passed ๐ŸŒธ
  • --crop-by-threshold-write-region <double> โ€” same threshold-crop vibe, but it writes the cropping region to standard output ๐Ÿ‘‘
  • --crop-by-threshold-write-xform <double> โ€” again, crop by threshold, except this one writes the cropping transformation to standard output ๐Ÿ”ฅ

๐Ÿ’– AUTHORS ๐Ÿ’–

Torsten Rohlfing, with contributions from Michael P. Hasak, Greg Jefferis, Calvin R. Maurer, Daniel B. Russakoff, and Yaroslav Halchenko ๐Ÿซถ squad goals fr fr


๐Ÿ“œ LICENSE ๐Ÿ“œ

http://www.fsf.org/licensing/licenses/gpl.html โ€” that's the whole thing, no cap, go read it ๐Ÿ’œ


๐Ÿ’€ BUGS ๐Ÿ’€

Found a bug? Report it at http://nitrc.org/projects/cmtk/ ๐Ÿ› not me gatekeeping the bug tracker, go tell them bestie


๐ŸŒˆ ACKNOWLEDGMENTS ๐ŸŒˆ

CMTK is developed with support from the NIAAA under Grant AA021697, National Consortium on Alcohol and Neurodevelopment in Adolescence (N-CANDA): Data Integration Component. From April 2009 through September 2011, CMTK development and maintenance was supported by the NIBIB under Grant EB008381 โœจ iconic funding behaviour honestly


and that's the whole page, we did it ๐ŸŽ‰ this bad boy is CMTK 3.3.1p2, dated Jun 24 2026, and it's convertx(1) โ€” now go crop something, slay ๐Ÿ’…๐Ÿ‘‘๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from