tools.bias_field_correct

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_factor and 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. None uses 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) if None.

  • return_field (bool, default=False) – Also return the field.

Returns:

  • corrected (torch.Tensor) – image divided by the field, with the dtype and device of image.

  • field (torch.Tensor) – The field, returned only with return_field.

Raises:
  • ImportError – If SimpleITK is not installed.

  • ValueError – If image is not 2D or 3D, or shrink_factor is not positive.

References

Examples using bias_field_correct#

Receive bias field

Receive bias field