RAWTOMINC(1)

πŸ’… rawtominc β€” straight outta the MINC User's Guide ✨

🌸 NAME 🌸

rawtominc β€” bestie, this thing converts a stream of binary image data into a minc format file. that's it. that's the job. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

rawtominc [options] output.mnc [[sz4] sz3] sz2 sz1

✨ DESCRIPTION ✨

okay so here's the tea β˜• β€” rawtominc reads a stream of binary data from standard input and writes it into the minc format file output.mnc. and when I say binary data I mean it: byte, short, long, float or double. unless you use the -input option, in which case it reads from a file like a normal person. 🫢

you specify the dimension sizes going from slowest varying to fastest varying. at least two dimensions must be given (that's an image, bestie, you need at least that) but you can go up to four. πŸŽ€

and the options?? the options let you control dimension names, data types, and voxel-to-world coordinate conversion. vector type data (like RGB pixel data, hello πŸ‘‘) can be read in too. iconic.


🌈 PIXEL VALUE SPECIFICATION 🌈

so pixel values are specified by a type and a sign (e.g. signed short integer). they're also characterized by a range of legal values. for example, lots of scanners produce images stored with short integer pixel values. some have values in the range 0 to 4095, others 0 to 32000, others -32768 to 32767. that range is the valid range, and you specify it with the -range option. (for floating point values, the valid range is the maximum and minimum of the whole dataset β€” no cap.)

rawtominc lets you specify both the input type, sign and range and the output type, sign and range. read short values, store byte values, whatever. slay. πŸ’…

there's a further twist though, and it's giving plot twist 😭:

  • Integer pixel values are generally taken to be simply scaled pixel representations of real (meaningful) physical values.
  • Floating point values are taken to be the real value itself.

so floating point values get scanned for the maximum and minimum, since they could be anything β€” and they're stored in the MINC variables image-max and image-min. integer values, however, are not scanned by default, since their range can be given by an option. but if you need to force scanning of integer values when the max and min are not known (some scanners produce files with variable ranges), use the option -scan_range. periodt. ✨


🧚 WORLD COORDINATES 🧚

world coordinates refer to millimetric coordinates relative to some physical origin (either the scanner or some anatomical structure). voxel coordinates are simply the indices into the image volume of a given voxel. and ngl, it's worth describing briefly how MINC coordinate conversions work, because this will affect how successful your new MINC file will be. no pressure bestie πŸ’€

each dimension of a MINC image is specified by name β€” the spatial dimensions are xspace, yspace and zspace. the convention is:

  • positive xspace coordinates run from the patient's left side to right side
  • positive yspace coordinates run from patient posterior to anterior
  • positive zspace coordinates run from inferior to superior

for each of these spatial dimensions, the world coordinate conversion is specified by a pair of attributes: step and start. the xspace world coordinate, for example, is calculated using x = v*step + start, where x is the x world coordinate and v is the voxel count (starting at zero). so:

  • the magnitude of the step attribute specifies the distance between voxels
  • the sign of the step attribute specifies the orientation of the axis

programs will use this information to display images with the correct aspect ratio and orientation, so make sure you get it right. πŸ™ˆ

lots of scanners store transverse images with the first pixel at the patient's anterior/right side, so you'd need to give negative x and y step values. other conventions have the opposite: first pixel at patient's posterior/left, so step values are positive. sometimes the first slice is inferior, so the z step should be positive. other times it's superior, so z step is negative. iykyk 🌸

and here's the part that's lowkey mind-blowing: the image axes do not have to be aligned with the world coordinate axes. the axis directions are recorded in the file as direction cosines β€” unit vectors β€” one for each spatial axis. in this case, the step and start attributes described in the previous paragraph refer to distances along the axis, not to coordinates of the first voxel. this makes them invariant under a change of axis direction (the whole coordinate system can in fact be rotated just by changing the direction cosines, bestie, that's the power ✨). if the coordinate of the first voxel is known, then it can be converted (projected) to a set of start values by using the -origin option. πŸŽ€


πŸ‘‘ OPTIONS πŸ‘‘

πŸ’« Dimension ordering

  • -transverse β€” Transverse images: [[time] z] y x (this is the default, bestie)
  • -sagittal β€” Sagittal images: [[time] x] z y
  • -coronal β€” Coronal images: [[time] y] z x
  • -time β€” Time ordered images: [[z] time] y x
  • -xyz β€” Dimension order: [[time] x] y z
  • -xzy β€” Dimension order: [[time] x] z y
  • -yxz β€” Dimension order: [[time] y] x z
  • -yzx β€” Dimension order: [[time] y] z x
  • -zxy β€” Dimension order: [[time] z] x y
  • -zyx β€” Dimension order: [[time] z] y x
  • -dimorder dim1,dim2[,dim3[,dim4]] β€” specify an arbitrary dimension order, given by a comma-separated list of between 2 and 4 dimension names. go off, customize your order πŸ’…
  • -vector size β€” gives the size of a vector dimension (which is always the fastest varying dimension, no exceptions). default is no vector dimension.

πŸ“ Input data type and range

  • -byte β€” 8-bit integer values (default).
  • -short β€” 16-bit integer values.
  • -int β€” 32-bit integer values.
  • -long β€” superseded by -int. (rip, it's giving legacy πŸ’€)
  • -float β€” single-precision floating point values.
  • -double β€” double-precision floating point values.
  • -signed β€” values are signed integers (default for short and long). ignored for floating point types.
  • -unsigned β€” values are unsigned integers (default for byte). ignored for floating point types.
  • -range min max β€” specifies the valid range of pixel values. default is the full range for the type and sign. this option is ignored for floating point values.
  • -real_range min max β€” specifies the real range of image values that corresponds to the pixel values of option -range. default is to not store the real image minimum and maximum. if -scan_range is used, then the image minimum and maximum corresponding to the scanned pixel minimum and maximum are calculated and stored. this option is ignored for floating point values.
  • -swap_bytes β€” input values (either -short or -int) need to be converted between Motorola (big-endian) and Intel (little-endian) data format. if short input is specified, adjacent bytes are swapped. if int input is specified, inner and outer byte pairs are swapped. this option has no effect with other input types.

πŸ¦„ Output data type and range

  • -obyte β€” store 8-bit integer values (default is input type).
  • -oshort β€” store 16-bit integer values (default is input type).
  • -oint β€” store 32-bit integer values (default is input type).
  • -olong β€” superseded by -oint.
  • -ofloat β€” single-precision floating point values (default is input type).
  • -odouble β€” double-precision floating point values (default is input type).
  • -osigned β€” values are signed integers (default for short and long). ignored for floating point types. if output type is not specified, then default is input sign type.
  • -ounsigned β€” values are unsigned integers (default for byte). ignored for floating point types. if output type is not specified, then default is input sign type.
  • -orange min max β€” specifies the valid range of pixel values. default is the full range for the type and sign. this option is ignored for floating point values. if output type and sign are not specified, then the default is the input range.

πŸ”₯ Scanning integers for range

  • -noscan_range β€” do not scan integer values for their minimum and maximum β€” assume that the -range option gives the appropriate range of pixel values (this is the default). no rescaling of pixel values is done (unless the output type differs from the input type) and the created images are assumed to have a real (not pixel value) minimum and maximum of zero and one.
  • -scan_range β€” integer values are scanned for their minimum and maximum. pixel values are rescaled to give the full range of pixel values and the real minimum and maximum are set to the pixel minimum and maximum (unless -real_range is used). this should be equivalent to converting the input to a floating point type and reading it in with -float -oshort (for example) assuming that -real_range is not used.

πŸ’– Writing output file

  • -2 β€” create MINC 2.0 format output files.
  • -clobber β€” overwrite existing minc file (this is the default).
  • -noclobber β€” don't overwrite existing minc file. (protective era 🫢)

🌟 Reading from input file

  • -input inputfile β€” read input data from inputfile instead of standard input.
  • -skip length β€” skip the first length bytes of the input.

🌈 World coordinate conversion

  • -xstep xstep β€” step size for x dimension (default = none).
  • -ystep ystep β€” step size for y dimension (default = none).
  • -zstep zstep β€” step size for z dimension (default = none).
  • -xstart xstart β€” starting coordinate for x dimension (default = none). this is a distance parallel to the axis.
  • -ystart ystart β€” starting coordinate for y dimension (default = none). this is a distance parallel to the axis.
  • -zstart zstart β€” starting coordinate for z dimension (default = none). this is a distance parallel to the axis.
  • -xdircos x1 x2 x3 β€” direction cosines for x dimension (default = none).
  • -ydircos y1 y2 y3 β€” direction cosines for y dimension (default = none).
  • -zdircos z1 z2 z3 β€” direction cosines for z dimension (default = none).
  • -origin o1 o2 o3 β€” specify the spatial coordinates of the first voxel. if the direction cosines are not given or are the default ones, this option will give the same results as using the -start options. otherwise, the coordinate is projected parallel to the axes to determine the appropriate start values.

okay bestie, that's part 1 of the lore β€” the rest is still loading, don't go anywhere πŸ’–

Frame time and length specification ⏰

ok bestie this is where you tell the program how your time frames are laid out, and it's lowkey strict about it:

  • -frame_times t1,t2,t3,... β€” this sets the start of each time frame. The number of values you give has to match the length of the time dimension you specified on the command line, no exceptions. And here's the thing: all the values have to be in one single argument β€” so no spaces between them, or if you do use spaces, the whole string needs quoting. Separation by spaces instead of commas is permitted, so you have options, but commas are the moment. πŸ’…
  • -frame_widths w1,w2,w3,... β€” this sets the length of each time frame. Everything I just said about -frame_times applies here too, same rules, same energy. 🫢

So like, if you wanna set the start and step values for a functional file with constant frame times, you use the -dattribute flag (described below, keep scrolling bestie) like this:

-dattribute time:step=1 -dattribute time:start=0

periodt, that's the whole vibe for timing. ✨


Imaging modality 🩻

Which flavour of scan are we dealing with? Pick your icon:

  • -nomodality β€” do not store the modality type in the file. This is the default, so if you say nothing, this is what you get.
  • -pet β€” PET data.
  • -mri β€” MRI data.
  • -spect β€” SPECT data.
  • -gamma β€” data from a gamma camera.
  • -mrs β€” MR spectroscopy data.
  • -mra β€” MR angiography data.
  • -ct β€” CT data.
  • -dsa β€” DSA data
  • -dr β€” digital radiography data.

main character modality selection fr fr 🌈


Attribute specification πŸŽ€

  • -sattribute variable:attribute=value β€” says that variable should be created with a string attribute set to value. The complete spec β€” variable, attribute and value β€” has to live in only one argument to the program, so if your string has blanks in it you're gonna need to quote it. 🫢
  • -dattribute variable:attribute=value β€” same as -sattribute, but for specifying double-precision attribute values. numbers girlies rise πŸ’œ
  • -attribute variable:attribute=value β€” like -sattribute or -dattribute, except the type gets chosen for you: it first tries to interpret the value as double precision, and if that fails, then it just assumes the value is a string. it's giving "we'll figure it out" 😭

Generic options ⭐

  • -help β€” print a summary of the command-line options and exit. your little cheat sheet bestie.
  • -version β€” print the program's version number and exit. πŸ’…

AUTHOR πŸ‘‘

Peter Neelin


COPYRIGHTS πŸ“œ

Copyright Β© 1993 by Peter Neelin


ok that's the whole page bestie, you ate that πŸ“ and just so you know, this one's stamped $Date: 2005-02-09 19:27:18 $ and it's page RAWTOMINC(1) β€” so if you're citing it, that's the version and the date, iykyk πŸ’– go forth and convert those raw files, you icon πŸ‘‘βœ¨

πŸ“¦ where this page comes from