The N3 package implements a non-parametric method for correction of intensity non-uniformity in MRI data.

An artifact often seen in MRI is for the signal intensity to vary smoothly across an image. Variously referred to as RF inhomogeneity, shading artifact, or B0 intensity non-uniformity, it is usually attributed to such factors as poor radio frequency (RF) field uniformity, eddy currents driven by the switching of field gradients, and patient anatomy both inside and outside the field of view.

nu_correct implements an approach to correcting for intensity non-uniformity in MR data that achieves high performance without requiring supervision. By making relatively few assumptions about the data, the method can be applied at an early stage in an automated data analysis, before a tissue intensity or geometric model is available. Described as Non-parametric Non-uniform intensity Normalisation (N3), the method is independent of pulse sequence and insensitive to pathological data that might otherwise violate model assumptions.

To eliminate the dependence of the field estimate on anatomy, an iterative approach is used to estimate both the multiplicative bias field and the distribution of the true tissue intensities. Pre processing of MR data using N3 has been shown to substantially improve the accuracy of anatomical analysis techniques such as tissue classification, registration and cortical surface extraction.

The N3 package's contents edit

There are a number of scripts and tools included in the N3 package. The main script that you will use is nu_correct. Each script or executable has its own own help page which can be accessed as such:

   nu_correct -help 

nu_correct makes use of a number of other binaries and scripts that are also useful on their own. Their functionality is summarised below:

 nu_correct     estimates and removes intensity non-uniformity from a volume.
 nu_estimate    estimates the intensity non-uniformity in a volume, 
                storing the result in a compact format referred to as an .imp file.
 nu_evaluate    corrects the intensity non-uniformity in a volume using the given .imp file.
 imp2field      expands an .imp file into a MINC volume representation of the correction field.
 field2imp      converts a MINC volume representation of a correction field into an .imp file.
 spline_smooth  smooths a volume using tensor cubic B splines or thin plate splines.

What N3 does and how to use it edit

B0 non-uniformity is difficult to detect when simply looking at images without the assistance of a judiciously ranged color map. In our test case we'll start with a simple T1 MPRAGE image from a 1.5T Siemens scanner.


The above image and all the images here were created using mincpik in a similar fashion to the below.

  mincpik -scale 2 original.mnc -slice 150 -image_range 10 80 original.png

Note that it is difficult to pick the non-uniformity in the image unless you look carefully at the intensity of the white matter in the lower parts of the image. In order to correct this image we run nu_correct with the default parameters.

  nu_correct original.mnc out.mnc

This will produce two output files

  out.mnc - the corrected minc file
  out.imp - the intensity correction field

We can now take a look at the corrected file (out.mnc)


As it is very hard to pick the differences between the original and corrected version we can create a field image to visualise the differences.

  imp2field -like out.mnc out.imp field.mnc

And then produce an image of it using the Spectral colormap

  mincpik -scale 2 field.mnc -slice 150 -lookup -spectral field.png


And then for completeness sake, here are the original and corrected image using a spectral colormap to better visualise the change. Note that in the second (corrected) image the intensity of the white matter is more uniform (the red part).


Frequently Asked Questions about MNI N3 edit

How can I convert raw data to the format that N3 uses?

N3 uses data in the MINC file format. The minc package provides two programs rawtominc and minctoraw for converting raw data to and from minc format respectively. An example of using these programs is as follows. Suppose the data is unsigned short integers consisting of twenty-four 256 by 256 slices. If this data came from an MRI scanner producing 12 bit data with different endian than the machine running rawtominc then one might do the conversion as follows:

  dd conv=swab if=mydata.raw | rawtominc -transverse -short -unsigned \
     -xstep -1 -ystep -1 -zstep 5.5 -mri -origin 0 0 0 \
     -range 0 4095 -real_range 0 4095 -clobber mydata.mnc 24 256 256 

And the conversion back to raw as follows:

   minctoraw -range 0 1800 -normalize somedata.mnc | dd conv=swab of=somedata.raw 

N3 produces an error message when I specify a mask volume. What's wrong?

The masked region for N3 is defined as any voxel greater than zero. However, the program extracttag which resamples the mask into the working resolution has some peculiarities which can result in errors. The trouble is that extracttag is fussy about the real range of the data set. In the minc format the mapping between the raw binary data (so called voxel values) and their interpretation as real numbers (so called real values) is somewhat arbitrary.

By default rawtominc sets the mapping to map the entire range of voxel values to the range [0, 1]. This can be overridden by giving the -range and -real_range options. For example, for 12 bit MR data one might choose -range 0 4095 -real_range 0 4095. Anyway, I'm not exactly clear on what extracttag excepts and doesn't except. However, I have found the command

   mincmath -gt -const 0 old_mask.mnc new_mask.mnc 

fixes the problem.

As an aside about real and voxel ranges, keep in mind that N3 treats values less than one as part of the background. Hence, a data set created by rawtominc without a range specification will yeild a volume that is empty as far as N3 is concerned.

Can N3 be used on single slice data?

Yes, it works fine on single slice data. Note, however, that a bug in version 1.02 may create erratic results for volumes with only a few slices. This is fixed in version 1.04.

Can I use N3 for surface coil data?

Yes, however the default settings are not optimal. Due to the extreme non-uniformity in surface coil data, N3 usually hits its iteration limit before the correction is complete. Try using nu_correct with the options -iterations 150. If that doesn't help, try reducing the stopping threshold as well by adding the option -stop 0.0001.

Why do I get a different result when I run N3 a second time?

For volumes with particularly severe non-uniformity, N3 reachs its iteration limit before the algorithm has converged. In these instances running the algorithm a second time should improve upon the result. However, it is more straight forward to adjust the stopping criteria using the -iterations and -stop options to set the maximum number of iterations and minimum change in field estimate respectively. Try for example the option '-iteration 150'.

Bibliography edit

  1. J. G. Sled, A. P. Zijdenbos, and A. C. Evans, ``A non-parametric method for automatic correction of intensity non-uniformity in MRI data, IEEE Transactions on Medical Imaging, vol. 17, pp. 87-97, February 1998.
  2. J. G. Sled, A. P. Zijdenbos, and A. C. Evans, ``A comparison of retrospective intensity non-uniformity correction methods for MRI, in Information Processing in Medical Imaging, pp. 459-464, 1997. (Conference poster: HTML version)
  3. J. G. Sled, ``A non-parametric method for automatic correction of intensity non-uniformity in MRI data, Master's thesis, McGill University, Montreal, QC, May 1997. (available at

Further information and Questions edit

Use the minc-users mailing list