Implemention
The N4ITK implementation is given as a single class itk::N3MRIBiasFieldCorrectionImageFilter. It is derived from the itk::ImageToImageFilter class (as is the related class itk::MRIBiasFieldCorrectionFilter) since its operation takes the MR image (with an associated mask) corrupted by a bias field as input, and outputs the corrected image. For the user that wants to reconstruct the bias field once the algorithm terminates, we demonstrate how that can be accomplished with the additional class itk::BSplineControlPointImageFilter which is included with this submission. Note that it is only needed if the bias field is to be reconstructed after the N3 algorithm terminates.
Algorithmic Overview
The steps for the N3 algorithm are illustrated in Figure 4 of [3]. Initially, the intensities of the input image are transformed into the log space and an initial log bias field of all zeros is instantiated. In N3MNI, an option is given whereby the user can provide an initial bias field estimate but, to keep the options to a minimum, we decided to omit that option. However, given the open-source nature of the code, the ITK user can modify the code according to preference. After initialization, we iterate by alternating between estimating the unbiased log image and estimating the log of the bias field.
Parameters
One of the attractive aspects of the N3 algorithm is the minimal number of parameters available to tune and the relatively good performance achieved with the default parameters which we tried to maintain, where we could, for both N3MNI and [3]. The available parameters are:

Figure 1: (a) Uncorrected image. (b) Mask image. (c) Bias field
corrected image. (d) Uncorrected image with the calculated bias field superimposed.
Bias Field Generation
Oftentimes, the user would like to see the calculated bias field. One of the more obvious reasons for this would be when the bias field is calculated on a downsampled image (suggested in [3] and given as an option in N3MNI and included in the testing code). One would then like to reconstruct the bias field to estimate the corrected image in full resolution. Since the B-spline bias field is a continuous object defined by the control point values and spline order, we can reconstruct the bias field of the full resolution image without loss of accuracy. We demonstrate how this is to be done in the test code itkN3MRIBiasFieldCorrectionImageFilterTest.cxx. Note that the control points describe a B-spline scalar field in log space so the itk::ExpImageFilter has to be used after reconstruction.
Test Code
The test code included with this submission, itkN3MRIBiasFieldCorrectionImageFilterTest.cxx, is designed to allow the user to immediately apply the N4ITK classes to their own images. Usage is given as follows:
This class takes the input image, subsamples it according to the optional shrinkFactor option, and creates the bias field corrected output image. Other optional parameters are the maskImage (if not available, one is created using the itk::OtsuThresholdImageFilter), the number of iterations (default = 50), the number of fitting levels (default = 4), and a file name for writing out the resulting bias field.
Sample Results
We demonstrate usage with two MR images—a 2D brain slice and a volume from a hyperpolarized helium-3 image. We use ITK-SNAP to visualize the results.
2D Brain Slice
Figure 1(a) is the uncorrected image used in our 2D brain test. Close inspection demonstrates a darkening in the white matter toward the upper right of the image. This darkening is corrected in Figure 1(c).
3D Hyperpolarized Helium-3 Lung MRI
Figure 2(a) is the uncorrected image used in our 3D helium-3 MR image volume. Close inspection demonstrates a darkening in the white matter toward the upper portion of the given axial slice. This darkening is corrected in Figure 2(c).

Figure 2: (a) Uncorrected image. (b) Mask image. (c) Bias field corrected image. (d) Uncorrected image with the calculated bias field superimposed.
References
[1] R. G. Boyes, J. L. Gunter, C. Frost, A. L. Janke, T. Yeatman, D. L.G. Hill, M. A. Bernstein, P. M. Thompson, M. W. Weiner, N. Schuff, G. E. Alexander, R. J. Killiany, C. DeCarli, C. R. Jack, N. C. Fox, and A. D. N. I. Study. Intensity non-uniformity correction using n3 on 3-t scanners with multichannel phased array coils. Neuroimage, 39(4):1752–1762, Feb 2008.
[2] Zujun Hou. A review on mr image intensity inhomogeneity correction. Internation Journal of Biomedical Imaging, 2006:1–11, 2006.
[3] J. G. Sled, A. P. Zijdenbos, and A. C. Evans. A nonparametric method for automatic correction of intensity nonuniformity in MRI data. IEEE Transactions on Medical Imaging, 17(1):87–97, Feb 1998.
[4] M. Styner, C. Brechbuhler, G. Szckely, and G. Gerig. Parametric Estimate of Intensity Inhomogeneities Applied to MRI. IEEE Transactions on Medical Imaging, 19(3):153–165, March 2000.
[5] N. J. Tustison and J. C. Gee. N-d Ck B-spline scattered data approximation. The Insight Journal, 2005.
[6] N. J. Tustison and J. C. Gee. Generalized n-d Ck B-spline scattered data approximation with confidence values. In Proc. Third International Workshop Medical Imaging and Augmented Reality, pages 76–83, 2006.
[7] U. Vovk, F. Pernus, and B. Likar. A review of methods for correction of intensity inhomogeneity in mri. IEEE Transactions on Medical Imaging, 26(3):405–421, March 2007.
[8] A listing of several relevant algorithms compiled by Finn A. Nielsen at the Technical University of Denmark is provided at http://neuro.imm.dtu.dk/staff/fnielsen/bib/ and clicking on the folder "Nielsen2001BibSegmentation/".
[9] http://www.bic.mni.mcgill.ca/software/N3/
[10] A complete discussion of ‘N4’ is provided at hdl.handle.net/10380/3053.
Nick Tustison borders his moments of software-writing serenity at the Penn Image Computing and Science Lab (PICSL) with attempts at integrating Heidegger’s notion of “Dasein” with the open source software paradigm---oh, and battling ninjas, too.
.