tools.bias_field_correct#
- bartorch.tools.bias_field_correct()#
Divide a magnitude image by its N4-estimated multiplicative bias field.
The field is SimpleITK’s N4 estimate [1], a B-spline fitted on the image shrunk by
shrink_factorand evaluated on the full grid. Voxels where the field is zero are set to zero.- Parameters:
image (torch.Tensor) – Real 2D or 3D magnitude image, typically after coil combination.
mask (torch.Tensor, default=None) – Voxels the field is estimated over, shaped like
image.Noneuses Otsu’s threshold of the image.shrink_factor (int, default=4) – Downsampling factor of the grid the field is fitted on.
iterations (tuple of int, default=(50, 50, 50, 50)) – Maximum iterations per fitting level, coarsest first.
fitting_levels (int, default=None) – Number of fitting levels;
len(iterations)ifNone.return_field (bool, default=False) – Also return the field.
- Returns:
corrected (torch.Tensor) –
imagedivided by the field, with the dtype and device ofimage.field (torch.Tensor) – The field, returned only with
return_field.
- Raises:
ImportError – If SimpleITK is not installed.
ValueError – If
imageis not 2D or 3D, orshrink_factoris not positive.
References