replace_probabilistic_region#
- petpal.preproc.segmentation_tools.replace_probabilistic_region(segmentation_numpy: numpy.ndarray, segmentation_zooms: list, blur_size_mm: float, regions: list, regions_to_replace: list)#
Runs a correction on a segmentation by replacing a list of regions with a set of nearby regions. This is accomplished by creating masks of the nearby regions, blurring them to create probabilistic segmentation maps, finding the highest probability nearby region in the region to replace, and replacing values with the respective nearby region.
This is useful for protocols where there residual regions not intended to be carried forward after generating new regions or merging segmentations.
- Parameters:
segmentation_numpy (np.ndarray) – Input segmentation array.
segmentation_zooms (list) – X,Y,Z side length of voxels in mm.
blur_size_mm (float) – FWHM of Gaussian kernal used to blur regions.
regions (list) – List of region indices to replace residual regions.
regions_to_replace (list) – List of regions to be replaced by nearby regions listed in
regions.
- Returns:
segmentation_numpy (np.ndarray) –
- The input segmentation with replaced
regions.