automask module

Automatically generate masks for a phantom in a scan.

automask.main(nifti_path, slice_idx, mask_output)

Load an image and mask one z-slice.

  • nifti_path (str) – Path to the image to be masked.
  • slice_idx (int) – Index of the slice to be masked.
  • mask_output (str) – Path to which the mask image should be saved.

Generate a mask for the phantom material in a slice.

Assuming the phantom’s diameter is similar to the test tube’s, Otsu’s method segments the phantom well. The initial results are eroded to avoid outliers near the edges of the phantom.

Big enough air bubbles may also be masked out by this function.

Parameters:slice_b0 (array_like) – 2D array of image data from a single slice (containing a single phantom).
Returns:2D boolean array, where True values indicate phantom voxels.
Return type:array_like