-
Notifications
You must be signed in to change notification settings - Fork 1
Bias Field Correction
Patient position in the scanner, the scanner itself, head coils, temperature, and many other issues can result in intensity heterogeneity across the MR image. In other words, the intensity value can vary within the same tissue in a way that is not biologically meaningful. This is known as a bias field. It's a low frequency smooth undesirable signal that corrupts MR images. The bias field results in inhomogeneities in the magnetic field of the MRI machine. The bias field, if not corrected, can cause all imaging processing algorithms like segmentation (e.g., Freesurfer) and classification to output less than ideal results. A preprocessing step is needed to correct for the effect of bias field before doing segmentation or classification.
FreeSurfer's main processing pipeline corrects the bias field automatically. This means you should not need to run bias field corrections separately.
However, if you are running other segmentation processes, it is good to be aware of bias field problems. You ideally should use images with bias field corrections.
The most automated methods I prefer are either using FreeSurfer or FSL. Below, I will post an alternative method using ANTs that also works well.
As previously stated, bias field correction is done automatically in the standard recon-all
stream. You could use FreeSurfer's nu_correct
to run it separately but I prefer to use FSL.
I like the FSL script fsl_anat.
The stages in the pipeline (in order) are:
- Reorient the images to the standard (MNI) orientation [fslreorient2std]
- Automatically crop the image [robustfov]
- Bias-field correction (RF/B1-inhomogeneity-correction) [FAST]
- Registration to standard space (linear and non-linear) [FLIRT and FNIRT]
- Brain-extraction [FNIRT-based or BET]
- Tissue-type segmentation [FAST]
- Subcortical structure segmentation [FIRST]
This will be covered elsewhere too but it is a script I run on all my T1 images. One of the outputs will be a bias field corrected T1 image. The whole stream takes about 20-90 minutes, depending on the image and your computer speed. I should note that step 7 sometimes does not complete. This does not affect earlier steps.
Refer to this page if you do not have ANTs installed. While I have commands there to run an ANTs-based bias field correction, more complete instructions are below. You will need to set the environmental variables when you want to use the application (I suggest adding these to your .bash_profile
or .bashrc
files so you don't need to do this each time):
$ export ANTSPATH=/usr/local/antsbin/bin/
$ PATH=${ANTSPATH}:${PATH}
The ANTSPATH
variable should be edited to match the path on your installation.
To run the script, you should be able to type in a new Terminal window to see the available options:
$ N4BiasFieldCorrection --help
COMMAND:
N4BiasFieldCorrection
N4 is a variant of the popular N3 (nonparameteric nonuniform normalization)
retrospective bias correction algorithm. Based on the assumption that the
corruption of the low frequency bias field can be modeled as a convolution of
the intensity histogram by a Gaussian, the basic algorithmic protocol is to
iterate between deconvolving the intensity histogram by a Gaussian, remapping
the intensities, and then spatially smoothing this result by a B-spline modeling
of the bias field itself. The modifications from and improvements obtained over
the original N3 algorithm are described in the following paper: N. Tustison et
al., N4ITK: Improved N3 Bias Correction, IEEE Transactions on Medical Imaging,
29(6):1310-1320, June 2010.
OPTIONS:
-d, --image-dimensionality 2/3/4
This option forces the image to be treated as a specified-dimensional image. If
not specified, N4 tries to infer the dimensionality from the input image.
-i, --input-image inputImageFilename
A scalar image is expected as input for bias correction. Since N4 log transforms
the intensities, negative values or values close to zero should be processed
prior to correction.
-x, --mask-image maskImageFilename
If a mask image is specified, the final bias correction is only performed in the
mask region. If a weight image is not specified, only intensity values inside
the masked region are used during the execution of the algorithm. If a weight
image is specified, only the non-zero weights are used in the execution of the
algorithm although the mask region defines where bias correction is performed in
the final output. Otherwise bias correction occurs over the entire image domain.
See also the option description for the weight image.
-w, --weight-image weightImageFilename
The weight image allows the user to perform a relative weighting of specific
voxels during the B-spline fitting. For example, some studies have shown that N3
performed on white matter segmentations improves performance. If one has a
spatial probability map of the white matter, one can use this map to weight the
b-spline fitting towards those voxels which are more probabilistically
classified as white matter. See also the option description for the mask image.
-s, --shrink-factor 1/2/3/4/...
Running N4 on large images can be time consuming. To lessen computation time,
the input image can be resampled. The shrink factor, specified as a single
integer, describes this resampling. Shrink factors <= 4 are commonly used.
-c, --convergence [<numberOfIterations=50x50x50x50>,<convergenceThreshold=0.0>]
Convergence is determined by calculating the coefficient of variation between
subsequent iterations. When this value is less than the specified threshold from
the previous iteration or the maximum number of iterations is exceeded the
program terminates. Multiple resolutions can be specified by using 'x' between
the number of iterations at each resolution, e.g. 100x50x50.
-b, --bspline-fitting [splineDistance,<splineOrder=3>]
[initialMeshResolution,<splineOrder=3>]
These options describe the b-spline fitting parameters. The initial b-spline
mesh at the coarsest resolution is specified either as the number of elements in
each dimension, e.g. 2x2x3 for 3-D images, or it can be specified as a single
scalar parameter which describes the isotropic sizing of the mesh elements. The
latter option is typically preferred. For each subsequent level, the spline
distance decreases in half, or equivalently, the number of mesh elements doubles
Cubic splines (order = 3) are typically used.
-t, --histogram-sharpening [<FWHM=0.15>,<wienerNoise=0.01>,<numberOfHistogramBins=200>]
These options describe the histogram sharpening parameters, i.e. the
deconvolution step parameters described in the original N3 algorithm. The
default values have been shown to work fairly well.
-o, --output correctedImage
[correctedImage,<biasField>]
The output consists of the bias corrected version of the input image.
Optionally, one can also output the estimated bias field.
-h
Print the help menu (short version).
--help
Print the help menu.
<VALUES>: 1
If you don't see any output like that, you don't have the N4BiasFieldCorrection script in your ANTs bin directory.
Correcting the bias field can be time consuming on the computer. One way to mitigate the computer processing time is to run the program several times on the same image from starting very coarse and moving in more finely:
$ N4BiasFieldCorrection -d 3 -i ~/preprocessing-t1-example/sub001-T1.nii -o ~/preprocessing-t1-example/sub001-T1_N4bias.nii.gz -s 8 -b [200] -c [50x50x50x50,0.000001]
$ N4BiasFieldCorrection -d 3 -i ~/preprocessing-t1-example/sub001-T1_N4bias -o ~/preprocessing-t1-example/sub001-T1_N4bias -s 4 -b [200] -c [50x50x50x50,0.000001]
$ N4BiasFieldCorrection -d 3 -i ~/preprocessing-t1-example/sub001-T1_N4bias -o ~/preprocessing-t1-example/sub001-T1_N4bias -s 2 -b [200] -c [50x50x50x50,0.000001]
Of course, you can modify any of the input and output files to match your naming convention and image location.