Index TableOfContents


mri_diff - test for differences between two volumes


mri_diff [options] vol1file vol2file [options]


Positional Arguments

vol1file, vol2file

volumes to be compared

Optional Flagged Arguments


do not check for resolution diffs


do not check for acq param diffs


do not check for geometry diffs


do not check for precision diffs


do not check for pixel diffs


do not check for orientation diffs


check res, acq, precision, and orientation only

--thresh thresh

pix diffs must be greater than this

--log DiffFile

store diff info in this file


turn on debugging


don't run anything, just check options and exit


print out information on how to use this program


print out version and exit



Volumes are not different and there were no errors


Errors encounted. Volumes may or may not be different


Volumes differ in dimension


Volumes differ in resolution


Volumes differ in acquisition parameters


Volumes differ in geometry


Volumes differ in precision


Volumes differ in pixel data


Volumes differ in orientation


Determines whether two volumes differ. See below for what 'differ' means.

The basic usage is something like:

mri_diff vol1 vol2

It then prints to the terminal whether they differ or not.

NOTE: stuff might get printed to the terminal regardless of whether the volumes are different or not, so you cannot just use the presence or absence of terminal output to determine whether they are different as you can with unix diff.

There are three ways to determine whether they are different: 1. Look for 'volumes differ' in the terminal output 2. Program exits with status > 100 3. Create a log file

To create a log file, add --log yourlogfile any where in the command line, eg:

mri_diff vol1 vol2 --log yourlogfile

If youlogfile exists, it will be immediately deleted when the program starts. If a difference is detected, yourlogfile will be created, and information about the difference will be printed to it. If there is no difference, yourlogfile will not exist when the program finishes.

Volumes can differ in six ways:

  1. Dimension, return status = 101
  2. Resolutions, return status = 102
  3. Acquisition Parameters, return status = 103
  4. Geometry, return status = 104
  5. Precision, return status = 105
  6. Pixel Data, return status = 106

Dimension is number of rows, cols, slices, and frames. Resolution is voxel size. Acqusition parameters are: flip angle, TR, TE, and TI. Geometry checks the vox2ras matrices for equality. Precision is int, float, short, etc.

By default, all of these are checked, but some can be turned off with certain command-line flags:


turns of resolution checking


turns of acquistion parameter checking


turns of geometry checking


turns of precision checking


turns of pixel checking

In addition, the minimum difference in pixel value required to be considered different can be controlled with --thresh. Eg, if two volumes differ by .00001, and you do not consider this to be significant, then --thresh .00002 will prevent that difference from being considered different. The default threshold is 0.

mri_diff can be used to check that two volumes where acquired in the same way with the --qa flag. This turns on Res, Acq, and Prec, and turns of Geo and Pix. Instead of checking geometry, it checks for the basic orientation of the volumes (eg, RAS, LPI, etc). The idea here is that the pixel data and exact geometry may be different, but other things should be the same.



See Also


FreeSurfer, FsFast

Methods Description



Reporting Bugs

Report bugs to <>