MR scans often display intensity non-uniformities due to variations in the magnetic field. So, one part of an image might appear lighter or darker when visualized, solely because of variations in the magnetic field. The map of these variations is called the bias field. The bias field can cause problems for a classifier as the variations in signal intensity are not due to any anatomical differences. ANTs N4 Bias Field Correctionattempts to correct the bias field by extracting it from the image.
#-*-coding:utf-8-*-
import os
import shutil
import SimpleITK as sitk
import warnings
import glob
import numpy as np
from nipype.interfaces.ants import N4BiasFieldCorrection
def correct_bias(in_file, out_file, image_type=sitk.sitkFloat