Let’s reset and read in the T1 image from a MS lesion data set:
t1 = neurobase::readnii("training01_01_t1.nii.gz") t1[ t1 < 0 ] = 0
Let’s reset and read in the T1 image from a MS lesion data set:
t1 = neurobase::readnii("training01_01_t1.nii.gz") t1[ t1 < 0 ] = 0
Image From https://www.slicer.org/w/images/7/77/MRI_Bias_Field_Correction_Slicer3_close_up.png
It’s hard to see subtler bias fields, but sometimes they can be seen visually.
ortho2(robust_window(t1))
flair = neurobase::readnii("training01_01_flair.nii.gz") ortho2(robust_window(flair))
image(robust_window(t1), useRaster = TRUE)
We will use N4: Improved N3 Bias Correction (Tustison et al. 2010).
The model assumed in the N4 is: \[ v(x) = u(x)f(x) + n(x) \]
The data is log-transformed and assuming a noise-free scenario, we have:
\[ \log(v(x)) = \log(u(x)) + \log( f(x) ) \]
Here we will use the bias_correct
function in extrantsr
, which calls n4BiasFieldCorrection
from ANTsR
.
You can pass in the image:
library(extrantsr) bc_t1 = bias_correct(file = t1, correction = "N4")
or the filename (but negatives are in there):
bc_t1 = bias_correct(file = "training01_01_t1.nii.gz", correction = "N4")
Here we take the ratio of the images and overlay it on the original image:
ratio = t1 / bc_t1; ortho2(t1, ratio)
We are breaking the ratio into quantiles:
ortho2(t1, ratio, col.y = colors, ybreaks = quantiles, ycolorbar = TRUE)
extrantsr
bias_correct
function
fsl_biascorrect
from fslr
(not as effective in our experience)Tustison, Nicholas J., Brian B. Avants, Philip A. Cook, Yuanjie Zheng, Alexander Egan, Paul A. Yushkevich, and James C. Gee. 2010. “N4ITK: Improved N3 Bias Correction.” IEEE Transactions on Medical Imaging 29 (6):1310–20. https://doi.org/10.1109/TMI.2010.2046908.