I'm trying to use sitk library to clear biased Mr image (MRI).
I'm able to get the corrected image but can't get the bias image.
Set the following parameters:
shrink_factor=1,
mask_image=mask,
number_of_iterations=100,
number_of_fitting_levels=4
This is the code I tried
corrected_image = corrector.Execute(image, maskImage)
log_bias_field = corrector.GetLogBiasFieldAsImage(inputImage)
bias_exp = sitk.Cast(sitk.Exp(log_bias_field), sitk.sitkFloat64)
bias = inputImage / bias_exp
bias = sitk.GetArrayFromImage(bias)
bias = bias / bias.max()
But I get this image:
Do you know how to get the bias only?
To get the bias field function you need to decide on what resolution, for the full resolution image:
bias_field_full_resolution = sitk.Exp(corrector.GetLogBiasFieldAsImage(biased_image_full_resolution))
When calling the Execute
method the bias field is estimated and the corrected image has the same resolution as the input, which is often a resampled version of the original biased image.
If we actually want to correct the image at the original resolution:
bias_field_full_resolution = sitk.Exp(corrector.GetLogBiasFieldAsImage(biased_image_full_resolution))
corrected_image_full_resolution = biased_image_full_resolution / bias_field_full_resolution